void load_chdk_palette() {... palette_control = 1; vid_bitmap_refresh();...void vid_bitmap_refresh() {... full_screen_refresh |= 3;...
G:\MISC\platform\ixus130_sd1400G:\MISC\platform\ixus200_sd980G:\MISC\platform\ixus220_elph300hsG:\MISC\platform\ixus230_elph310hsG:\MISC\platform\ixus240_elph320hsG:\MISC\platform\ixus310_elph500hsG:\MISC\platform\ixus870_sd880G:\MISC\platform\ixus970_sd890G:\MISC\platform\ixus990_sd970G:\MISC\platform\s90G:\MISC\platform\s95G:\MISC\platform\sx210
I don't know that this is worth cleaning up, but most ports only use palette control in load_chdk_colors, ...
I think this is only a significant problem for cameras that have a 'Color Options' setting in the Canon Menu and the option has been changed from the default value. I was not aware of this until you pointed out the option in another thread.
Cameras with this option will probably have a value of 16 for the playback active_palette_buffer; but apart from the IXUS 310 none of the other ports use this. So identifying affected cameras is also an issue. I have no idea how many cameras offer this option.
The normal vid_get_bitmap_active_palette logic is only valid for the default color scheme (orange). When a different color scheme is used, the location in palette_buffer is offset by the number of the color scheme. This logic appears in ixus240 102a FUN_ff2ddd74 (ixus140 equivalent is FUN_ff20f904)That's why in post 295, caefix's rmem -i32 0x194b88 shows palette_buffer[0] being NULL, and palette_buffer[1] having a value, while koshy's (set to orange, has a a value in palette_buffer[0].This also explains why playback is 16 rather than 4, because there needs to be space for each color option. This may provide a way of detecting the affected firmwares.We could use get_parameter_data(0x1a,1) in vid_get_bitmap_active_palette replicate this, but it's not clear the current CHDK custom entries will be appropriate in different Canon palettes. I'm also not sure we want to call get_parameter_data so often.It seems like there should be a variable somewhere that has the offset already applied or points to the actual current palette, but I haven't seen one.Making vid_get_bitmap_active_palette and load_custom_colors handle NULLs correctly will at least avoid the memory corruption, and people affected may complain that the colors are messed up.All cameras that offer this color option will need to a fix. I'm not sure how many there are, none of my cams have it, but the firmware code still checks the flash param.
We could use get_parameter_data(0x1a,1) in vid_get_bitmap_active_palette replicate this, but it's not clear the current CHDK custom entries will be appropriate in different Canon palettes.
Patch attached to ensure vid_get_bitmap_active_palette returns 0 for NULL palette and check for valid palette in load_chdk_palette.
@reyalp - can you check that I got all the offsets correct in vid_get_bitmap_palette please.