Commit graph

11 commits

Author SHA1 Message Date
3c5b57c6b5 Size form dynamically from terminal dimensions; fix signed/unsigned mismatch
Expose CellWidth/CellHeight properties on TKPAnsi and remove hardcoded
Width/Height from both the TKPAnsi constructor and TMainForm constructor.
TESTMAIN now computes form size from FAnsi.Width/Height after handle
allocation triggers RecalcCellSize.  Fix bytesRead in reccom() from
int16_t to uint16_t to match avail/chunk types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 17:30:34 -06:00
eebcf100ad Fix hard lockup on COM port open from stale UART interrupt
Clear IER and read IIR/LSR/MSR/RBR before hookIsr unmasks the PIC.
A pending interrupt from a previous session would fire immediately,
but the ISR skipped dispatch (isOpen still FALSE), leaving the IRQ
asserted on level-triggered ISA -- infinite ISR loop.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 17:18:31 -06:00
c378abc9e5 Inline CSI parsing, ASM nibble table, cursor dedup, reccom block copy
Four performance optimizations targeting the hottest paths:

- Parse CSI params (P1/P2) as integers during scan-ahead loop,
  eliminating ParseParamBuf call from ExecuteCSI (~200 cycles/seq)
- Replace 16-iteration Pascal nibble table rebuild (64 branch+store)
  with 32 straight-line MOV word using precomputed BGBG/BGFG/FGBG/FGFG
- Integrate cursor FG/BG swap into main RenderRow column loop,
  removing duplicate nibble rebuild + ASM glyph expansion overlay pass
- Replace byte-at-a-time reccom loop with _fmemcpy block copy split
  at ring buffer wrap point, reducing far pointer overhead from O(n) to O(1)

Also includes previously uncommitted space fast-path in RenderRow and
inlined escape sequence handling in ParseDataBuf.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 18:20:51 -06:00
c8ccedf569 Change default FIFO trigger from 8 to 1, yield CPU when idle
Default RX FIFO trigger level of 8 (FCR_TRIG_8) caused exactly 8
characters to buffer in hardware before the ISR fired. Change default
to 1 (FCR_TRIG_1) for responsive single-character interrupts while
keeping the 16-byte FIFO enabled as a safety buffer. COMnRxTRIGGER
SYSTEM.INI key still allows override.

The PM_NOYIELD polling loop never yielded the CPU timeslice, starving
other Windows applications. Add Yield call when no serial data is
flowing so other apps get CPU time. During bulk data flow HasData
stays true and the loop runs at full speed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 20:44:14 -06:00
ec0ec8f074 Replace event-driven WM_COMMNOTIFY architecture with polling main loop
The ISR still fills the ring buffer (mandatory for 115200 baud), but the
app now polls ReadComm directly via a PeekMessage loop instead of waiting
for WM_COMMNOTIFY.  Blink uses GetTickCount instead of WM_TIMER.  This
eliminates all Windows message overhead from the data path while keeping
the message loop alive for keyboard, paint, and scrollbar.

Removed from KPCOMM.PAS: NotifyWndProc, hidden notification window,
RegisterClass/CreateWindow, EnableCommNotification, SetCommEventMask,
DoCommEvent, Process*Notify methods, OnComm/CommEvent/RThreshold/
SThreshold properties, modem shadow state (CTS/DSR/CD).

Removed from KPANSI.PAS: WM_TIMER handler, SetTimer/KillTimer, replaced
with public TickBlink method using GetTickCount at 500ms intervals.

Removed from drv/isr.c: checkNotify function and its call from
isrDispatch.  Removed from drv/commdrv.c: pfnPostMessage, all
rxNotifySent/txNotifySent edge-trigger bookkeeping, gutted
enableNotification to a no-op API-compat stub.  Removed from
drv/commdrv.h: rxNotifySent/txNotifySent fields (shifts struct layout),
PostMessageProcT typedef, pfnPostMessage extern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 19:01:40 -06:00
acf1a6b691 Remove BeginUpdate/EndUpdate, fix rendering starvation, add variable docs
Remove BeginUpdate/EndUpdate batching from TKPAnsi entirely -- Write now
renders immediately via FlipToScreen after every ParseData call.  Remove
FPendingScroll (caused rendering deadlock: EndUpdate refused to call
FlipToScreen while FPendingScroll > 0, but only FlipToScreen cleared it).
DoScrollUp simplified to set FAllDirty directly.

