Repository navigation
Description
SoftIEC compatibility with C64 OS [HyperSpeed KERNAL / UCI]
Related to #975 — Hyperspeed: Should not require extra zero page addresses
Debugging and experimental fixes with ChatGPT assistance
The issue was investigated and the experimental fixes were developed with the assistance of ChatGPT. All reported results were verified through testing on real Ultimate II+ hardware.
Description
As already discussed in #975, C64 OS has compatibility issues when using HyperSpeed KERNAL with SoftIEC through UCI.
Previously, C64 OS could not complete a normal startup and would hang at "Loading App Launcher".
It was possible to work around this by starting C64 OS with JiffyDOS, creating an REU preload, and then restoring it under HyperSpeed KERNAL. With this workaround, Desktop 1 was displayed with its background and icons, but switching to Desktop 2 caused the system to hang.
I tested two changes in kernal/uci.s.
1. EOI handling in my_chrin
Adding an EOI check before attempting to read more data allowed C64 OS to boot from scratch without using an REU preload and reach Desktop 1.
However, the desktop background and icons were not displayed, and switching to Desktop 2 caused the system to hang.
2. Relocating HyperSpeed UCI variables outside Zero Page
The original uci.s source already contains commented-out definitions suggesting alternative addresses at $02BC–$02BF.
I used these suggested addresses to relocate the four UCI state variables outside Zero Page.
The four variables currently reuse existing Zero Page locations:
Variable Original Test
----------------------------------
MY_OUTLEN $9B $02BF
UCI_PENDING_CMD $9C $02BE
UCI_LAST_CMD $BE $02BD
UCI_LAST_SA $96 $02BC
A comparison of two 64 KB memory dumps taken under JiffyDOS, one after loading Desktop 1 and the other after switching to Desktop 2, showed that the contents of $02BC–$02BF remained unchanged.
This suggests that these addresses may be available at these stages of C64 OS operation. However, this does not prove that they are unused, nor does it guarantee that C64 OS will not overwrite them later during normal operation or when running applications.
After relocating the variables, C64 OS 1.09 successfully booted from scratch under HyperSpeed KERNAL with SoftIEC/UCI enabled, without an REU preload.
Desktop 1 displayed its background and icons correctly, and switching to Desktop 2 also worked.
These results strongly suggest that reusing the existing Zero Page locations causes a compatibility conflict with C64 OS.
Experimental diff
kernal/uci.s
@@ -45,19 +45,16 @@
NAMELEN = $B7
LOADADDR = $C3
SAVEADDR = $C1
SAVEEND = $AE
-; MY_OUTLEN = $02BF ; Last byte of free area, before sprite 11
-; UCI_PENDING_CMD = $02BE
-; UCI_LAST_CMD = $02BD
-; UCI_LAST_SA = $02BC
-
- MY_OUTLEN = prty
- UCI_PENDING_CMD = dpsw
- UCI_LAST_CMD = fsblk
- UCI_LAST_SA = syno
+; Experimental relocation of HyperSpeed UCI state outside zero page.
+; WARNING: $02BC-$02BF are not confirmed free under C64 OS.
+ MY_OUTLEN = $02BF
+ UCI_PENDING_CMD = $02BE
+ UCI_LAST_CMD = $02BD
+ UCI_LAST_SA = $02BC
ulti_restor
lda CMD_IF_COMMAND
cmp #UCI_IDENTIFIER
bne rest1
@@ -256,10 +253,19 @@ ultichrin cmp OUR_DEVICE
bne cin1 ;no...
jmp bn15
cin1 jmp bn20
my_chrin
+ ; Experimental: stop after EOI, but do not treat unrelated
+ ; KERNAL status bits as end of stream.
+ lda STATUS
+ and #$40
+ beq _check_uci_data
+ lda #$0D
+ clc
+ rts
+_check_uci_data
; is there any data available in the current buffer?
lda CMD_IF_CONTROL
bpl _no_data_avail
; read available data and store it on the stack
Test environment
Ultimate II+ f488352
C64 OS 1.09
HyperSpeed KERNAL 931 SoftIEC follow-up: final compatibility pass and E2E fixes #931
SoftIEC with UCI enabled
Cold startup without REU preload
Notes
The addresses $02BC–$02BF were already present as commented-out alternatives in uci.s. I reused them for this experiment.
These addresses have not been confirmed safe for general use, so this should be considered a diagnostic workaround rather than a final fix.
The results suggest that both EOI handling and the location of the UCI state variables deserve further investigation.
A permanent solution should avoid conflicts with memory used by C64 software.
Activity
chrisgleissner commentedon Oct 12, 2026
Hi @radius75 , thanks for that. Given there are vast model differences, could you please also add which concrete model and effort level you used? Currently, you must mention ChatGPT. Many thanks.
radius75 commentedon Oct 12, 2026
Hi @chrisgleissner,
I used ChatGPT GPT-6 in Instant mode.
chrisgleissner commentedon Oct 12, 2026
Thanks @radius75.
BTW great work on getting C64os to start with the Hyperspeed kernal. Why don't you open a draft PR with your change and some e2e tests. It could provide further context to the discussion. I very strongly recommend Anthropic Opus 5.5 High for any such work as it is currently the best model for software engineering.
Also, maybe you could do an impact analysis of your suggested change, ie. whether the approach you took would be viable and what potential downsides are, and whether there are any alternatives, again with pros and cons.
@markusC64 @bvl1999 Any thoughts on this change?
markusC64 commentedon Oct 12, 2026
Well, those extended zero page locations are probably used in another software, so every other zer page location or extended zero page location is not a real solution. It might help C64 OS or not, there might be even a C64 OS application that uses those extended zeropage memory locations.
Therefore I still think that having those in the IO2 area as mentioned is the better way, T guess @radius75 has done the test this way because that only needed a kernal change and not an updated FPGA for the ultimate. Right?
For the other change, I hope @bvl1999 can comment on that.
radius75 commentedon Oct 12, 2026
Attached is the compiled HyperSpeed KERNAL containing these changes.
As mentioned earlier, this build should be considered a diagnostic workaround, not a final fix.
u64hskernal931+.zip
chrisgleissner commentedon Oct 12, 2026
Yeah, my concern would also be incompatibility with existing applications that rely on these zero page addresses. It will be impossible to tell without an exhaustive scan of all 20k (?) C64 programs, which not sure anyone would be keen to do. My vote would also be for the IO area.
Which area specifically did you have in mind @markusC64, and was there prior discussion on this?
Thanks @radius75 for sharing the patched Kernal. I'd still very much prefer draft PRs with such changes as they make it much easier to see what has been changed, instead of sharing binaries. PRs also allow for easy discussion of the changes via in-line comments.
And yeah, would be good to get @bvl1999 's opinion as he is listed as Hyperspeed Kernal expert in our CONTRIBUTING.md guide.
markusC64 commentedon Oct 12, 2026
@radius75 has linked my proposal in the very first sentence of this issue (except the headline) - it mentions my suggestion explicitly.
chrisgleissner commentedon Oct 12, 2026
The ticket here is so similar to #975 - I fail to see any relevant difference. Why do we need two tickets @markusC64 @radius75 ? Are they not both about C64OS + Hyperspeed Kernal?
Normally, when we start working on a ticket, we create draft PRs, not a spin-off ticket with code snippets.
radius75 commentedon Oct 13, 2026
Hi Christian,
I created a separate issue for the C64 OS compatibility problem because I didn't want to shift the focus of #975 away from the broader HyperSpeed KERNAL improvement.
Markus himself explicitly stated in #975 that he didn't intend to debug C64 OS compatibility issues there.
My issue actually reinforces his reasoning behind #975.
markusC64 commentedon Oct 13, 2026
Good question, why two issues? Well, the other ticket is about changing the firmware so the RAM is available in the IO2 Area. This ticket is about changing the hyper speed kernal, which is not part of the firmware release package. Only the sources are in the same repository.
You see, this way, you can update the hyperspeed kernal independent from the release of the firmware. One the one hand firmware, on the other hand the kernal, that is C64 Software.
PS: es, my mechanical keyboard is sometimes repeating something I do not want to have repeated.
[-]SoftIEC compatibility with C64 OS[/-][+]SoftIEC compatibility with C64 OS [HyperSpeed KERNAL / UCI][/+]chrisgleissner commentedon Oct 13, 2026
Hi @markusC64 and @radius75, thanks for explaining. Maybe we need a build step on our CI build that automatically builds the Hyperspeed UCI kernal so people can just download and use it. It would also avoid the need to hand build it and attach it to github issues.
By the way, which mechanical keyboard are you using @markusC64 ? I also like them a lot. I use the Keychron C3 Pro as my main retro dev keyboard. It is programmable and has adjustable lighting effects. Recently the s key got stuck so it would not actuate anymore, the reverse problem that you seem to face, but some cleaning of the key made it work again.
markusC64 commentedon Oct 13, 2026
Well, perhaps. It’s up to Gideon to decide what to package with the firmware.
OT: I am using a Keychron K10 with alternative 3rd party key caps (E1 German layout, quite rare to get).
chrisgleissner commentedon Oct 14, 2026
@markusC64 We could also just offer it as an artifact that is added to each build. Does not need to be part of the firmware image. Makes it also easier to spot regressions and we can then easily add tests for it.
radius75 commentedon Oct 14, 2026
I've updated the patch with several optimizations to address the performance regression introduced by the previous version.
I tested the previous patch using several benchmarks and found that loading was approximately 10% slower than with the original HyperSpeed KERNAL.
The latest patch includes several optimizations to eliminate this overhead. In my 100 × 4 KB SEQ read benchmark, the results are now:
So the performance is now practically identical to the original.
I also tested the latest version with Image BBS 3.0, C64 OS, Sonic, and BattleTech. All tests passed, but of course this does not guarantee that I haven't introduced any regressions.
Another difficulty is testing compatibility with different software when the four UCI state variables may conflict with memory used by an application. To investigate such conflicts, I would need to compile and maintain several HyperSpeed KERNAL variants with these variables placed at different memory locations, which is rather inconvenient.
Regarding Christian's suggestion to provide the HyperSpeed KERNAL as a CI build artifact: I think this would be very useful, especially for testing and identifying regressions. It would make comparing different builds much easier without having to compile each variant manually.
u64hskernal931+++.zip
I've committed the latest version.
radius75@2e3ee00
radius75 commentedon Oct 19, 2026
I found another HSKernal compatibility issue while testing C64 OS Gallery.
With HSK, loading a nonexistent
INIT.Orepeatedly fails instead of continuing toMAIN.O:The problem is that HSK returns
A=4, Carry=1, ST=0on a failed KERNALLOAD, while the original CBM KERNAL and JiffyDOS returnA=4, Carry=1, ST=66.The fix in
kernal/uci.sis:After the fix, Gallery correctly continues from the missing
INIT.OtoMAIN.O.u64hskernal931v3.zip
Using the latest patched u64hskernal931v3, I successfully performed a clean installation of C64 OS 1.08 on a DNP partition
and upgraded it to version 1.09 without encountering any issues.
radius75 commentedon Oct 21, 2026
During further HyperSpeed KERNAL compatibility testing, I found several differences in the returned register values compared with the standard Commodore KERNAL and JiffyDOS.
I have not determined whether these differences affect C64 OS functionality. They are simply compatibility discrepancies discovered during testing.
The following results were recorded before the latest HSK fixes.
Format: A / X / Y / Carry / ST
One difference was the X register returned by the UCI implementation of CHKIN. HSK returned 21 (
$15, the UCI CHKIN command code) instead of the device number.In HSK 931v4, I changed the CHKIN return path to restore X from
DFLTN, preserving the processor flags:u64hskernal931v4.zip
HSK 931v4 test results:
/Temp— PASS.The remaining differences in OPEN and CHRIN register values have not yet been investigated further.
radius75 commentedon Oct 21, 2026
Hi @chrisgleissner
While testing HSKERNAL compatibility with C64OS, I noticed a possible inconsistency in the JiffyDOS/SoftIEC implementation.
The test opens a non-existing SEQ file, performs
CHKINfollowed byCHRIN, and records the returned A/X/Y registers, Carry, ST, and processor status register P.I initially noticed that JiffyDOS 6.01 with SoftIEC returns A=$47 instead of A=$C7, even though both configurations report ST=66.
Diagnostic program repeats the
OPEN → CHKIN → CHRINsequence 20 times.Results on Ultimate II+
All results were consistent across 20 out of 20 runs for each configuration.
UCI was disabled, so communication with SoftIEC went through the physical IEC bus.
So far, only the JiffyDOS 6.01 + SoftIEC combination produces A=$47 instead of $C7.
Additional observations
OPENandCHKINreturned Carry=0 and ST=0 in all configurations.CHRIN.$A4remained unchanged duringCHRIN: 0→0 for CBM + SoftIEC and JiffyDOS + Drive A, but 255→255 for JiffyDOS + SoftIEC.I also ran the same test program in VICE with both the standard CBM KERNAL and JiffyDOS 6.01, using an emulated 1541-II.
Both configurations produced identical results, matching those obtained with Ultimate Drive A: A=$C7, Carry=0 and ST=66.
Possible cause
Looking at the SoftIEC source, I noticed that
IecChannel::prefetch_data()returnsIEC_NO_FILEwhen the channel is in an error state.In
iec_interface.cc, this leads toIEC_CMD_TX_TERM, terminating the transmission without supplying another data byte.I wonder whether the JiffyDOS transfer termination or error handling in SoftIEC differs slightly from the behavior of an emulated 1541-II.
I'm not claiming this is necessarily a functional bug, since ST=66 is reported correctly and the accumulator and processor flags may not be defined after an unsuccessful
CHRIN.However, the difference is fully reproducible and appears specific to the JiffyDOS + SoftIEC combination.
Do you think this is worth investigating?