Skip to content

Commit 68a6d21

Browse files
committed
docs: add visual branding with heading and cartridge images to README
1 parent 72f5e7e commit 68a6d21

5 files changed

Lines changed: 114 additions & 137 deletions

File tree

Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
.PHONY: help setup install test lint shell run clean rebuild build-wasm serve-wasm check-sdl install-sdl run-sdl run-sdl-host
1+
.PHONY: help setup install test lint shell run run-no-jit clean rebuild build-wasm serve-wasm check-sdl install-sdl run-sdl run-sdl-host
22

33
help: ## Show this help message
44
@echo 'Usage: make [target]'
55
@echo ''
66
@echo 'Available targets:'
77
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
88

9-
setup: ## Build Docker image with PHP 8.5 RC4
9+
setup: ## Build Docker image with PHP 8.4
1010
docker compose build
1111

1212
rebuild: ## Rebuild Docker image from scratch (no cache)
@@ -27,11 +27,21 @@ lint: ## Run PHPStan static analysis in Docker
2727
shell: ## Open bash shell in Docker container
2828
docker compose run --rm phpboy bash
2929

30-
run: ## Run emulator with ROM in Docker (usage: make run ROM=path/to/rom.gb)
30+
run: ## Run emulator with ROM in Docker with JIT enabled (usage: make run ROM=path/to/rom.gb)
3131
@if [ -z "$(ROM)" ]; then \
3232
echo "Error: ROM parameter is required. Usage: make run ROM=path/to/rom.gb"; \
3333
exit 1; \
3434
fi
35+
docker compose run --rm -it \
36+
-e PHP_INI_SCAN_DIR=/usr/local/etc/php/conf.d:/app/docker/php-jit \
37+
phpboy php -d opcache.jit_buffer_size=100M -d opcache.jit=tracing \
38+
bin/phpboy.php $(ROM)
39+
40+
run-no-jit: ## Run emulator without JIT for baseline performance (usage: make run-no-jit ROM=path/to/rom.gb)
41+
@if [ -z "$(ROM)" ]; then \
42+
echo "Error: ROM parameter is required. Usage: make run-no-jit ROM=path/to/rom.gb"; \
43+
exit 1; \
44+
fi
3545
docker compose run --rm phpboy php bin/phpboy.php $(ROM)
3646

3747
debug: ## Run emulator in debug mode (usage: make debug ROM=path/to/rom.gb)

README.md

Lines changed: 101 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,107 @@
1-
# PHPBoy - Game Boy Color Emulator
1+
<p align="center">
2+
<img src="docs/heading.png" alt="PHPBoy - Game Boy Emulator" />
3+
</p>
24

3-
A readable, well-architected Game Boy Color (GBC) emulator written in PHP 8.5 with multiple frontend options: native SDL2 desktop, CLI terminal, and browser via WebAssembly.
5+
A readable, well-architected Game Boy (DMG) emulator written in PHP 8.4 with multiple frontend options: CLI terminal (primary), browser via WebAssembly, and native SDL2 desktop (WIP).
6+
7+
## Current Status
8+
9+
PHPBoy is a highly accurate DMG (original Game Boy) emulator with:
10+
11+
- ✅ CLI Terminal Frontend: Fully working, 25-30 FPS baseline, 60+ FPS with PHP JIT enabled
12+
- ✅ DMG Emulation: Complete CPU, PPU, memory bus, input, and cartridge support (MBC1/MBC3/MBC5)
13+
- ✅ Test Accuracy: 100% pass rate on Blargg's test suite (11/11 CPU tests + timing test)
14+
- ✅ Commercial ROMs: Tetris, Pokemon Red, Zelda all run stably
15+
- ✅ Browser (WASM): Renderer works but very slow due to WASM overhead
16+
- ⏳ GBC Color Support: Planned for future implementation after DMG emulation is fully complete
17+
- 🔄 Audio: APU implemented, working on output integration (CLI/SDL2/WASM)
18+
- 🔄 Mooneye Test Suite: Working on full support (10/39 currently passing)
19+
- 🔄 Acid Tests: Working on dmg-acid2/cgb-acid2 support
20+
- 🔄 SDL2 Native Desktop: Work in progress
21+
22+
<p align="center">
23+
<img src="docs/cartridges.png" alt="Supported Cartridges" />
24+
</p>
425

526
## Features
627

