ZH
games/alis / src / Alis / OPL.php · commit 9c722cf
<?phpnamespace App\Alis;/** * C struct __OPL (emu8950.h): one OPL (Y8950 / YM3526 / YM3812) emulator instance. * PORT: the 18 OPL_SLOT structs (with their OPL_PATCH) are stored "column-wise": one array of 18 ints per * C field (slot i = index i), which the block renderer copies into local variables. */final class OPL{    /** C OPL_ADPCM *adpcm: always null (the ADPCM unit only exists on the Y8950, ALIS sets a YM3812) */    public $adpcm = null;    public int $clk = 0;    public int $rate = 0;    public int $chip_type = 0;    public int $adr = 0;    public int $csm_mode = 0;    public int $csm_key_count = 0;    public int $notesel = 0;    public int $inp_step = 0;    public int $out_step = 0;    public int $out_time = 0;    /** C uint8_t reg[0x100] */    public array $reg = [];    public int $test_flag = 0;    public int $slot_key_status = 0;    public int $rhythm_mode = 0;    public int $eg_counter = 0;    public int $pm_phase = 0;    public int $pm_dphase = 0;    public int $am_phase = 0;    public int $am_dphase = 0;    public int $lfo_am = 0;    public int $noise = 0;    public int $short_noise = 0;    /** C uint8_t ch_alg[9] */    public array $ch_alg = [];    public array $pan = [];    public array $pan_fine = [];    public int $mask = 0;    public int $am_mode = 0;    public int $pm_mode = 0;    /** C int16_t ch_out[15]: 0..8 tone, 9 bd, 10 hh, 11 sd, 12 tom, 13 cym, 14 adpcm */    public array $ch_out = [];    public array $mix_out = [0, 0];    public ?OPL_RateConv $conv = null;    public int $timer1_counter = 0;    public int $timer2_counter = 0;    public int $status = 0;    // ---- OPL_SLOT slot[18], one array per field ----    public array $number = [];    public array $type = [];    // OPL_PATCH    public array $TL = [];    public array $FB = [];    public array $EG = [];    public array $ML = [];    public array $AR = [];    public array $DR = [];    public array $SL = [];    public array $RR = [];    public array $KR = [];    public array $KL = [];    public array $AM = [];    public array $PM = [];    public array $WS = [];    /** C int32_t output[2]: latest and previous */    public array $output0 = [];    public array $output1 = [];    /** C uint16_t *wave_table: index 0..3 into the wave tables */    public array $wave_table = [];    public array $pg_phase = [];    public array $pg_out = [];    public array $pg_keep = [];    public array $blk_fnum = [];    public array $fnum = [];    public array $blk = [];    public array $eg_state = [];    public array $tll = [];    public array $rks = [];    public array $eg_rate_h = [];    public array $eg_rate_l = [];    public array $eg_shift = [];    public array $eg_out = [];    public array $update_requests = [];    public function __construct()    {        $z18 = array_fill(0, 18, 0);        foreach (['number', 'type', 'TL', 'FB', 'EG', 'ML', 'AR', 'DR', 'SL', 'RR', 'KR', 'KL', 'AM', 'PM', 'WS',                     'output0', 'output1', 'wave_table', 'pg_phase', 'pg_out', 'pg_keep', 'blk_fnum', 'fnum', 'blk',                     'eg_state', 'tll', 'rks', 'eg_rate_h', 'eg_rate_l', 'eg_shift', 'eg_out', 'update_requests'] as $f) {            $this->$f = $z18;        }        $this->reg = array_fill(0, 0x100, 0);        $this->ch_alg = array_fill(0, 9, 0);        $this->pan = array_fill(0, 16, 0);        $this->pan_fine = array_fill(0, 16, [0.0, 0.0]);        $this->ch_out = array_fill(0, 15, 0);    }}