The Sharpe ratio tells us the amount of excess return we get for taking on each additional unit of portfolio standard deviation.
$$\frac{\mu_p - r_f}{\sigma_p }$$
We are looking for the combination of the two risky assets with the highest Sharpe ratio ($P^*$). Once we do that, we can take linear combinations of that portfolio and the risk-less asset and form the Capital-Market Line. This is usually solved for numerically rather than analytically but it is possible to do so analytically, particularly in the two asset case.
A portfolio $p$ has an expected return of:
$$\mu_p(W_A) = w_A \cdot \mu_A + (1 - w_A) \cdot \mu_B $$
and a standard deviation of:
$$\sigma_p(W_A) = \sqrt(w^2_A \cdot \sigma^2_A + (1 - w_A)^2 \cdot \sigma^2_B + 2(1-W_A)W_A \sigma_{AB}) $$
where $\sigma^2_A$ is the variance of asset $A$, $\sigma^2_B$ is the variance of asset $B$, and $\sigma_{AB}$ is their covariance. It therefore has a Sharpe Ratio of:
$$\frac{\mu_p(W_A) - r_f}{\sigma_p(W_A) } = \frac{w_A \cdot \mu_A + (1 - w_A) \cdot \mu_B}{+\sqrt(w^2_A \cdot \sigma^2_A + (1 - w_A)^2 \cdot \sigma^2_B + 2(1-W_A)W_A \sigma_{AB})}$$
To maximize this you'll want to solve:
$$ \frac{d}{dW_A} \frac{\mu_p(W_A) - r_f}{\sigma_p(W_A) } = 0 $$
$\Rightarrow W^{*}_A$ s.t. $P(W^{*}_A)=P^*$
and check that the second order condition is met:
$$ \frac{d^2}{dW^2_A} \frac{\mu_p(W_A) - r_f}{\sigma_p(W_A) } < 0$$
The algebra is a bit hairy but there is nothing tricky from here on out.