7-
- **Modern PHP 8.5 RC**: Leverages the latest PHP 8.5 release candidate features including strict types, readonly properties, enums, typed class constants, and property hooks
8-
- **Multiple Frontends**:
9-
- **SDL2 Native Desktop**: Hardware-accelerated rendering with true native performance ⭐ **NEW!**
10-
- **Browser (WebAssembly)**: Runs in the browser via php-wasm - no backend required!
11-
- **CLI Terminal**: ANSI color rendering in your terminal
12-
- **Fully Dockerized Development**: All PHP/Composer/testing tools run exclusively in Docker containers for consistency
13-
- **Comprehensive Testing**: PHPUnit 10 for unit and integration tests
14-
- **Static Analysis**: PHPStan at maximum level (9) for type safety
15-
- **Modular Architecture**: Clean separation of concerns with dedicated namespaces for CPU, PPU, APU, Bus, and Frontend
28+
- Modern PHP 8.4: Leverages the latest PHP 8.4 features including strict types, readonly properties, enums, typed class constants, and property hooks
29+
- Excellent Performance: Achieves 60+ FPS with PHP JIT enabled on typical hardware
30+
- Multiple Frontends:
31+
- CLI Terminal ✅: ANSI color rendering in your terminal - primary working frontend
32+
- Browser (WebAssembly) ✅: Runs in the browser via php-wasm - no backend required! (slow performance)
33+
- SDL2 Native Desktop 🔄: Hardware-accelerated rendering (WIP)
34+
- High Accuracy: 100% pass rate on Blargg's CPU instruction and timing tests
35+
- Fully Dockerized Development: All PHP/Composer/testing tools run exclusively in Docker containers for consistency
36+
- Comprehensive Testing: PHPUnit 10 for unit and integration tests
37+
- Static Analysis: PHPStan at maximum level (9) for type safety
38+
- Modular Architecture: Clean separation of concerns with dedicated namespaces for CPU, PPU, APU, Bus, and Frontend
1639

1740
## Requirements
1841

1942
- Docker
2043
- Docker Compose
2144
- Make (for convenient task automation)
2245

23-
**Important**: All PHP, Composer, PHPUnit, and PHPStan commands must run through Docker. Never run these tools directly on the host machine.
24-
2546
## Getting Started
2647

2748
### Initial Setup
2849

2950
1. Clone the repository:
51+
3052
```bash
3153
git clone <repository-url>
3254
cd phpboy
3355
```
3456

3557
2. Build the Docker image:
58+
3659
```bash
3760
make setup
3861
```
3962

4063
3. Install PHP dependencies:
64+
4165
```bash
4266
make install
4367
```
4468

69+
### Running a Game Boy ROM
70+
71+
The CLI terminal frontend is the primary way to run PHPBoy:
72+
73+
```bash
74+
# Run with CLI frontend (JIT enabled by default for 60+ FPS)
75+
make run ROM=path/to/rom.gb
76+
77+
# Run without JIT for baseline performance testing (25-30 FPS)
78+
make run-no-jit ROM=path/to/rom.gb
79+
```
80+
81+
CLI Controls:
82+
83+
- Arrow Keys: D-pad
84+
- Z: A button
85+
- X: B button
86+
- Enter: Start
87+
- Shift: Select
88+
- Q: Quit
89+
4590
### Development Workflow
4691

47-
All development tasks are managed through the Makefile and run inside Docker containers. **Never run PHP, Composer, PHPUnit, or PHPStan directly on the host machine.**
92+
All development tasks are managed through the Makefile and run inside Docker containers.
4893

4994
#### Available Commands
5095

5196
- `make help` - Show available commands
52-
- `make setup` - Build Docker image with PHP 8.5 RC4
97+
- `make setup` - Build Docker image with PHP 8.4
5398
- `make rebuild` - Rebuild Docker image from scratch (no cache)
5499
- `make install` - Install Composer dependencies in Docker
55100
- `make test` - Run PHPUnit tests in Docker
56101
- `make lint` - Run PHPStan static analysis in Docker
57102
- `make shell` - Open bash shell in Docker container
58-
- `make run ROM=path/to/rom.gb` - Run emulator with specified ROM in Docker
103+
- `make run ROM=path/to/rom.gb` - Run emulator with JIT enabled (60+ FPS)
104+
- `make run-no-jit ROM=path/to/rom.gb` - Run emulator without JIT (25-30 FPS baseline)
59105
- `make build-wasm` - Build WebAssembly version for browser
60106
- `make serve-wasm` - Serve WASM build locally on port 8080
61107
- `make clean` - Remove vendor directory and composer.lock
@@ -76,77 +122,39 @@ make lint
76122
#### Opening a Shell
77123

