Skip to content

fix: decode unpacked indexed PICT pixmaps - #607

Open
benletchford wants to merge 2 commits into
masterfrom
dev/decode-unpacked-bitsrect
Open

fix: decode unpacked indexed PICT pixmaps#607
benletchford wants to merge 2 commits into
masterfrom
dev/decode-unpacked-bitsrect

Conversation

@benletchford

Copy link
Copy Markdown
Owner

Closes #606.

Root cause

The PICT decoder treated every BitsRect / BitsRgn opcode as a 1-bit BitMap. Version 2 pictures can set the high bit of rowBytes and supply an indexed PixMap with a color table and unpacked pixel data. Reading that structure as a BitMap desynchronized the opcode stream; a later pixel word could then be interpreted as a reserved opcode with a huge length and overflow the parser position.

Change

  • Detect indexed PixMap forms of BitsRect and BitsRgn.
  • Share the existing indexed color mapping, clipping, transfer, and blit paths with PackBitsRect while reading BitsRect rows uncompressed.
  • Teach byte-slice PICT scanning to skip the same PixMap structure correctly.
  • Stop safely when a reserved-opcode payload length would overflow.
  • Add regression tests for an unpacked 4-bit PixMap and the overflow boundary.

The implementation follows Inside Macintosh: Imaging With QuickDraw (1994), Appendix A, pp. A-13 and A-17.

Qualification

The checksum-pinned, pure-68K Falcon MC promotional demo now:

  • renders its authentic monitor-depth prompt;
  • switches through its requested 16-color path;
  • renders its promotional menu and bundled controls reference;
  • enters live Instant Action cockpit gameplay;
  • accepts the bundled view and Space trigger inputs while simulation continues.

Before this change, startup panicked while decoding PICT 132 (BitsRect, rowBytes=$8004, 4-bit indexed PixMap).

Validation

  • cargo fmt --check
  • New focused regressions: passed
  • cargo test --lib: 2,950 passed, 3 ignored
  • cargo check --no-default-features: passed

@benletchford
benletchford marked this pull request as ready for review August 14, 2026 08:26
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.

Decode unpacked indexed PixMaps in PICT BitsRect opcodes

1 participant