It is stated in Geometry of Algebraic Curves by Harris that there are two equivalent definitions of a hyperelliptic curve $X$:
(i) There exists a degree $2$ meromorphic global function of $X$.
(ii) $X$ is expressible as a $2$-sheeted cover of $\mathbb{P}^1$.
Question: How are these equivalent?
I have introductory knowledge of embeddings of curves in projective space, and I understand that the equivalence should follow somewhat as follows:
Condition $(i) \Rightarrow$ we have a degree $2$ divisor $D$ on $X$ such that $\dim(H^0(O_C(D)))\geq 2$
$\Rightarrow$ we have a map $\phi_D:X\longrightarrow \mathbb{P}^1=\mathbb{P}H^0(O_C(D))^*$ given by $p\mapsto H_p\subset H^0(O_C(D))$, where $H_p$ is the hyperplane in the vector space given by $\sigma\in H^0(O_C(D))|(\sigma)\geq p$, $(\bullet)$ denoting the divisor.
How do we get from here that the map is degree $2$ and thus condition $(ii)$? Also, how do we show the converse?