First, you need to enable this in the Custom Function:
Second, you need to set the aperture ring of your K-mount lens out of the A position, provided that your lens has it:
Now, your semi-dead Pentax camera will work in the Av and M modes with correct exposure, as long as a non-A aperture position is selected. The credit of this clever method belongs to Mr M R Padmaraju of the DPR Pentax forum, the thread of his original post can be found here.