clcd.cpp: Added IEC bus connections. #9843
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add IEC bus connections to the Commodore LCD based on firmware evidence from Bil Herd's LCD prototype and the schematics released by Bil.
I disassembled the IEC code in the KERNAL ROM to find the connections. With these additions and the clock fix, IEC almost works but most of the time it locks up. Since we don't know if the IEC support in the LCD prototype ever actually worked, the problem could be the KERNAL or an emulation bug.
Out of dozens of attempts, I got a disk directory from
c1541
twice. Since it got that far, I think the signals are hooked up correctly. I asked Curt about it and he thought so too. I hadn't committed the patch because I wanted to look into it more, but then Bil released the schematics. They confirm the connections. Since that is the case, and the emulator still works as it did before this change, I don't see any harm in committing this.Disassembly
The IEC routines are extremely similar to those in the C64 (see below). The pin assignments are the same but the two input lines are inverted.
Routines (click to expand)
The IEC signals are connected to VIA1 ($F800):
VIA1 Timer 2 is used in one-shot mode for IEC bus timing. It is not used for interrupts but is polled by the IEC bus routines (ISRCLK at $BD11, ISR04 at $BD2C, EOIACP at $BDB3, and ACP00 at $BDBB).
Testing
Run
mame clcd
with no drive options and the emulator will work as before. The device tree will show the IEC bus but no attached drive, since the LCD is a laptop that wouldn't normally have an external drive attached.Run it again with
-iec8 c1541
. In the debugger, switch toc1541
's CPU andbpset ea2d
. In the drive ROM, $EA2D is the end of ACPTR, the routine that receives a byte from IEC. When sitting at the LCD's power-on menu, the breakpoint will soon be hit and the accumulator will contain $5F. This shows that the 1541 successfully received the UNLISTEN ($5F) command on IEC. The menu sends UNLISTEN periodically due to a bug in the LCD KERNAL's CLRCHN routine described below.CLRCHN Bug (click to expand)
If the LCD menu does not come up, delete the
nvram
. That issue is not related to this change.Screenshot
I took the attached screenshot after one of the times I saw it work. However, most of the time, it locks up.