pcjs/versions/pc8080/1.30.1/pc8080.js

835 lines
106 KiB
JavaScript

(function(){/*
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
Jeff Parsons 2012-2016
This file is part of PCjs, a computer emulation software project at <http://pcjs.org/>.
PCjs is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.
PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with PCjs. If not,
see <http://www.gnu.org/licenses/gpl.html>.
You are required to include the above copyright notice in every source code file of every
copy or modified version of this work, and to display that copyright notice on every screen
that loads or runs any version of this software (see COPYRIGHT in /modules/shared/lib/defines.js).
Some PCjs files also attempt to load external resource files, such as character-image files,
ROM files, and disk image files. Those external resource files are not considered part of PCjs
for purposes of the GNU General Public License, and the author does not claim any copyright
as to their contents.
*/
var k,m={pd:1,qd:3,rd:26," ":32,"!":33,'"':34,"#":35,$:36,"%":37,"&":38,"'":39,"(":40,")":41,"*":42,"+":43,",":44,"-":45,".":46,"/":47,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,":":58,";":59,"<":60,"=":61,">":62,"?":63,"@":64,jb:65,Mb:66,Ob:67,mb:68,E:69,Rb:70,Sb:71,Tb:72,Ub:73,ac:74,bc:75,ob:76,ic:77,jc:78,mc:79,nc:80,Q:81,tc:82,wc:83,Bc:84,Cc:85,Dc:86,Ec:87,Gc:88,Hc:89,Ic:90,"[":91,"\\":92,"]":93,"^":94,_:95,"`":96,Zd:97,$d:98,ae:99,d:100,e:101,be:102,ce:103,de:104,ee:105,fe:106,k:107,ge:108,
he:109,n:110,ie:111,p:112,q:113,r:114,je:115,t:116,ke:117,le:118,me:119,x:120,y:121,z:122,"{":123,"|":124,"}":125,"~":126};
function aa(a){var b=16,c;if(a){b||(b=10);var d=a.charAt(0),e=0<a.indexOf(",");e&&(a=a.replace(/,/g,""));"#"==d?(b=8,d=null):"$"==d&&(b=16,d=null);null==d?a=a.substr(1):("0"==d&&(d=a.charAt(1),"b"==d&&e&&(b=2,d=null),"o"==d?(b=8,d=null):"x"==d&&(b=16,d=null)),null==d?a=a.substr(2):(d=a.charAt(a.length-1).toLowerCase(),"y"==d?(b=2,d=null):"."==d?(b=10,d=null):"h"==d&&(b=16,d=null),null==d&&(a=a.substr(0,a.length-1))));var f,d=a;((e=b)&&10!=e?16==e?d.match(/^[0-9a-f]+$/i):8==e?d.match(/^[0-7]+$/):2==
e&&d.match(/^[01]+$/):d.match(/^[0-9]+$/))&&!isNaN(f=parseInt(a,b))&&(c=f|0)}return c}function p(a,b,c){var d="";b?8<b&&(b=8):b=a&-65536?8:4;if(null==a||isNaN(a))for(;0<b--;)d="?"+d;else for(;0<b--;){var e=a&15,e=e+(0<=e&&9>=e?48:55),d=String.fromCharCode(e)+d;a>>=4}return(c?"0x":"")+d}function ba(a){var b=a,c=a.lastIndexOf("/");0<=c&&(b=a.substr(c+1));c=b.indexOf("&");0<c&&(b=b.substr(0,c));return b}function ca(a){var b="",c=a.lastIndexOf(".");0<=c&&(b=a.substr(c+1).toLowerCase());return b}
function da(){var a=ea();return-1!==a.indexOf("pcjs.org",a.length-8)}var fa={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"};function ga(a){return a.replace(/[&<>"']/g,function(a){return fa[a]})}function ha(a){return String.prototype.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}
var ia={0:"NUL",1:"SOH",2:"STX",3:"ETX",4:"EOT",5:"ENQ",6:"ACK",7:"BEL",8:"BS",9:"TAB",11:"VT",12:"FF",13:"CR",14:"SO",15:"SI",16:"DLE",17:"XON",18:"DC2",19:"XOFF",20:"DC4",21:"NAK",22:"SYN",23:"ETB",24:"CAN",25:"EM",26:"SUB",27:"ESC",28:"FS",29:"GS",30:"RS",31:"US"},ja=Date.now||function(){return+new Date};
function ka(){function a(a){return(10>a?"0":"")+a}var b=new Date;return b.getFullYear()+"-"+a(b.getMonth()+1)+"-"+a(b.getDate())+" "+a(b.getHours())+":"+a(b.getMinutes())+":"+a(b.getSeconds())}
function la(a,b,c,d){var e=0,f=null,g=null;if("object"==typeof resources&&(f=resources[a]))return d&&d(a,f,e),[f,e];if(c&&"function"==typeof resources)return resources(a,function(b,c){d&&d(a,b,c)}),g;var h=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP");c&&(h.onreadystatechange=function(){4===h.readyState&&(f=h.responseText,200==h.status||!h.status&&f.length&&"file:"==(window?window.location.protocol:"file:")||(e=h.status||-1),d&&d(a,f,e))});if(b&&"object"==
typeof b){var l="",n;for(n in b)b.hasOwnProperty(n)&&(l&&(l+="&"),l+=n+"="+encodeURIComponent(b[n]));l=l.replace(/%20/g,"+");h.open("POST",a,!!c);h.setRequestHeader("Content-type","application/x-www-form-urlencoded");h.send(l)}else h.open("GET",a,!!c),"bytes"==b&&h.overrideMimeType("text/plain; charset=x-user-defined"),h.send();c||(f=h.responseText,200!=h.status&&(e=h.status||-1),d&&d(a,f,e),g=[f,e]);return g}function ea(){return"http://"+(window?window.location.host:"www.pcjs.org")}
function q(a){window&&window.alert(a)}function ma(a){var b=!1;window&&(b=window.confirm(a));return b}var na=null;function oa(){if(null==na){var a=!1;if(window)try{window.localStorage.setItem("PCjs.localStorage","PCjs.localStorage"),a="PCjs.localStorage"==window.localStorage.getItem("PCjs.localStorage"),window.localStorage.removeItem("PCjs.localStorage")}catch(b){a=!1}na=a}return na}function pa(a){var b;if(window)try{b=window.localStorage.getItem(a)}catch(c){}return b}
function qa(a,b){try{return window.localStorage.setItem(a,b),!0}catch(c){}return!1}function ra(a){if(window){var b=window?window.navigator.userAgent:"";return"iOS"==a&&b.match(/(iPod|iPhone|iPad)/)&&b.match(/AppleWebKit/)||"MSIE"==a&&b.match(/(MSIE|Trident)/)||0<=b.indexOf(a)?!0:!1}return!1}var ta={init:[],show:[],exit:[]},ua=!1,va=!1,wa=!0;function xa(a,b){if(window){var c=window[a];window[a]="function"!==typeof c?b:function(){c&&c();b()}}}function ya(a){ta.init.push(a)}
function za(a){if(wa)try{for(var b=0;b<a.length;b++)a[b]()}catch(c){Aa("An unexpected exception occurred:\n\n"+c.message+"\n\nPlease send this information to support@pcjs.org. Thanks.",void 0,void 0)}}function Ba(a){!wa&&a?(wa=!0,ua&&Ca("init"),va&&Ca("show")):wa=a}function Ca(a){ta[a]&&za(ta[a])}xa("onload",function(){ua=!0;za(ta.init)});xa("onpageshow",function(){va=!0;za(ta.show)});xa(ra("Opera")||ra("iOS")?"onunload":"onbeforeunload",function(){za(ta.exit)});
function r(a,b,c){this.type=a;b||(b={id:"",name:""});this.id=b.id||"";this.name=b.name;this.ub=b.comment;this.Mc=b;b=this.id.indexOf(".");0>b?this.Sa=this.id:(this.Ta=this.id.substr(0,b),this.Sa=this.id.substr(b+1));this[a]=c;this.l={ready:!1,Wa:!1,eb:!1,Y:!1,error:!1};this.Za=null;this.l.error=!1;this.A={};this.O=null;v.push(this)}var Da=void 0,Ea={};
if(window){Da||(Da=window.location.search.substr(1));for(var Fa,Ga=/\+/g,Ha=/([^&=]+)=?([^&]*)/g;Fa=Ha.exec(Da);)Ea[decodeURIComponent(Fa[1].replace(Ga," "))]=decodeURIComponent(Fa[2].replace(Ga," "))}function Ia(a){function b(){}if(window){if(!a)throw new TypeError;if(Object.create)return Object.create(a);var c=typeof a;if("object"!==c&&"function"!==c)throw new TypeError;}b.prototype=a;return new b}
function w(a,b){b||(b=r);a.prototype=Ia(b.prototype);a.prototype.constructor=a;a.prototype.parent=b.prototype}if(window){window.PCjs||(window.PCjs={});var Ja=window.PCjs.Machines||(window.PCjs.Machines={}),v=window.PCjs.Components||(window.PCjs.Components=[])}else Ja={},v=[];function Ka(a,b,c){Ja[a]&&b&&(Ja[a][b]=c)}function Aa(a,b,c){b||q((c?c+": ":"")+a)}
function La(a){var b,c=[];a&&(a=0<(b=a.indexOf("."))?a.substr(0,b+1):"");for(b=0;b<v.length;b++){var d=v[b];a&&d.id.indexOf(a)||c.push(d)}return c}function Ma(a){if(void 0!==a){var b;for(b=0;b<v.length;b++)if(v[b].id===a)return v[b]}return null}function Oa(a,b){var c;if(void 0!==a){var d;b&&(b=0<(d=b.indexOf("."))?b.substr(0,d+1):"");for(d=0;d<v.length;d++)if(c)c==v[d]&&(c=null);else if(!(a!=v[d].type||b&&v[d].id.indexOf(b)))return v[d]}return null}
function z(a){var b=null;if(a=a.getAttribute("data-value"))try{b=eval("("+a+")")}catch(c){q(c.message+" ("+a+")")}return b}function Pa(a,b){b=A(b.parentNode,"pc8080-control");for(var c=0;c<b.length;c++)for(var d=b[c].childNodes,e=0;e<d.length;e++){var f=d[e];if(1===f.nodeType){var g=f.getAttribute("class");if(g)for(var h=g.split(" "),l=0;l<h.length;l++)switch(g=h[l],g){case "pc8080-binding":(g=z(f))&&g.binding&&a.V(g.type,g.binding,f,g.value),l=h.length}}}}
function A(a,b,c){c&&(b+="-"+c+"-object");if(a.getElementsByClassName)return a.getElementsByClassName(b);var d;c=[];a=a.getElementsByTagName("*");var e=new RegExp("(^| )"+b+"( |$)");b=0;for(d=a.length;b<d;b++)e.test(a[b].className)&&c.push(a[b]);return c}
r.prototype={constructor:r,parent:null,toString:function(){return this.name?this.name:this.id||this.type},V:function(a,b,c){switch(b){case "clear":return this.A[b]||(this.A[b]=c,c.onclick=function(a){return function(){a.A.print&&(a.A.print.value="")}}(this)),!0;case "print":return this.A[b]||(this.va=this.A[b]=c,c.value="",this.da=function(a){return function(b,c){8192<a.value.length&&(a.value=a.value.substr(a.value.length-4096));a.value+=(void 0!==c?c+": ":"")+(b||"")+"\n";a.scrollTop=a.scrollHeight}}(c),
this.L=function(a){this.da(a,this.Sa)}),!0;default:return!1}},log:function(){},da:function(){},status:function(a){this.da(this.Sa+": "+a)},L:function(a,b,c){Aa(a,b,c||this.type)},ga:function(){return this.l.Y=!0},ia:function(a,b){b&&(this.l.Y=!1);return!0}};function Qa(a,b){if(a.l.eb)return a.l.Wa=!1,a.l.eb=!1;if(a.l.error)return a.da(a.toString()+" error"),!1;a.l.Wa=b;return a.l.Wa}function B(a){if(!a.l.error&&(a.l.ready=!0,a.l.ready)){var b=a.Za;a.Za=null;b&&b()}}
function Ra(a,b){b&&(a.l.ready?b():a.Za=b);return a.l.ready}Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){b=b||0;for(var c=this.length;b<c;b++)if(this[b]===a)return b;return-1});
Function.prototype.bind||(Function.prototype.bind=function(a){function b(){return e.apply(this instanceof c&&a?this:a,d.concat(Array.prototype.slice.call(arguments)))}function c(){}if("function"!=typeof this)throw new TypeError("Function.prototype.bind: non-callable object");var d=Array.prototype.slice.call(arguments,1),e=this;c.prototype=this.prototype;b.prototype=new c;return b});
var Sa="undefined"!==typeof ArrayBuffer,Ta=[1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,
0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1];function Ua(a){r.call(this,"Panel",a,Ua)}w(Ua);k=Ua.prototype;k.V=function(a,b,c,d){return this.v&&this.v.V(a,b,c,d)||this.a&&this.a.V(a,b,c,d)||this.m&&this.m.V(a,b,c,d)?!0:this.parent.V.call(this,a,b,c,d)};k.qa=function(a,b,c,d){this.v=a;this.j=b;this.a=c;this.O=d;this.m=Va(a,"Keyboard")};k.ga=function(a,b){b||Wa();return!0};k.ia=function(){return!0};k.Aa=function(){};
function Wa(){for(var a=!1,b=A(document,"pc8080","panel"),c=0;c<b.length;c++){var d=b[c],e=z(d),f=Ma(e.id);f||(a=!0,f=new Ua(e));Pa(f,d);a&&B(f)}}ya(Wa);
function Xa(a,b,c){r.call(this,"Bus",a,Xa);this.a=b;this.O=c;this.s=a.busWidth||16;this.u=Math.pow(2,this.s);this.g=this.u-1|0;this.j=(this.s>>1)+2;10>this.j&&(this.j=10);15<this.j&&(this.j=15);this.c=1<<this.j;this.w=this.c>>2;this.f=this.c-1;this.i=this.u/this.c|0;this.o=this.i-1;this.m=[];this.v=[];this.B=[];this.C=[];a=new D;Ya(a,this.O);this.b=Array(this.i);for(b=0;b<this.i;b++)this.b[b]=a;B(this)}w(Xa);Xa.prototype.reset=function(){};Xa.prototype.ga=function(a,b){b||this.reset();return!0};
function Za(a,b,c,d){for(var e=b,f=c,g=e>>>a.j;0<f&&g<a.b.length;){var h=a.b[g],l=g*a.c,n=a.c-(e-l);n>f&&(n=f);if(h&&h.size){if(h.type==d){if(e+f<=h.Ma)return h.cb+=h.Ma-e,h.Ma=e,!0;if(e>=h.Ma+h.cb){n=h.size-(e-l);n>f&&(n=f);h.cb=e-h.Ma+n;e=l+a.c;f-=n;g++;continue}}return $a(1,e,f)}e=new D(e,n,a.c,d);Ya(e,a.O,h);a.b[g++]=e;e=l+a.c;f-=n}return 0>=f?(a.status(Math.floor(c/1024)+"Kb "+ab[d]+" at "+p(b,4,!0)),!0):$a(2,b,c)}Xa.prototype.J=function(a){return this.b[(a&this.g)>>>this.j].Pa(a&this.f,a)};
function bb(a,b){return a.b[(b&a.g)>>>a.j].bb(b&a.f,b)}function cb(a,b){var c=b&a.f,d=(b&a.g)>>>a.j;return c!=a.f?a.b[d].kd(c,b):a.b[d++].Pa(c,b)|a.b[d&a.o].Pa(0,b+1)<<8}Xa.prototype.aa=function(a,b){this.b[(a&this.g)>>>this.j].Qa(a&this.f,b&255,a)};function db(a,b,c){a.b[(b&a.g)>>>a.j].Hb(b&a.f,c&255,b)}function fb(a,b,c){var d=b&a.f,e=(b&a.g)>>>a.j;d!=a.f?a.b[e].ld(d,c&65535,b):(a.b[e++].Qa(d,c&255,b),a.b[e&a.o].Qa(0,c>>8&255,b+1))}
function gb(a){for(var b=0,c=[],d=0;d<a.i;d++){var e=a.b[d];if(e.na||e.Ab){c[b++]=d;var f=b++;if(e=e.save()){for(var g=0,h=0,l=[];g<e.length;){for(var n=e[g],u=g+1;u<e.length&&e[u]===n;)u++;l[h++]=u-g;l[h++]=n;g=u}l.length<e.length&&(e=l)}c[f]=e}}return c}function hb(a,b,c,d){void 0===d&&(d=0);if(c)for(var e in c){var f=a,g=+e+d,h=c[e].bind(b);if(h)for(var l=+e+d;l<=g;l++)void 0!==f.m[l]?q("Input port "+p(l,4,!0)+" already registered"):f.m[l]=[h,!1]}}
function ib(a,b,c,d){void 0===d&&(d=0);if(c)for(var e in c){var f=a,g=+e+d,h=c[e].bind(b);if(h)for(var l=+e+d;l<=g;l++)void 0!==f.v[l]?q("Output port "+p(l,4,!0)+" already registered"):f.v[l]=[h,!1]}}function $a(a,b,c){q("Memory block error ("+a+": "+p(b)+","+p(c)+")");return!1}var jb;if(Sa){var kb=new ArrayBuffer(2);(new DataView(kb)).setUint16(0,256,!0);jb=256===(new Uint16Array(kb))[0]}else jb=!1;var lb=jb;
function D(a,b,c,d){this.id=mb+=2;this.a=null;this.Ma=a;this.cb=b;this.size=c||0;this.type=d||nb;this.c=d==ob;Ya(this);this.na=this.Ab=!1;if(c)if(Sa)this.j=new ArrayBuffer(c),this.A=new DataView(this.j,0,c),this.b=new Uint8Array(this.j,0,c),this.i=new Uint16Array(this.j,0,c>>1),this.a=new Int32Array(this.j,0,c>>2),pb(this,lb?qb:rb);else{this.a=Array(c>>2);for(a=0;a<this.a.length;a++)this.a[a]=0;pb(this,sb)}else pb(this)}var nb=0,ob=2,ab=["NONE","RAM","ROM","VID","H/W"],mb=0;
D.prototype={constructor:D,parent:null,save:function(){var a,b;if(Sa)for(a=Array(this.size>>2),b=0;b<a.length;b++)a[b]=this.A.getInt32(b<<2,!0);else a=this.a;return a},restore:function(a){if(a&&this.size==a.length<<2){var b;if(Sa)for(b=0;b<a.length;b++)this.A.setInt32(b<<2,a[b],!0);else this.a=a;return this.na=!0}return!1},m:function(){return 255},o:function(){},v:function(a,b){return this.Pa(a++,b++)|this.Pa(a,b)<<8},s:function(a,b,c){this.Qa(a++,b&255,c++);this.Qa(a,b>>8,c)},C:function(a){return this.a[a>>
2]>>>((a&3)<<3)&255},I:function(a){var b=a>>2;a=(a&3)<<3;var c=this.a[b]>>a;return 24>a?c&65535:c&255|(this.a[b+1]&255)<<8},S:function(a,b){var c=a>>2;a=(a&3)<<3;this.a[c]=this.a[c]&~(255<<a)|b<<a;this.na=!0},ea:function(a,b){var c=a>>2;a=(a&3)<<3;24>a?this.a[c]=this.a[c]&~(65535<<a)|b<<a:(this.a[c]=this.a[c]&16777215|b<<24,c++,this.a[c]=this.a[c]&-256|b>>8);this.na=!0},w:function(a,b){return this.bb(a,b)},H:function(a,b){return this.Eb(a,b)},N:function(a,b,c){this.c||this.Hb(a,b,c)},W:function(a,
b,c){this.c||this.X(a,b,c)},u:function(a){return this.b[a]},B:function(a){return this.b[a]},G:function(a){return this.A.getUint16(a,!0)},M:function(a){return a&1?this.b[a]|this.b[a+1]<<8:this.i[a>>1]},K:function(a,b){this.b[a]=b;this.na=!0},R:function(a,b){this.b[a]=b;this.na=!0},U:function(a,b){this.A.setUint16(a,b,!0);this.na=!0},Z:function(a,b){a&1?(this.b[a]=b,this.b[a+1]=b>>8):this.i[a>>1]=b;this.na=!0}};function Ya(a,b,c){a.O=b;a.f=a.g=0;c&&((a.f=c.f)&&tb(a,ub,!1),(a.g=c.g)&&vb(a,ub,!1))}
function vb(a,b,c){c&&a.g||(a.Qa=!a.c&&b[1]||a.o,a.ld=!a.c&&b[3]||a.s);if(c||void 0===c)a.Hb=b[1]||a.o,a.X=b[3]||a.s}function tb(a,b,c){c&&a.f||(a.Pa=b[0]||a.m,a.kd=b[2]||a.v);if(c||void 0===c)a.bb=b[0]||a.m,a.Eb=b[2]||a.v}function pb(a,b){b||(b=wb);tb(a,b,void 0);vb(a,b,void 0)}var wb=[],sb=[D.prototype.C,D.prototype.S,D.prototype.I,D.prototype.ea],ub=[D.prototype.w,D.prototype.N,D.prototype.H,D.prototype.W];
if(Sa)var rb=[D.prototype.u,D.prototype.K,D.prototype.G,D.prototype.U],qb=[D.prototype.B,D.prototype.R,D.prototype.M,D.prototype.Z];function xb(a,b){r.call(this,"CPU",a,xb);var c=a.multiplier||1;this.la=a.cycles||b;this.K=c;this.Ca=Math.round(this.la/1E4)/100;this.U=this.Ca*this.K;this.l.oa=!1;this.l.Fb=!1;this.l.Na=a.autoStart;this.l.yb=!1;this.l.Xa=!1;this.ta=this.X=0;this.ua=a.csStart;this.Z=a.csInterval;this.ea=a.csStop;this.G=[];this.Va=this.hb.bind(this);B(this)}w(xb);var yb=["power","reset"];
k=xb.prototype;k.qa=function(a,b,c,d){this.v=a;this.j=b;this.O=d;for(b=0;b<yb.length;b++)(c=this.A[yb[b]])&&this.v.V(null,yb[b],c);this.M=Va(a,"ChipSet");a=zb(a,"autoStart");null!=a&&(this.l.Na="true"==a?!0:"false"==a?!1:!!a);B(this)};k.reset=function(){};k.save=function(){return null};k.restore=function(){return!1};k.ga=function(a,b){if(!b){if(a&&this.restore){Ab(this);if(!this.restore(a))return!1;Bb(this)}else this.reset();this.da("No debugger detected")}Cb(this);return!0};
k.ia=function(a){return a?this.save():!0};k.Na=function(){return this.l.Na||void 0===this.A.run?(this.hb(!0),!0):!1};k.Bb=function(){return 0};function Bb(a){void 0===a.ua&&(a.ua=0);void 0===a.Z&&(a.Z=-1);void 0===a.ea&&(a.ea=-1);a.l.Xa=0<=a.ua&&0<a.Z;a.l.Xa&&(a.ta=0,a.X=a.ua-a.H)}
k.V=function(a,b,c){var d=this;a=!1;switch(b){case "power":case "reset":this.A[b]=c;a=!0;break;case "run":this.A[b]=c;c.onclick=function(){var a;if(a=d.v)if(a=d.v,a.l.Y)a=!0;else{var b=null,c,h=La(a.id);for(c=0;c<h.length&&(b=h[c],b===a||b.l.ready);c++);if(c==h.length)for(c=0;c<h.length&&(b=h[c],b===a||b.l.Y);c++);c==h.length&&(b=a);q("The "+b.type+" component ("+b.id+") is not "+(b.l.ready?"powered yet":"ready yet"+(b.Za?" (waiting for notification)":""))+".");a=!1}a&&(d.l.oa?Db(d):d.hb())};a=!0;
break;case "speed":this.A[b]=c;a=!0;break;case "setSpeed":this.A[b]=c,c.onclick=function(){Eb(d,d.K<<1,!0)},c.textContent=this.U.toFixed(2)+"Mhz",a=!0}return a};function Fb(a,b){var c=1;b&&1<a.K&&a.R&&(c=a.R/a.Ca);a.Ka=Math.round(1E3/30);a.xa=Math.floor(a.la/30*c);b||(a.ja=a.xa);a.Da=0}function Gb(a){return a.H+a.N+a.W-a.a}function Ab(a){a.R=0;a.La=0;a.H=a.N=a.W=a.a=0;Bb(a);Eb(a,1)}
function Eb(a,b,c){if(void 0!==b){.8>a.R/a.U&&(b=1);a.K=b;b=a.Ca*a.K;if(a.U!=b){a.U=b;b=a.U.toFixed(2)+"Mhz";var d=a.A.setSpeed;d&&(d.textContent=b);a.da("target speed: "+b)}c&&a.v&&Hb(a.v)}a.H+=a.N;a.N=0;a.I=ja();a.S=0;Fb(a)}function Ib(a,b){var c=a.G.length;a.G.push([-1,b]);return c}function Kb(a,b,c){0<=b&&b<a.G.length&&0>a.G[b][0]&&(c*=a.la*a.K/1E3,a.G[b][0]=c+Lb(a))}function Lb(a,b){var c=a.W-=a.a;a.a=0;b&&(a.W=0);return c}
k.hb=function(a){if(Qa(this,!0)){if(!this.l.oa){Eb(this);this.v&&this.v.start(this.I,Gb(this));this.l.oa=!0;this.l.Fb=!0;this.M&&this.M.start();var b=this.A.run;b&&(b.textContent="Halt");this.v&&(this.v.Aa(!0),a&&Hb(this.v,!0))}this.Da>=this.la&&Fb(this,!0);this.pa=0;this.sa=ja();this.S&&(a=this.sa-this.S,a>this.Ka&&(this.I+=a,this.I>this.sa&&(this.I=this.sa)));try{do{for(var c,d=this.l.Xa?1:this.xa,e=this.G.length-1;0<=e;e--){var f=this.G[e];0>f[0]||d>f[0]&&(d=f[0])}c=d;this.Gb(c);c=Lb(this,!0);
this.pa+=c;this.N+=c;a=c;this.l.Xa&&(b=!1,this.ta=this.ta+this.Bb()|0,this.X-=a,0>=this.X&&(this.X+=this.Z,b=!0),0<=this.ea&&this.ea<=Gb(this)&&(this.Z=this.ea=-1,Bb(this),Db(this),b=!0),b&&this.da(Gb(this)+" cycles: checksum="+p(this.ta)));a=c;for(var g=this.G.length-1;0<=g;g--){var h=this.G[g];0>h[0]||(h[0]-=a,0>=h[0]&&(h[0]=-1,h[1]()))}this.ja-=c;if(0>=this.ja){this.ja+=this.xa;15<=++this.La&&(this.v&&this.v.Aa(),this.La=0);break}}while(this.l.oa)}catch(l){Db(this);Cb(this);this.v&&this.v.stop(ja(),
Gb(this));Qa(this,!1);c=l.stack||l.message;this.l.error=!0;this.L(c);return}c=setTimeout;d=this.Va;this.S=ja();e=this.Ka;this.pa&&(e=Math.round(e*this.pa/this.xa));e-=this.S-this.sa;if(f=this.S-this.I)this.R=Math.round(this.N/(10*f))/100,864E5<=f&&(this.H=0,Eb(this));if(0>e||this.R<this.U)-1E3>e&&(this.I-=e),e=0;this.Da+=this.pa;this.S+=e;c(d,e)}else Cb(this),this.v&&this.v.stop(ja(),Gb(this))};k.Gb=function(){return 0};
function Db(a){a.l.Wa&&(a.l.eb=!0);Lb(a);a.H+=a.N;a.N=0;if(a.l.oa){a.l.oa=!1;a.M&&a.M.stop();var b=a.A.run;b&&(b.textContent="Run")}a.l.complete=void 0}function Cb(a){if(a.v){for(var b=a.v,c=0;c<b.m.length;c++)Mb(b.m[c],void 0);a.v.Aa(void 0)}}function Nb(a){xb.call(this,a,1E6);this.Ha=Ob;Ab(this);this.l.complete=this.l.Nc=!1;this.Ja=0;this.ra=[];this.Ia=0;Pb(this)}w(Nb,xb);function Qb(a,b){a.ra.push(b)}k=Nb.prototype;k.reset=function(){this.l.oa&&Db(this);Pb(this);Ab(this);this.l.error=!1;this.parent.reset.call(this)};
function Pb(a){a.b=0;a.c=0;a.D=0;a.f=0;a.F=0;a.g=0;a.i=0;a.u=0;E(a,a.Ia);Rb(a,0);a.B=0}function Sb(a,b){a.Ia=b;E(a,b)}k.Bb=function(){var a=this.b+this.c+this.D+this.f+this.F+this.g+this.i|0;return a=a+this.u+this.o+Tb(this)|0};k.save=function(){var a=new F(this);a.set(0,[this.b,this.c,this.D,this.f,this.F,this.g,this.i,this.u,this.o,Tb(this)]);a.set(1,[this.B,this.H,this.K]);a.set(2,gb(this.j));return a.data()};
k.restore=function(a){var b=a[0];this.b=b[0];this.c=b[1];this.D=b[2];this.f=b[3];this.F=b[4];this.g=b[5];this.i=b[6];this.u=b[7]&65535;E(this,b[8]);Rb(this,b[9]);b=a[1];this.B=b[0];this.H=b[1];Eb(this,b[3]);a:{b=this.j;a=a[2];var c;for(c=0;c<a.length-1;c+=2){var d=a[c],e=a[c+1];if(e&&e.length<b.w){for(var f=0,g=Array(b.w),h=0;h<e.length-1;)for(var l=e[h++],n=e[h++];l--;)g[f++]=n;e=g}f=b.b[d];if(!f||!f.restore(e)){q("Unable to restore memory block "+d);b=!1;break a}}b=!0}return b};
k.V=function(a,b,c){switch(b){case "A":case "B":case "C":case "BC":case "D":case "E":case "DE":case "H":case "L":case "HL":case "SP":case "PC":case "PS":case "IF":case "SF":case "ZF":case "AF":case "PF":case "CF":this.A[b]=c;this.Ja++;a=!0;break;default:a=this.parent.V.call(this,a,b,c)}return a};function Ub(a){return a.c<<8|a.D}function Vb(a,b){a.c=b>>8&255;a.D=b&255}function Wb(a){return a.f<<8|a.F}function Xb(a,b){a.f=b>>8&255;a.F=b&255}function G(a){return a.g<<8|a.i}
function I(a,b){a.g=b>>8&255;a.i=b&255}function E(a,b){a.o=b&65535}function J(a){return a.m&256?1:0}function K(a,b){a.m=a.m&255|b}function Yb(a){return Ta[a.s&255]?4:0}function Tb(a){return a.C&-214|(a.s&128?128:0)|(a.m&255?0:64)|((a.s^a.w)&16?16:0)|Yb(a)|J(a)}function Rb(a,b){a.m=a.s=a.w=0;b&1&&(a.m|=256);b&4||(a.s|=1);b&16&&(a.w|=16);b&64||(a.m|=255);b&128&&(a.s^=192);a.C=a.C&-726|b&512|2}function L(a,b){a.w=a.b^b;return a.s=(a.m=a.b+b)&255}
function Zb(a,b){a.w=a.b^b;return a.s=(a.m=a.b+b+(a.m&256?1:0))&255}function $b(a,b){a.m=a.s=a.w=a.b&b;(a.b|b)&8&&(a.w^=16);return a.m}function ac(a,b){a.w=b^255;b=a.s=b+255&255;a.m=a.m&-256|b;return b}function bc(a,b){a.w=b;b=a.s=b+1&255;a.m=a.m&-256|b;return b}function cc(a,b){return a.s=a.m=a.w=a.b|b}function M(a,b){b^=255;a.w=a.b^b;return a.s=(a.m=a.b+b+1^256)&255}function dc(a,b){b^=255;a.w=a.b^b;return a.s=(a.m=a.b+b+(a.m&256?0:1)^256)&255}function ec(a,b){return a.s=a.m=a.w=a.b^b}k.J=function(a){return this.j.J(a)};
k.aa=function(a,b){this.j.aa(a,b)};function N(a){var b=a.J(a.o);E(a,a.o+1);return b}function O(a){var b=cb(a.j,a.o);E(a,a.o+2);return b}function P(a){var b=cb(a.j,a.u);a.u=a.u+2&65535;return b}function R(a,b){a.u=a.u-2&65535;fb(a.j,a.u,b)}function fc(a){if(a.a&&a.B&255&&a.C&512){for(var b=0;8>b&&!(a.B&1<<b);b++);a.B&=~(0>b?255:1<<b);a.C&=-513;a.B&=-257;a.Ha[199|b<<3].call(a)}return a.B&256?(Lb(a),!1):!0}function gc(a,b){a.B|=1<<b;a.C&512&&Lb(a)}
function S(a,b,c,d){d=d||2;a.A[b]&&(void 0===c&&(a.l.error=!0,a.L("Value for "+b+" is invalid"),Db(a)),c=!a.l.oa||a.l.yb?p(c,d):"--------".substr(0,d),a.A[b].textContent!=c&&(a.A[b].textContent=c))}
k.Aa=function(a){this.Ja&&(a||!this.l.oa||this.l.yb)&&(S(this,"A",this.b),S(this,"B",this.c),S(this,"C",this.D),S(this,"BC",Ub(this),4),S(this,"D",this.f),S(this,"E",this.F),S(this,"DE",Wb(this),4),S(this,"H",this.g),S(this,"L",this.i),S(this,"HL",G(this),4),S(this,"SP",this.u,4),S(this,"PC",this.o,4),a=Tb(this),S(this,"PS",a,4),S(this,"IF",a&512?1:0,1),S(this,"SF",a&128?1:0,1),S(this,"ZF",a&64?1:0,1),S(this,"AF",a&16?1:0,1),S(this,"PF",a&4?1:0,1),S(this,"CF",a&1?1:0,1));if(a=this.A.speed)a.textContent=
this.l.oa&&this.R?this.R.toFixed(2)+"Mhz":"Stopped"};k.Gb=function(a){this.l.complete=!0;this.l.Nc=!1;this.l.Fb=!1;this.W=this.a=a;if(fc(this)){do this.Ha[N(this)].call(this);while(0<this.a)}return this.l.complete?this.W-this.a:void 0===this.l.complete?0:-1};ya(function(){for(var a=A(document,"pc8080","cpu"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new Nb(d);Pa(d,c)}});function hc(){this.a-=4}function ic(){E(this,O(this));this.a-=10}function jc(){E(this,P(this));this.a-=10}
function kc(){var a=O(this);R(this,this.o);E(this,a);this.a-=17}
var Ob=[hc,function(){Vb(this,O(this));this.a-=10},function(){this.aa(Ub(this),this.b);this.a-=7},function(){Vb(this,Ub(this)+1);this.a-=5},function(){this.c=bc(this,this.c);this.a-=5},function(){this.c=ac(this,this.c);this.a-=5},function(){this.c=N(this);this.a-=7},function(){var a=this.b<<1;this.b=a&255|a>>8;K(this,a&256);this.a-=4},hc,function(){var a;I(this,a=G(this)+Ub(this));K(this,a>>8&256);this.a-=10},function(){this.b=this.J(Ub(this));this.a-=7},function(){Vb(this,Ub(this)-1);this.a-=5},
function(){this.D=bc(this,this.D);this.a-=5},function(){this.D=ac(this,this.D);this.a-=5},function(){this.D=N(this);this.a-=7},function(){var a=this.b<<8&256;this.b=(a|this.b)>>1;K(this,a);this.a-=4},hc,function(){Xb(this,O(this));this.a-=10},function(){this.aa(Wb(this),this.b);this.a-=7},function(){Xb(this,Wb(this)+1);this.a-=5},function(){this.f=bc(this,this.f);this.a-=5},function(){this.f=ac(this,this.f);this.a-=5},function(){this.f=N(this);this.a-=7},function(){var a=this.b<<1;this.b=a&255|J(this);
K(this,a&256);this.a-=4},hc,function(){var a;I(this,a=G(this)+Wb(this));K(this,a>>8&256);this.a-=10},function(){this.b=this.J(Wb(this));this.a-=7},function(){Xb(this,Wb(this)-1);this.a-=5},function(){this.F=bc(this,this.F);this.a-=5},function(){this.F=ac(this,this.F);this.a-=5},function(){this.F=N(this);this.a-=7},function(){var a=this.b<<8;this.b=(J(this)<<8|this.b)>>1;K(this,a&256);this.a-=4},hc,function(){I(this,O(this));this.a-=10},function(){var a=O(this);fb(this.j,a,G(this));this.a-=16},function(){I(this,
G(this)+1);this.a-=5},function(){this.g=bc(this,this.g);this.a-=5},function(){this.g=ac(this,this.g);this.a-=5},function(){this.g=N(this);this.a-=7},function(){var a=0,b=J(this);if((this.s^this.w)&16||9<(this.b&15))a|=6;if(b||154<=this.b)a|=96,b=1;this.b=L(this,a);K(this,b?256:0);this.a-=4},hc,function(){var a;I(this,a=G(this)+G(this));K(this,a>>8&256);this.a-=10},function(){var a;a=O(this);a=cb(this.j,a);I(this,a);this.a-=16},function(){I(this,G(this)-1);this.a-=5},function(){this.i=bc(this,this.i);
this.a-=5},function(){this.i=ac(this,this.i);this.a-=5},function(){this.i=N(this);this.a-=7},function(){this.b=~this.b&255;this.a-=4},hc,function(){this.u=O(this)&65535;this.a-=10},function(){this.aa(O(this),this.b);this.a-=13},function(){this.u=this.u+1&65535;this.a-=5},function(){var a=G(this);this.aa(a,bc(this,this.J(a)));this.a-=10},function(){var a=G(this);this.aa(a,ac(this,this.J(a)));this.a-=10},function(){this.aa(G(this),N(this));this.a-=10},function(){this.m|=256;this.a-=4},hc,function(){var a;
I(this,a=G(this)+this.u);K(this,a>>8&256);this.a-=10},function(){this.b=this.J(O(this));this.a-=13},function(){this.u=this.u-1&65535;this.a-=5},function(){this.b=bc(this,this.b);this.a-=5},function(){this.b=ac(this,this.b);this.a-=5},function(){this.b=N(this);this.a-=7},function(){K(this,J(this)?0:256);this.a-=4},function(){this.a-=5},function(){this.c=this.D;this.a-=5},function(){this.c=this.f;this.a-=5},function(){this.c=this.F;this.a-=5},function(){this.c=this.g;this.a-=5},function(){this.c=this.i;
this.a-=5},function(){this.c=this.J(G(this));this.a-=7},function(){this.c=this.b;this.a-=5},function(){this.D=this.c;this.a-=5},function(){this.a-=5},function(){this.D=this.f;this.a-=5},function(){this.D=this.F;this.a-=5},function(){this.D=this.g;this.a-=5},function(){this.D=this.i;this.a-=5},function(){this.D=this.J(G(this));this.a-=7},function(){this.D=this.b;this.a-=5},function(){this.f=this.c;this.a-=5},function(){this.f=this.D;this.a-=5},function(){this.a-=5},function(){this.f=this.F;this.a-=
5},function(){this.f=this.g;this.a-=5},function(){this.f=this.i;this.a-=5},function(){this.f=this.J(G(this));this.a-=7},function(){this.f=this.b;this.a-=5},function(){this.F=this.c;this.a-=5},function(){this.F=this.D;this.a-=5},function(){this.F=this.f;this.a-=5},function(){this.a-=5},function(){this.F=this.g;this.a-=5},function(){this.F=this.i;this.a-=5},function(){this.F=this.J(G(this));this.a-=7},function(){this.F=this.b;this.a-=5},function(){this.g=this.c;this.a-=5},function(){this.g=this.D;this.a-=
5},function(){this.g=this.f;this.a-=5},function(){this.g=this.F;this.a-=5},function(){this.a-=5},function(){this.g=this.i;this.a-=5},function(){this.g=this.J(G(this));this.a-=7},function(){this.g=this.b;this.a-=5},function(){this.i=this.c;this.a-=5},function(){this.i=this.D;this.a-=5},function(){this.i=this.f;this.a-=5},function(){this.i=this.F;this.a-=5},function(){this.i=this.g;this.a-=5},function(){this.a-=5},function(){this.i=this.J(G(this));this.a-=7},function(){this.i=this.b;this.a-=5},function(){this.aa(G(this),
this.c);this.a-=7},function(){this.aa(G(this),this.D);this.a-=7},function(){this.aa(G(this),this.f);this.a-=7},function(){this.aa(G(this),this.F);this.a-=7},function(){this.aa(G(this),this.g);this.a-=7},function(){this.aa(G(this),this.i);this.a-=7},function(){var a=this.o-1;if(this.ra.length)for(var b=0;b<this.ra.length;b++)if(this.ra[b](a))return;this.a-=7;this.B|=256;Lb(this);this.C&512||Db(this)},function(){this.aa(G(this),this.b);this.a-=7},function(){this.b=this.c;this.a-=5},function(){this.b=
this.D;this.a-=5},function(){this.b=this.f;this.a-=5},function(){this.b=this.F;this.a-=5},function(){this.b=this.g;this.a-=5},function(){this.b=this.i;this.a-=5},function(){this.b=this.J(G(this));this.a-=7},function(){this.a-=5},function(){this.b=L(this,this.c);this.a-=4},function(){this.b=L(this,this.D);this.a-=4},function(){this.b=L(this,this.f);this.a-=4},function(){this.b=L(this,this.F);this.a-=4},function(){this.b=L(this,this.g);this.a-=4},function(){this.b=L(this,this.i);this.a-=4},function(){this.b=
L(this,this.J(G(this)));this.a-=7},function(){this.b=L(this,this.b);this.a-=4},function(){this.b=Zb(this,this.c);this.a-=4},function(){this.b=Zb(this,this.D);this.a-=4},function(){this.b=Zb(this,this.f);this.a-=4},function(){this.b=Zb(this,this.F);this.a-=4},function(){this.b=Zb(this,this.g);this.a-=4},function(){this.b=Zb(this,this.i);this.a-=4},function(){this.b=Zb(this,this.J(G(this)));this.a-=7},function(){this.b=Zb(this,this.b);this.a-=4},function(){this.b=M(this,this.c);this.a-=4},function(){this.b=
M(this,this.D);this.a-=4},function(){this.b=M(this,this.f);this.a-=4},function(){this.b=M(this,this.F);this.a-=4},function(){this.b=M(this,this.g);this.a-=4},function(){this.b=M(this,this.i);this.a-=4},function(){this.b=M(this,this.J(G(this)));this.a-=7},function(){this.b=M(this,this.b);this.a-=4},function(){this.b=dc(this,this.c);this.a-=4},function(){this.b=dc(this,this.D);this.a-=4},function(){this.b=dc(this,this.f);this.a-=4},function(){this.b=dc(this,this.F);this.a-=4},function(){this.b=dc(this,
this.g);this.a-=4},function(){this.b=dc(this,this.i);this.a-=4},function(){this.b=dc(this,this.J(G(this)));this.a-=7},function(){this.b=dc(this,this.b);this.a-=4},function(){this.b=$b(this,this.c);this.a-=4},function(){this.b=$b(this,this.D);this.a-=4},function(){this.b=$b(this,this.f);this.a-=4},function(){this.b=$b(this,this.F);this.a-=4},function(){this.b=$b(this,this.g);this.a-=4},function(){this.b=$b(this,this.i);this.a-=4},function(){this.b=$b(this,this.J(G(this)));this.a-=7},function(){this.b=
$b(this,this.b);this.a-=4},function(){this.b=ec(this,this.c);this.a-=4},function(){this.b=ec(this,this.D);this.a-=4},function(){this.b=ec(this,this.f);this.a-=4},function(){this.b=ec(this,this.F);this.a-=4},function(){this.b=ec(this,this.g);this.a-=4},function(){this.b=ec(this,this.i);this.a-=4},function(){this.b=ec(this,this.J(G(this)));this.a-=7},function(){this.b=ec(this,this.b);this.a-=4},function(){this.b=cc(this,this.c);this.a-=4},function(){this.b=cc(this,this.D);this.a-=4},function(){this.b=
cc(this,this.f);this.a-=4},function(){this.b=cc(this,this.F);this.a-=4},function(){this.b=cc(this,this.g);this.a-=4},function(){this.b=cc(this,this.i);this.a-=4},function(){this.b=cc(this,this.J(G(this)));this.a-=7},function(){this.b=cc(this,this.b);this.a-=4},function(){M(this,this.c);this.a-=4},function(){M(this,this.D);this.a-=4},function(){M(this,this.f);this.a-=4},function(){M(this,this.F);this.a-=4},function(){M(this,this.g);this.a-=4},function(){M(this,this.i);this.a-=4},function(){M(this,
this.J(G(this)));this.a-=7},function(){M(this,this.b);this.a-=4},function(){this.m&255&&(E(this,P(this)),this.a-=6);this.a-=5},function(){Vb(this,P(this));this.a-=10},function(){var a=O(this);this.m&255&&E(this,a);this.a-=10},ic,function(){var a=O(this);this.m&255&&(R(this,this.o),E(this,a),this.a-=6);this.a-=11},function(){R(this,Ub(this));this.a-=11},function(){this.b=L(this,N(this));this.a-=7},function(){R(this,this.o);E(this,0);this.a-=11},function(){this.m&255||(E(this,P(this)),this.a-=6);this.a-=
5},jc,function(){var a=O(this);this.m&255||E(this,a);this.a-=10},ic,function(){var a=O(this);this.m&255||(R(this,this.o),E(this,a),this.a-=6);this.a-=11},kc,function(){this.b=Zb(this,N(this));this.a-=7},function(){R(this,this.o);E(this,8);this.a-=11},function(){J(this)||(E(this,P(this)),this.a-=6);this.a-=5},function(){Xb(this,P(this));this.a-=10},function(){var a=O(this);J(this)||E(this,a);this.a-=10},function(){for(var a=N(this),b=this.j,c=this.b,d=this.o+-2&65535,e=1,f=0;0<e;){var g=b.v[a],h=b.C[a]||
1,l=1==h?255:2==h?65535:-1,l=(c>>>=f)&l;if(void 0!==g&&g[0])g[0](a,l,d);f+=h<<3;a+=h;e-=h}this.a-=10},function(){var a=O(this);J(this)||(R(this,this.o),E(this,a),this.a-=6);this.a-=11},function(){R(this,Wb(this));this.a-=11},function(){this.b=M(this,N(this));this.a-=7},function(){R(this,this.o);E(this,16);this.a-=11},function(){J(this)&&(E(this,P(this)),this.a-=6);this.a-=5},jc,function(){var a=O(this);J(this)&&E(this,a);this.a-=10},function(){for(var a=N(this),b=this.j,c=this.o+-2&65535,d=1,e=0,
f=0;0<d;){var g=b.m[a],h=b.B[a]||1,l=1==h?255:2==h?65535:-1,n=l;void 0!==g&&g[0]&&(n=g[0](a,c),void 0===n?n=l:n&=l);e|=n<<f;f+=h<<3;a+=h;d-=h}this.b=e&255;this.a-=10},function(){var a=O(this);J(this)&&(R(this,this.o),E(this,a),this.a-=6);this.a-=11},kc,function(){this.b=dc(this,N(this));this.a-=7},function(){R(this,this.o);E(this,24);this.a-=11},function(){Yb(this)||(E(this,P(this)),this.a-=6);this.a-=5},function(){I(this,P(this));this.a-=10},function(){var a=O(this);Yb(this)||E(this,a);this.a-=10},
function(){var a=P(this);R(this,G(this));I(this,a);this.a-=18},function(){var a=O(this);Yb(this)||(R(this,this.o),E(this,a),this.a-=6);this.a-=11},function(){R(this,G(this));this.a-=11},function(){this.b=$b(this,N(this));this.a-=7},function(){R(this,this.o);E(this,32);this.a-=11},function(){Yb(this)&&(E(this,P(this)),this.a-=6);this.a-=5},function(){E(this,G(this));this.a-=5},function(){var a=O(this);Yb(this)&&E(this,a);this.a-=10},function(){var a=G(this);I(this,Wb(this));Xb(this,a);this.a-=5},function(){var a=
O(this);Yb(this)&&(R(this,this.o),E(this,a),this.a-=6);this.a-=11},kc,function(){this.b=ec(this,N(this));this.a-=7},function(){R(this,this.o);E(this,40);this.a-=11},function(){this.s&128||(E(this,P(this)),this.a-=6);this.a-=5},function(){var a=P(this);Rb(this,a&255|this.C&-256);this.b=a>>8;this.a-=10},function(){var a=O(this);this.s&128||E(this,a);this.a-=10},function(){this.C&=-513;this.a-=4},function(){var a=O(this);this.s&128||(R(this,this.o),E(this,a),this.a-=6);this.a-=11},function(){R(this,
Tb(this)&255|this.b<<8);this.a-=11},function(){this.b=cc(this,N(this));this.a-=7},function(){R(this,this.o);E(this,48);this.a-=11},function(){this.s&128&&(E(this,P(this)),this.a-=6);this.a-=5},function(){this.u=G(this)&65535;this.a-=5},function(){var a=O(this);this.s&128&&E(this,a);this.a-=10},function(){this.C|=512;this.a-=4;fc(this)},function(){var a=O(this);this.s&128&&(R(this,this.o),E(this,a),this.a-=6);this.a-=11},kc,function(){M(this,N(this));this.a-=7},function(){R(this,this.o);E(this,56);
this.a-=11}];function T(a){r.call(this,"ChipSet",a,T);var b=a.model;b&&!lc[b]&&Aa("Unrecognized ChipSet model: "+b);this.c=lc[b]||{};a.sound&&(this.I=null,window&&(this.I=window.AudioContext||window.webkitAudioContext),this.I&&new this.I);B(this)}w(T);
var V={ba:1978.1,zc:{ca:0,td:1,xd:16,Ed:32,Nd:64,Md:128,Fa:14},za:{ca:1,Pb:1,sc:2,oc:4,pc:16,qc:32,rc:64,Fa:8},Ac:{ca:2,sd:3,Wd:4,ud:8,Id:16,Jd:32,Kd:64,vd:128,Fa:0},Rd:{ca:3},Pd:{ca:2,Fd:7},Td:{ca:3,Xd:1,Sd:2,Ld:4,Cd:8,wd:16,md:32},Qd:{ca:4},Ud:{ca:5,yd:1,zd:2,Ad:4,Bd:8,Yd:16}},W={ba:100,ka:{ca:66,vb:1,kc:2,lc:4,Hd:8,Gd:16,sb:32,rb:64,nb:128},Nb:{ca:66,INIT:0},wa:{ca:194,od:0,lb:16,uc:32,tb:48,Xb:0,Yb:32},Ra:{ca:162,Od:0,$b:0,Wb:0,Zb:0,Vb:0},ma:{Dd:{ca:98},Ba:{Kb:0,Jb:1,xc:2,Fc:4,Qb:5,vc:6,Vd:7},
Ua:16383}},lc={SI1978:V,VT100:W};T.prototype.V=function(){return!1};T.prototype.qa=function(a,b,c,d){this.j=b;this.a=c;this.O=d;this.v=a;this.m=Va(a,"Keyboard");this.Z=Va(a,"SerialPort");this.video=Va(a,"Video");hb(b,this,this.c.$a);ib(b,this,this.c.ab)};T.prototype.ga=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};T.prototype.ia=function(a){return a?this.save():!0};V.INIT=[[V.zc.Fa,V.za.Fa,V.Ac.Fa,0,0,0,0]];
W.INIT=[[W.Nb.INIT,W.ka.kc|W.ka.lc],[W.wa.Xb,W.wa.Yb],[W.Ra.$b,W.Ra.Wb,W.Ra.Zb,W.Ra.Vb],[0,0,0,0,[11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11776,11784,11918,11776,11984,11888,11776,11808,11776,12E3,12E3,11901,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11904,11776,11784,11918,11808,11984,11856,11776,11808,11776,12E3,12E3,11881,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]];k=T.prototype;k.reset=function(){this.c.INIT&&!this.restore(this.c.INIT)&&this.L("reset error")};
k.save=function(){var a=new F(this);switch(this.c.ba){case V.ba:a.set(0,[this.W,this.g,this.X,this.C,this.M,this.S,this.U]);break;case W.ba:a.set(0,[this.K,this.u]),a.set(1,[this.o,this.s]),a.set(2,[this.f,this.G,this.R,this.N]),a.set(3,[this.B,this.b,this.w,this.H,this.i])}return a.data()};
k.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.c.ba){case V.ba:return this.W=b[0],this.g=b[1],this.X=b[2],this.C=b[3],this.M=b[4],this.S=b[5],this.U=b[6],!0;case W.ba:return this.K=b[0],this.u=b[1],b=a[1],this.o=b[0],this.s=b[1],b=a[2],this.f=b[0],this.G=b[1],this.R=b[2],this.N=b[3],b=a[3],this.B=b[0],this.b=b[1],this.w=b[2],this.H=b[3],this.i=b[4],!0}return!1};k.start=function(){};k.stop=function(){};k.Sc=function(){return this.W};k.Tc=function(){return this.g};k.Uc=function(){return this.X};
k.Rc=function(){return this.C>>8-this.M&255};k.$c=function(a,b){this.M=b};k.bd=function(a,b){this.S=b};k.ad=function(a,b){this.C=b<<8|this.C>>8};k.cd=function(a,b){this.U=b};k.dd=function(){};function mc(a){var b=0,c=0,d=~a.B;for(a=0;10>a;a++)d&1&&(b=9-a),d>>=1;for(a=0;10>a;a++)d&1&&(c=9-a),d>>=1;return 10*b+c}
k.Vc=function(){var a=this.u,a=a&~W.ka.rb;if((Gb(this.a)&64)<<1&&(a|=W.ka.rb,a!=this.u)){var b,c;b=this.w&1;switch(this.w>>1&7){case W.ma.Ba.Jb:this.B=this.B<<1|b;break;case W.ma.Ba.Qb:b=mc(this);this.i[b]=W.ma.Ua;break;case W.ma.Ba.Kb:this.b=this.b<<1|b;break;case W.ma.Ba.Fc:b=mc(this);c=this.b&W.ma.Ua;this.i[b]=c;break;case W.ma.Ba.vc:b=mc(this);c=this.i[b];null==c&&(c=W.ma.Ua);this.b=c;break;case W.ma.Ba.xc:this.b<<=1,this.H=this.b&W.ma.Ua+1}}a&=~W.ka.sb;this.H&&(a|=W.ka.sb);a&=~W.ka.nb;if(b=this.m){b=
this.m;if(c=b.f)c=b.a,c=Gb(b.a)>=b.m+c.la*c.K/1E3*1.2731488;c&&(b.f=!1);b=!b.f}b&&(a|=W.ka.nb);a&=~W.ka.vb;this.Z&&this.Z.fa&1&&(a|=W.ka.vb);return this.u=a};k.ed=function(a,b){this.K=b};k.hd=function(a,b){this.w=b};k.gd=function(a,b){a=b&3;switch(b>>2&3){case 0:this.f=this.f&-4|a;break;case 1:this.f=this.f&-13|a<<2;this.video&&(b=this.video,a=this.f,b.pa!==a&&((b.pa=a)?Mb(b,!0):b.sa=!0));break;case 2:switch(a){case 0:this.G=~this.G;break;case 2:case 3:this.R=3-a}break;case 3:this.N=a}};
k.fd=function(a,b){b&W.wa.uc?(b&=W.wa.tb,this.s!=b&&(this.s=b,this.video&&(this.video.Db=this.s==W.wa.tb?50:60))):(b&=W.wa.lb,this.o!=b&&(this.o=b,this.video&&(a=this.video,b=this.o==W.wa.lb?132:80,a.H=b,a.T=a.xa,80<b&&a.T--,nc(a)&&oc(a))))};V.$a={0:T.prototype.Sc,1:T.prototype.Tc,2:T.prototype.Uc,3:T.prototype.Rc};V.ab={2:T.prototype.$c,3:T.prototype.bd,4:T.prototype.ad,5:T.prototype.cd,6:T.prototype.dd};W.$a={66:T.prototype.Vc};W.ab={66:T.prototype.ed,98:T.prototype.hd,162:T.prototype.gd,194:T.prototype.fd};
ya(function(){for(var a=A(document,"pc8080","chipset"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new T(d);Pa(d,c)}});function pc(a){r.call(this,"ROM",a,pc);this.b=null;this.m=a.addr;this.c=a.size;this.v=a.writable;this.f=a.alias;this.g=a.file;this.o=ba(this.g);if(this.g){a=this.g;var b=ca(this.o);"json"!=b&&"hex"!=b&&(a=ea()+"/api/v1/dump?file="+this.g+"&format=bytes&decimal=true");var c=this;la(a,null,!0,function(a,b,f){qc(c,a,b,f)})}}w(pc);var rc=[0,5];
pc.prototype.qa=function(a,b,c,d){this.j=b;this.a=c;this.O=d;sc(this)};pc.prototype.ga=function(){this.i&&(this.O&&this.O.a(this.id,this.m,this.c,this.i),delete this.i);return!0};pc.prototype.ia=function(){return!0};
function qc(a,b,c,d){if(d)a.L("Unable to load system ROM (error "+d+": "+b+")");else{Ka(a.Ta,b,c);if("["==c.charAt(0)||"{"==c.charAt(0))try{var e=eval("("+c+")"),f=e.bytes,g=e.data;if(f)a.b=f;else if(g)for(a.b=Array(4*g.length),d=c=0;c<g.length;c++)a.b[d++]=g[c]&255,a.b[d++]=g[c]>>8&255,a.b[d++]=g[c]>>16&255,a.b[d++]=g[c]>>24&255;else a.b=e;a.i=e.symbols;if(!a.b.length){q("Empty ROM: "+b);return}if(1==a.b.length){q(a.b[0]);return}}catch(h){a.L("ROM data error: "+h.message);return}else for(b=c.replace(/\n/gm,
" ").replace(/ +$/,"").split(" "),a.b=Array(b.length),e=0;e<b.length;e++)a.b[e]=aa(b[e]);sc(a)}}
function sc(a){if(!Ra(a))if(!a.g)B(a);else if(a.b&&a.j){a.c||(a.c=a.b.length);if(a.b.length!=a.c){var b="ROM size ("+p(a.b.length,8,!0)+") does not match specified size ("+p(a.c,8,!0)+")";a.l.error=!0;a.L(b)}else if(tc(a,a.m)){b=[];"number"==typeof a.f?b.push(a.f):null!=a.f&&a.f.length&&(b=a.f);for(var c=0;c<b.length;c++){for(var d=a,e=b[c],f=d.j,g=d.c,h=[],l=d.m>>>f.j;0<g&&l<f.b.length;)h.push(f.b[l++]),g-=f.c;f=d.j;d=d.c;g=0;for(e>>>=f.j;0<d&&e<f.b.length;){l=h[g++];if(!l)break;f.b[e++]=l;d-=f.c}}delete a.b}B(a)}}
function tc(a,b){if(Za(a.j,b,a.c,a.v?1:ob)){var c;for(c=0;c<a.b.length;c++)db(a.j,b+c,a.b[c]);if(a.v&&256==b){for(c=0;c<rc.length;c++)db(a.j,rc[c],118);Qb(a.a,function(a){return function(b){if(0<=rc.indexOf(b)){var c=!1,d=a.a,e=a.O;if(5==b)switch(c=!0,d.D){case 2:uc(a,String.fromCharCode(d.F));break;case 9:for(var l=Wb(d),n="",u=255;u--;){var y=a.a.J(l++);if(36==y)break;n+=String.fromCharCode(y)}uc(a,n);break;default:c=!1}c?jc.call(d):e&&(a.da("\nCP/M vector "+p(b,4,!0)),E(d,b),Db(e));b=!0}else b=
!1;return b}}(a));Sb(a.a,b)}return!0}return!1}function uc(a,b){b=b.replace(/\r/g,"");a.va&&(a.va.value+=b,a.va.scrollTop=a.va.scrollHeight)}ya(function(){for(var a=A(document,"pc8080","rom"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new pc(d);Pa(d,c)}});function vc(a){r.call(this,"RAM",a,vc);this.f=a.addr;this.c=a.size;this.b=!1}w(vc);k=vc.prototype;k.qa=function(a,b,c,d){this.j=b;this.a=c;this.O=d;B(this)};k.ga=function(a,b){b||this.reset();return!0};k.ia=function(a){return a?this.save():!0};
k.reset=function(){!this.b&&this.c&&Za(this.j,this.f,this.c,1)&&(this.b=!0);this.b||q("No RAM allocated")};k.save=function(){return null};k.restore=function(){return!0};ya(function(){for(var a=A(document,"pc8080","ram"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new vc(d);Pa(d,c)}});function X(a){r.call(this,"Keyboard",a,X);(a=a.model)&&!wc[a]&&Aa("Unrecognized Keyboard8080 model: "+a);this.b=wc[a]||{};this.reset();B(this)}w(X);var yc={};yc[m.jb]=37;yc[m.mb]=39;yc[m.ob]=32;
var zc={ba:1978.1,h:{},kb:yc,Ga:{},ya:{"1p":49,"2p":50,coin:51,left:37,right:39,fire:32}},Y={ba:100,h:{},kb:{},Ga:{},ya:{setup:120},Lb:{ca:130,INIT:127},ha:{ca:130,gc:1,fc:2,ec:4,dc:8,hc:16,qb:32,pb:63,yc:64,nd:128,INIT:0},cc:127};Y.h[46]=3;Y.h[m.nc]=5;Y.h[m.mc]=6;Y.h[m.Hc]=7;Y.h[m.Bc]=8;Y.h[m.Ec]=9;Y.h[m.Q]=10;Y.h[39]=16;Y.h[221]=20;Y.h[219]=21;Y.h[m.Ub]=22;Y.h[m.Cc]=23;Y.h[m.tc]=24;Y.h[m.E]=25;Y.h[49]=26;Y.h[37]=32;Y.h[40]=34;Y.h[117]=35;Y.h[19]=35;Y.h[192]=36;Y.h[189]=37;Y.h[57]=38;Y.h[55]=39;
Y.h[52]=40;Y.h[51]=41;Y.h[27]=42;Y.h[38]=48;Y.h[114]=49;Y.h[112]=50;Y.h[8]=51;Y.h[187]=52;Y.h[48]=53;Y.h[56]=54;Y.h[54]=55;Y.h[53]=56;Y.h[50]=57;Y.h[9]=58;Y.h[103]=64;Y.h[115]=65;Y.h[113]=66;Y.h[96]=67;Y.h[118]=68;Y.h[220]=69;Y.h[m.ob]=70;Y.h[m.bc]=71;Y.h[m.Sb]=72;Y.h[m.Rb]=73;Y.h[m.jb]=74;Y.h[104]=80;Y.h[2013]=81;Y.h[98]=82;Y.h[97]=83;Y.h[222]=85;Y.h[186]=86;Y.h[m.ac]=87;Y.h[m.Tb]=88;Y.h[m.mb]=89;Y.h[m.wc]=90;Y.h[110]=96;Y.h[116]=97;Y.h[101]=98;Y.h[100]=99;Y.h[13]=100;Y.h[190]=101;Y.h[188]=102;
Y.h[m.jc]=103;Y.h[m.Mb]=104;Y.h[m.Gc]=105;Y.h[119]=106;Y.h[105]=112;Y.h[99]=113;Y.h[102]=114;Y.h[109]=115;Y.h[191]=117;Y.h[m.ic]=118;Y.h[m[" "]]=119;Y.h[m.Dc]=120;Y.h[m.Ob]=121;Y.h[m.Ic]=122;Y.h[120]=123;Y.h[17]=124;Y.h[16]=125;Y.h[20]=126;Y.Ga={l4:Y.ha.gc,l3:Y.ha.fc,l2:Y.ha.ec,l1:Y.ha.dc,locked:Y.ha.hc,local:Y.ha.qb,online:~Y.ha.qb};var wc={SI1978:zc,VT100:Y};
X.prototype.V=function(a,b,c){var d=this,e=a+"-"+b;if(void 0===this.A[e]){if("led"==a&&this.b.Ga[b])return this.A[e]=c,!0;switch(b){case "kbd":return c.onkeydown=function(a){return Ac(d,a,!0)},c.onkeyup=function(a){return Ac(d,a,!1)},!0;default:if(this.b.ya&&void 0!==this.b.ya[b])return this.A[e]=c,a=function(a,b){return function(c){c.preventDefault();Bc(a,b,!0)}}(this,this.b.ya[b]),b=function(a,b){return function(){Bc(a,b,!1)}}(this,this.b.ya[b]),"ontouchstart"in window?(c.ontouchstart=a,c.ontouchend=
b):(c.onmousedown=a,c.onmouseup=c.onmouseout=b),!0}}return!1};X.prototype.qa=function(a,b,c,d){this.v=a;this.a=c;this.O=d;this.M=Va(a,"ChipSet");hb(b,this,this.b.$a);ib(b,this,this.b.ab)};X.prototype.ga=function(a,b){if(!b)if(!a)this.reset();else if(!this.restore(a))return!1;return!0};X.prototype.ia=function(a){return a?this.save():!0};Y.INIT=[[Y.ha.INIT,Y.Lb.INIT,!1,0,-1]];k=X.prototype;k.reset=function(){this.j=[];this.b.INIT&&!this.restore(this.b.INIT)&&this.L("reset error")};
k.save=function(){var a=new F(this);switch(this.b.ba){case Y.ba:a.set(0,[this.i,this.g,this.f,this.m,-1])}return a.data()};k.restore=function(a){var b;if(a&&(b=a[0])&&b.length)switch(this.b.ba){case zc.ba:return!0;case Y.ba:return this.i=b[0],Cc(this,this.i&Y.ha.pb),this.g=b[1],this.f=b[2],this.m=b[3],this.c=b[4],!0}return!1};function Cc(a,b){for(var c in a.b.Ga){var d=a.A["led-"+c];if(d){var e=a.b.Ga[c],f=!!(b&e);e&e-1&&(f=!(b&~e));d.style.backgroundColor=f?"#ff0000":"#000000"}}}
function Ac(a,b,c){var d=!0,e;a:if(e=b.keyCode,e=a.b.kb[e]||e,!a.b.h[e]){for(var f in a.b.ya)if(a.b.ya[f]===e){e=f;break a}e=null}e&&(d=Bc(a,e,c),b.preventDefault());return d}
function Bc(a,b,c){var d;a:{for(d=0;d<a.j.length;d++)if(a.j[d].ib==b)break a;d=-1}if(c)0>d?a.j.push({ib:b,fb:Date.now(),Ya:!1}):(a.j[d].fb=Date.now(),a.j[d].Ya=!1);else if(0<=d){if(!a.j[d].Ya){var e=a.j[d].fb;if(e&&100>Date.now()-e)return a.j[d].Ya=!0,Dc(a),!0}a.j.splice(d,1)}if(a.M){d=0;switch(b){case "1p":d=V.za.oc;break;case "2p":d=V.za.sc;break;case "coin":d=V.za.Pb;break;case "left":d=V.za.qc;break;case "right":d=V.za.rc;break;case "fire":d=V.za.pc}d&&(a=a.M,b=d,a.g&=~b,c&&(a.g|=b))}return!0}
function Dc(a){for(var b=0,c=-1;b<a.j.length;){if(a.j[b].Ya){var d=a.j[b].ib,e=100-(Date.now()-a.j[b].fb);if(0<e){if(0>c||c>e)c=e}else{Bc(a,d,!1);b=0;continue}}b++}0<=c&&setTimeout(function(){Dc(a)},c)}k.Wc=function(){var a=this.g;0<=this.c&&(this.c<this.j.length?(a=this.j[this.c],this.c++,a=Y.h[a.ib],a&128&&(a&=127)):(this.c=-1,a=Y.cc),this.g=a,gc(this.a,1));return a};k.jd=function(a,b){this.i=b;this.f=!0;this.m=Gb(this.a);Cc(this,b&Y.ha.pb);b&Y.ha.yc&&(this.c=0,gc(this.a,1))};Y.$a={130:X.prototype.Wc};
Y.ab={130:X.prototype.jd};ya(function(){for(var a=A(document,"pc8080","keyboard"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new X(d);Pa(d,c)}});
function Ec(a,b,c,d,e){var f=this;this.Ia=ra("Gecko/");var g=["","moz","ms","webkit"];r.call(this,"Video",a,Ec);this.C=a.screenWidth;this.w=a.screenHeight;this.ea=a.bufferAddr;this.Kc=a.bufferRAM;var h=a.bufferFormat;this.U=h&&Fc[h.toUpperCase()]||Gc;this.H=a.bufferCols;this.W=a.bufferRows;this.xa=this.T=a.cellWidth||1;this.P=a.cellHeight||1;this.X=null;this.Ha=!1;this.ja=a.bufferBits||1;this.Lc=a.bufferLeft||0;if(this.c=a.bufferRotate)this.c=this.c%360,0<this.c&&(this.c-=360),-90!=this.c&&(this.L("unsupported buffer rotation: "+
this.c),this.c=0);this.la=a.interruptRate;this.wb=a.refreshRate||60;this.u=b;this.f=c;this.R=(this.Oc=d)||b||null;this.Jc=this.C;this.Ib=this.w;this.Ca=this.C/this.H|0;this.Da=this.w/this.W|0;1<this.P&&(this.W++,this.pa=0,this.sa=!1);b=a.smoothing;(c=Ea.smoothing)&&(b="true"==c);if(null!=b)for(c=0;c<g.length;c++)if(d=(d=g[c])?d+"ImageSmoothingEnabled":"imageSmoothingEnabled",void 0!==this.f[d]){this.f[d]=b;break}if(this.g=a.screenRotate)this.g=this.g%360,0<this.g&&(this.g-=360),-90!=this.g?(this.L("unsupported screen rotation: "+
this.g),this.g=0):(this.f.translate(0,this.w),this.f.rotate(this.g*Math.PI/180),this.f.scale(this.w/this.C,this.C/this.w));if(this.b=e)if(this.b.Ea=e.requestFullscreen||e.msRequestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen,this.b.Ea){for(c=0;c<g.length;c++)if(d=g[c]+"fullscreenchange","on"+d in document){document.addEventListener(d,function(){Hc(f,document.fullscreenElement||document.msFullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement?!0:!1)},!1);
break}for(c=0;c<g.length;c++)if(d=g[c]+"fullscreenerror","on"+d in document){document.addEventListener(d,function(){Hc(f,null)},!1);break}}if(this.M=a.fontROM)"json"!=ca(this.M)&&(this.M=ea()+"/api/v1/dump?file="+this.M+"&format=bytes"),la(this.M,null,!0,function(a,b,c){Ic(f,a,b,c)});this.ua={}}w(Ec);var Gc=0,Fc={SI1978:1,VT100:2};
function nc(a){a.o=a.H*a.T;a.G=a.W*a.P;var b=a.o,c=a.G;a.c&&(b=a.G,c=a.o);a.B=0;if(!a.Kc&&(a.B=(a.o*a.ja>>3)*a.G,!Za(a.j,a.ea,a.B,3)))return!1;a.B?(a.Ja=a.f.createImageData(b,c),a.La=16/a.ja|0,Jc(a,a.B>>1)):Jc(a,(a.H+1)*a.W);a.s=document.createElement("canvas");a.s.width=b;a.s.height=c;a.ra=a.s.getContext("2d");a.I={};a.S=1<<a.ja;a.K=Array(a.S+2);a.K[0]=[0,0,0,255];a.K[1]=[255,255,255,255];1==a.U&&(a.K[a.S+0]=[255,255,0,255],a.K[a.S+1]=[0,255,0,255]);2==a.U&&(a.Db=60,a.ta=!1,a.Z=Array(a.H));return!0}
Ec.prototype.qa=function(a,b,c,d){this.v=a;this.j=b;this.a=c;this.O=d;nc(this);if(this.m=Va(a,"Keyboard")){for(var e in this.ua)this.m.V("led",e,this.ua[e]);this.u&&this.m.V(this.Oc?"textarea":"canvas","kbd",this.R)}var f=this;this.xb=Ib(this.a,function(){Mb(f)});Kb(this.a,this.xb,1E3/Math.max(this.wb,this.la));this.Va=0;this.M||B(this)};
function Ic(a,b,c,d){if(d)a.L("Unable to load font ROM (error "+d+": "+b+")");else{Ka(a.Ta,b,c);try{var e=eval("("+c+")"),f=e.bytes||e;if(!f||!f.length){q("Empty font ROM: "+b);return}if(1==f.length){q(f[0]);return}if(2048==f.length)a.X=f,oc(a);else{a.L("Unrecognized font data length ("+f.length+")");return}}catch(g){a.L("Font ROM data error: "+g.message);return}(a.f||a.O)&&B(a)}}
function oc(a){a.X&&(a.Ha=2==a.U,a.I[96]=[Kc(a,a.T,a.P),Kc(a,a.T,a.P,a.ta)],a.I[64]=[Kc(a,2*a.T,a.P),Kc(a,2*a.T,a.P,a.ta)],a.I[32]=a.I[0]=[Kc(a,2*a.T,2*a.P),Kc(a,2*a.T,2*a.P,a.ta)])}
function Kc(a,b,c,d){var e=8>=a.xa?8:16,f=8<e?15:0,g=a.X.length/e,h=!1===d,l={T:b,P:c};l.canvas=document.createElement("canvas");l.canvas.width=16*b;l.canvas.height=g/16*c;l.context=l.canvas.getContext("2d");for(var n=l.context.createImageData(b,c),u=0;u<g;u++){for(var y=0,H=y;y<a.P;y++)for(var x=u*e+(f+y&e-1),x=d&&8==y?255:a.X[x],t=0;t<c/a.P;t++){for(var C=0,Q=0,U=Q;Q<a.T;Q++){for(var Z=x&128>>(7<Q?7:Q),C=a.Ha&&!Z&&C?C:Z,sa=0;sa<b/a.T;sa++)h&&(C=!C),Lc(a,n,U,H,C?1:0),U++;C=Z}H++}l.context.putImageData(n,
(u&15)*b,(u>>4)*c)}return l}Ec.prototype.ga=function(){return!0};Ec.prototype.V=function(a,b,c){var d=this;if("led"==a||"rled"==a)return this.ua[b]=c,!0;switch(b){case "fullScreen":return this.A[b]=c,this.b&&this.b.Ea?c.onclick=function(){d.Ea()}:c.parentNode.removeChild(c),!0}return!1};
Ec.prototype.Ea=function(){var a=!1;if(this.b){if(this.b.Ea){a="100%";if(screen&&screen.width&&screen.height){var b=screen.width/screen.height,c=this.C/this.w;b>c&&(a=Math.round(c/b*100)+"%")}this.Ia?(this.u.style.width=a,this.u.style.width=a,this.u.style.display="block",this.u.style.margin="auto"):(this.b.style.width=a,this.b.style.height="auto");this.b.style.backgroundColor="black";this.b.Ea();a=!0}this.R&&this.R.focus()}return a};
function Hc(a,b){!b&&a.b&&(a.Ia?a.u.style.width=a.u.style.height="":a.b.style.width=a.b.style.height="")}function Jc(a,b){a.Ka=b;a.N=!1;if(void 0===a.i||a.i.length!=a.Ka)a.i=Array(a.Ka)}function Lc(a,b,c,d,e){d=a.c?(b.height-c-1)*b.width+d:c+d*b.width;e&&1==a.U&&(208<=c&&236>c?e=a.S+0:28<=c&&72>c&&(e=a.S+1));a=a.K[e];d*=a.length;b.data[d]=a[0];b.data[d+1]=a[1];b.data[d+2]=a[2];b.data[d+3]=a[3]}
function Mb(a,b){var c=!0;if(!b){a.la&&(120==a.la?a.Va&1?(gc(a.a,2),c=!1):gc(a.a,1):gc(a.a,4));if(c&&a.N&&a.B){for(var d=a.j,e=a.B,f=!0,g=a.ea>>>d.j;0<e&&g<d.b.length;)d.b[g].na&&(d.b[g].na=f=!1,d.b[g].Ab=!0),e-=d.c,g++;f&&(c=!1)}Kb(a.a,a.xb,1E3/Math.max(a.wb,a.la));a.Va++}if(c)if(1<a.T)switch(a.U){case 2:for(var c=a.ea,d=-1,e=0,f=60==a.Db?2:5,h=g=0,l=-1;e<a.W;){var n=0,u=c,y=d,H=a.H;for(96!=y&&(H>>=1);;){var x=bb(a.j,u++);if(127==(x&127)){var t=bb(a.j,u++),d=t&96,c=(t&15)<<8|bb(a.j,u),c=c+(t&16?
8192:16384);break}if(n<H)a.Z[n++]=x;else break}if(f)f--;else{for(;n<a.Z.length;)a.Z[n++]=0;if(0<=y)for(u=a.N&&a.i[g]==H,a.i[g++]=H,H=0;H<n;H++){x=a.Z[H];if(!u||x!==a.i[g]){a.i[l=g]=x;var t=a,C=a.ra,Q=x&127;if(x=t.I[y][x&128?1:0]){var U=(Q&15)*x.T,Q=(Q>>4)*x.P,Z,sa,Na,eb,xc=x.T,Jb=x.P;C?(Z=H*t.T,sa=e*t.P,Na=t.T,eb=t.P):(Z=H*t.Ca,sa=e*t.Da,Na=t.Ca,eb=t.Da);x.T>t.T&&(Z*=2,Na*=2);x.P>t.P&&(y||(Q+=t.P),Jb=t.P);C?C.drawImage(x.canvas,U,Q,xc,Jb,Z,sa,Na,eb):(Z+=0,sa+=0,t.f.drawImage(x.canvas,U,Q,xc,Jb,Z,
sa,Na,eb))}h++}g++}e++}}a.N=!0;!b&&a.sa&&1==h&&(a.i[l]=-1,h=0);a.sa=!1;(h||b)&&a.ra&&a.f.drawImage(a.s,0,a.pa,a.o,a.G-a.P,0,0,a.Jc,a.Ib)}else{e=a.ea;f=e+a.B;l=h=g=0;b=a.o;n=0;c=a.G;y=d=0;u=a.ja;H=(1<<u)-1;a.Lc&&(u=-u,y=16+u);for(;e<f;){t=a.j;C=e;x=C&t.f;U=(C&t.g)>>>t.j;t=x!=t.f?t.b[U].Eb(x,C):t.b[U++].bb(x,C)|t.b[U&t.o].bb(0,C+1)<<8;if(a.N&&t===a.i[g])h+=a.La;else{a.i[g]=t;(C=y)&&(t=t>>8|(t&255)<<8);h<b&&(b=h);for(x=a.La;x--;)U=t>>C&H,Lc(a,a.Ja,h++,l,U),C+=u;h>n&&(n=h);l<c&&(c=l);l>=d&&(d=l+1)}e+=
2;g++;if(h>=a.o&&(h=0,l++,l>a.G))break}a.N=!0;b<a.o&&(e=n-b,d-=c,a.c&&(f=b,g=e,b=c,e=d,c=a.o-(f+g),d=g),a.ra.putImageData(a.Ja,0,0,b,c,e,d),a.f.drawImage(a.s,0,0,a.s.width,a.s.height,0,0,a.C,a.w))}}
ya(function(){for(var a=A(document,"pc8080","video"),b=0;b<a.length;b++){var c=a[b],d=z(c),e=document.createElement("canvas");if(!e||!e.getContext){c.innerHTML="<br/>Missing &lt;canvas&gt; support. Please try a newer web browser.";break}e.setAttribute("class","pcjs-canvas");e.setAttribute("width",d.screenWidth);e.setAttribute("height",d.screenHeight);e.style.backgroundColor=d.screenColor;e.style.height="auto";0<=(window?window.navigator.userAgent:"").indexOf("MSIE")&&(c.onresize=function(a,b,c,d){return function(){b.style.height=
(a.clientWidth*d/c|0)+"px"}}(c,e,d.screenWidth,d.screenHeight),c.onresize());var f=+(d.aspect||Ea.aspect);f&&.3<=f&&3.33>=f&&(xa("onresize",function(a,b,c){return function(){b.style.height=(a.clientWidth/c|0)+"px"}}(c,e,f)),window.onresize());c.appendChild(e);f=document.createElement("textarea");ra("iOS")&&(f.setAttribute("autocapitalize","off"),f.setAttribute("autocorrect","off"));c.appendChild(f);var g=e.getContext("2d"),d=new Ec(d,e,g,f,c);Pa(d,c)}});
function Mc(a){this.I=+a.adapter;switch(this.I){case 0:this.K=0;this.R=2;break;default:q("Unrecognized serial adapter #"+this.I);return}this.b=this.c=null;this.N=a.tabSize;this.H=a.charBOL;this.f=0;this.C=!1;r.call(this,"SerialPort",a,Mc);var b=a.binding;if("console"==b)this.c="";else{var c;a=Nc;b&&(void 0===c&&(c="Panel"),(c=Oa(c,this.id))&&(b=c.A[b])&&this.V(null,a,b))}this.g="";this.i=this.s=null;this.exports={connect:this.Cb,receiveData:this.gb}}w(Mc);
var Oc=[50,75,110,134.5,150,200,300,600,1200,1800,2E3,2400,3600,4800,9600,19200],Pc=[!1,0,0,133,142,39,238],Nc="buffer";k=Mc.prototype;
k.V=function(a,b,c,d){var e=this;switch(b){case Nc:return this.A[b]=this.b=c,c.onkeydown=function(a){a=a||window.event;var b=a.keyCode;if(8===b||a.ctrlKey&&65<=b&&90>=b)a.preventDefault&&a.preventDefault(),64<b&&(b-=64),Qc(e,b);return!0},c.onkeypress=function(a){a=a||window.event;Qc(e,a.which||a.keyCode);a.preventDefault&&a.preventDefault();return!0},c.removeAttribute("readonly"),!0;default:if(d)return this.A[b]=c,d=d.replace(/\\e/g,String.fromCharCode(27)),c.onclick=function(){e.gb(d);return!0},
!0}return!1};k.qa=function(a,b,c,d){this.v=a;this.j=b;this.a=c;this.O=d;var e=this;this.S=Ib(this.a,function(){e.gb()});this.U=Ib(this.a,function(){e.fa|=5});this.M=Va(a,"ChipSet");hb(b,this,Rc,this.K);ib(b,this,Sc,this.K);B(this)};
k.Cb=function(){if(!this.i){var a=zb(this.v,"connection");if(a){var b=a.split("->");if(2==b.length){var c=ha(b[0]);if(c!=this.Sa)return;b=ha(b[1]);if(this.i=Ma(b)){var d=this.i.exports;if(d){var e=d.connect;e&&e.call(this.i);if(this.s=d.receiveData){this.status(this.Ta+"."+c+" connected to "+b);return}}}}this.status("Unable to establish connection: "+a)}}};k.ga=function(a,b){if(!b)if(this.Cb(),!a||!this.restore)this.reset();else if(!this.restore(a))return!1;return!0};
k.ia=function(a){return a?this.save():!0};k.reset=function(){Tc(this)};k.save=function(){var a=new F(this),b=0,c=[];c[b++]=this.o;c[b++]=this.B;c[b++]=this.G;c[b++]=this.fa;c[b++]=this.m;c[b++]=this.w;c[b]=this.u;a.set(0,c);return a.data()};k.restore=function(a){return Tc(this,a[0])};function Tc(a,b){var c=0;b||(b=Pc);a.o=b[c++];a.B=b[c++];a.G=b[c++];a.fa=b[c++];a.m=b[c++];a.w=b[c++];a.u=b[c];return!0}
function Uc(a,b){var c=a.u&b;b&15||(c>>=4);b=Oc[c];c=((a.m&12)>>2)+6;a.m&16&&c++;c+=((a.m&192)>>6)+1>>1;return 1E3/Math.round(b/c)}function Qc(a,b){return a.C||a.fa&2?!1:(a.B=b,a.fa|=2,gc(a.a,a.R),!0)}k.gb=function(a){null!=a&&(this.g="number"!=typeof a?a:this.g+String.fromCharCode(a));this.g&&(Qc(this,this.g.charCodeAt(0))&&(this.g=this.g.substr(1)),this.g&&this.a&&Kb(this.a,this.S,Uc(this,15)));return!0};k.Qc=function(){var a=this.B;this.fa&=-3;return a};k.Pc=function(){return this.fa};
k.Zc=function(a,b){this.G=b;this.fa&=-6;if(19==b)this.C=!0;else if(17==b)this.C=!1;else if(this.s&&this.s.call(this.i,b),this.b)if(8==b)this.b.value=this.b.value.slice(0,-1),0<this.f&&this.f--;else{a=(a=ia[b])?"<"+a+">":String.fromCharCode(b);var c=a.length;9==b?(b=this.N||8,c=b-this.f%b,this.N&&(a=" ".slice(0,c))):13==b&&(this.f=c=0,a="\n");this.H&&!this.f&&c&&(a=String.fromCharCode(this.H)+a);this.b.value+=a;this.b.scrollTop=this.b.scrollHeight;this.f+=c}else if(null!=
this.c){if(10==b||1024<=this.c.length)this.da(this.c),this.c="";10!=b&&(this.c+=String.fromCharCode(b))}this.a&&Kb(this.a,this.U,Uc(this,240))};k.Yc=function(a,b){this.o?(this.w=b,this.w&64&&(this.o=!1)):(this.m=b,this.o=!0)};k.Xc=function(a,b){this.u=b};var Rc={0:Mc.prototype.Qc,1:Mc.prototype.Pc},Sc={0:Mc.prototype.Zc,1:Mc.prototype.Yc,2:Mc.prototype.Xc};ya(function(){for(var a=A(document,"pc8080","serial"),b=0;b<a.length;b++){var c=a[b],d=z(c),d=new Mc(d);Pa(d,c)}});
function Vc(a,b,c){r.call(this,"Computer",a,Vc);this.l.Y=!1;Wc(this,b);this.w=zb(this,"autoPower",a);this.f=0;this.M=a.busWidth||a.buswidth;this.b=Xc;this.s=null;this.v=this.G=!1;this.I=zb(this,"url")||"";(Math.random()+.1).toString(36);this.c=Yc(this);if(this.a=Oa("CPU",this.id)){this.O=Oa("Debugger",this.id);this.m=[];for(b=null;b=Va(this,"Video",b);)this.m.push(b);this.j=new Xa({id:this.Ta+".bus",busWidth:this.M},this.a,this.O);var d,e=La(this.id);if((this.g=Oa("Panel",this.id))&&this.g.va)for(b=
0;b<e.length;b++)d=e[b],d.L=this.g.L,d.da=this.g.da,d.va=this.g.va;this.da("PC8080 v1.30.1\nCopyright \u00a9 2012-2016 Jeff Parsons <Jeff@pcjs.org>\nLicense: GPL version 3 or later <http://gnu.org/licenses/gpl.html>");for(b=0;b<e.length;b++)d=e[b],d.qa&&d.qa(this,this.j,this.a,this.O);b=null;d=a.resume;void 0!==d&&(1<d.length?b=this.o=d:this.b=parseInt(d,10));var f;if(a=zb(this,"state")||(f=!0,a.state))b=this.B=a,f||(this.v=!0,this.b=Xc),this.b&&(this.u=new F(this,"1.30.1"),Zc(this.u)?b=null:delete this.u);
!b&&this.b&&(b=$c(this))&&(this.v=!0);if(b){var g=this;la(b,null,!0,function(a,b,c){c?(g.o=null,g.v=!1,g.L("Unable to load machine state from server (error "+c+(b?": "+ha(b):"")+")")):(g.s=b,g.G=!0);B(g)})}else B(this);this.A.power||(this.w=!0);!c&&this.w&&ad(this,this.Oa)}else q("Unable to find CPU component")}w(Vc);var Xc=0;function Wc(a,b){if(!b){var c;if("object"==typeof resources&&(c=resources.parms))try{b=eval("("+c+")")}catch(d){q(d.message+" ("+c+")")}}a.H=b}
function zb(a,b,c){var d=b.toLowerCase(),d=Ea[b]||Ea[d];void 0===d&&a.H&&(d=a.H[b]);void 0===d&&c&&(d=c[b]);void 0===d&&"object"==typeof resources&&resources[b]&&(d=b);return d}function ad(a,b,c){for(var d=La(a.id),e=0;e<=d.length;e++){var f=e<d.length?d[e]:a;if(!Ra(f)){Ra(f,function(){ad(a,b,c)});return}}b.call(a,c)}
function bd(a,b){var c=new F(a,"1.30.1","validate");if(Zc(c)&&cd(c)){var d=c.get("timestamp"),e=b?b.get("timestamp"):"unknown";d!=e&&(a.L("Machine state may be out-of-date\n("+d+" vs. "+e+")\nCheck your browser's local storage limits"),b||c.clear())}}k=Vc.prototype;
k.Oa=function(a){void 0===a&&(a=this.b||(this.s?1:Xc));if(!this.f){this.f++;var b=!1,c=!1;this.C=!1;var d=this.u||new F(this,"1.30.1");if(-1==a)b=!0;else if(a>Xc){if(Zc(d,this.s)){this.i=new F(this,"1.30.1","failsafe");Zc(this.i)&&(dd(this,d),a=2,ed(this.i));this.i.set("timestamp",ka());fd(this.i);var e=this.b&&!this.v;if(1==a||ma("Click OK to restore the previous PC8080 machine state, or CANCEL to reset the machine.")){if(c=cd(d)){var f=d.get("code"),g=d.get("data");f&&("ok"==f?Zc(d,g):("error"==
f&&"no machine state"!=g?(this.L("Error: "+g),"unable to verify user"==g&&(qa("user",""),this.c=null)):this.da(f+": "+g),ed(d),Zc(d)?(c=cd(d),e=!0):c=!1))}e&&bd(this,c?d:null)}else 2==a&&d.clear()}else bd(this);delete this.s;delete this.u}e=La(this.id);for(f=0;f<e.length;f++)g=e[f],g!==this&&g!=this.a&&(c=gd(this,g,d,b,c));b=[d,a,c];-1!=a?ad(this,this.zb,b):this.zb(b)}};
function gd(a,b,c,d,e){if(!b.l.Y){b.l.Y=!0;if(b.ga){var f=null;e&&((f=c.get(b.id))||(f=c.get(b.id.replace(/[a-z0-9]\./i,"."))));"string"===typeof f&&(f=null);!b.ga(f,d)&&f&&(q("Unable to restore state for "+b.type),a.B&&!a.G?(c.clear(),a.b=Xc,window&&window.location.reload()):a.C=!0,b.ga(null),e=!1)}if(!d&&b.ub)for(a=b.ub.split("|"),c=0;c<a.length;c++)b.status(a[c])}return e}
k.zb=function(a){var b=a[0],c=0>a[1];a=a[2];this.K=!0;this.l.Y=!0;var d=this.A.power;d&&(d.textContent="Shutdown");this.a&&(gd(this,this.a,b,c,a),this.a.Na());this.C&&(dd(this,b),b.clear());!c&&this.i&&(this.i.clear(),delete this.i);this.f=0};
function dd(a,b){if(ma("There may be a problem with your PC8080 machine.\n\nTo help us diagnose it, click OK to send this PC8080 machine state to http://www.pcjs.org.")){var c=a.c||"";b=b.toString();var d={app:"PC8080",ver:"1.30.1"};d.url=a.I;d.user=c;d.type="bug";d.data=b;la("http://www.pcjs.org/api/v1/report",d,!0)}}
function hd(a,b,c){var d,e="none";if(a.f)return null;a.f--;var f=new F(a,"1.30.1"),g=new F(a,"1.30.1","validate"),h=ka();g.set("timestamp",h);f.set("timestamp",h);f.set("version","1.30.1");f.set("url",window?window.location.href:null);f.set("browser",window?window.navigator.userAgent:"");a.a&&a.a.ia&&(c&&Db(a.a),d=a.a.ia(b,c),"object"===typeof d&&f.set(a.a.id,d),c&&(a.a.l.Y=!1,!1===d&&(e=null)));for(var h=La(a.id),l=0;l<h.length;l++){var n=h[l];n.l.Y&&(n.ia&&(d=n.ia(b,c),"object"===typeof d&&f.set(n.id,
d)),c&&(n.l.Y=!1,!1===d&&(e=null)))}e&&(c?(h=d=!1,b?(a.c&&id(a,a.c,f.toString()),fd(g)&&fd(f)||(e=null,d=h=!0)):a.b&&(d=!0,h=3==a.b),d&&f.clear(h)):e=f.toString());c&&(a.l.Y=!1,b=a.A.power)&&(b.textContent="Power");a.f=0;return e}k.reset=function(){this.j&&this.j.reset&&this.j.reset();for(var a=La(this.id),b=0;b<a.length;b++){var c=a[b];c!==this&&c!==this.j&&c.reset&&c.reset()}};
k.start=function(a,b){for(var c=La(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.start&&e.start(a,b)}};k.stop=function(a,b){for(var c=La(this.id),d=0;d<c.length;d++){var e=c[d];"CPU"!=e.type&&e!==this&&e.stop&&e.stop(a,b)}};
k.V=function(a,b,c){var d=this;switch(b){case "power":return this.A[b]=c,c.onclick=function(){d.f||(d.l.Y?hd(d,!1,!0):ad(d,d.Oa))},!0;case "reset":return this.A[b]=c,c.onclick=function(){if(d.l.Y&&!d.f)if(d.b&&!d.o){var a=ma("Click OK to save changes to this PC8080 machine.\n\nWARNING: If you CANCEL, all disk changes will be discarded.");hd(d,a,!0);!a&&d.B?window&&window.location.reload():d.Oa(Xc)}else d.reset(),d.a&&d.a.Na()},!0;case "save":if(da())c.parentNode.removeChild(c);else return this.A[b]=
c,c.onclick=function(){var a=Yc(d,!0);if(a){var b=!!(d.b&&!d.o||d.B),c=hd(d,b);b?id(d,a,c):d.L("Resume disabled, machine state not saved")}},!0}return!1};
function Yc(a,b){var c=a.c;c||((c=pa("user"),void 0!==c)?!c&&b&&(b=null,window&&(b=window.prompt("Saving machine states on the pcjs.org server is currently unsupported.\n\nIf you're running your own server, enter your user ID below.","")),c=b)&&((c=jd(a,c))||a.L("The user ID is invalid.")):b&&a.L("Browser local storage is not available"));return c}
function jd(a,b){a.c=null;b=la(ea()+"/api/v1/user?req=verify&user="+b);var c=b[1];if(!b[0]&&c)try{b=eval("("+c+")"),b.code&&"ok"==b.code&&(qa("user",b.data),a.c=b.data)}catch(d){q(d.message+" ("+c+")")}return a.c}function $c(a){var b=null;a.c&&(b=ea()+"/api/v1/user?req=load&user="+a.c+"&state="+kd(a,"1.30.1"));return b}
function id(a,b,c){if(c){var d={req:"store"};d.user=b;d.state=kd(a,"1.30.1");d.data=c;b=la(ea()+"/api/v1/user",d);d=b[0];if(b[1]){if(d){var e=d.indexOf("\n");0<e&&(d=d.substr(0,e));d.indexOf("Error: ")||(d=d.substr(7))}d='{"code":'+b[1]+',"data":"'+d+'"}'}b=JSON.parse(d);b&&"ok"==b.code?a.L("Machine state saved to server"):c&&(c=b&&b.data||"unable to save machine state",c="error"==b.code?"Error: "+c:"Error "+b.code+": "+c,a.L(c),qa("user",""),a.c=null)}}
function Va(a,b,c){a=La(a.id);for(var d=0;d<a.length;d++){var e=a[d];if(c)c==e&&(c=null);else if(e.type==b)return e}return null}function Hb(a,b){if(a.m.length){var c=0,d=0;!b&&window&&(c=window.scrollX,d=window.scrollY);a=a.m[0];a.R&&a.R.focus();!b&&window&&window.scrollTo(c,d)}}k.Aa=function(a){this.a&&this.a.Aa(a);this.g&&this.g.Aa(a)};
ya(function(){for(var a=A(document,"pc8080-machine"),b=0;b<a.length;b++)for(var c=a[b],d=z(c),c=A(c,"pc8080","computer"),e=0;e<c.length;e++){var f=c[e],g=z(f),g=new Vc(g,d,!0);Pa(g,f);g.w&&ad(g,g.Oa)}});ta.show.push(function(){for(var a=A(document,"pc8080","computer"),b=0;b<a.length;b++){var c=z(a[b]);(c=Oa("Computer",c.id))&&c.K&&!c.l.Y&&c.Oa(-1)}});
ta.exit.push(function(){for(var a=A(document,"pc8080","computer"),b=0;b<a.length;b++){var c=z(a[b]);(c=Oa("Computer",c.id))&&c.l.Y&&hd(c,!(!c.b||c.o),!0)}});function F(a,b,c){this.id=a.id;this.key=kd(a,b,c);this.O=a.O;ed(this,a.Mc)}function kd(a,b,c){a=a.id;if(b){var d=b.indexOf(".");0<d&&(a+=".v"+b.substr(0,d))}c&&(a+="."+c);return a}
F.prototype={constructor:F,set:function(a,b){try{this[this.id][a]=b}catch(c){}},get:function(a){return this[this.id][a]||null},value:function(){return this[this.id]},data:function(){return this[this.id]},toString:function(){var a=this[this.id];return"string"==typeof a?a:JSON.stringify(a)},clear:function(a){ed(this);var b=[];try{for(var c=0,d=window.localStorage.length;c<d;c++)b.push(window.localStorage.key(c))}catch(e){}for(c=0;c<b.length;c++)if((d=b[c])&&(a||d.substr(0,this.key.length)==this.key)){try{window.localStorage.removeItem(d)}catch(e){}b.splice(c,
1);c=0}}};function ed(a,b){a[a.id]={};b&&a.set("parms",b);a.a=!1}function fd(a){var b=!0;if(oa()){var c=JSON.stringify(a[a.id]);qa(a.key,c)||(q("Unable to store "+c.length+" bytes in browser local storage"),b=!1)}return b}function cd(a){var b=!0;try{a[a.id]=JSON.parse(a[a.id])}catch(c){q(c.message||c),b=!1}return b}function Zc(a,b){return b?(a[a.id]=b,a.a=!0):a.a?!0:oa()&&(b=pa(a.key))?(a[a.id]=b,a.a=!0):!1}var ld=0;
function md(a,b,c,d,e,f){e("Loading "+a+"...");la(a,null,!0,function(g,h,l){l?(h||(h="unable to load "+a+" ("+l+")"),f(h,null)):nd(h,a,b,c,d,e,f)})}
function nd(a,b,c,d,e,f,g){function h(a,f){if(f)g(f,null);else{c&&(Ka(c,b,a),(f=b)&&0>f.indexOf("/")&&"/"==window.location.pathname.slice(-1)&&(f=window.location.pathname+f),d?"}"==d.slice(-1)?(d=d.slice(0,-1),1<d.length&&(d+=",")):d='{state:"'+d+'",':d="{",d+='url:"'+f+'"}',"object"==typeof resources&&(f=null),a=a.replace(/(<machine[^>]*\sid=)(['"]).*?\2/,"$1$2"+c+"$2"+(d?" parms='"+d+"'":"")+(f?' url="'+f+'"':"")));e||(a=a.replace(/(<xsl:variable name="APPNAME">).*?(<\/xsl:variable>)/,"$1PC8080$2"),
a=a.replace(/(<xsl:variable name="APPCLASS">).*?(<\/xsl:variable>)/,"$1pc8080$2"));f=null;if("<"==a.charAt(0))try{e||(a=a.replace(/<!DOCTYPE(.|[\r\n])*]>\s*/g,"")),window.ActiveXObject||"ActiveXObject"in window?(f=new window.ActiveXObject("Microsoft.XMLDOM"),f.async=!1,f.loadXML(a)):f=(new window.DOMParser).parseFromString(a,"text/xml")}catch(u){f=null,a=u.message}else a="unrecognized XML: "+(255<a.length?a.substr(0,255)+"...":a);g(a,f)}}a?e?od(a,f,h):h(a,null):g("no data"+(b?" for file: "+b:""),
null)}
function od(a,b,c){var d;if(d=/<([a-z]+)\s+ref="(.*?)"(.*?)\/>/g.exec(a)){var e=d[2];b("Loading "+e+"...");la(e,null,!0,function(f,g,h){if(h||!g)c(a,"unable to resolve XML reference: "+d[0]+" ("+h+")");else{if(f=d[3])if(h=g.match(new RegExp("<"+d[1]+"[^>]*>"))){for(var l=h[0],n,u=/( [a-z]+=)(['"])(.*?)\2/g;n=u.exec(f);)l=0>l.indexOf(n[1])?l.replace(">",n[0]+">"):l.replace(new RegExp(n[1]+"(['\"])(.*?)\\1"),n[0]);h[0]!=l&&(g=g.replace(h[0],l))}else{c(a,"missing <"+d[1]+"> in "+e);return}g=g.replace(/<\?xml[^>]*>[\r\n]*/,"");
a=a.replace(d[0],g);od(a,b,c)}})}else c(a,null)}
function pd(a,b,c,d){function e(a){if(void 0===h){var b=g&&A(g,"machine-warning");h=b&&b[0]||g}h&&(h.innerHTML=ga(a))}function f(a){e("Error: "+a);l&&(--ld||Ba(!0));l=!1}var g,h,l=!0;ld++;Ja[a]={};try{if(g=document.getElementById(a)){var n;if("object"==typeof resources&&(n=resources.css)){var u=document.head||document.getElementsByTagName("head")[0],y=document.createElement("style");y.type="text/css";y.styleSheet?y.styleSheet.cssText=n:y.appendChild(document.createTextNode(n));u.appendChild(y)}c||
(c="/versions/pc8080/1.30.1/components.xsl");n=function(d,h){h?md(c,null,null,!1,e,function(d,l){l?(Ka(a,c,d),e("Processing "+b+"..."),window.ActiveXObject||"ActiveXObject"in window?(l=h.transformNode(l))?(g.outerHTML=l,--ld||Ba(!0)):f("transformNodeToObject failed"):document.implementation&&document.implementation.createDocument?(d=new XSLTProcessor,d.importStylesheet(l),(l=d.transformToFragment(h,document))?g.parentNode?(g.parentNode.replaceChild(l,g),--ld||Ba(!0)):f("invalid machine element: "+
a):f("transformToFragment failed")):f("unable to transform XML: unsupported browser")):f(d)}):f(d)};"<"!=b.charAt(0)?md(b,a,d,!0,e,n):nd(b,null,a,d,!1,e,n)}else f("missing machine element: "+a)}catch(H){f(H.message)}return l}window.embedPC8080=function(a,b,c,d){Ba(!1);return pd(a,b,c,d)};window.enableEvents=Ba;window.sendEvent=Ca;})();