2.8 KiB
2.8 KiB
The buttery chip-8
Just a personal project for me to get the hang of emulator development.
Load a .ch8 rom with buttery8 filename.ch8.
TODO
Project Setup
- Initialize Rust project
- Set up
Cargo.tomlwith dependencies - Set up window/display library (I went with minifb)
- Set up audio library
- CLI ROM loading via command line argument
CPU / Core
- Define CPU struct (registers, memory, stack, timers, PC, I)
- Load ROM into memory at 0x200
- Load fontset into memory at 0x050
- Fetch / decode / execute loop
- Proper cycle timing
Opcodes
00E0- CLS (clear display)00EE- RET (return from subroutine)1nnn- JP addr2nnn- CALL addr3xkk- SE Vx, byte4xkk- SNE Vx, byte5xy0- SE Vx, Vy6xkk- LD Vx, byte7xkk- ADD Vx, byte8xy0- LD Vx, Vy8xy1- OR Vx, Vy8xy2- AND Vx, Vy8xy3- XOR Vx, Vy8xy4- ADD Vx, Vy (with carry)8xy5- SUB Vx, Vy (with borrow)8xy6- SHR Vx8xy7- SUBN Vx, Vy (with borrow)8xyE- SHL Vx9xy0- SNE Vx, VyAnnn- LD I, addrBnnn- JP V0, addrCxkk- RND Vx, byteDxyn- DRW Vx, Vy, nibble (draw sprite)Ex9E- SKP Vx (skip if key pressed)ExA1- SKNP Vx (skip if key not pressed)Fx07- LD Vx, DT (read delay timer)Fx0A- LD Vx, K (wait for key press)Fx15- LD DT, Vx (set delay timer)Fx18- LD ST, Vx (set sound timer)Fx1E- ADD I, VxFx29- LD F, Vx (set I to font sprite)Fx33- LD B, Vx (BCD conversion)Fx55- LD [I], Vx (store registers to memory)Fx65- LD Vx, [I] (read registers from memory)
Display
- 64x32 pixel framebuffer
- XOR sprite drawing
- Set VF on sprite collision
- Render framebuffer to window
- Correct draw timing / refresh rate
Input
- Map keyboard to CHIP-8 hex keypad (0x0-0xF)
- Key pressed state
- Key released state
- Blocking wait for keypress (
Fx0A)
Timers
- Delay timer counts down at 60hz
- Sound timer counts down at 60hz
- Buzzer sounds while sound timer > 0
Audio
- Generate beep / tone while sound timer active
Testing & Compatibility
- Pass
1-chip8-logo.ch8 - Pass
2-ibm-logo.ch8 - Pass
3-corax+.ch8 - Pass
4-flags.ch8 - Pass
5-quirks.ch8 - Pass
6-keypad.ch8 - Pass
7-beep.ch8 - Pass
8-scrolling.ch8 - Test with real ROMs / games
Polish
- Configurable CPU speed / cycles per frame
- Configurable color palette
- Window scaling / resize support
- Pause / resume
- Reset / reload ROM
- SUPER-CHIP / CHIP-48 quirks mode (optional)
- XO-CHIP support (optional)