public function joyPadEvent($key, $down)
{
if ($down) {
$this->JoyPad &= 0xff ^ 1 << $key;
} else {
$this->JoyPad |= 1 << $key;
}
$this->memory[0xff00] = ($this->memory[0xff00] & 0x30) + ((($this->memory[0xff00] & 0x20) == 0 ? $this->JoyPad >> 4 : 0xf) & (($this->memory[0xff00] & 0x10) == 0 ? $this->JoyPad & 0xf : 0xf));
}