CommEvent drain loop retained (required by edge-triggered CN_RECEIVE) but
each chunk renders immediately -- no deferred batching.  Edge-triggered
notifications verified starvation-free at all levels: ISR, driver, KPCOMM
dispatch, terminal rendering, and keyboard output path.

Add comprehensive variable comments to all project files: TKPAnsi (44
fields), TKPComm (23 fields), TMainForm (9 fields), PortStateT, and
driver globals.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 18:34:19 -06:00
5dd464eb18 Fix hang on second COM port open: CLI deadlock, MOVEABLE buffers, stale UART
setque (called by USER.EXE after every inicom) was running GlobalAlloc and
GlobalFree with interrupts disabled.  On the second open the global heap
could need compaction or DPMI selector work, deadlocking under CLI.
Restructured to allocate new buffers first, swap pointers under CLI, then
free old buffers after STI.

Ring buffers changed from GMEM_MOVEABLE to GMEM_FIXED so addresses are
inherently stable at interrupt time.  Added rxBufH/txBufH handle fields
to PortStateT, eliminating the fragile GlobalHandle(SELECTOROF()) recovery
in freeBuffers.

trmcom now resets FIFOs and drains all pending UART conditions (LSR, MSR,
RBR, IIR) before unhooking the ISR, leaving hardware clean for reopen.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 20:06:04 -06:00
ca99d1d21b Optimize TKPAnsi rendering with batched TextOut and dirty row tracking
Separate parsing from rendering to eliminate per-character GDI calls.
ProcessChar now only updates cell data in memory; rendering is deferred
to FlipToScreen which batches consecutive same-color cells into single
TextOut calls (~5-10 per row instead of 80). Partial BitBlt transfers
only the dirty row band to the screen. Non-blinking rows render to one
buffer and BitBlt to the second, halving GDI work for typical content.

Also removes redundant GetCommError from KPComm receive path and adds
BeginUpdate/EndUpdate batching in the test app's CommEvent handler.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 21:15:51 -06:00
4218da32eb Rename output from COMM.DRV to KPCOMM.DRV to avoid clashing with stock driver
LIBRARY name stays COMM for import resolution. Debug strings updated to KPCOMM.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 20:07:45 -06:00
d68405550d Fix COMM.DRV calling conventions and add ComDEB compatibility
Resolve GPFs in both USER.EXE and COMMTASK.DLL by correcting RETF
sizes for SETCOM and GETDCB, confirmed by disassembling CyberCom.DRV.
Add stock-compatible ComDEB structure so third-party code (ProComm
COMMTASK.DLL) can safely access internal fields at known offsets per
Microsoft KB Q101417.

COMM.DRV changes:
- SETCOM (ord 2): RETF 4, takes DCB FAR * only (not commId + DCB*)
- GETDCB (ord 15): RETF 2, takes commId, returns DCB FAR * in DX:AX
- Add 40-byte ComDebT matching stock COMM.DRV internal layout
  (evtWord at +0, MSR shadow at +35, queue counts at +8/+18)
- cevt returns pointer to ComDebT for third-party compatibility
- Sync ComDEB fields in ISR dispatch, reccom, sndcom, cflush, setque
- Move WEP to ordinal 16, add ordinal 101 stub (match stock/CyberCom)
- Default DBG_ENABLED to 0 (set to 1 to re-enable debug logging)

VBX control fixes:
- Fix SETBREAK/CLRBREAK constants (use numeric 8/9, not undefined macros)
- Fix serialEnableNotify return type (BOOL, not int16_t)
- Fix mscomm.h to work with RC compiler (#ifndef RC_INVOKED)
- Fix vbapi.h USHORT typedef and MODEL.flWndStyle type
- Add vbapi.lib dependency to makefile

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 20:03:34 -06:00
f666825417 Initial commit. 2026-02-23 20:53:02 -06:00