summaryrefslogtreecommitdiffstats
path: root/boot.php
blob: c0524387d67ff3bee969c598d36e2a6e323881d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

require_once __DIR__.'/vendor/autoload.php';

use GameBoy\Core;
use GameBoy\Keyboard;
use GameBoy\Settings;

$rom = base64_decode(file_get_contents('pokemon.rom'));

$core = new Core($rom);
$keyboard = new Keyboard($core);

$core->start();

if ($core->stopEmulator & 2 == 2) {
    $core->stopEmulator &= 1;
    $core->lastIteration = (int) (microtime(true) * 1000);

    while (true) {
        $core->run();
        $keyboard->check();
    }
} else if (($core->stopEmulator & 2) == 0) {
    echo "The GameBoy core is already running." . PHP_EOL;
}
else {
    echo "GameBoy core cannot run while it has not been initialized." . PHP_EOL;
}