78124
For debugging or manual operations:
125+
79126
```bash
80127
make shell
81128
```
82129

83-
### Running with SDL2 Native Frontend
84-
85-
PHPBoy supports true native desktop rendering using SDL2 for hardware-accelerated, low-latency gameplay.
86-
87-
#### Prerequisites
130+
## Performance
88131

89-
1. Install SDL2 development libraries:
90-
```bash
91-
# Ubuntu/Debian
92-
sudo apt-get install libsdl2-dev
132+
PHPBoy achieves excellent performance thanks to PHP 8.4's JIT compiler:
93133

94-
# macOS
95-
brew install sdl2
96-
```
134+
- Baseline (no JIT): 25-30 FPS
135+
- With JIT enabled: 60+ FPS (full Game Boy speed!)
136+
- Commercial ROMs: Tetris, Pokemon Red, Zelda all run stably at full speed
97137

98-
2. Install SDL2 PHP extension:
99-
```bash
100-
sudo pecl install sdl-beta
101-
echo "extension=sdl.so" | sudo tee -a $(php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||")
102-
```
138+
The JIT compiler provides a 2-3x performance improvement, allowing PHPBoy to exceed the original Game Boy's 60 FPS target on modern hardware.
103139

104-
3. Verify installation:
105-
```bash
106-
make check-sdl
107-
```
140+
## Additional Frontends
108141

109-
#### Running a ROM
110-
111-
```bash
112-
# Run with SDL2 frontend (on host machine)
113-
make run-sdl-host ROM=path/to/rom.gb
114-
115-
# Or directly with PHP
116-
php bin/phpboy.php path/to/rom.gb --frontend=sdl
117-
```
118-
119-
**Features**:
120-
- ✅ Hardware-accelerated rendering (GPU-based)
121-
- ✅ VSync support for smooth 60fps
122-
- ✅ Native desktop window
123-
- ✅ Low-latency keyboard input
124-
- ✅ Pixel-perfect integer scaling
125-
- ✅ Cross-platform (Linux, macOS, Windows)
126-
127-
**Default Controls**:
128-
- Arrow Keys: D-pad
129-
- Z or A: A button
130-
- X or S: B button
131-
- Enter: Start
132-
- Right Shift: Select
133-
134-
**Documentation**:
135-
- [SDL2 Setup Guide](docs/sdl2-setup.md) - Installation instructions
136-
- [SDL2 Usage Guide](docs/sdl2-usage.md) - Usage and customization
137-
138-
### Running in the Browser
142+
### Running in the Browser (WebAssembly)
139143

