Files
Brian Holman a07c41555a Fix target joystick calibration arguments and scene transitions
Avoid a demonstrated CMOC -O2 removed-index-reload error with independent calibration and position pointers. Keep established joystick readiness across menus, stabilize shared fire/keyboard scans, and protect input sampling from IRQ interference.

Ship pristine QUADPSL04.DSK. Native right-port emulated analog/button checks pass for both directions, four lasting T-piece turns, and steering after keyboard resume. Host input/store/rules/video regressions and unchanged memory guards pass. Preserve personal score disks and record physical/128 KB/audio limits.
2026-11-11 14:26:06 -07:00

12 KiB

Build 02 joystick correction — November 11, 2026

Brian reported that the right joystick could not move pieces reliably in either VCC Plus or on the physical CoCo 3. Pressing fire appeared to rotate a piece; releasing it turned the piece back. Build 01's simulated input tests had not covered the actual keyboard adapter or a separately uncentered vertical axis.

Reproduced causes and changes

The public coco.h key coordinates put A, D and E on row bit 0x01. Right fire also grounds this shared input line. Calling isKeyPressed on that row while fire is down can therefore report Left, Right and clockwise rotation together. Releasing fire then generates the intended preferred rotation. With the default counterclockwise preference, those two turns cancel, matching Brian's report.

The keyboard adapter now calls the same standard isKeyPressed API but skips only rows grounded by joystick buttons. It uses the raw low nibble returned by the standard readJoystickButtons API, covering all four button lines, including the other port. Unaffected keyboard rows remain usable. Keyboard/joystick aliasing is filtered before logical action processing. No direct hardware accesses, custom driver or assembly were added. The adapter is now a separate, testable C module, src/platform/keyboard.c, with build/project membership updated.

Separately, the old neutral guard required both X and Y to center before either axis could work. A centered horizontal axis followed by left/right movement was ignored indefinitely if Y remained outside its dead zone. The new guard arms X and Y independently. It still requires an axis to center before accepting it, retains hysteresis and horizontal repeat, requires neutral before another upward hard drop, and keeps keyboard controls usable with a disconnected stick. This independent guard defect is reproduced by tests; actual ADC traces from Brian's physical joystick have not been captured.

Shared examples and attribution

Pierre Sarrazin's CoCoPlanes 0.1.0 coco-planes.c (Copyright 2026 Pierre Sarrazin, GPL-3.0-or-later) was consulted read-only. Its separate keyboard/joystick controller paths, periodic sampling and active-low right/left primary-button masks informed the comparison. The public installed Joystick.h and coco.h API contracts were also read, including shared sound/analog input behavior. No CoCoPlanes raw-register, interrupt or assembly routines were copied or used. Existing standard CMOC joystick/sound APIs remain in use.

Tests and memory

The new keyboard regression uses the actual keyboard adapter and an authored mock of the shared keyboard/fire input lines. With the original polling it fails immediately on right fire, reproducing false A/D/E actions. With the filter it passes: all four fire lines, an unaffected BREAK key, left/right while holding fire, one lasting rotation on release, both preferred rotation choices, and normal keyboard/menu/initials aliases. The original axis guard also failed the new centered-X/off-center-Y left/right test; the independent guards pass it.

Host ASan/UBSan rules, input, keyboard-adapter, persistence and video suites pass. The existing 25 scoring cases still pass, including actual piece drops. Palette and font pixels are unchanged. All caption scene/column/row/label values were checked against build 01 after packing scene+column into one byte.

To retain the existing memory contract, unchanged caption coordinates are packed, the 11 palette bytes and 15 preference-validation limits live in low static data, and optional video_worst_ticks instrumentation is compiled only with QUAD_PROFILE. That instrumentation is absent/unavailable in Release, rather than reporting zero timing as a measurement. Profile builds still must pass the same memory guard; they are not qualified by this release. Menu/game rendering and all original bounds remain intact.

