Skip to content

Mgrasfixes - #188

Merged
techomancer merged 10 commits into
mainfrom
mgrasfixes
Oct 8, 2026
Merged

techomancer merged 10 commits into
mainfrom
mgrasfixes

Conversation

@techomancer

Copy link
Copy Markdown
Owner

fixed from iblowmymind with more on top of this.

iblowmymind and others added 10 commits October 7, 2026 19:43
X paints a window's visible region with a clip ID (draw field 0x50) when
the screen masks cannot hold its clip; the kernel has the window's GL
drawing match it (pp1winmode bit 4 + id). Keep a 2-bit plane per pixel,
write it under pp1winmode bits 11:10, and test it in visible(). Load
pp1winmode from context image word 4 and CP_WINDOW, whose words 1 and 2
are winmode and pp1winmode (the kernel stores them as one doubleword,
winmode high), not the other way round.

Both sides added the clip-ID plane and the GL window's pp1winmode.
Reconciled on the reading the sources support:

- CIDmatch is bits 7:4, one bit per ID (the kernel's 1 << (id + 4),
  the diagnostics' MGRAS_CIDMATCH(cid) = cid << 4), and 0 disables the
  check (mgras_tport.c sets 0 for "CID disabled"). Not a value compare
  at bit 5, which would miss ID 3 (0x80) and make 0 mean "ID 0 only".
- Clip-ID writes: two planes, enabled by pp1winmode bits 11:10 (the
  CIDmask field; X's 0xC00), rather than ColorMaskMSBs.
- CP_WINDOW: window mode in word 1, pp1winmode in word 2 (the kernel's
  doubleword is winmode << 32 | pp1winmode).

Kept from the PR: clip IDs in the state hash, pp1winmode in the GL
summary, and its tests, adapted to the above.

Co-Authored-By: iblowmymind <28228415+iblowmymind@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The file manager scrolls its double-buffered 12-bit window (drawn with
draw field 2) by reading it to the host with read field 1 and writing it
back a line up. Read field 1 fell back to the drawing target, buffer A,
so the scroll copied stale pixels over the icons. It is DRBpointers'
second buffer.

4/4/4 host pixels read a component as c / 0x11 and wrote n * 0x11, so
the background 0x502020 came back as 0x441111. A 12-bit visual's
components are the top nibbles (as X's fills store them): read c >> 4,
write n << 4, and the round trip keeps the pixel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libGLcore's __glMgrasDrawBuffer sends three words: the buffers drawn
before an odd number of swaps, the buffers drawn after, and the count
less one (GL_BACK is [4, 1, 0] in a 24-bit visual, [2, 1, 0] in a 12-bit
one; GL_FRONT [1, 4] / [1, 2]; both [5, 5, 1] / [3, 3, 1]). Word 1 is not
an absolute PP1 selector: taken as one, every double-buffered demo traced
(atlantis, powerflip, solidview send [4, 1, 0]) would draw into buffer A
whatever the swap state. Pick the word by the swap state; B is bit 1 or
2, both buffers draw field 3, overlay selectors (0x4N) and DRAW_NONE keep
the previous commit's handling. Fixes 12-bit double-buffered GL_BACK too,
which the one-word logic drew to the front.

Also put the PR tests' CP_WINDOW tokens in the kernel's word order
(window mode in word 1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Expose write masks, viewport and scissor bounds, clear state, matrix stacks and matrices through native libGLcore state queries. Returning placeholder zeros caused Alias PowerAnimator to restore disabled drawing and empty viewports.

Add a regression that queries and restores CI drawing state, then checks the resulting clipped pixels. Validated with 111 MGRAS tests and live PowerAnimator menus, four grids with axes, and Shelves displaying correctly.
The kernel's MgrasValidateBanks sends token 0x98 with the bank GL draws
into next (the window's displayed bank xor 1; main buffers, then the
second set) before every SCHEDULE_SWAP and on window validation, and
stores it in a parked context's image (words 16-17, flag bit 26). Traced
with Maya: [1, 1], swap, frame in B; [0, 0], swap, frame in A. The GE
model counted swaps instead, which loses the phase for good on any swap
it does not see. Take the bank from the token and the context image;
swaps toggle only for contexts the kernel never named a bank for.

A single-buffered window's missing second page now falls back to A.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
glCopyPixels draws its image back by DMA: pixel state 0xDA8 sets the
size, the RSS list the transfer mode, _WRITE_DMAGESETUP [0, ?, ?, 0x49D0]
arms glDrawPixels' routine, and one host DMA line carries every row.
Only the texture restore form (0x511A) was modelled, so the write half
was dropped ("host DMA start 0xa7 with no write transfer armed"). Maya
copies the front buffer to the back after a full redraw and afterwards
redraws only the lines that change, so its back buffer kept stale
pixels and every other frame showed them (brown viewport).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@techomancer
techomancer merged commit 95ab911 into main Oct 8, 2026
1 check passed
@techomancer
techomancer deleted the mgrasfixes branch October 8, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants