SAM: paint-by-numbers fix
|Reported by:||eriktorbjorn||Owned by:||SF/ender|
|Game:||Sam and Max|
This patch fixes the paint-by-number mini-game so that it works flawlessly for me. I'm still a bit concerned about the correctness of the patch, though. Here's what it does:
First of all, it implements the missing kernelFunction 113. It pushes the palette index of the pixel the mouse is currently over onto the stack. Since I still don't quite understand how VirtScreen works, I don't know if I got this right. I guess it also depends on whether it's the real or virtual mouse coordinates.
In doing this I uncovered a problem in swapPalColors(): When calling setDirtyColors(), it doesn't make sure the first parameter is smaller than the second one, and that can cause ScummVM to crash. I've changed it to dirty only the two colours in question, not every colour in between. (The way dirty colours are implemented it will dirty all those colours anyway, but that's beside the point.)
Finally, for the whole thing to work, miscOps 123 had to be changed to just copy one palette entry to another, not swap them. Otherwise the crayons will absorb the colour of everything they paint, which will eventually leave you with a box full of mostly black crayons. This change makes sense since there aready is a miscOps 120 for swapping colours, but since I don't know where else miscOps 123 is used I can't test if I accidentally broke anything else.
Apart from these caveats, the patch is complete and cleaned up.
Ticket imported from: #612847. Ticket imported from: patches/166.