Release code/constants end $7AF6; static data end $13F6. Ten bytes remain before each enforced limit. The 1,024-byte stack reserve is unchanged. No extra RAM is required by design; actual 128 KB qualification remains pending.

Official build and guest checks

Brian explicitly approved installed VCC Plus 3.6.1 (53) for the joystick checks and granted an idle desktop window. The official project refresh reviewed the new adapter, fixtures and Make/settings changes.

  • Base revision: 356a7fc, main, plus this correction.
  • Project: 7D6E1D9C-DF7C-4B15-B64D-6B30732417CB, revision 2.
  • Release build: 9CFA6AC6-F75A-4515-9029-69129FEF3DD2; zero diagnostics.
  • Artifact: C5E785C7-F0D2-407B-A626-D0FF3F9BCC22.
  • QUAD.bin: 26,608 bytes, SHA-256 f7e0aacb35782f6bbb8ccab1761b196b02afa4120ea496277c5a14dc478856db.
  • QUADPSL02.DSK: 161,280 bytes, SHA-256 4e3af2440a3195ee5864498e39a779362988257d8a39cfc1c413157ace287a3c. Local delivery bytes match the official clean artifact. No QPSAVE data is present; build 02 starts with defaults and an empty scoreboard.
  • Owned MC6809/512 KB run: 4F2B442F-433B-4F30-8394-A6205C01FA0B, stopped. DOS/title and keyboard move/rotate/Hold smoke checks passed. The title layout and gameplay framebuffer were inspected after caption packing.
  • Direct 120-field stereo PCM captures: idle entirely zero; movement effect varies in both channels, peak 7936, ten changing edges, final 500 ms zero. These build-53 results do not establish that the reported normal-window buzz is fixed. The sound API usage was not changed by this correction.

Build 02 title Build 02 gameplay

The current MCP playtest_input schema injects keys only. These guest smoke checks are keyboard evidence; authored host hardware models are regression evidence, not physical joystick-port passes. Actual right/left port testing and the reported normal-window buzzing remain pending user confirmation with build 02. No new HD6309 qualification was performed. The personal normal emulator was not reset or remounted; its loaded build-01 disk and personal score backups remain intact.

Manual check for build 02

Use the right port and a fresh QUADPSL02.DSK copy. Center the stick, then hold left, reverse to right and return to center. A short fire press must produce one rotation on release that remains after the button is released. Repeat while steering. Hold fire 400 ms to open Actions; release must not rotate or select a second action. Check keyboard fallback and, separately, the left-port setting. If X still sticks, distinguish movement that never starts from movement that works once and then locks; record which system and port exhibit it.

Actual build-02 result and CoCoMan reference

Brian confirmed DOS loaded QUADPSL02.DSK; he still could not move left and reported press/release rotations cancelling. Passive observation of his current VCC Plus session showed pieces collecting at the right edge. Build 02 therefore did not pass actual joystick acceptance. Keyboard smoke tests and the prior static button mocks were insufficient to establish that result.

On November 11 Brian granted read-only access to CoCoMan. Relevant working-tree references were game/main.c, game/keys.c and game/title.c, based on revision 439bd25ac46fbc7ecdfd67d98893a1cff90aef66 (main.c had local edits). CoCoMan keeps its input record across pause/resume. Its published vcc/input.h contract masks interrupts during the shared PIA transaction. Its keyboard/title readers mask button-grounded rows, and title_keys checks button state on both sides of the scan and retries if it changed. No CoCoMan source was modified or copied; its custom assembly and VCC input extension were not imported.

