MEGA65 / mega65-rom-public

MEGA65 ROM public issue reporting
4 stars 0 forks source link

Decide on the VECTOR API #137

Closed dansanderson closed 3 months ago

dansanderson commented 3 months ago

In 920398, we adjusted VECTOR to copy a 56-byte table instead of a 32-byte table, to include serial and editor vectors. This change was incomplete and caused issues after Run/Stop + Restore, which uses RESTOR + VECTOR but with a different conditional call path. This specific change was reverted in 920399. This issue tracks the repair of this feature.

Previously, the user-accessible vector table did not include the Serial vectors. VECTOR would always reset these to one of two sets of defaults: IEC vectors if FDC is not present, or CBDOS vectors if FDC is present. VECTOR would not touch the serial vectors at all on Run/Stop + Restore or a program call to VECTOR.

Three options to move forward:

1) Leave it as completely reverted. VECTOR does not include either serial or editor vectors. This would be disappointing because there's a ton of potential in exposing the KEYSCAN vector this way. Update the documentation to only cover the KERNAL vectors. 2) Include the editor vectors but not the serial vectors. Reorganize the vector table accordingly, and update the documentation. 3) Make VECTOR more sophisticated so that a Run/Stop + Restore call to VECTOR resets the Serial vectors according to the FDC-conditional logic. It's not clear why this is skipped in the previous version, so that might need research. Distinguish between Run/Stop + Restore and a user call, so that the user call can update the Serial vectors if desired.

The intent of this feature was to include everything that looked like a useful user-adjustable vector in the VECTOR mechanism, so that we would not need to expose the raw addresses of the vector table to support KERNAL extensions. It's possible that Commodore's original intent was to never expose these vectors at all (editor vectors were for internal use only), or to expose them with documented direct access instead of the VECTOR call (after vector table addresses had settled). There are notable vectors in the BASIC system as well, which currently are not exposed through any accessor.

The fact that Run/Stop + Restore resets vectors indicates that extending the screen editor with custom vectors might not have been an important use case for the original design. C64 programmers enjoy IRQ vector party tricks, but as far as I know these aren't expected to be a robust way to extend the BASIC environment. As charmed as I am by a way to override the Help key within the editor using a KEYSCAN vector, maybe it isn't meant to be.