Generally in an RT, your basis is reduced (but not below zero) bu any depletion you claimed or should have claimed. Upon sale, the depletion is recaptured and taxed as ordinary income BUT only to the extent of gain as I understand it.
So you buy an RT for $20 and take $10 of depletion and sell it for $40. Your gain is $30 ($10 at ordinary income rates and $20 as CG
you buy at $20, take $10 of depletion and sell for $8 You have a $2 Cap loss.
you buy ar $30, take $10 of depletion and sell for $25. You have a $5 gain taxed as ordinary income.