Build-03 candidate changes

  • Standard CMOC disableInterrupts/enableInterrupts now bracket the foreground analog/button/keyboard transaction. Player_disableSound is asserted before and after sampling. The IRQ-sharing risk is addressed; its role in Brian's horizontal failure has not been demonstrated with real analog readings.
  • keyboard_read samples standard readJoystickButtons before and after the key scan and retries if they differ. A single fire edge during build 02's scan can bypass its initial row mask; the authored hardware mock reproduces this gap. Logical fire uses the same stable final sample as the keyboard filter.
  • Scene transitions clear transient key/button/repeat state and preserve the joystick's established neutral readiness and hysteresis. Keyboard confirmation does not change port selection. Cold start, explicit port change and explicit neutral calibration still reset readiness. Held confirm/fire retains a release guard; Up requires neutral again before a hard drop after a transition.
  • The smaller original coco.h position reader is retained. A trial using the standard bcontrol full-resolution reader exceeded the unchanged memory bounds and was not delivered. No VCC-specific API, new hardware code or assembly is used. Caption pointer iteration, equivalent compact hysteresis, shared return code, seven effect-duration bytes in low static data and shorter status text keep the correction inside the original memory/stack contract.

Host regressions cover each reachable key-probe boundary for one press/release edge on each of four button lines, four lasting L-piece rotations, steering with fire, keyboard-confirmed transitions, and held-button release guarding. Rules, persistence and video suites pass. This is simulated hardware evidence. Actual analog joystick acceptance remains pending; Controls readings are still entry snapshots, not live measurements. A very brief press/release entirely between samples cannot be observed by either endpoint check.

Official build-03 artifact and isolated checks

VCC Plus 3.6.1 (53), project 7D6E1D9C-DF7C-4B15-B64D-6B30732417CB, revision 3, Release disk action. Build C4E09234-A50B-4930-996E-A37A5521BFE7 succeeded with zero diagnostics; artifact A699546A-0A49-4521-BDF0-BA493FCFA850. QUAD.bin is 26,574 bytes, SHA-256 86d1854f901c4c80f7b06b1fc048b7957f6fcd35ed2a8d1dd78fb7538df3a96b. QUADPSL03.DSK is 161,280 bytes, SHA-256 80c511fe9c9b1a0faaeffa688dec6d73de39280f8eb3c9ce584727fc396f09ca. The delivery matches the official artifact and contains only QUAD.BIN, WORDS.DAT and QPTEXT.DAT, plus the DOS launcher; no QPSAVE data is present.

MC6809/512 KB owned run 74607F0C-BE7D-4931-9378-48DA2E4263D4 is stopped. Actual guest captures show keyboard start, left/right movement, rotation, pause and keyboard-confirmed resume followed by movement. Title and gameplay idle PCM are zero in both channels. Movement has a positive effect (peak 7,936 in each channel, 21 changing edges) and a silent final 500 ms. Captures span 120 fields each. Host suites passed with ASan/UBSan; 128 KB, physical joystick and the user's normal-window audio symptom are not qualified by this worker.

An experimental file-path output exclusion was accepted by the MCP inventory, but later broke native project opening with a misleading missing-resource error. It was removed: outputDirectories must contain real folders, not DSK file paths. The first refresh was rejected to avoid adopting the personal build-02 disk as an input. A second refresh approved the source changes and output exclusions. The ordinary STDIO helper must stay connected until its native refresh dialog is reviewed. Closing C Development later invalidated the temporary connection; all owned workers had already been stopped.

Final build 04: demonstrated target compiler error

Build 03 was withdrawn after native testing found that correct raw analog values were paired with an incorrect horizontal calibration argument in generated code. Independent base pointers in sample() avoid the bundled CMOC -O2 index-reload error. This is the demonstrated cause of constant right movement and inability to move left. Full excerpts, paused guest state and native qualification: CMOC_JOYSTICK_ARGUMENTS.md.

Final clean disk SHA-256: 1cddb6bdf17857b915e96a6929e14181bad05cfae73278a4919add26fea0ba45. Official build53 native Release build A7A18927 succeeded. Code/const end $7AD4, static end $13FD, stack reserve 1024 bytes. Right-port Keyboard joystick mapping passes native analog left/right, four lasting T-piece turns and steering after keyboard-confirmed resume. DualSense mapping was restored and game left paused. These tests use actual emulated analog/button circuits; physical controller/CoCo, left port and 128 KB remain pending. Build04 audio was not recaptured after this pointer-only correction; build03's isolated audio evidence remains historical.