You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<imgsrc="docs/heading.png"alt="PHPBoy - Game Boy Emulator" />
3
+
</p>
2
4
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:
-**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
- 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
16
39
17
40
## Requirements
18
41
19
42
- Docker
20
43
- Docker Compose
21
44
- Make (for convenient task automation)
22
45
23
-
**Important**: All PHP, Composer, PHPUnit, and PHPStan commands must run through Docker. Never run these tools directly on the host machine.
24
-
25
46
## Getting Started
26
47
27
48
### Initial Setup
28
49
29
50
1. Clone the repository:
51
+
30
52
```bash
31
53
git clone <repository-url>
32
54
cd phpboy
33
55
```
34
56
35
57
2. Build the Docker image:
58
+
36
59
```bash
37
60
make setup
38
61
```
39
62
40
63
3. Install PHP dependencies:
64
+
41
65
```bash
42
66
make install
43
67
```
44
68
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
+
45
90
### Development Workflow
46
91
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.
48
93
49
94
#### Available Commands
50
95
51
96
-`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
53
98
-`make rebuild` - Rebuild Docker image from scratch (no cache)
54
99
-`make install` - Install Composer dependencies in Docker
55
100
-`make test` - Run PHPUnit tests in Docker
56
101
-`make lint` - Run PHPStan static analysis in Docker
57
102
-`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)
59
105
-`make build-wasm` - Build WebAssembly version for browser
60
106
-`make serve-wasm` - Serve WASM build locally on port 8080
61
107
-`make clean` - Remove vendor directory and composer.lock
@@ -76,77 +122,39 @@ make lint
76
122
#### Opening a Shell
77
123
78
124
For debugging or manual operations:
125
+
79
126
```bash
80
127
make shell
81
128
```
82
129
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
88
131
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:
93
133
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
97
137
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.
0 commit comments