Advancing Brainwave Modeling with a Codebook-Based Foundation Model