Repository navigation
fix: scale indexed images, tileset narrower than one tile - #163
Merged
Merged
Conversation
oslDrawMap computes the tile count per line as the tileset's width over the tile width, then divides tile indices by it: with a tileset narrower than a tile that count is 0, and the division traps (Exception - Breakpoint, break 7 after divu, map.c:106 on the PSP). It now returns before drawing in that case, and when a tile or map size isn't positive: oslCreateMap checks those, but OSL_MAP's fields can change afterwards and every one of them divides something below.
oslScaleImage read pixels with oslConvertColor, which has no palette: an indexed source came out transparent black. Writing to an indexed destination stored converted colours as if they were indices. A source is now read through its palette. An indexed destination needs a source in its own format and takes the index under each pixel (indices can't be blended); oslScaleImageCreate then gives the new image a copy of the source's palette. Any other source for an indexed destination is refused: blended colours have no palette to map to (NULL from oslScaleImageCreate, oslScaleImage leaves the destination untouched). drawfix: 8 and 4-bit to 8888, 16/16 wrong before, 0 now; 8-bit to 8-bit, 13/15 wrong and no palette before, 0 and a copied palette now; 8888 to 8-bit returned an image, now NULL.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two drawing bugs found while doing #158.
ccb2fc7oslDrawMapdraws nothing instead of trapping on a tileset narrower than one tile; it also guards the other divisors (OSL_MAP's fields can change afteroslCreateMap)627a703oslScaleImagereads indexed sources through their palette; it scales indexed images to their own format by index, with a copy of the palette, and refuses other sources for an indexed destinationEvidence
PSP-2000 (5.00 M33) over PSPLink,
drawfix:Exception - Breakpoint(break 0x7afterdivu,map.c:106)drawfix's other cases pass, as doimgpal,imgload,formats,blend,imgmem,imgmisc,palvram,bigdrawandrotate, all matching theirexpected.txt.Merge Danger
Door: two-way.
Blast Radius: image
oslScaleImageCreatereturns NULL for a true-colour image scaled to an indexed format. It used to return an image with meaningless indices.oslScaleImageinto an indexed destination from another format is now a no-op.