140144
PHPBoy can run entirely in the browser via WebAssembly using [php-wasm](https://github.com/seanmorris/php-wasm).
141145

146+
Note: The WASM frontend works but has significant performance overhead. Expect slower-than-realtime performance. Audio is work in progress.
147+
142148
#### Build for Browser
143149

144150
1. Build the WASM distribution:
151+
145152
```bash
146153
make build-wasm
147154
```
148155

149156
2. Serve locally:
157+
150158
```bash
151159
make serve-wasm
152160
```
@@ -155,96 +163,55 @@ make serve-wasm
155163

156164
4. Load a ROM file and play!
157165

158-
**Features**:
166+
Features:
167+
159168
- ✅ Full emulation in the browser
160169
- ✅ No backend server required
161170
- ✅ Keyboard controls
162171
- ✅ Speed control
163172
- ✅ Pause/Resume
164173
- ✅ Works offline after first load
174+
- 🔄 Audio output integration in progress
175+
- ⚠️ Performance: Very slow due to WASM overhead
176+
177+
Browser Requirements:
165178

166-
**Browser Requirements**:
167179
- Chrome 90+, Firefox 88+, Safari 14+, or Edge 90+
168180
- WebAssembly support required
169181

170-
**Documentation**:
182+
Documentation:
183+
171184
- [WASM Build Guide](docs/wasm-build.md) - How to build and deploy
172185
- [Browser Usage Guide](docs/browser-usage.md) - How to use in browser
173186
- [WASM Options Evaluation](docs/wasm-options.md) - Technical decisions
174187

175-
## Project Structure
188+
### Running with SDL2 Native Frontend (Work in Progress)
176189

177-
```
178-
phpboy/
179-
├── bin/ # CLI entry point
180-
├── docs/ # Documentation
181-
│ ├── research.md # Game Boy hardware research
182-
│ ├── sdl2-setup.md # SDL2 native frontend setup
183-
│ ├── sdl2-usage.md # SDL2 usage guide
184-
│ ├── wasm-build.md # WebAssembly build guide
185-
│ ├── browser-usage.md # Browser usage guide
186-
│ └── wasm-options.md # WASM implementation options
187-
├── src/ # Source code
188-
│ ├── Apu/ # Audio Processing Unit
189-
│ ├── Bus/ # Memory bus
190-
│ ├── Cartridge/ # ROM/MBC handling
191-
│ ├── Cpu/ # CPU emulation
192-
│ ├── Frontend/ # Multiple frontend implementations
193-
│ │ ├── Cli/ # CLI terminal frontend
194-
│ │ ├── Sdl/ # SDL2 native desktop frontend
195-
│ │ └── Wasm/ # WebAssembly browser frontend
196-
│ ├── Ppu/ # Pixel Processing Unit
197-
│ └── Support/ # Utilities and helpers
198-
├── tests/ # Test suite
199-
│ ├── Integration/ # Integration tests
200-
│ └── Unit/ # Unit tests
201-
├── third_party/ # External resources
202-
│ ├── references/ # Technical documentation
203-
│ └── roms/ # Test ROMs
204-
├── web/ # Browser frontend
205-
│ ├── index.html # Main page
206-
│ ├── css/ # Stylesheets
207-
│ ├── js/ # JavaScript bridge
208-
│ └── phpboy-wasm.php # PHP entry point
209-
├── composer.json # PHP dependencies
210-
├── package.json # npm dependencies (for php-wasm)
211-
├── Dockerfile # Docker image definition
212-
├── docker-compose.yml # Docker services
213-
├── Makefile # Task automation
214-
├── phpstan.neon # PHPStan configuration
215-
├── phpunit.xml # PHPUnit configuration
216-
└── PLAN.md # Development roadmap
217-
```
190+
PHPBoy has experimental support for native desktop rendering using SDL2 for hardware-accelerated, low-latency gameplay.
218191

219-
## Development Philosophy
192+
Status: 🔄 Work in progress - code implemented but not fully tested/integrated.
220193

221-
PHPBoy follows a step-by-step development approach, implementing each Game Boy subsystem incrementally. Each step includes:
194+
Documentation:
222195

223-
- Historical context about the Game Boy hardware
224-
- Clear implementation tasks
225-
- Comprehensive tests
226-
- Documentation updates
227-
- Verification criteria
196+
- [SDL2 Setup Guide](docs/sdl2-setup.md) - Installation instructions
197+
- [SDL2 Usage Guide](docs/sdl2-usage.md) - Usage and customization
198+
199+
## Testing & Accuracy
228200

229-
See `PLAN.md` for the complete development roadmap.
201+
PHPBoy has excellent accuracy verified by industry-standard test ROMs:
230202

231-
## Testing
203+
### Test Suite Results
232204

233-
PHPBoy uses industry-standard test ROMs to verify accuracy:
205+
- ✅ Blargg's CPU Instruction Tests: 11/11 passing (100%)
206+
- `cpu_instrs` - All CPU instructions validated
207+
- `instr_timing` - Instruction timing accuracy verified
208+
- 🔄 Mooneye Test Suite: 10/39 passing - working on full support
209+
- Focus on improving timing accuracy for remaining tests
210+
- 🔄 Acid Tests: Working on dmg-acid2/cgb-acid2 support
211+
- PPU rendering accuracy improvements in progress
234212

235-
- **Blargg's test suite**: CPU instruction validation
236-
- **Mooneye test suite**: Hardware behavior verification
237-
- **dmg-acid2/cgb-acid2**: PPU rendering accuracy
213+
See `docs/test-results.md` for detailed test results.
238214

239215
## License
240216

241217
MIT License
242-
243-
## Contributing
244-
245-
Contributions are welcome! Please ensure:
246-
247-
1. All code passes PHPStan level 9
248-
2. Tests are included for new features
249-
3. Follow conventional commits format
250-
4. Use the Makefile for all operations

docs/cartridges.png

1.24 MB
Loading

docs/heading-alt.png

674 KB
Loading

docs/heading.png

1.48 MB
Loading

0 commit comments

Comments
 (0)