hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
sequencelengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
sequencelengths
1
9
max_issues_count
int64
1
48.5k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
sequencelengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
f5ae32e32a5638d8fef7af97cff86068943bda25
201
cpp
C++
ComputerGraphics/Script.cpp
ylzf0000/TinyGameEngine
d15c3eb80189d91ed430eca1089475213ef0cad3
[ "MIT" ]
null
null
null
ComputerGraphics/Script.cpp
ylzf0000/TinyGameEngine
d15c3eb80189d91ed430eca1089475213ef0cad3
[ "MIT" ]
null
null
null
ComputerGraphics/Script.cpp
ylzf0000/TinyGameEngine
d15c3eb80189d91ed430eca1089475213ef0cad3
[ "MIT" ]
null
null
null
#include "stdafx.h" #include "Script.h" #include "Object.h" #include "Mesh.h" #include "Transform.h" cg::Script::Script(Object *pObj) :pObject(pObj), transform(pObj->transform), pMesh(pObj->pMesh) {}
22.333333
95
0.706468
ylzf0000
f5aedeeaf31c124b8443217321b012f263ebce23
1,065
hpp
C++
src/backend/cuda/Param.hpp
ckeitz/arrayfire
a1a1bbbc8487a032eb27a6c894b1b3dfb19d123b
[ "BSD-3-Clause" ]
4
2015-12-16T09:41:32.000Z
2018-10-29T10:38:53.000Z
src/backend/cuda/Param.hpp
ckeitz/arrayfire
a1a1bbbc8487a032eb27a6c894b1b3dfb19d123b
[ "BSD-3-Clause" ]
3
2015-11-15T18:43:47.000Z
2015-12-16T09:43:14.000Z
src/backend/cuda/Param.hpp
pavanky/arrayfire
f983a79c7d402450bd2a704bbc1015b89f0cd504
[ "BSD-3-Clause" ]
null
null
null
/******************************************************* * Copyright (c) 2014, ArrayFire * All rights reserved. * * This file is distributed under 3-clause BSD license. * The complete license agreement can be obtained at: * http://arrayfire.com/licenses/BSD-3-Clause ********************************************************/ #pragma once #include <af/defines.h> #include <backend.hpp> namespace cuda { template<typename T> struct Param { T *ptr; dim_type dims[4]; dim_type strides[4]; }; template<typename T> class CParam { public: const T *ptr; dim_type dims[4]; dim_type strides[4]; __DH__ CParam(const T *iptr, const dim_type *idims, const dim_type *istrides) : ptr(iptr) { for (int i = 0; i < 4; i++) { dims[i] = idims[i]; strides[i] = istrides[i]; } } __DH__ CParam(Param<T> &in) : ptr(in.ptr) { for (int i = 0; i < 4; i++) { dims[i] = in.dims[i]; strides[i] = in.strides[i]; } } __DH__ ~CParam() {} }; }
19.722222
83
0.504225
ckeitz
f5b37d1b06dc760e0ba78f9280eeca201e8afdef
3,200
cpp
C++
ExplorerXP/TextUtil.cpp
avrionov/explorerxp
c68bf161bb77bf5c9b3476be0e795d23bb0b6b5f
[ "Apache-2.0" ]
12
2016-11-10T01:21:48.000Z
2022-02-16T00:03:50.000Z
ExplorerXP/TextUtil.cpp
avrionov/explorerxp
c68bf161bb77bf5c9b3476be0e795d23bb0b6b5f
[ "Apache-2.0" ]
4
2021-05-28T03:58:27.000Z
2022-01-02T13:13:36.000Z
ExplorerXP/TextUtil.cpp
avrionov/explorerxp
c68bf161bb77bf5c9b3476be0e795d23bb0b6b5f
[ "Apache-2.0" ]
2
2016-12-21T15:06:39.000Z
2022-01-26T08:43:44.000Z
/* Copyright 2002-2020 Nikolay Avrionov. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "stdafx.h" #include "TextUtil.h" #include "SplitPath.h" #include "Resource.h" #include "globals.h" void MakeUpper (CString &str) { int last = str.GetLength (); /*int ext_pos = str.ReverseFind ('.'); if (ext_pos != -1) last = ext_pos;*/ for (int i = 0; i < last; i++) str.SetAt (i, _totupper (str[i])); } void TitleCase (CString& str) { if (str.GetLength () == 0) return; str.MakeLower (); bool bNewWord = true; int last = str.GetLength (); /* int ext_pos = str.ReverseFind ('.'); if (ext_pos != -1) last = ext_pos;*/ for (int i = 0; i < last; i++) { if (_istalpha (str[i])) { if (bNewWord) { bNewWord = false; str.SetAt (i, _totupper (str[i])); } } else bNewWord = true; } } void ToggleCase (CString& str) { if (str.GetLength () == 0) return; MakeUpper (str); bool bNewWord = true; int last = str.GetLength (); /*int ext_pos = str.ReverseFind ('.'); if (ext_pos != -1) last = ext_pos;*/ for (int i = 0; i < last; i++) { if (_istalpha (str[i])) { if (bNewWord) { bNewWord = false; str.SetAt (i, _tolower (str[i])); } } else bNewWord = true; } } void SentenceCase (CString& str) { if (str.GetLength () == 0) return; str.MakeLower (); str.SetAt (0, _toupper (str[0])); } void ChangeCase (int iCmd , CString &str) { switch (iCmd) { case ID_SENTENCECASE: SentenceCase (str); break; case ID_LOWERCASE: str.MakeLower (); break; case ID_UPPERCASE: MakeUpper (str); break; case ID_TITLECASE: TitleCase (str); break; case ID_TOGGLECASE: ToggleCase (str); break; } } void Space2Underscore (CString & str) { while (str.Replace (' ','_')); } void Underscore2Space (CString & str) { while (str.Replace ('_',' ')); } void Convert202Space (CString & str) { while (str.Replace (_T("%20"), _T(" "))); } void ConvertPoint2Space (CString & str, bool bExtentions) { if (bExtentions) { CSplitPath path (str); CString tmp; tmp = path.GetDrive(); tmp += path.GetDir(); tmp += path.GetFName(); while (tmp.Replace (_T("."), _T(" "))); tmp += path.GetExt(); str = tmp; } else while (str.Replace (_T("."), _T(" "))); } void ConvertSpaces (int iCmd, CString &str, bool bExtentions) { switch (iCmd) { case ID_CONVERT20TOSPACE: Convert202Space (str); break; case ID_CONVERTUNDERSCORETOSPACE: Underscore2Space (str); break; case ID_CONVERTSPACETOUNDERSCORE: Space2Underscore (str); break; case ID_CONVERTPOINTTOSPACE: ConvertPoint2Space (str, bExtentions); break; } }
17.486339
74
0.632188
avrionov
f5b442608e25181a2e86f9403215f627de5eb23e
305
hpp
C++
src/renderbufferformat.hpp
mharrys/gust
db458cd604d5d560844c0f7c2364f098fd6937a0
[ "MIT" ]
6
2016-07-25T06:44:23.000Z
2020-11-08T11:19:11.000Z
src/renderbufferformat.hpp
mharrys/gust
db458cd604d5d560844c0f7c2364f098fd6937a0
[ "MIT" ]
null
null
null
src/renderbufferformat.hpp
mharrys/gust
db458cd604d5d560844c0f7c2364f098fd6937a0
[ "MIT" ]
1
2019-06-05T13:02:32.000Z
2019-06-05T13:02:32.000Z
#ifndef RENDERBUFFERFORMAT_HPP_INCLUDED #define RENDERBUFFERFORMAT_HPP_INCLUDED namespace gst { // Supported renderbuffer storage formats. enum class RenderbufferFormat { DEPTH_COMPONENT16, DEPTH_COMPONENT24, DEPTH_COMPONENT32, DEPTH_COMPONENT32F }; } #endif
19.0625
46
0.727869
mharrys
f5bb9e00f615f3bb76cc87691eb8a7aab5dc1fd4
7,660
hpp
C++
include/Core/Transform/Polygon.hpp
mjopenglsdl/ObEngine
a56116c8cdf1ce30b7fadb749f8ca4df54e5ee36
[ "MIT" ]
null
null
null
include/Core/Transform/Polygon.hpp
mjopenglsdl/ObEngine
a56116c8cdf1ce30b7fadb749f8ca4df54e5ee36
[ "MIT" ]
null
null
null
include/Core/Transform/Polygon.hpp
mjopenglsdl/ObEngine
a56116c8cdf1ce30b7fadb749f8ca4df54e5ee36
[ "MIT" ]
null
null
null
#pragma once #include <functional> #include <memory> #include <optional> #include <vector> #include <Transform/Movable.hpp> #include <Transform/Rect.hpp> #include <Transform/UnitBasedObject.hpp> #include <Transform/UnitVector.hpp> namespace obe::Transform { class Polygon; using point_index_t = unsigned int; class PolygonPoint : public UnitVector { private: friend class Polygon; Polygon* m_parent; point_index_t rw_index; public: enum class RelativePositionFrom { Point0, Centroid }; explicit PolygonPoint(Polygon* parent, unsigned int index); explicit PolygonPoint(Polygon* parent, unsigned int index, const Transform::UnitVector& position); const point_index_t& index = rw_index; void remove() const; double distance(const Transform::UnitVector& position) const; UnitVector getRelativePosition(RelativePositionFrom from) const; void setRelativePosition(RelativePositionFrom from, const Transform::UnitVector& position); void move(const Transform::UnitVector& position); }; class PolygonSegment { public: const PolygonPoint& first; const PolygonPoint& second; double getAngle() const; double getLength() const; PolygonSegment(const PolygonPoint& first, const PolygonPoint& second); }; using PolygonPath = std::vector<std::unique_ptr<PolygonPoint>>; /** * \brief Class used for all Collisions in the engine, it's a Polygon containing n points * @Bind */ class Polygon : public Transform::UnitBasedObject, public Transform::Movable { protected: friend class PolygonPoint; PolygonPath m_points; float m_angle = 0; void resetUnit(Transform::Units unit) override; public: static constexpr double DefaultTolerance = 0.02; /** * \brief Adds a new Point to the Polygon at Position (x, y) * \param position Coordinate of the Position where to add the new Point * \param pointIndex Index where to insert the new Point, Use pointIndex = -1 <DefaultArg> to insert at the end (between last and first Point) */ void addPoint(const Transform::UnitVector& position, int pointIndex = -1); /** * \brief Finds the closest Line from the given Position * \param position Position used to get the closest Line * \return The index of the line that is the closest one of the given Position (Line between point 0 and point 1 is index 0) */ PolygonSegment findClosestSegment(const Transform::UnitVector& position); /** * \brief Find the closest Point from the given Position(x, y) * \param position Coordinate of the Position used to get the closest Point * \param neighbor Get the closest neighboor of the closest Point instead of the Point * \param excludedPoints A std::vector containing points you want to exclude from the calculus (Not used in neighboor check step) * \return The index of the Point (or one of its neighboor) that is the closest one of the given Position */ PolygonPoint& findClosestPoint(const Transform::UnitVector& position, bool neighbor = false, const std::vector<point_index_t>& excludedPoints = {}); /** * \brief Get all the Points of the Polygon * \return A Path containing all the Points of the Polygon */ PolygonPath& getAllPoints(); /** * \brief Get the position of the Master Point (centroid) of the Polygon * \return An UnitVector containing the position of the Master Point (centroid) of the Polygon */ Transform::UnitVector getCentroid() const; /** * \brief Get the number of points in the Polygon * \return An unsigned int containing the number of points of the Polygon */ unsigned int getPointsAmount() const; /** * \brief Get the Position of the first point (index 0) of the Polygon * \return An UnitVector containing the position of the first point of the Polygon */ Transform::UnitVector getPosition() const override; /** * \brief Gets the current angle of the PolygonalCollider * \return A float containing the value of the current angle of the PolygonalCollider */ float getRotation() const; /* * \brief Gets the segment of the Polygon at index segment * \param segment Index of the Segment to get * \return The segment of the Polygon at index segment */ PolygonSegment getSegment(point_index_t segment); /** * \brief Get if the Position (x, y) is on one of the side of the Polygon * \param position Coordinate of the Position to test * \param tolerance * \return An unsigned int containing the index of the side containing the position or -1 if not found */ std::optional<PolygonSegment> getSegmentContainingPoint(const Transform::UnitVector& position, double tolerance = DefaultTolerance); /** * \brief Check if the MasterPoint of the Polygon is on Position (x - tolerance <= x <= x + tolerance, y - tolerance <= tolerance <= y + tolerance) * \param position Coordinate of the Position to test * \param tolerance Position tolerance, bigger number means less precise * \return true if the MasterPoint is on the given Positon, false otherwise */ bool isCentroidAroundPosition(const Transform::UnitVector& position, const Transform::UnitVector& tolerance) const; /** * \brief Check if a point of the Polygon is on Position (x - tolerance <= x <= x + tolerance, y - tolerance <= tolerance <= y + tolerance) * \param position Coordinate of the Position to test * \param tolerance Position tolerance, bigger number means less precise * \return An unsigned int containing the index of the point containing the position or -1 if not found */ std::optional<PolygonPoint*> getPointAroundPosition(const Transform::UnitVector& position, const Transform::UnitVector& tolerance); /** * \brief Moves the Polygon (relative to the current position) * \param position UnitVector containing the offset to move the Polygon */ void move(const Transform::UnitVector& position) override; /** * \brief Adds an angle to the current angle of the PolygonalCollider (will rotate all points around the given origin) * \param angle Angle to add to the PolygonalCollider * \param origin Origin to rotate all the points around */ void rotate(float angle, Transform::UnitVector origin); /** * \brief Sets the new position of the Polygon (using the point at index 0) * \param position UnitVector containing the new Position of the Polygon */ void setPosition(const Transform::UnitVector& position) override; /** * \brief Sets the angle of the PolygonalCollider (will rotate all points around the given origin) * \param angle Angle to set to the PolygonalCollider * \param origin Origin to rotate all the points around */ void setRotation(float angle, Transform::UnitVector origin); void setPositionFromCentroid(const Transform::UnitVector& position); PolygonPoint& operator[](point_index_t i); PolygonPoint& get(point_index_t i); Rect getBoundingBox() const; }; }
45.595238
156
0.663316
mjopenglsdl
f5bf0ad176c860aed0ec40730959b6320c256315
35,812
cpp
C++
DT3LevelEditor/Animation/EdLevelAnimationWindow.cpp
nemerle/DT3
801615d507eda9764662f3a34339aa676170e93a
[ "MIT" ]
3
2016-01-27T13:17:18.000Z
2019-03-19T09:18:25.000Z
DT3LevelEditor/Animation/EdLevelAnimationWindow.cpp
nemerle/DT3
801615d507eda9764662f3a34339aa676170e93a
[ "MIT" ]
1
2016-01-28T14:39:49.000Z
2016-01-28T22:12:07.000Z
DT3LevelEditor/Animation/EdLevelAnimationWindow.cpp
adderly/DT3
e2605be091ec903d3582e182313837cbaf790857
[ "MIT" ]
3
2016-01-25T16:44:51.000Z
2021-01-29T19:59:45.000Z
//============================================================================== /// /// File: EdLevelAnimationWindow.cpp /// /// Copyright (C) 2000-2014 by Smells Like Donkey Software Inc. All rights reserved. /// /// This file is subject to the terms and conditions defined in /// file 'LICENSE.txt', which is part of this source code package. /// //============================================================================== // Editor include #include "EdLevelAnimationWindow.hpp" #include "EdLevelDocument.hpp" // Qt include #include <QtWidgets/qdrawutil.h> #include <QtWidgets/QStyle> #include <QtCore/QFile> #include <QtGui/QMouseEvent> #include <QtGui/QWheelEvent> // Engine includes #include "DT3Core/Types/Utility/MoreStrings.hpp" #include "DT3Core/Objects/ObjectBase.hpp" #include "DT3Core/Scripting/ScriptingKeyframesRoot.hpp" //============================================================================== //============================================================================== using namespace DT3; //============================================================================== //============================================================================== EdLevelAnimationWindow::EdLevelAnimationWindow(QWidget *parent, QToolBar *toolbar, EdLevelDocument *document) : QWidget (parent), _font("Arial", 9), _font_bold("Arial", 9, QFont::Bold), _fm(_font), _pixels_per_second(100), _time (0.0F), _scroll (0), _root (NULL), _thumb_image (":/images/thumb.png"), _keyframe_image (":/images/keyframe.png"), _keyframe_image_selected (":/images/keyframe_selected.png") { _document = document; _toolbar = toolbar; // // Actions and toolbar // _anim_play = new QAction(tr("&Play"), this); _anim_play->setIcon(QIcon(":/images/play.png")); _anim_play->setStatusTip(tr("Play")); connect(_anim_play, SIGNAL(triggered()), this, SLOT(onScriptPlay())); _anim_stop = new QAction(tr("&Play"), this); _anim_stop->setIcon(QIcon(":/images/stop.png")); _anim_stop->setStatusTip(tr("Play")); connect(_anim_stop, SIGNAL(triggered()), this, SLOT(onScriptStop())); toolbar->addAction(_anim_play); toolbar->addAction(_anim_stop); // // Set up window // _horz_scrollbar = new QScrollBar(Qt::Horizontal, this); _horz_scrollbar->setSingleStep(20); _vert_scrollbar = new QScrollBar(Qt::Vertical, this); _vert_scrollbar->setSingleStep(10); connect( _horz_scrollbar, SIGNAL(valueChanged(int)), this, SLOT(onScrollTime(int)) ); connect( _vert_scrollbar, SIGNAL(valueChanged(int)), this, SLOT(onScroll(int)) ); _time_min = new EdLevelLineEdit(this); _time_min->setText("-1"); _time_max = new EdLevelLineEdit(this); _time_max->setText("30"); connect( _time_min, SIGNAL(editingFinished()), this, SLOT(onChangeTimeRange()) ); connect( _time_max, SIGNAL(editingFinished()), this, SLOT(onChangeTimeRange()) ); _scroll_width = _vert_scrollbar->sizeHint().width(); _scroll_height = _horz_scrollbar->sizeHint().height(); setFocusPolicy(Qt::ClickFocus); } EdLevelAnimationWindow::~EdLevelAnimationWindow (void) { } //============================================================================== //============================================================================== void EdLevelAnimationWindow::onAnimPlay (void) { //_anim_timer.start(200, this); } void EdLevelAnimationWindow::onAnimStop (void) { //_anim_timer.stop(); } //============================================================================== //============================================================================== void EdLevelAnimationWindow::scanRoot (const std::shared_ptr<ScriptingKeyframesRoot> &root, std::vector<PlugEventCache> &plug_event_cache) { _root = root; // Get all of the plugs for the current node std::list<PlugBase*> plugs; root->all_plugs(plugs); FOR_EACH (j,plugs) { // We only care about outputs if ( !(**j).is_output() ) continue; // Make sure it's hooked up if ( !(**j).has_outgoing_connection() ) continue; // Check each outgoing connection const std::vector<PlugBase*> connections = (**j).outgoing_connections(); for (int k = 0; k < connections.size(); ++k) { // Get connected keyframes std::shared_ptr<ScriptingKeyframes> keyframes = checked_cast<ScriptingKeyframes>( checked_cast<ScriptingKeyframes>(connections[k]->owner()->shared_from_this()) ); if (!keyframes) continue; // Get Keyframes output PlugBase *keyframes_out_plug = keyframes->plug_by_name("Out"); if (keyframes_out_plug) { // Make sure output is connected if (!keyframes_out_plug->has_outgoing_connection()) continue; // Get the FIRST output connection PlugBase* next_input_plug = keyframes_out_plug->outgoing_connections()[0]; // Record the nodes PlugEventCache animated_node; animated_node._node = checked_static_cast<PlugNode>(next_input_plug->owner()->shared_from_this()); animated_node._plug = next_input_plug; animated_node._keyframes = keyframes; plug_event_cache.push_back(animated_node); } // Get Keyframes output Event *keyframes_out_event = keyframes->event_by_name("Out"); if (keyframes_out_event) { // Make sure output is connected if (!keyframes_out_event->has_outgoing_connection()) continue; // Get the FIRST output connection Event* next_input_event = keyframes_out_event->outgoing_connections()[0]; // Record the nodes PlugEventCache animated_node; animated_node._node = checked_static_cast<PlugNode>(next_input_event->owner()->shared_from_this()); animated_node._event = next_input_event; animated_node._keyframes = keyframes; plug_event_cache.push_back(animated_node); } } } } //============================================================================== //============================================================================== void EdLevelAnimationWindow::layoutItems (std::vector<PlugEventCache> &plug_event_cache) { std::shared_ptr<PlugNode> last_node; int ypos = 0; for (int i = 0; i < plug_event_cache.size(); ++i) { if (plug_event_cache[i]._node != last_node) { last_node = plug_event_cache[i]._node; PlugEventCache c; //c._node = last_node; c._title = last_node->full_name(); c._ypos = ypos; plug_event_cache.insert (plug_event_cache.begin() + i, c); ypos += NODE_ITEM_HEIGHT; ++i; } if (plug_event_cache[i]._plug) plug_event_cache[i]._title = MoreStrings::captialize_and_format(plug_event_cache[i]._plug->name()); else plug_event_cache[i]._title = MoreStrings::captialize_and_format(plug_event_cache[i]._event->name()); plug_event_cache[i]._ypos = ypos; ypos += NODE_ITEM_HEIGHT; } _nodes_height = ypos; } //============================================================================== //============================================================================== void EdLevelAnimationWindow::scanRelevantNodes (const std::list<std::shared_ptr<PlugNode>> &selection_list) { _root.reset(); // // Build a giant list of all of the relevant nodes breadth-first // std::list<std::shared_ptr<PlugNode>> visited_nodes = selection_list; std::vector<PlugEventCache> plug_event_cache; FOR_EACH (i,visited_nodes) { // Check if node is a root if ((*i)->isa(ScriptingKeyframesRoot::kind())) { std::shared_ptr<ScriptingKeyframesRoot> root = checked_static_cast<ScriptingKeyframesRoot>(*i); scanRoot (root, plug_event_cache); layoutItems (plug_event_cache); if (_plug_event_cache != plug_event_cache) { _plug_event_cache = plug_event_cache; } return; } // Special case components too if ((*i)->isa(ObjectBase::kind())) { std::shared_ptr<ObjectBase> node_base = checked_static_cast<ObjectBase>(*i); for (int i = 0; i < ComponentBase::NUM_COMPONENT_TYPES; ++i) { std::shared_ptr<ComponentBase> component_base = node_base->component_by_type ( (ComponentBase::ComponentType) i); if (component_base) { // Check if we already visited the node auto j = std::find(visited_nodes.begin(), visited_nodes.end(), component_base); if (j != visited_nodes.end()) continue; visited_nodes.push_back(component_base); } } } // Get all of the plugs for the current node std::list<PlugBase*> plugs; (**i).all_plugs(plugs); FOR_EACH (j, plugs) { // We only care about inputs if ( !(**j).is_input() ) continue; // Make sure it's hooked up if ( !(**j).has_incoming_connection() ) continue; // Get the node std::shared_ptr<PlugNode> node = checked_static_cast<PlugNode>((**j).incoming_connection()->owner()->shared_from_this()); if (!node) continue; // Check if we already visited the node auto k = std::find(visited_nodes.begin(), visited_nodes.end(), node); if (k == visited_nodes.end()) visited_nodes.push_back(node); } // Get all of the events for the current node std::list<Event*> events; (**i).all_events(events); FOR_EACH (k, events) { // We only care about inputs if ( !(**k).is_input() ) continue; // Make sure it's hooked up if ( !(**k).has_incoming_connection() ) continue; // Get the nodes const std::vector<Event*> events = (*k)->incoming_connections(); FOR_EACH (i, events) { std::shared_ptr<PlugNode> node = checked_static_cast<PlugNode>((*i)->owner()->shared_from_this()); auto k = std::find(visited_nodes.begin(), visited_nodes.end(), node); if (k == visited_nodes.end()) visited_nodes.push_back(node); } } } } //============================================================================== //============================================================================== void EdLevelAnimationWindow::itemRect(PlugEventCache &n, QRect &tr, QRect &r) const { if (n._node) { const int INDENT = 15; tr = QRect(INDENT, n._ypos, NODE_ITEM_WIDTH-INDENT, NODE_ITEM_HEIGHT); r = QRect(0, n._ypos, NODE_ITEM_WIDTH, NODE_ITEM_HEIGHT); } else { const int INDENT = 5; tr = QRect(INDENT, n._ypos, NODE_ITEM_WIDTH-INDENT, NODE_ITEM_HEIGHT); r = QRect(0, n._ypos, NODE_ITEM_WIDTH, NODE_ITEM_HEIGHT); } } //============================================================================== //============================================================================== void EdLevelAnimationWindow::thumbRect (QRect &r) const { if (_root) { DTfloat t = _root->time(); int xpos = timeToPosition(t); r = QRect(xpos - _thumb_image.width()/2,0, _thumb_image.width(),_thumb_image.height()); } else { r = QRect(_thumb_image.width()/2,0, _thumb_image.width(),_thumb_image.height()); } } //============================================================================== //============================================================================== void EdLevelAnimationWindow::selectionRect (QRect &r) const { QPoint selection_start = _start_point + QPoint(timeToPosition(_time) - NODE_ITEM_WIDTH, -TITLE_HEIGHT + _scroll); QPoint selection_end = _end_point + QPoint(timeToPosition(_time) - NODE_ITEM_WIDTH, -TITLE_HEIGHT + _scroll); DTfloat xmin = selection_start.x(); DTfloat xmax = selection_end.x(); if (xmin > xmax) std::swap(xmin,xmax); DTfloat ymin = selection_start.y(); DTfloat ymax = selection_end.y(); if (ymin > ymax) std::swap(ymin,ymax); r = QRect( xmin, ymin, xmax - xmin, ymax - ymin); } void EdLevelAnimationWindow::keyRect (PlugEventCache &p, int k, QRect &rk) const { QRect tr, r; itemRect(p, tr, r); DTfloat kf_time = p._keyframes->key_time(k); int xpos = timeToPosition(kf_time); rk = QRect( xpos - _keyframe_image.width()/2, r.center().y() - _keyframe_image.height()/2, _keyframe_image.width(), _keyframe_image.height() ); } //============================================================================== //============================================================================== int EdLevelAnimationWindow::timeToPosition (DTfloat seconds) const { return _pixels_per_second * seconds; } DTfloat EdLevelAnimationWindow::positionToTime (int position) const { return static_cast<DTfloat>(position) / static_cast<DTfloat>(_pixels_per_second); } //============================================================================== //============================================================================== void EdLevelAnimationWindow::onSelectionChanged (const std::list<std::shared_ptr<PlugNode>> &selection_list) { blockSignals(true); scanRelevantNodes(selection_list); blockSignals(false); update(); } //============================================================================== //============================================================================== void EdLevelAnimationWindow::resizeEvent (QResizeEvent *event) { _title = QRect(0,0,NODE_ITEM_WIDTH, TITLE_HEIGHT); _timeline = QRect(NODE_ITEM_WIDTH,0,rect().width() - NODE_ITEM_WIDTH - _scroll_width, TITLE_HEIGHT); _nodes = QRect(0,TITLE_HEIGHT, NODE_ITEM_WIDTH, rect().height() - TITLE_HEIGHT); _controls = QRect(NODE_ITEM_WIDTH, TITLE_HEIGHT, rect().width() - NODE_ITEM_WIDTH - _scroll_width, rect().height() - TITLE_HEIGHT - _scroll_height); // Place scrollbars _horz_scrollbar->setGeometry(NODE_ITEM_WIDTH, rect().height() - _scroll_height, rect().width() - NODE_ITEM_WIDTH - _scroll_width, _scroll_height); _vert_scrollbar->setGeometry(rect().width() - _scroll_width, TITLE_HEIGHT, _scroll_width, rect().height() - TITLE_HEIGHT - _scroll_height); // Scale scrollbars int page_step = rect().height() - TITLE_HEIGHT - _scroll_height; _vert_scrollbar->setPageStep(page_step); _vert_scrollbar->setRange(0,_nodes_height - page_step); // Scale fields _time_min->setGeometry(NODE_ITEM_WIDTH, rect().height() - _scroll_height - TIME_FIELD_HEIGHT, TIME_FIELD_WIDTH, TIME_FIELD_HEIGHT); _time_max->setGeometry(rect().width() - _scroll_width - TIME_FIELD_WIDTH, rect().height() - _scroll_height - TIME_FIELD_HEIGHT, TIME_FIELD_WIDTH, TIME_FIELD_HEIGHT); onChangeTimeRange(); } //============================================================================== //============================================================================== void EdLevelAnimationWindow::onScrollTime(int time) { _time = positionToTime(time); update(); } void EdLevelAnimationWindow::onScroll(int scroll) { _scroll = scroll; update(); } void EdLevelAnimationWindow::onChangeTimeRange() { _time_min_sec = _time_min->text().toFloat(); _time_max_sec = _time_max->text().toFloat(); if (_time < _time_min_sec) _time = _time_min_sec; if (_time > _time_max_sec) _time = _time_max_sec; int page_step = _controls.width(); _horz_scrollbar->setPageStep(page_step); _horz_scrollbar->setRange( timeToPosition(_time_min_sec), timeToPosition(_time_max_sec) - page_step); update(); } //============================================================================== //============================================================================== void EdLevelAnimationWindow::mouseDoubleClickEvent (QMouseEvent *event) { event->accept(); } void EdLevelAnimationWindow::mousePressEvent(QMouseEvent *event) { emit doUndoBlock(); _start_point = _last_point = _end_point = event->pos(); // Translate into timeline space QPoint local_pos = _end_point + QPoint(timeToPosition(_time) - NODE_ITEM_WIDTH, -TITLE_HEIGHT + _scroll); // Check click in thumb if (_timeline.contains(event->pos())) { setMode(MODE_DRAGGING_THUMB); if (_root) { DTfloat t = positionToTime(local_pos.x()); emit doCommand(QString("SetProp \"") + _root->full_name().c_str() + ".Time_Out\" " + MoreStrings::cast_to_string(t).c_str()); } update(); } else if (_controls.contains(_end_point)) { if ( (event->buttons() & Qt::LeftButton) && ( (event->buttons() & Qt::MidButton) || (event->modifiers() & Qt::ALT)) ) { setMode(MODE_ZOOMING); } else { // Check all keyframes to see if one is clicked for (int i = 0; i < _plug_event_cache.size(); ++i) { if (!_plug_event_cache[i]._node || !_plug_event_cache[i]._keyframes) continue; for (int k = 0; k < getNumKeys(_plug_event_cache[i]); ++k) { QRect rk; keyRect (_plug_event_cache[i], k, rk); if (rk.contains(local_pos)) { int id = _plug_event_cache[i]._keyframes->key_id(k); // Check select new keyframe if (!isSelected(_plug_event_cache[i], id)) { clearSelected(); setSelected(_plug_event_cache[i], id, true); } setMode(MODE_DRAGGING); update(); return; } } } setMode(MODE_DRAG_SELECTING); } } else { setMode(MODE_NONE); } } void EdLevelAnimationWindow::mouseMoveEvent(QMouseEvent *event) { _end_point = event->pos(); //QPoint dist = _end_point - _start_point; QPoint delta = _end_point - _last_point; // Translate into timeline space QPoint local_pos = _end_point + QPoint(timeToPosition(_time) - NODE_ITEM_WIDTH, -TITLE_HEIGHT); switch (getMode()) { case MODE_DRAGGING_THUMB: if (_root) { DTfloat t = positionToTime(local_pos.x()); emit doCommand(QString("SetProp \"") + _root->full_name().c_str() + ".Time_Out\" " + MoreStrings::cast_to_string(t).c_str()); } update(); break; case MODE_DRAG_SELECTING: update(); // Just displaying selection rect break; case MODE_DRAGGING: // Check all keyframes to see if one is clicked for (int i = 0; i < _plug_event_cache.size(); ++i) { if (!_plug_event_cache[i]._node || !_plug_event_cache[i]._keyframes) continue; DTfloat dt = positionToTime(delta.x()); int num_keys = getNumKeys(_plug_event_cache[i]); // Since order can flip when keys are set, we start with the farther ahead points first // depending on direction of dt if (dt < 0.0F) { for (int k = 0; k < num_keys; ++k) { int id = _plug_event_cache[i]._keyframes->key_id(k); if (isSelected(_plug_event_cache[i], id)) { DTfloat current_time = _plug_event_cache[i]._keyframes->key_time(k); std::string cmd = "SetKeyframeTimeByID " + _plug_event_cache[i]._keyframes->full_name() + " " + MoreStrings::cast_to_string(id) + " " + MoreStrings::cast_to_string(current_time + dt); emit doCommand(cmd.c_str()); } } } else { for (int k = num_keys-1; k >= 0; --k) { int id = _plug_event_cache[i]._keyframes->key_id(k); if (isSelected(_plug_event_cache[i], id)) { DTfloat current_time = _plug_event_cache[i]._keyframes->key_time(k); std::string cmd = "SetKeyframeTimeByID " + _plug_event_cache[i]._keyframes->full_name() + " " + MoreStrings::cast_to_string(id) + " " + MoreStrings::cast_to_string(current_time + dt); emit doCommand(cmd.c_str()); } } } } update(); break; case MODE_ZOOMING: { DTfloat center_time_before = (_horz_scrollbar->value() + _controls.width() / 2) / static_cast<DTfloat>(_pixels_per_second); DTfloat zoom = -delta.y(); _pixels_per_second += zoom; if (_pixels_per_second < 5) _pixels_per_second = 5; else if (_pixels_per_second > 500) _pixels_per_second = 500; DTfloat center_time_after= (_horz_scrollbar->value() + _controls.width() / 2) / static_cast<DTfloat>(_pixels_per_second); _horz_scrollbar->setValue(_horz_scrollbar->value() - (center_time_after - center_time_before) * _pixels_per_second); onChangeTimeRange(); } break; default: break; }; _last_point = _end_point; } void EdLevelAnimationWindow::mouseReleaseEvent(QMouseEvent *event) { _end_point = event->pos(); // Translate into timeline space QPoint local_pos = _end_point + QPoint(timeToPosition(_time) - NODE_ITEM_WIDTH, -TITLE_HEIGHT); switch (getMode()) { case MODE_DRAGGING_THUMB: if (_root) { DTfloat t = positionToTime(local_pos.x()); emit doCommand(QString("SetProp \"") + _root->full_name().c_str() + ".Time_Out\" " + MoreStrings::cast_to_string(t).c_str()); } update(); break; case MODE_DRAG_SELECTING: { QRect rs; selectionRect(rs); for (int i = 0; i < _plug_event_cache.size(); ++i) { if (!_plug_event_cache[i]._node || !_plug_event_cache[i]._keyframes) continue; // Append selection if (event->modifiers() & Qt::SHIFT) { for (int k = 0; k < getNumKeys(_plug_event_cache[i]); ++k) { QRect rk; keyRect (_plug_event_cache[i], k, rk); if (rs.intersects(rk)) { int id = _plug_event_cache[i]._keyframes->key_id(k); // Invert keyframes if (isSelected(_plug_event_cache[i], id)) setSelected(_plug_event_cache[i], id, false); else setSelected(_plug_event_cache[i], id, true); } } // New selection } else { clearSelected (_plug_event_cache[i]); for (int k = 0; k < getNumKeys(_plug_event_cache[i]); ++k) { QRect rk; keyRect (_plug_event_cache[i], k, rk); if (rs.contains(rk)) { int id = _plug_event_cache[i]._keyframes->key_id(k); setSelected(_plug_event_cache[i], id, true); } } } } update(); } break; case MODE_DRAGGING: update(); break; default: break; } setMode(MODE_NONE); } //============================================================================== //============================================================================== void EdLevelAnimationWindow::wheelEvent (QWheelEvent *event) { int move = -event->delta(); if (event->orientation() == Qt::Horizontal) { _horz_scrollbar->setValue(_horz_scrollbar->value() + move); } else { _vert_scrollbar->setValue(_vert_scrollbar->value() + move); } update(); event->accept(); } //============================================================================== //============================================================================== void EdLevelAnimationWindow::keyPressEvent (QKeyEvent *event) { emit doUndoBlock(); int key = event->key(); if (event->matches(QKeySequence::Delete) || key == 0x1000003) { for (int i = 0; i < _plug_event_cache.size(); ++i) { if (!_plug_event_cache[i]._node || !_plug_event_cache[i]._keyframes) continue; std::list<int> &selected = _plug_event_cache[i]._selected_ids; FOR_EACH (j ,selected) { std::string cmd = "ClearKeyframeByID " + _plug_event_cache[i]._keyframes->full_name() + " " + MoreStrings::cast_to_string(*j); emit doCommand(cmd.c_str()); } } clearSelected(); update(); } } //============================================================================== //============================================================================== void EdLevelAnimationWindow::setSelected (PlugEventCache &p, int id, bool selected) { if (selected) { auto i = std::find(p._selected_ids.begin(), p._selected_ids.end(), id); if (i == p._selected_ids.end()) p._selected_ids.push_back(id); } else { auto i = std::find(p._selected_ids.begin(), p._selected_ids.end(), id); if (i != p._selected_ids.end()) p._selected_ids.erase(i); } } void EdLevelAnimationWindow::clearSelected (PlugEventCache &p) { p._selected_ids.clear(); } void EdLevelAnimationWindow::clearSelected (void) { for (int i = 0; i < _plug_event_cache.size(); ++i) clearSelected(_plug_event_cache[i]); } bool EdLevelAnimationWindow::isSelected (PlugEventCache &p, int id) { auto i = std::find(p._selected_ids.begin(), p._selected_ids.end(), id); if (i == p._selected_ids.end()) return false; return true; } //============================================================================== //============================================================================== void EdLevelAnimationWindow::onRefreshAnimation(void) { scanRelevantNodes( _document->selection() ); update(); } //============================================================================== //============================================================================== void EdLevelAnimationWindow::paintEvent(QPaintEvent * /* event */) { QPainter painter(this); draw(&painter); } void EdLevelAnimationWindow::draw(QPainter *painter) { painter->setRenderHint(QPainter::Antialiasing, false); painter->setClipRect(rect()); painter->setPen(Qt::NoPen); painter->setBrush(QBrush(QColor(100,100,100,255))); painter->drawRect(rect()); painter->setBrush(QBrush(QColor(95,95,95,255))); painter->drawRect(_nodes); painter->drawRect(_title); painter->drawRect(_timeline); // // Draw Node Names // painter->resetTransform (); painter->setClipRect ( _nodes ); painter->translate (0, TITLE_HEIGHT - _scroll); for (int i = 0; i < _plug_event_cache.size(); ++i) { QRect tr, r; itemRect(_plug_event_cache[i], tr, r); if (_plug_event_cache[i]._node) { painter->setPen(QPen(QColor(100,100,100,255),0)); painter->setBrush(QBrush(QColor(130,130,130,255))); painter->drawRect(r); painter->setPen(QPen(QColor(40,40,40,255),1)); painter->setFont(_font); painter->drawText(tr, Qt::AlignLeft | Qt::AlignVCenter, _plug_event_cache[i]._title.c_str() ); } else { painter->setPen(QPen(QColor(40,40,40,255),1)); painter->setFont(_font_bold); painter->drawText(tr, Qt::AlignLeft | Qt::AlignVCenter, _plug_event_cache[i]._title.c_str() ); } } // // Draw Node Keyframes // painter->resetTransform (); painter->setClipRect ( _controls ); painter->translate (NODE_ITEM_WIDTH - timeToPosition(_time), TITLE_HEIGHT - _scroll); for (int i = 0; i < _plug_event_cache.size(); ++i) { if (!_plug_event_cache[i]._node || !_plug_event_cache[i]._keyframes) continue; QRect tr, r; itemRect(_plug_event_cache[i], tr, r); // Build a new Rect based on this one r.setLeft( timeToPosition(_time_min_sec) ); r.setWidth( timeToPosition(_time_max_sec - _time_min_sec) ); painter->setPen(QPen(QColor(100,100,100,255),0)); painter->setBrush(QBrush(QColor(130,130,130,255))); painter->drawRect(r); // Draw guide line painter->setPen(QPen(QColor(100,100,100,255),1)); painter->drawLine( timeToPosition(_time_min_sec), r.center().y(), timeToPosition(_time_max_sec - _time_min_sec), r.center().y()); if (getNumKeys(_plug_event_cache[i]) > 0) { // Draw regions between keyframes for (int k = 0; k < getNumKeys(_plug_event_cache[i])-1; ++k) { QRect r1,r2; keyRect (_plug_event_cache[i], k, r1); keyRect (_plug_event_cache[i], k+1, r2); QRect r = r1.united(r2); r.adjust(_keyframe_image.width()/2, 0, -_keyframe_image.width()/2, 0); painter->setPen(Qt::NoPen); painter->setBrush(QBrush(QColor(0,0,0,30))); painter->drawRect(r); } // Draw keyframes for (int k = 0; k < getNumKeys(_plug_event_cache[i]); ++k) { QRect r; keyRect (_plug_event_cache[i], k, r); int id = _plug_event_cache[i]._keyframes->key_id(k); if (isSelected (_plug_event_cache[i], id)) painter->drawImage(r, _keyframe_image_selected); else painter->drawImage(r, _keyframe_image); } } } // Selection if (getMode() == MODE_DRAG_SELECTING) { QRect rs; selectionRect(rs); painter->setPen(QPen(QColor(53,120,255,255),2)); painter->setBrush(QBrush(QColor(0,0,0,50))); painter->drawRoundedRect(rs, 5, 5); } // // Draw Seconds // painter->resetTransform (); painter->setClipRect ( _timeline.united(_controls) ); painter->translate (NODE_ITEM_WIDTH - timeToPosition(_time), 0); painter->setFont(_font); // Milliseconds for (int t = _time_min_sec*1000; t <= _time_max_sec*1000; t += 100) { int xpos = timeToPosition(t/1000.0F); // Full second if (t % 1000 == 0) { if (t == 0) painter->setPen(QPen(QColor(75,75,75,255),3,Qt::SolidLine)); else painter->setPen(QPen(QColor(75,75,75,255),1,Qt::SolidLine)); painter->drawLine( QPoint(xpos, TITLE_HEIGHT) , QPoint(xpos, rect().height() - _scroll_height) ); QRect tr(xpos - _pixels_per_second/2,0,_pixels_per_second,TITLE_HEIGHT); painter->setPen(QPen(QColor(25,25,25,255),1,Qt::SolidLine)); std::stringstream ss; ss << (t/1000) << " s"; painter->drawText(tr, Qt::AlignHCenter | Qt::AlignBottom, ss.str().c_str()); } else { painter->setPen(QPen(QColor(90,90,90,255),1,Qt::DotLine)); painter->drawLine( QPoint(xpos, TITLE_HEIGHT) , QPoint(xpos, rect().height() - _scroll_height) ); } } // // Draw Current Time // if (_root) { painter->resetTransform (); painter->setClipRect ( _timeline.united(_controls) ); painter->translate (NODE_ITEM_WIDTH - timeToPosition(_time), 0); DTfloat t = _root->time(); int xpos = timeToPosition(t); QRect thr; thumbRect(thr); painter->drawImage(thr, _thumb_image); painter->setPen(QPen(QColor(0,255,0,255),1,Qt::SolidLine)); painter->drawLine( QPoint(xpos, TITLE_HEIGHT) , QPoint(xpos, rect().height() - _scroll_height) ); QRect tr(xpos - _pixels_per_second/2,0,_pixels_per_second,TITLE_HEIGHT); std::stringstream ss; ss << t << " s"; painter->drawText(tr, Qt::AlignHCenter | Qt::AlignTop, ss.str().c_str()); } // // Draw Separators // painter->resetTransform (); painter->setClipRect (rect()); painter->setPen(QPen(QColor(75,75,75,255),2)); painter->setBrush(QBrush(QColor(100,100,100,255))); painter->drawLine( QPoint(0, TITLE_HEIGHT), QPoint(rect().width(), TITLE_HEIGHT) ); painter->drawLine( QPoint(NODE_ITEM_WIDTH, 0), QPoint(NODE_ITEM_WIDTH, rect().height()) ); } //============================================================================== //============================================================================== #include "moc_EdLevelAnimationWindow.cpp"
34.500963
211
0.501703
nemerle
f5c1054a308d3b17d7a75fc95ddf2f5624dd9ea8
12,266
cpp
C++
folly/experimental/coro/test/AsyncGeneratorTest.cpp
muralivemulapati/folly
d7808b52813448e4535455e87fbea838a2307ce7
[ "Apache-2.0" ]
null
null
null
folly/experimental/coro/test/AsyncGeneratorTest.cpp
muralivemulapati/folly
d7808b52813448e4535455e87fbea838a2307ce7
[ "Apache-2.0" ]
null
null
null
folly/experimental/coro/test/AsyncGeneratorTest.cpp
muralivemulapati/folly
d7808b52813448e4535455e87fbea838a2307ce7
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2019-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <folly/Portability.h> #if FOLLY_HAS_COROUTINES #include <folly/ScopeGuard.h> #include <folly/Traits.h> #include <folly/experimental/coro/AsyncGenerator.h> #include <folly/experimental/coro/Baton.h> #include <folly/experimental/coro/BlockingWait.h> #include <folly/experimental/coro/Collect.h> #include <folly/experimental/coro/Sleep.h> #include <folly/experimental/coro/Task.h> #include <folly/experimental/coro/WithCancellation.h> #include <folly/futures/Future.h> #include <folly/portability/GTest.h> #include <chrono> #include <map> #include <string> #include <tuple> TEST(AsyncGenerator, DefaultConstructedGeneratorIsEmpty) { folly::coro::blockingWait([]() -> folly::coro::Task<void> { folly::coro::AsyncGenerator<int> g; auto result = co_await g.next(); CHECK(!result); }()); } TEST(AsyncGenerator, GeneratorDestroyedBeforeCallingBegin) { bool started = false; auto makeGenerator = [&]() -> folly::coro::AsyncGenerator<int> { started = true; co_return; }; { auto gen = makeGenerator(); (void)gen; } CHECK(!started); } TEST(AsyncGenerator, PartiallyConsumingSequenceDestroysObjectsInScope) { bool started = false; bool destroyed = false; auto makeGenerator = [&]() -> folly::coro::AsyncGenerator<int> { SCOPE_EXIT { destroyed = true; }; started = true; co_yield 1; co_yield 2; co_return; }; folly::coro::blockingWait([&]() -> folly::coro::Task<void> { { auto gen = makeGenerator(); CHECK(!started); CHECK(!destroyed); auto result = co_await gen.next(); CHECK(started); CHECK(!destroyed); CHECK(result); CHECK_EQ(1, *result); } CHECK(destroyed); }()); } TEST(AsyncGenerator, FullyConsumeSequence) { auto makeGenerator = []() -> folly::coro::AsyncGenerator<int> { for (int i = 0; i < 4; ++i) { co_yield i; } }; folly::coro::blockingWait([&]() -> folly::coro::Task<void> { auto gen = makeGenerator(); auto result = co_await gen.next(); CHECK(result); CHECK_EQ(0, *result); result = co_await gen.next(); CHECK(result); CHECK_EQ(1, *result); result = co_await gen.next(); CHECK(result); CHECK_EQ(2, *result); result = co_await gen.next(); CHECK(result); CHECK_EQ(3, *result); result = co_await gen.next(); CHECK(!result); }()); } namespace { struct SomeError : std::exception {}; } // namespace TEST(AsyncGenerator, ThrowExceptionBeforeFirstYield) { auto makeGenerator = []() -> folly::coro::AsyncGenerator<int> { if (true) { throw SomeError{}; } co_return; }; folly::coro::blockingWait([&]() -> folly::coro::Task<void> { auto gen = makeGenerator(); bool caughtException = false; try { (void)co_await gen.next(); CHECK(false); } catch (const SomeError&) { caughtException = true; } CHECK(caughtException); }()); } TEST(AsyncGenerator, ThrowExceptionAfterFirstYield) { auto makeGenerator = []() -> folly::coro::AsyncGenerator<int> { co_yield 42; throw SomeError{}; }; folly::coro::blockingWait([&]() -> folly::coro::Task<void> { auto gen = makeGenerator(); auto result = co_await gen.next(); CHECK(result); CHECK_EQ(42, *result); bool caughtException = false; try { (void)co_await gen.next(); CHECK(false); } catch (const SomeError&) { caughtException = true; } CHECK(caughtException); }()); } TEST(AsyncGenerator, ConsumingManySynchronousElementsDoesNotOverflowStack) { auto makeGenerator = []() -> folly::coro::AsyncGenerator<std::uint64_t> { for (std::uint64_t i = 0; i < 1'000'000; ++i) { co_yield i; } }; folly::coro::blockingWait([&]() -> folly::coro::Task<void> { auto gen = makeGenerator(); std::uint64_t sum = 0; while (auto result = co_await gen.next()) { sum += *result; } CHECK_EQ(499999500000u, sum); }()); } TEST(AsyncGenerator, ProduceResultsAsynchronously) { folly::coro::blockingWait([&]() -> folly::coro::Task<void> { folly::Executor* executor = co_await folly::coro::co_current_executor; auto makeGenerator = [&]() -> folly::coro::AsyncGenerator<int> { using namespace std::literals::chrono_literals; CHECK_EQ(executor, co_await folly::coro::co_current_executor); co_await folly::coro::sleep(1ms); CHECK_EQ(executor, co_await folly::coro::co_current_executor); co_yield 1; CHECK_EQ(executor, co_await folly::coro::co_current_executor); co_await folly::coro::sleep(1ms); CHECK_EQ(executor, co_await folly::coro::co_current_executor); co_yield 2; CHECK_EQ(executor, co_await folly::coro::co_current_executor); co_await folly::coro::sleep(1ms); CHECK_EQ(executor, co_await folly::coro::co_current_executor); }; auto gen = makeGenerator(); auto result = co_await gen.next(); CHECK_EQ(1, *result); result = co_await gen.next(); CHECK_EQ(2, *result); result = co_await gen.next(); CHECK(!result); }()); } struct ConvertibleToIntReference { int value; operator int&() { return value; } }; TEST(AsyncGenerator, GeneratorOfLValueReference) { auto makeGenerator = []() -> folly::coro::AsyncGenerator<int&> { int value = 10; co_yield value; // Consumer gets a mutable reference to the value and can modify it. CHECK_EQ(20, value); // NOTE: Not allowed to yield an rvalue from an AsyncGenerator<T&>? // co_yield 30; // Compile-error co_yield ConvertibleToIntReference{30}; }; folly::coro::blockingWait([&]() -> folly::coro::Task<void> { auto gen = makeGenerator(); auto result = co_await gen.next(); CHECK_EQ(10, result.value()); *result = 20; result = co_await gen.next(); CHECK_EQ(30, result.value()); result = co_await gen.next(); CHECK(!result.has_value()); }()); } struct ConvertibleToInt { operator int() const { return 99; } }; TEST(AsyncGenerator, GeneratorOfConstLValueReference) { auto makeGenerator = []() -> folly::coro::AsyncGenerator<const int&> { int value = 10; co_yield value; // Consumer gets a const reference to the value. // Allowed to yield an rvalue from an AsyncGenerator<const T&>. co_yield 30; co_yield ConvertibleToInt{}; }; folly::coro::blockingWait([&]() -> folly::coro::Task<void> { auto gen = makeGenerator(); auto result = co_await gen.next(); CHECK_EQ(10, *result); result = co_await gen.next(); CHECK_EQ(30, *result); result = co_await gen.next(); CHECK_EQ(99, *result); result = co_await gen.next(); CHECK(!result); }()); } TEST(AsyncGenerator, GeneratorOfRValueReference) { auto makeGenerator = []() -> folly::coro::AsyncGenerator<std::unique_ptr<int>&&> { co_yield std::make_unique<int>(10); auto ptr = std::make_unique<int>(20); co_yield std::move(ptr); CHECK(ptr == nullptr); }; folly::coro::blockingWait([&]() -> folly::coro::Task<void> { auto gen = makeGenerator(); auto result = co_await gen.next(); CHECK_EQ(10, **result); // Don't move it to a local var. result = co_await gen.next(); CHECK_EQ(20, **result); auto ptr = *result; // Move it to a local var. result = co_await gen.next(); CHECK(!result); }()); } struct MoveOnly { explicit MoveOnly(int value) : value_(value) {} MoveOnly(MoveOnly&& other) noexcept : value_(std::exchange(other.value_, -1)) {} ~MoveOnly() {} MoveOnly& operator=(MoveOnly&&) = delete; int value() const { return value_; } private: int value_; }; TEST(AsyncGenerator, GeneratorOfMoveOnlyType) { auto makeGenerator = []() -> folly::coro::AsyncGenerator<MoveOnly> { MoveOnly rvalue(1); co_yield std::move(rvalue); CHECK_EQ(-1, rvalue.value()); co_yield MoveOnly(2); }; folly::coro::blockingWait([&]() -> folly::coro::Task<void> { auto gen = makeGenerator(); auto result = co_await gen.next(); // NOTE: It's an error to dereference using '*it' as this returns a copy // of the iterator's reference type, which in this case is 'MoveOnly'. CHECK_EQ(1, result->value()); result = co_await gen.next(); CHECK_EQ(2, result->value()); result = co_await gen.next(); CHECK(!result); }()); } TEST(AsyncGenerator, GeneratorOfConstValue) { auto makeGenerator = []() -> folly::coro::AsyncGenerator<const int> { // OK to yield prvalue co_yield 42; // OK to yield lvalue int x = 123; co_yield x; co_yield ConvertibleToInt{}; }; folly::coro::blockingWait([&]() -> folly::coro::Task<void> { auto gen = makeGenerator(); auto result = co_await gen.next(); CHECK_EQ(42, *result); static_assert(std::is_same_v<decltype(*result), const int&>); result = co_await gen.next(); CHECK_EQ(123, *result); result = co_await gen.next(); CHECK_EQ(99, *result); result = co_await gen.next(); CHECK(!result); }()); } TEST(AsyncGenerator, ExplicitValueType) { std::map<std::string, std::string> items; items["foo"] = "hello"; items["bar"] = "goodbye"; auto makeGenerator = [&]() -> folly::coro::AsyncGenerator< std::tuple<const std::string&, std::string&>, std::tuple<std::string, std::string>> { for (auto& [k, v] : items) { co_yield{k, v}; } }; folly::coro::blockingWait([&]() -> folly::coro::Task<void> { auto gen = makeGenerator(); auto result = co_await gen.next(); { auto [kRef, vRef] = *result; CHECK_EQ("bar", kRef); CHECK_EQ("goodbye", vRef); decltype(gen)::value_type copy = *result; vRef = "au revoir"; CHECK_EQ("goodbye", std::get<1>(copy)); CHECK_EQ("au revoir", std::get<1>(*result)); } }()); CHECK_EQ("au revoir", items["bar"]); } TEST(AsyncGenerator, InvokeLambda) { folly::coro::blockingWait([]() -> folly::coro::Task<void> { auto ptr = std::make_unique<int>(123); auto gen = folly::coro::co_invoke( [p = std::move(ptr)]() mutable -> folly::coro::AsyncGenerator<std::unique_ptr<int>&&> { co_yield std::move(p); }); auto result = co_await gen.next(); CHECK(result); ptr = *result; CHECK(ptr); CHECK(*ptr == 123); }()); } template <typename Ref, typename Value = folly::remove_cvref_t<Ref>> folly::coro::AsyncGenerator<Ref, Value> neverStream() { folly::coro::Baton baton; folly::CancellationCallback cb{ co_await folly::coro::co_current_cancellation_token, [&] { baton.post(); }}; co_await baton; } TEST(AsyncGenerator, CancellationTokenPropagatesFromConsumer) { folly::coro::blockingWait([]() -> folly::coro::Task<void> { folly::CancellationSource cancelSource; bool suspended = false; bool done = false; co_await folly::coro::collectAll( folly::coro::co_withCancellation( cancelSource.getToken(), [&]() -> folly::coro::Task<void> { auto stream = neverStream<int>(); suspended = true; auto result = co_await stream.next(); CHECK(!result.has_value()); done = true; }()), [&]() -> folly::coro::Task<void> { co_await folly::coro::co_reschedule_on_current_executor; co_await folly::coro::co_reschedule_on_current_executor; co_await folly::coro::co_reschedule_on_current_executor; CHECK(suspended); CHECK(!done); cancelSource.requestCancellation(); }()); CHECK(done); }()); } #endif
27.502242
78
0.628974
muralivemulapati
f5cd8edcce6b2ab80301b10999ca540023b06dc7
28,923
cxx
C++
Interaction/Widgets/vtkPointHandleRepresentation3D.cxx
DmitrySemikin/vtk-mirror
7e70ac8c84797c7603686bd9bf8030c2ad8f101f
[ "BSD-3-Clause" ]
1
2021-07-21T07:15:44.000Z
2021-07-21T07:15:44.000Z
Interaction/Widgets/vtkPointHandleRepresentation3D.cxx
DmitrySemikin/vtk-mirror
7e70ac8c84797c7603686bd9bf8030c2ad8f101f
[ "BSD-3-Clause" ]
null
null
null
Interaction/Widgets/vtkPointHandleRepresentation3D.cxx
DmitrySemikin/vtk-mirror
7e70ac8c84797c7603686bd9bf8030c2ad8f101f
[ "BSD-3-Clause" ]
2
2020-03-24T14:09:05.000Z
2021-09-17T09:30:26.000Z
/*========================================================================= Program: Visualization Toolkit Module: vtkPointHandleRepresentation3D.cxx Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #include "vtkPointHandleRepresentation3D.h" #include "vtkActor.h" #include "vtkAssemblyPath.h" #include "vtkCamera.h" #include "vtkCellPicker.h" #include "vtkCoordinate.h" #include "vtkCursor3D.h" #include "vtkEventData.h" #include "vtkFocalPlanePointPlacer.h" #include "vtkInteractorObserver.h" #include "vtkLine.h" #include "vtkMath.h" #include "vtkObjectFactory.h" #include "vtkPickingManager.h" #include "vtkPolyDataMapper.h" #include "vtkProperty.h" #include "vtkRenderWindow.h" #include "vtkRenderWindowInteractor.h" #include "vtkRenderer.h" #include <assert.h> vtkStandardNewMacro(vtkPointHandleRepresentation3D); vtkCxxSetObjectMacro(vtkPointHandleRepresentation3D, Property, vtkProperty); vtkCxxSetObjectMacro(vtkPointHandleRepresentation3D, SelectedProperty, vtkProperty); //---------------------------------------------------------------------- vtkPointHandleRepresentation3D::vtkPointHandleRepresentation3D() { // Initialize state this->InteractionState = vtkHandleRepresentation::Outside; // Represent the line this->Cursor3D = vtkCursor3D::New(); this->Cursor3D->AllOff(); this->Cursor3D->AxesOn(); this->Cursor3D->TranslationModeOn(); this->Mapper = vtkPolyDataMapper::New(); this->Mapper->SetInputConnection(this->Cursor3D->GetOutputPort()); // Set up the initial properties this->CreateDefaultProperties(); this->Actor = vtkActor::New(); this->Actor->SetMapper(this->Mapper); this->Actor->SetProperty(this->Property); // Manage the picking stuff this->CursorPicker = vtkCellPicker::New(); this->CursorPicker->PickFromListOn(); this->CursorPicker->AddPickList(this->Actor); this->CursorPicker->SetTolerance(0.01); // need some fluff // Override superclass' this->PlaceFactor = 1.0; // The size of the hot spot this->HotSpotSize = 0.05; this->WaitingForMotion = 0; this->ConstraintAxis = -1; // Current handle size this->HandleSize = 15.0; // in pixels this->CurrentHandleSize = this->HandleSize; // Translation control this->TranslationMode = 1; vtkFocalPlanePointPlacer* pointPlacer = vtkFocalPlanePointPlacer::New(); this->SetPointPlacer(pointPlacer); pointPlacer->Delete(); // Continuous moves this->SmoothMotion = 1; } //---------------------------------------------------------------------- vtkPointHandleRepresentation3D::~vtkPointHandleRepresentation3D() { this->Cursor3D->Delete(); this->CursorPicker->Delete(); this->Mapper->Delete(); this->Actor->Delete(); this->Property->Delete(); this->SelectedProperty->Delete(); } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::RegisterPickers() { vtkPickingManager* pm = this->GetPickingManager(); if (!pm) { return; } pm->AddPicker(this->CursorPicker, this); } //------------------------------------------------------------------------- void vtkPointHandleRepresentation3D::PlaceWidget(double bds[6]) { int i; double bounds[6], center[3]; this->AdjustBounds(bds, bounds, center); this->Cursor3D->SetModelBounds(bounds); this->SetWorldPosition(center); for (i = 0; i < 6; i++) { this->InitialBounds[i] = bounds[i]; } this->InitialLength = sqrt((bounds[1] - bounds[0]) * (bounds[1] - bounds[0]) + (bounds[3] - bounds[2]) * (bounds[3] - bounds[2]) + (bounds[5] - bounds[4]) * (bounds[5] - bounds[4])); } //------------------------------------------------------------------------- double* vtkPointHandleRepresentation3D::GetBounds() { return this->Cursor3D->GetModelBounds(); } //------------------------------------------------------------------------- void vtkPointHandleRepresentation3D::SetWorldPosition(double p[3]) { if (this->Renderer && this->PointPlacer) { if (this->PointPlacer->ValidateWorldPosition(p)) { this->Cursor3D->SetFocalPoint(p); // this may clamp the point this->WorldPosition->SetValue(this->Cursor3D->GetFocalPoint()); this->WorldPositionTime.Modified(); } } else { this->Cursor3D->SetFocalPoint(p); // this may clamp the point this->WorldPosition->SetValue(this->Cursor3D->GetFocalPoint()); this->WorldPositionTime.Modified(); } } //------------------------------------------------------------------------- void vtkPointHandleRepresentation3D::SetDisplayPosition(double p[3]) { if (this->Renderer && this->PointPlacer) { if (this->PointPlacer->ValidateDisplayPosition(this->Renderer, p)) { double worldPos[3], worldOrient[9]; if (this->PointPlacer->ComputeWorldPosition(this->Renderer, p, worldPos, worldOrient)) { this->DisplayPosition->SetValue(p); this->WorldPosition->SetValue(worldPos); this->DisplayPositionTime.Modified(); this->SetWorldPosition(this->WorldPosition->GetValue()); } } } else { this->DisplayPosition->SetValue(p); this->DisplayPositionTime.Modified(); } } //------------------------------------------------------------------------- void vtkPointHandleRepresentation3D::SetHandleSize(double size) { this->Superclass::SetHandleSize(size); this->CurrentHandleSize = this->HandleSize; } //------------------------------------------------------------------------- int vtkPointHandleRepresentation3D ::ComputeInteractionState(int X, int Y, int vtkNotUsed(modify)) { this->VisibilityOn(); // actor must be on to be picked // First make sure that the cursor is within the bounding sphere of the // representation in display space. double d[3], bounds[6]; this->Cursor3D->GetModelBounds(bounds); this->GetDisplayPosition(d); if (!this->NearbyEvent(X, Y, bounds)) { this->InteractionState = vtkHandleRepresentation::Outside; return this->InteractionState; } // Now see if anything is picked vtkAssemblyPath* path = this->GetAssemblyPath(X, Y, 0., this->CursorPicker); if (path != nullptr) { this->InteractionState = vtkHandleRepresentation::Nearby; } else { this->InteractionState = vtkHandleRepresentation::Outside; if (this->ActiveRepresentation) { this->VisibilityOff(); } } return this->InteractionState; } //------------------------------------------------------------------------- int vtkPointHandleRepresentation3D::ComputeComplexInteractionState( vtkRenderWindowInteractor*, vtkAbstractWidget*, unsigned long, void* calldata, int) { this->VisibilityOn(); // actor must be on to be picked vtkEventData* edata = static_cast<vtkEventData*>(calldata); vtkEventDataDevice3D* edd = edata->GetAsEventDataDevice3D(); if (edd) { double pos[3]; edd->GetWorldPosition(pos); vtkAssemblyPath* path = this->GetAssemblyPath3DPoint(pos, this->CursorPicker); double focus[3]; this->Cursor3D->GetFocalPoint(focus); double d[3]; this->GetDisplayPosition(d); if (path != nullptr) { this->InteractionState = vtkHandleRepresentation::Nearby; } else { this->InteractionState = vtkHandleRepresentation::Outside; if (this->ActiveRepresentation) { this->VisibilityOff(); } } } return this->InteractionState; } //------------------------------------------------------------------------- int vtkPointHandleRepresentation3D::DetermineConstraintAxis( int constraint, double* x, double* startPickPoint) { // Look for trivial cases if (!this->Constrained) { return -1; } else if (constraint >= 0 && constraint < 3) { return constraint; } // Okay, figure out constraint. First see if the choice is // outside the hot spot if (!x) { double p[3], d2, tol; this->CursorPicker->GetPickPosition(p); d2 = vtkMath::Distance2BetweenPoints(p, this->LastPickPosition); tol = this->HotSpotSize * this->InitialLength; if (d2 > (tol * tol)) { this->WaitingForMotion = 0; return this->CursorPicker->GetCellId(); } else { this->WaitingForMotion = 1; this->WaitCount = 0; return -1; } } else if (x) { this->WaitingForMotion = 0; double v[3]; v[0] = fabs(x[0] - startPickPoint[0]); v[1] = fabs(x[1] - startPickPoint[1]); v[2] = fabs(x[2] - startPickPoint[2]); return (v[0] > v[1] ? (v[0] > v[2] ? 0 : 2) : (v[1] > v[2] ? 1 : 2)); } else { return -1; } } //---------------------------------------------------------------------- // Record the current event position, and the translation state void vtkPointHandleRepresentation3D::StartWidgetInteraction(double startEventPos[2]) { this->StartEventPosition[0] = startEventPos[0]; this->StartEventPosition[1] = startEventPos[1]; this->StartEventPosition[2] = 0.0; this->LastEventPosition[0] = startEventPos[0]; this->LastEventPosition[1] = startEventPos[1]; // Make sure events are close to widget and something is picked double bounds[6]; this->Cursor3D->GetModelBounds(bounds); bool nearby = this->NearbyEvent(startEventPos[0], startEventPos[1], bounds); vtkAssemblyPath* path = this->GetAssemblyPath(startEventPos[0], startEventPos[1], 0., this->CursorPicker); if (nearby && path != nullptr) { this->InteractionState = vtkHandleRepresentation::Nearby; this->ConstraintAxis = -1; this->CursorPicker->GetPickPosition(this->LastPickPosition); } else { this->InteractionState = vtkHandleRepresentation::Outside; this->ConstraintAxis = -1; } this->Cursor3D->SetTranslationMode(this->TranslationMode); this->WaitCount = 0; } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::StartComplexInteraction( vtkRenderWindowInteractor*, vtkAbstractWidget*, unsigned long, void* calldata) { vtkEventData* edata = static_cast<vtkEventData*>(calldata); vtkEventDataDevice3D* edd = edata->GetAsEventDataDevice3D(); if (edd) { edd->GetWorldPosition(this->StartEventPosition); this->LastEventPosition[0] = this->StartEventPosition[0]; this->LastEventPosition[1] = this->StartEventPosition[1]; this->LastEventPosition[2] = this->StartEventPosition[2]; double bounds[6]; this->Cursor3D->GetModelBounds(bounds); bool nearby = this->NearbyEvent(this->StartEventPosition[0], this->StartEventPosition[1], bounds); vtkAssemblyPath* path = this->GetAssemblyPath3DPoint(this->StartEventPosition, this->CursorPicker); if (nearby && path != nullptr) { this->InteractionState = vtkHandleRepresentation::Nearby; this->ConstraintAxis = -1; this->CursorPicker->GetPickPosition(this->LastPickPosition); } else { this->InteractionState = vtkHandleRepresentation::Outside; this->ConstraintAxis = -1; } this->Cursor3D->SetTranslationMode(this->TranslationMode); this->WaitCount = 0; } } //---------------------------------------------------------------------- // Based on the displacement vector (computed in display coordinates) and // the cursor state (which corresponds to which part of the widget has been // selected), the widget points are modified. // First construct a local coordinate system based on the display coordinates // of the widget. void vtkPointHandleRepresentation3D::WidgetInteraction(double eventPos[2]) { // Do different things depending on state // Calculations everybody does double focalPoint[4], pickPoint[4], prevPickPoint[4], startPickPoint[4], z; // Compute the two points defining the motion vector vtkInteractorObserver::ComputeWorldToDisplay(this->Renderer, this->LastPickPosition[0], this->LastPickPosition[1], this->LastPickPosition[2], focalPoint); z = focalPoint[2]; vtkInteractorObserver::ComputeDisplayToWorld( this->Renderer, this->LastEventPosition[0], this->LastEventPosition[1], z, prevPickPoint); vtkInteractorObserver::ComputeDisplayToWorld( this->Renderer, eventPos[0], eventPos[1], z, pickPoint); // Process the motion if (this->InteractionState == vtkHandleRepresentation::Selecting || this->InteractionState == vtkHandleRepresentation::Translating) { this->WaitCount++; if (this->WaitCount > 3 || !this->Constrained) { vtkInteractorObserver::ComputeDisplayToWorld(this->Renderer, this->StartEventPosition[0], this->StartEventPosition[1], z, startPickPoint); this->ConstraintAxis = this->DetermineConstraintAxis(this->ConstraintAxis, pickPoint, startPickPoint); if (this->InteractionState == vtkHandleRepresentation::Selecting && !this->TranslationMode) { vtkDebugMacro(<< "Processing widget interaction for Select mode"); // If we are doing axis constrained motion, ignore the placer. // Can't have both the placer and an axis constraint dictating // handle placement. if (this->ConstraintAxis >= 0 || this->Constrained || !this->PointPlacer) { this->MoveFocus(prevPickPoint, pickPoint); } else { double newCenterPointRequested[3]; // displayPosition double newCenterPoint[3], worldOrient[9]; // Make a request for the new position. this->MoveFocusRequest(prevPickPoint, pickPoint, eventPos, newCenterPointRequested); vtkFocalPlanePointPlacer* fPlacer = vtkFocalPlanePointPlacer::SafeDownCast(this->PointPlacer); if (fPlacer) { // Offset the placer plane to one that passes through the current // world position and is parallel to the focal plane. Offset = // the distance currentWorldPos is from the focal plane // double currentWorldPos[3], projDir[3], fp[3]; this->GetWorldPosition(currentWorldPos); this->Renderer->GetActiveCamera()->GetFocalPoint(fp); double vec[3] = { currentWorldPos[0] - fp[0], currentWorldPos[1] - fp[1], currentWorldPos[2] - fp[2] }; this->Renderer->GetActiveCamera()->GetDirectionOfProjection(projDir); fPlacer->SetOffset(vtkMath::Dot(vec, projDir)); } vtkDebugMacro(<< "Request for computing world position at " << "display position of " << newCenterPointRequested[0] << "," << newCenterPointRequested[1]); // See what the placer says. if (this->PointPlacer->ComputeWorldPosition( this->Renderer, newCenterPointRequested, newCenterPoint, worldOrient)) { // Once the placer has validated us, update the handle position this->SetWorldPosition(newCenterPoint); } } } else { vtkDebugMacro(<< "Processing widget interaction for translate"); // If we are doing axis constrained motion, ignore the placer. // Can't have both the placer and the axis constraint dictating // handle placement. if (this->ConstraintAxis >= 0 || this->Constrained || !this->PointPlacer) { this->Translate(prevPickPoint, pickPoint); } else { double newCenterPointRequested[3]; // displayPosition double newCenterPoint[3], worldOrient[9]; // Make a request for the new position. this->MoveFocusRequest(prevPickPoint, pickPoint, eventPos, newCenterPointRequested); vtkFocalPlanePointPlacer* fPlacer = vtkFocalPlanePointPlacer::SafeDownCast(this->PointPlacer); if (fPlacer) { // Offset the placer plane to one that passes through the current // world position and is parallel to the focal plane. Offset = // the distance currentWorldPos is from the focal plane // double currentWorldPos[3], projDir[3], fp[3]; this->GetWorldPosition(currentWorldPos); this->Renderer->GetActiveCamera()->GetFocalPoint(fp); double vec[3] = { currentWorldPos[0] - fp[0], currentWorldPos[1] - fp[1], currentWorldPos[2] - fp[2] }; this->Renderer->GetActiveCamera()->GetDirectionOfProjection(projDir); fPlacer->SetOffset(vtkMath::Dot(vec, projDir)); } vtkDebugMacro(<< "Request for computing world position at " << "display position of " << newCenterPointRequested[0] << "," << newCenterPointRequested[1]); // See what the placer says. if (this->PointPlacer->ComputeWorldPosition( this->Renderer, newCenterPointRequested, newCenterPoint, worldOrient)) { // Once the placer has validated us, update the handle // position and its bounds. double* p = this->GetWorldPosition(); // Get the motion vector double v[3] = { newCenterPoint[0] - p[0], newCenterPoint[1] - p[1], newCenterPoint[2] - p[2] }; double *bounds = this->Cursor3D->GetModelBounds(), newBounds[6]; for (int i = 0; i < 3; i++) { newBounds[2 * i] = bounds[2 * i] + v[i]; newBounds[2 * i + 1] = bounds[2 * i + 1] + v[i]; } this->Cursor3D->SetModelBounds(newBounds); this->SetWorldPosition(newCenterPoint); } } } } } else if (this->InteractionState == vtkHandleRepresentation::Scaling) { // Scaling does not change the position of the handle, we needn't // ask the placer.. this->Scale(prevPickPoint, pickPoint, eventPos); } // Book keeping this->LastEventPosition[0] = eventPos[0]; this->LastEventPosition[1] = eventPos[1]; this->Modified(); } void vtkPointHandleRepresentation3D::ComplexInteraction( vtkRenderWindowInteractor*, vtkAbstractWidget*, unsigned long, void* calldata) { vtkEventData* edata = static_cast<vtkEventData*>(calldata); vtkEventDataDevice3D* edd = edata->GetAsEventDataDevice3D(); if (edd) { double eventPos[3]; edd->GetWorldPosition(eventPos); // Process the motion if (this->InteractionState == vtkHandleRepresentation::Selecting || this->InteractionState == vtkHandleRepresentation::Translating) { this->WaitCount++; if (this->WaitCount > 3 || !this->Constrained) { this->ConstraintAxis = this->DetermineConstraintAxis(this->ConstraintAxis, eventPos, this->StartEventPosition); if (this->InteractionState == vtkHandleRepresentation::Selecting && !this->TranslationMode) { vtkDebugMacro(<< "Processing widget interaction for Select mode"); this->MoveFocus(this->LastEventPosition, eventPos); } else { vtkDebugMacro(<< "Processing widget interaction for translate"); this->Translate(this->LastEventPosition, eventPos); } } } // Book keeping this->LastEventPosition[0] = eventPos[0]; this->LastEventPosition[1] = eventPos[1]; this->LastEventPosition[2] = eventPos[2]; this->Modified(); } } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D ::MoveFocusRequest( const double* p1, const double* p2, const double eventPos[2], double center[3]) { if (this->SmoothMotion) { double focus[4], v[3]; this->Cursor3D->GetFocalPoint(focus); this->GetTranslationVector(p1, p2, v); // Move the center of the handle along the motion vector focus[0] += v[0]; focus[1] += v[1]; focus[2] += v[2]; focus[3] = 1.0; // Get the display position that this center would fall on. this->Renderer->SetWorldPoint(focus); this->Renderer->WorldToDisplay(); this->Renderer->GetDisplayPoint(center); } else { center[0] = eventPos[0]; center[1] = eventPos[1]; center[2] = 1.0; } } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::MoveFocus(const double* p1, const double* p2) { this->Translate(p1, p2); } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::SetTranslationMode(vtkTypeBool mode) { if (this->TranslationMode != mode) { this->TranslationMode = mode; // Pass new setting to Cursor3D, otherwise PlaceWidget will not work // as it should when TranslationMode is off. this->Cursor3D->SetTranslationMode(mode); this->Modified(); } } //---------------------------------------------------------------------- // Translate everything void vtkPointHandleRepresentation3D::Translate(const double* p1, const double* p2) { double v[3] = { 0, 0, 0 }; vtkHandleRepresentation::Translate(p1, p2); this->GetTranslationVector(p1, p2, v); double* bounds = this->Cursor3D->GetModelBounds(); double* pos = this->Cursor3D->GetFocalPoint(); double newBounds[6], newFocus[3]; int i; if (this->ConstraintAxis >= 0) { // move along axis for (i = 0; i < 3; i++) { if (i != this->ConstraintAxis) { v[i] = 0.0; } } } for (i = 0; i < 3; i++) { newBounds[2 * i] = bounds[2 * i] + v[i]; newBounds[2 * i + 1] = bounds[2 * i + 1] + v[i]; newFocus[i] = pos[i] + v[i]; } this->Cursor3D->SetModelBounds(newBounds); this->Cursor3D->SetFocalPoint(newFocus); } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::SizeBounds() { // Only change the size of the bounding box if translation mode is on. if (this->TranslationMode) { double center[3], bounds[6]; this->Cursor3D->GetFocalPoint(center); double radius = this->SizeHandlesInPixels(1.0, center); radius *= this->CurrentHandleSize / this->HandleSize; for (int i = 0; i < 3; i++) { bounds[2 * i] = center[i] - radius; bounds[2 * i + 1] = center[i] + radius; } this->Cursor3D->SetModelBounds(bounds); } } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::Scale( const double* p1, const double* p2, const double eventPos[2]) { // Get the motion vector double v[3]; v[0] = p2[0] - p1[0]; v[1] = p2[1] - p1[1]; v[2] = p2[2] - p1[2]; double* bounds = this->Cursor3D->GetModelBounds(); // Compute the scale factor double sf = vtkMath::Norm(v) / sqrt((bounds[1] - bounds[0]) * (bounds[1] - bounds[0]) + (bounds[3] - bounds[2]) * (bounds[3] - bounds[2]) + (bounds[5] - bounds[4]) * (bounds[5] - bounds[4])); if (eventPos[1] > this->LastEventPosition[1]) { sf = 1.0 + sf; } else { sf = 1.0 - sf; } this->CurrentHandleSize *= sf; this->CurrentHandleSize = (this->CurrentHandleSize < 0.001 ? 0.001 : this->CurrentHandleSize); this->SizeBounds(); } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::Highlight(int highlight) { if (highlight) { this->Actor->SetProperty(this->SelectedProperty); } else { this->Actor->SetProperty(this->Property); } } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::CreateDefaultProperties() { this->Property = vtkProperty::New(); this->Property->SetAmbient(1.0); this->Property->SetAmbientColor(1.0, 1.0, 1.0); this->Property->SetLineWidth(0.5); this->SelectedProperty = vtkProperty::New(); this->SelectedProperty->SetAmbient(1.0); this->SelectedProperty->SetAmbientColor(0.0, 1.0, 0.0); this->SelectedProperty->SetLineWidth(2.0); } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::SetVisibility(vtkTypeBool visible) { this->Actor->SetVisibility(visible); // Forward to superclass this->Superclass::SetVisibility(visible); } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::BuildRepresentation() { // The net effect is to resize the handle if (this->GetMTime() > this->BuildTime || (this->Renderer && this->Renderer->GetVTKWindow() && this->Renderer->GetVTKWindow()->GetMTime() > this->BuildTime)) { if (!this->Placed) { this->ValidPick = 1; this->Placed = 1; } this->SizeBounds(); this->Cursor3D->Update(); this->BuildTime.Modified(); } } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::ShallowCopy(vtkProp* prop) { vtkPointHandleRepresentation3D* rep = vtkPointHandleRepresentation3D::SafeDownCast(prop); if (rep) { this->SetOutline(rep->GetOutline()); this->SetXShadows(rep->GetXShadows()); this->SetYShadows(rep->GetYShadows()); this->SetZShadows(rep->GetZShadows()); this->SetTranslationMode(rep->GetTranslationMode()); this->SetProperty(rep->GetProperty()); this->Actor->SetProperty(rep->GetProperty()); this->SetSelectedProperty(rep->GetSelectedProperty()); this->SetHotSpotSize(rep->GetHotSpotSize()); } this->Superclass::ShallowCopy(prop); } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::DeepCopy(vtkProp* prop) { vtkPointHandleRepresentation3D* rep = vtkPointHandleRepresentation3D::SafeDownCast(prop); if (rep) { this->SetOutline(rep->GetOutline()); this->SetXShadows(rep->GetXShadows()); this->SetYShadows(rep->GetYShadows()); this->SetZShadows(rep->GetZShadows()); this->SetTranslationMode(rep->GetTranslationMode()); this->SetProperty(rep->GetProperty()); this->Actor->SetProperty(rep->GetProperty()); this->SetSelectedProperty(rep->GetSelectedProperty()); this->SetHotSpotSize(rep->GetHotSpotSize()); } this->Superclass::DeepCopy(prop); } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::GetActors(vtkPropCollection* pc) { this->Actor->GetActors(pc); } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::ReleaseGraphicsResources(vtkWindow* win) { this->Actor->ReleaseGraphicsResources(win); } //---------------------------------------------------------------------- int vtkPointHandleRepresentation3D::RenderOpaqueGeometry(vtkViewport* viewport) { this->BuildRepresentation(); // Sanity check double worldPos[3]; this->GetWorldPosition(worldPos); if (worldPos[0] == VTK_DOUBLE_MAX) { return 0; } return this->Actor->RenderOpaqueGeometry(viewport); } //----------------------------------------------------------------------------- int vtkPointHandleRepresentation3D::RenderTranslucentPolygonalGeometry(vtkViewport* viewport) { this->BuildRepresentation(); // Sanity check double worldPos[3]; this->GetWorldPosition(worldPos); if (worldPos[0] == VTK_DOUBLE_MAX) { return 0; } return this->Actor->RenderTranslucentPolygonalGeometry(viewport); } //----------------------------------------------------------------------------- vtkTypeBool vtkPointHandleRepresentation3D::HasTranslucentPolygonalGeometry() { this->BuildRepresentation(); return this->Actor->HasTranslucentPolygonalGeometry(); } //---------------------------------------------------------------------- void vtkPointHandleRepresentation3D::PrintSelf(ostream& os, vtkIndent indent) { // Superclass typedef defined in vtkTypeMacro() found in vtkSetGet.h this->Superclass::PrintSelf(os, indent); os << indent << "Hot Spot Size: " << this->HotSpotSize << "\n"; if (this->Property) { os << indent << "Property: " << this->Property << "\n"; } else { os << indent << "Property: (none)\n"; } if (this->SelectedProperty) { os << indent << "Selected Property: " << this->SelectedProperty << "\n"; } else { os << indent << "Selected Property: (none)\n"; } os << indent << "Outline: " << (this->GetOutline() ? "On\n" : "Off\n"); os << indent << "XShadows: " << (this->GetXShadows() ? "On\n" : "Off\n"); os << indent << "YShadows: " << (this->GetYShadows() ? "On\n" : "Off\n"); os << indent << "ZShadows: " << (this->GetZShadows() ? "On\n" : "Off\n"); os << indent << "Translation Mode: " << (this->TranslationMode ? "On\n" : "Off\n"); os << indent << "SmoothMotion: " << this->SmoothMotion << endl; }
32.136667
99
0.608097
DmitrySemikin
f5cedba503219973d90e24eda157451a4a95d3c5
83,256
cpp
C++
runtime/variable.cpp
redm-pro/mLang
67f12ecb9f8d451d2eeab1ed00e6e709ff52945d
[ "BSD-3-Clause" ]
null
null
null
runtime/variable.cpp
redm-pro/mLang
67f12ecb9f8d451d2eeab1ed00e6e709ff52945d
[ "BSD-3-Clause" ]
null
null
null
runtime/variable.cpp
redm-pro/mLang
67f12ecb9f8d451d2eeab1ed00e6e709ff52945d
[ "BSD-3-Clause" ]
null
null
null
/* $Author = Sargis Ananyan; $Corp = RedM Inc; $Web = https://redm.pro/; $Lincese = BSD 3; $Name = mLang; $Description = A programming language for web programming.; */ #pragma once bool empty_bool __attribute__ ((weak)); int empty_int __attribute__ ((weak)); double empty_float __attribute__ ((weak)); string empty_string __attribute__ ((weak)); char empty_array_var_storage[sizeof (array <var>)] __attribute__ ((weak)); array <var> *empty_array_var __attribute__ ((weak)) = reinterpret_cast <array <var> *> (empty_array_var_storage); var empty_var __attribute__ ((weak)); void var::copy_from (const var &other) { switch (other.type) { case NULL_TYPE: break; case BOOLEAN_TYPE: b = other.b; break; case INTEGER_TYPE: i = other.i; break; case FLOAT_TYPE: f = other.f; break; case STRING_TYPE: new (&s) string (*STRING(other.s)); break; case ARRAY_TYPE: new (&a) array <var> (*ARRAY(other.a)); break; case OBJECT_TYPE: new (&o) object (*OBJECT(other.o)); break; } type = other.type; } var::var (void): type (NULL_TYPE) { } var::var (const Unknown &u): type (NULL_TYPE) { php_assert ("Unknown used!!!" && 0); } var::var (bool b): type (BOOLEAN_TYPE), b (b) { } var::var (int i): type (INTEGER_TYPE), i (i) { } var::var (double f): type (FLOAT_TYPE), f (f) { } var::var (const string &s_): type (STRING_TYPE) { new (&s) string (s_); } var::var (const char *s_, int len): type (STRING_TYPE) { new (&s) string (s_, len); } template <class T> var::var (const array <T> &a_): type (ARRAY_TYPE) { new (&a) array <var> (a_); } template <class T> var::var (const object_ptr <T> &o_): type (OBJECT_TYPE) { new (&o) object (o_); } var::var (const OrFalse <int> &v) { if (likely (v.bool_value)) { type = INTEGER_TYPE; i = v.value; } else { type = BOOLEAN_TYPE; b = false; } } var::var (const OrFalse <double> &v) { if (likely (v.bool_value)) { type = FLOAT_TYPE; f = v.value; } else { type = BOOLEAN_TYPE; b = false; } } var::var (const OrFalse <string> &v) { if (likely (v.bool_value)) { type = STRING_TYPE; new (&s) string (v.value); } else { type = BOOLEAN_TYPE; b = false; } } template <class T> var::var (const OrFalse <array <T> > &v) { if (likely (v.bool_value)) { type = ARRAY_TYPE; new (&a) array <var> (v.value); } else { type = BOOLEAN_TYPE; b = false; } } template <class T> var::var (const OrFalse <object_ptr <T> > &v) { if (likely (v.bool_value)) { type = OBJECT_TYPE; new (&o) object (v.value); } else { type = BOOLEAN_TYPE; b = false; } } var::var (const var &v) { copy_from (v); } var& var::operator = (bool other) { switch (type) { case NULL_TYPE: type = BOOLEAN_TYPE; b = other; return *this; case BOOLEAN_TYPE: b = other; return *this; case INTEGER_TYPE: type = BOOLEAN_TYPE; b = other; return *this; case FLOAT_TYPE: type = BOOLEAN_TYPE; b = other; return *this; case STRING_TYPE: STRING(s)->~string(); type = BOOLEAN_TYPE; b = other; return *this; case ARRAY_TYPE: ARRAY(a)->~array <var>(); type = BOOLEAN_TYPE; b = other; return *this; case OBJECT_TYPE: OBJECT(o)->~object(); type = BOOLEAN_TYPE; b = other; return *this; default: php_assert (0); exit (1); } } var& var::operator = (int other) { switch (type) { case NULL_TYPE: type = INTEGER_TYPE; i = other; return *this; case BOOLEAN_TYPE: type = INTEGER_TYPE; i = other; return *this; case INTEGER_TYPE: i = other; return *this; case FLOAT_TYPE: type = INTEGER_TYPE; i = other; return *this; case STRING_TYPE: STRING(s)->~string(); type = INTEGER_TYPE; i = other; return *this; case ARRAY_TYPE: ARRAY(a)->~array <var>(); type = INTEGER_TYPE; i = other; return *this; case OBJECT_TYPE: OBJECT(o)->~object(); type = INTEGER_TYPE; i = other; return *this; default: php_assert (0); exit (1); } } var& var::operator = (double other) { switch (type) { case NULL_TYPE: type = FLOAT_TYPE; f = other; return *this; case BOOLEAN_TYPE: type = FLOAT_TYPE; f = other; return *this; case INTEGER_TYPE: type = FLOAT_TYPE; f = other; return *this; case FLOAT_TYPE: f = other; return *this; case STRING_TYPE: STRING(s)->~string(); type = FLOAT_TYPE; f = other; return *this; case ARRAY_TYPE: ARRAY(a)->~array <var>(); type = FLOAT_TYPE; f = other; return *this; case OBJECT_TYPE: OBJECT(o)->~object(); type = FLOAT_TYPE; f = other; return *this; default: php_assert (0); exit (1); } } var& var::operator = (const string &other) { switch (type) { case NULL_TYPE: type = STRING_TYPE; new (&s) string (other); return *this; case BOOLEAN_TYPE: type = STRING_TYPE; new (&s) string (other); return *this; case INTEGER_TYPE: type = STRING_TYPE; new (&s) string (other); return *this; case FLOAT_TYPE: type = STRING_TYPE; new (&s) string (other); return *this; case STRING_TYPE: *STRING(s) = other; return *this; case ARRAY_TYPE: ARRAY(a)->~array <var>(); type = STRING_TYPE; new (&s) string (other); return *this; case OBJECT_TYPE: OBJECT(o)->~object(); type = STRING_TYPE; new (&s) string (other); return *this; default: php_assert (0); exit (1); } } var& var::assign (const char *other, int len) { switch (type) { case NULL_TYPE: type = STRING_TYPE; new (&s) string (other, len); return *this; case BOOLEAN_TYPE: type = STRING_TYPE; new (&s) string (other, len); return *this; case INTEGER_TYPE: type = STRING_TYPE; new (&s) string (other, len); return *this; case FLOAT_TYPE: type = STRING_TYPE; new (&s) string (other, len); return *this; case STRING_TYPE: STRING(s)->assign (other, len); return *this; case ARRAY_TYPE: ARRAY(a)->~array <var>(); type = STRING_TYPE; new (&s) string (other, len); return *this; case OBJECT_TYPE: OBJECT(o)->~object(); type = STRING_TYPE; new (&s) string (other, len); return *this; default: php_assert (0); exit (1); } } template <class T> var& var::operator = (const array <T> &other) { switch (type) { case NULL_TYPE: type = ARRAY_TYPE; new (&a) array <var> (other); return *this; case BOOLEAN_TYPE: type = ARRAY_TYPE; new (&a) array <var> (other); return *this; case INTEGER_TYPE: type = ARRAY_TYPE; new (&a) array <var> (other); return *this; case FLOAT_TYPE: type = ARRAY_TYPE; new (&a) array <var> (other); return *this; case STRING_TYPE: STRING(s)->~string(); type = ARRAY_TYPE; new (&a) array <var> (other); return *this; case ARRAY_TYPE: *ARRAY(a) = other; return *this; case OBJECT_TYPE: OBJECT(o)->~object(); type = ARRAY_TYPE; new (&a) array <var> (other); return *this; default: php_assert (0); exit (1); } } template <class T> var& var::operator = (const object_ptr <T> &other) { switch (type) { case NULL_TYPE: type = OBJECT_TYPE; new (&o) object (other); return *this; case BOOLEAN_TYPE: type = OBJECT_TYPE; new (&o) object (other); return *this; case INTEGER_TYPE: type = OBJECT_TYPE; new (&o) object (other); return *this; case FLOAT_TYPE: type = OBJECT_TYPE; new (&o) object (other); return *this; case STRING_TYPE: STRING(s)->~string(); type = OBJECT_TYPE; new (&o) object (other); return *this; case ARRAY_TYPE: ARRAY(a)->~array <var>(); type = OBJECT_TYPE; new (&o) object (other); return *this; case OBJECT_TYPE: *OBJECT(o) = other; return *this; default: php_assert (0); exit (1); } } var& var::operator = (const var &other) { if (this != &other) { destroy(); copy_from (other); } return *this; /* switch (other.type) { case NULL_TYPE: destroy(); type = NULL_TYPE; return *this; case BOOLEAN_TYPE: return *this = other.b; case INTEGER_TYPE: return *this = other.i; case FLOAT_TYPE: return *this = other.f; case STRING_TYPE: return *this = *STRING(other.s); case ARRAY_TYPE: return *this = *ARRAY(other.a); case OBJECT_TYPE: return *this = *OBJECT(other.o); default: php_assert (0); exit (1); }*/ } var& var::operator = (const OrFalse <int> &other) { destroy(); if (likely (other.bool_value)) { type = INTEGER_TYPE; i = other.value; } else { type = BOOLEAN_TYPE; b = false; } return *this; } var& var::operator = (const OrFalse <double> &other) { destroy(); if (likely (other.bool_value)) { type = FLOAT_TYPE; f = other.value; } else { type = BOOLEAN_TYPE; b = false; } return *this; } var& var::operator = (const OrFalse <string> &other) { if (likely (other.bool_value)) { *this = other.value; } else { destroy(); type = BOOLEAN_TYPE; b = false; } return *this; } template <class T> var& var::operator = (const OrFalse <array <T> > &other) { if (likely (other.bool_value)) { *this = other.value; } else { destroy(); type = BOOLEAN_TYPE; b = false; } return *this; } template <class T> var& var::operator = (const OrFalse <object_ptr <T> > &other) { if (likely (other.bool_value)) { *this = other.value; } else { destroy(); type = BOOLEAN_TYPE; b = false; } return *this; } const var var::operator - (void) const { var arg1 = to_numeric(); if (arg1.type == INTEGER_TYPE) { arg1.i = -arg1.i; } else { arg1.f = -arg1.f; } return arg1; } const var var::operator + (void) const { return to_numeric(); } int var::operator ~(void) const { return ~to_int(); } var& var::operator += (const var &other) { if (likely (type == INTEGER_TYPE && other.type == INTEGER_TYPE)) { i += other.i; return *this; } if (unlikely (type == ARRAY_TYPE || other.type == ARRAY_TYPE)) { if (type == ARRAY_TYPE && other.type == ARRAY_TYPE) { *ARRAY(a) += *ARRAY(other.a); } else { php_warning ("Unsupported operand types for operator += (%s and %s)", get_type_c_str(), other.get_type_c_str()); } return *this; } convert_to_numeric(); const var arg2 = other.to_numeric(); if (type == INTEGER_TYPE) { if (arg2.type == INTEGER_TYPE) { i += arg2.i; } else { type = FLOAT_TYPE; f = i + arg2.f; } } else { if (arg2.type == INTEGER_TYPE) { f += arg2.i; } else { f += arg2.f; } } return *this; } var& var::operator -= (const var &other) { if (likely (type == INTEGER_TYPE && other.type == INTEGER_TYPE)) { i -= other.i; return *this; } convert_to_numeric(); const var arg2 = other.to_numeric(); if (type == INTEGER_TYPE) { if (arg2.type == INTEGER_TYPE) { i -= arg2.i; } else { type = FLOAT_TYPE; f = i - arg2.f; } } else { if (arg2.type == INTEGER_TYPE) { f -= arg2.i; } else { f -= arg2.f; } } return *this; } var& var::operator *= (const var &other) { if (likely (type == INTEGER_TYPE && other.type == INTEGER_TYPE)) { i *= other.i; return *this; } convert_to_numeric(); const var arg2 = other.to_numeric(); if (type == INTEGER_TYPE) { if (arg2.type == INTEGER_TYPE) { i *= arg2.i; } else { type = FLOAT_TYPE; f = i * arg2.f; } } else { if (arg2.type == INTEGER_TYPE) { f *= arg2.i; } else { f *= arg2.f; } } return *this; } var& var::operator /= (const var &other) { if (likely (type == INTEGER_TYPE && other.type == INTEGER_TYPE)) { if (i % other.i == 0) { i /= other.i; } else { type = FLOAT_TYPE; f = (double)i / other.i; } return *this; } convert_to_numeric(); const var arg2 = other.to_numeric(); if (arg2.type == INTEGER_TYPE) { if (arg2.i == 0) { php_warning ("Integer division by zero"); type = BOOLEAN_TYPE; b = false; return *this; } if (type == INTEGER_TYPE) { if (i % arg2.i == 0) { i /= arg2.i; } else { type = FLOAT_TYPE; f = (double)i / other.i; } } else { f /= arg2.i; } } else { if (arg2.f == 0) { php_warning ("Float division by zero"); type = BOOLEAN_TYPE; b = false; return *this; } if (type == INTEGER_TYPE) { type = FLOAT_TYPE; f = i / arg2.f; } else { f /= arg2.f; } } return *this; } var& var::operator %= (const var &other) { int div = other.to_int(); if (div == 0) { php_warning ("Modulo by zero"); *this = false; return *this; } convert_to_int(); i %= div; return *this; } var& var::operator &= (const var &other) { convert_to_int(); i &= other.to_int(); return *this; } var& var::operator |= (const var &other) { convert_to_int(); i |= other.to_int(); return *this; } var& var::operator ^= (const var &other) { convert_to_int(); i ^= other.to_int(); return *this; } var& var::operator <<= (const var &other) { convert_to_int(); i <<= other.to_int(); return *this; } var& var::operator >>= (const var &other) { convert_to_int(); i >>= other.to_int(); return *this; } var& var::safe_set_add (const var &other) { if (likely (type == INTEGER_TYPE && other.type == INTEGER_TYPE)) { ::safe_set_add (i, other.i); return *this; } if (unlikely (type == ARRAY_TYPE || other.type == ARRAY_TYPE)) { if (type == ARRAY_TYPE && other.type == ARRAY_TYPE) { *ARRAY(a) += *ARRAY(other.a); } else { php_warning ("Unsupported operand types for operator += (%s and %s)", get_type_c_str(), other.get_type_c_str()); } return *this; } convert_to_numeric(); const var arg2 = other.to_numeric(); if (type == INTEGER_TYPE) { if (arg2.type == INTEGER_TYPE) { ::safe_set_add (i, arg2.i); } else { type = FLOAT_TYPE; f = i + arg2.f; } } else { if (arg2.type == INTEGER_TYPE) { f += arg2.i; } else { f += arg2.f; } } return *this; } var& var::safe_set_sub (const var &other) { if (likely (type == INTEGER_TYPE && other.type == INTEGER_TYPE)) { ::safe_set_sub (i, other.i); return *this; } convert_to_numeric(); const var arg2 = other.to_numeric(); if (type == INTEGER_TYPE) { if (arg2.type == INTEGER_TYPE) { ::safe_set_sub (i, arg2.i); } else { type = FLOAT_TYPE; f = i - arg2.f; } } else { if (arg2.type == INTEGER_TYPE) { f -= arg2.i; } else { f -= arg2.f; } } return *this; } var& var::safe_set_mul (const var &other) { if (likely (type == INTEGER_TYPE && other.type == INTEGER_TYPE)) { ::safe_set_mul (i, other.i); return *this; } convert_to_numeric(); const var arg2 = other.to_numeric(); if (type == INTEGER_TYPE) { if (arg2.type == INTEGER_TYPE) { ::safe_set_mul (i, arg2.i); } else { type = FLOAT_TYPE; f = i * arg2.f; } } else { if (arg2.type == INTEGER_TYPE) { f *= arg2.i; } else { f *= arg2.f; } } return *this; } var& var::safe_set_shl (const var &other) { safe_convert_to_int(); ::safe_set_shl (i, other.safe_to_int()); return *this; } var& var::operator ++ (void) { switch (type) { case NULL_TYPE: type = INTEGER_TYPE; i = 1; return *this; case BOOLEAN_TYPE: php_warning ("Can't apply operator ++ to boolean"); return *this; case INTEGER_TYPE: ++i; return *this; case FLOAT_TYPE: f += 1; return *this; case STRING_TYPE: *this = STRING(s)->to_numeric(); return ++(*this); case ARRAY_TYPE: php_warning ("Can't apply operator ++ to array"); return *this; case OBJECT_TYPE: php_warning ("Can't apply operator ++ to object"); return *this; default: php_assert (0); exit (1); } } const var var::operator ++ (int) { switch (type) { case NULL_TYPE: type = INTEGER_TYPE; i = 1; return var(); case BOOLEAN_TYPE: php_warning ("Can't apply operator ++ to boolean"); return b; case INTEGER_TYPE: { var res (i); ++i; return res; } case FLOAT_TYPE: { var res (f); f += 1; return res; } case STRING_TYPE: { var res (*STRING(s)); *this = STRING(s)->to_numeric(); (*this)++; return res; } case ARRAY_TYPE: php_warning ("Can't apply operator ++ to array"); return *ARRAY(a); case OBJECT_TYPE: php_warning ("Can't apply operator ++ to object"); return *this; default: php_assert (0); exit (1); } } var& var::operator -- (void) { if (likely (type == INTEGER_TYPE)) { --i; return *this; } switch (type) { case NULL_TYPE: php_warning ("Can't apply operator -- to null"); return *this; case BOOLEAN_TYPE: php_warning ("Can't apply operator -- to boolean"); return *this; case INTEGER_TYPE: --i; return *this; case FLOAT_TYPE: f -= 1; return *this; case STRING_TYPE: *this = STRING(s)->to_numeric(); return --(*this); case ARRAY_TYPE: php_warning ("Can't apply operator -- to array"); return *this; case OBJECT_TYPE: php_warning ("Can't apply operator -- to object"); return *this; default: php_assert (0); exit (1); } } const var var::operator -- (int) { if (likely (type == INTEGER_TYPE)) { var res (i); --i; return res; } switch (type) { case NULL_TYPE: php_warning ("Can't apply operator -- to null"); return var(); case BOOLEAN_TYPE: php_warning ("Can't apply operator -- to boolean"); return b; case INTEGER_TYPE: { var res (i); --i; return res; } case FLOAT_TYPE: { var res (f); f -= 1; return res; } case STRING_TYPE: { var res (*STRING(s)); *this = STRING(s)->to_numeric(); (*this)--; return res; } case ARRAY_TYPE: php_warning ("Can't apply operator -- to array"); return *ARRAY(a); case OBJECT_TYPE: php_warning ("Can't apply operator -- to object"); return *this; default: php_assert (0); exit (1); } } var& var::safe_incr_pre (void) { switch (type) { case NULL_TYPE: type = INTEGER_TYPE; i = 1; return *this; case BOOLEAN_TYPE: php_warning ("Can't apply operator ++ to boolean"); return *this; case INTEGER_TYPE: ::safe_incr_pre (i); return *this; case FLOAT_TYPE: f += 1; return *this; case STRING_TYPE: *this = STRING(s)->to_numeric(); return safe_incr_pre(); case ARRAY_TYPE: php_warning ("Can't apply operator ++ to array"); return *this; case OBJECT_TYPE: php_warning ("Can't apply operator ++ to object"); return *this; default: php_assert (0); exit (1); } } const var var::safe_incr_post (void) { switch (type) { case NULL_TYPE: type = INTEGER_TYPE; i = 1; return var(); case BOOLEAN_TYPE: php_warning ("Can't apply operator ++ to boolean"); return b; case INTEGER_TYPE: { var res (i); ::safe_incr_post (i); return res; } case FLOAT_TYPE: { var res (f); f += 1; return res; } case STRING_TYPE: { var res (*STRING(s)); *this = STRING(s)->to_numeric(); safe_incr_post(); return res; } case ARRAY_TYPE: php_warning ("Can't apply operator ++ to array"); return *ARRAY(a); case OBJECT_TYPE: php_warning ("Can't apply operator ++ to object"); return *this; default: php_assert (0); exit (1); } } var& var::safe_decr_pre (void) { switch (type) { case NULL_TYPE: php_warning ("Can't apply operator -- to null"); return *this; case BOOLEAN_TYPE: php_warning ("Can't apply operator -- to boolean"); return *this; case INTEGER_TYPE: ::safe_decr_pre (i); return *this; case FLOAT_TYPE: f -= 1; return *this; case STRING_TYPE: *this = STRING(s)->to_numeric(); return safe_decr_pre(); case ARRAY_TYPE: php_warning ("Can't apply operator -- to array"); return *this; case OBJECT_TYPE: php_warning ("Can't apply operator -- to object"); return *this; default: php_assert (0); exit (1); } } const var var::safe_decr_post (void) { switch (type) { case NULL_TYPE: php_warning ("Can't apply operator -- to null"); return var(); case BOOLEAN_TYPE: php_warning ("Can't apply operator -- to boolean"); return b; case INTEGER_TYPE: { var res (i); ::safe_decr_post (i); return res; } case FLOAT_TYPE: { var res (f); f -= 1; return res; } case STRING_TYPE: { var res (*STRING(s)); *this = STRING(s)->to_numeric(); safe_decr_post(); return res; } case ARRAY_TYPE: php_warning ("Can't apply operator -- to array"); return *ARRAY(a); case OBJECT_TYPE: php_warning ("Can't apply operator -- to object"); return *this; default: php_assert (0); exit (1); } } bool var::operator ! (void) const { return !to_bool(); } var& var::append (const string &v) { if (unlikely (type != STRING_TYPE)) { convert_to_string(); } STRING(s)->append (v); return *this; } void var::destroy (void) { switch (type) { case NULL_TYPE: case BOOLEAN_TYPE: case INTEGER_TYPE: case FLOAT_TYPE: break; case STRING_TYPE: STRING(s)->~string(); break; case ARRAY_TYPE: ARRAY(a)->~array <var>(); break; case OBJECT_TYPE: OBJECT(o)->~object(); break; default: php_assert (0); exit (1); } } var::~var (void) { destroy(); type = NULL_TYPE; } const var var::to_numeric (void) const { switch (type) { case NULL_TYPE: return 0; case BOOLEAN_TYPE: return (b ? 1 : 0); case INTEGER_TYPE: return i; case FLOAT_TYPE: return f; case STRING_TYPE: return STRING(s)->to_numeric(); case ARRAY_TYPE: php_warning ("Wrong convertion from array to number"); return ARRAY(a)->to_int(); case OBJECT_TYPE: php_warning ("Wrong convertion from object to number"); return 1; default: php_assert (0); exit (1); } } bool var::to_bool (void) const { switch (type) { case NULL_TYPE: return false; case BOOLEAN_TYPE: return b; case INTEGER_TYPE: return (bool)i; case FLOAT_TYPE: return (bool)f; case STRING_TYPE: return STRING(s)->to_bool(); case ARRAY_TYPE: return !ARRAY(a)->empty(); case OBJECT_TYPE: return true; default: php_assert (0); exit (1); } } int var::to_int (void) const { switch (type) { case NULL_TYPE: return 0; case BOOLEAN_TYPE: return (int)b; case INTEGER_TYPE: return i; case FLOAT_TYPE: return (int)f; case STRING_TYPE: return STRING(s)->to_int(); case ARRAY_TYPE: php_warning ("Wrong convertion from array to int"); return ARRAY(a)->to_int(); case OBJECT_TYPE: php_warning ("Wrong convertion from object to int"); return 1; default: php_assert (0); exit (1); } } double var::to_float (void) const { switch (type) { case NULL_TYPE: return 0.0; case BOOLEAN_TYPE: return (b ? 1.0 : 0.0); case INTEGER_TYPE: return (double)i; case FLOAT_TYPE: return f; case STRING_TYPE: return STRING(s)->to_float(); case ARRAY_TYPE: php_warning ("Wrong convertion from array to float"); return ARRAY(a)->to_float(); case OBJECT_TYPE: php_warning ("Wrong convertion from object to float"); return 1.0; default: php_assert (0); exit (1); } } const string var::to_string (void) const { switch (type) { case NULL_TYPE: return string(); case BOOLEAN_TYPE: return (b ? string ("1", 1) : string()); case INTEGER_TYPE: return string (i); case FLOAT_TYPE: return string (f); case STRING_TYPE: return *STRING(s); case ARRAY_TYPE: php_warning ("Convertion from array to string"); return string ("Array", 5); case OBJECT_TYPE: return OBJECT(o)->to_string(); default: php_assert (0); exit (1); } } const array <var> var::to_array (void) const { switch (type) { case NULL_TYPE: return array <var>(); case BOOLEAN_TYPE: case INTEGER_TYPE: case FLOAT_TYPE: case STRING_TYPE: { array <var> res (array_size (1, 0, true)); res.push_back (*this); return res; } case ARRAY_TYPE: return *ARRAY(a); case OBJECT_TYPE: return OBJECT(o)->to_array(); default: php_assert (0); exit (1); } } const object var::to_object (void) const { switch (type) { case NULL_TYPE: return object(); case BOOLEAN_TYPE: case INTEGER_TYPE: case FLOAT_TYPE: case STRING_TYPE: { object res; res.set (string ("scalar", 6), *this); return res; } case ARRAY_TYPE: return ARRAY(a)->to_object(); case OBJECT_TYPE: return *OBJECT(o); default: php_assert (0); exit (1); } } int var::safe_to_int (void) const { switch (type) { case NULL_TYPE: return 0; case BOOLEAN_TYPE: return (int)b; case INTEGER_TYPE: return i; case FLOAT_TYPE: if (fabs (f) > 2147483648) { php_warning ("Wrong convertion from double %.6lf to int", f); } return (int)f; case STRING_TYPE: return STRING(s)->safe_to_int(); case ARRAY_TYPE: php_warning ("Wrong convertion from array to int"); return ARRAY(a)->to_int(); case OBJECT_TYPE: php_warning ("Wrong convertion from object to int"); return 1; default: php_assert (0); exit (1); } } void var::convert_to_numeric (void) { switch (type) { case NULL_TYPE: type = INTEGER_TYPE; i = 0; return; case BOOLEAN_TYPE: type = INTEGER_TYPE; i = b; return; case INTEGER_TYPE: case FLOAT_TYPE: return; case STRING_TYPE: *this = STRING(s)->to_numeric(); return; case ARRAY_TYPE: { php_warning ("Wrong convertion from array to number"); int int_val = ARRAY(a)->to_int(); ARRAY(a)->~array <var>(); type = INTEGER_TYPE; i = int_val; return; } case OBJECT_TYPE: php_warning ("Wrong convertion from object to number"); OBJECT(o)->~object(); type = INTEGER_TYPE; i = 1; return; default: php_assert (0); exit (1); } } void var::convert_to_bool (void) { switch (type) { case NULL_TYPE: type = BOOLEAN_TYPE; b = 0; return; case BOOLEAN_TYPE: return; case INTEGER_TYPE: type = BOOLEAN_TYPE; b = (bool)i; return; case FLOAT_TYPE: type = BOOLEAN_TYPE; b = (bool)f; return; case STRING_TYPE: { bool bool_val = STRING(s)->to_bool(); STRING(s)->~string(); type = BOOLEAN_TYPE; b = bool_val; return; } case ARRAY_TYPE: { bool bool_val = ARRAY(a)->to_bool(); ARRAY(a)->~array <var>(); type = BOOLEAN_TYPE; b = bool_val; return; } case OBJECT_TYPE: OBJECT(o)->~object(); type = BOOLEAN_TYPE; b = true; return; default: php_assert (0); exit (1); } } void var::convert_to_int (void) { switch (type) { case NULL_TYPE: type = INTEGER_TYPE; i = 0; return; case BOOLEAN_TYPE: type = INTEGER_TYPE; i = b; return; case INTEGER_TYPE: return; case FLOAT_TYPE: type = INTEGER_TYPE; i = (int)f; return; case STRING_TYPE: { int int_val = STRING(s)->to_int(); STRING(s)->~string(); type = INTEGER_TYPE; i = int_val; return; } case ARRAY_TYPE: { php_warning ("Wrong convertion from array to int"); int int_val = ARRAY(a)->to_int(); ARRAY(a)->~array <var>(); type = INTEGER_TYPE; i = int_val; return; } case OBJECT_TYPE: php_warning ("Wrong convertion from object to int"); OBJECT(o)->~object(); type = INTEGER_TYPE; i = 1; return; default: php_assert (0); exit (1); } } void var::convert_to_float (void) { switch (type) { case NULL_TYPE: type = FLOAT_TYPE; f = 0.0; return; case BOOLEAN_TYPE: type = FLOAT_TYPE; f = b; return; case INTEGER_TYPE: type = FLOAT_TYPE; f = (double)i; return; case FLOAT_TYPE: return; case STRING_TYPE: { double float_val = STRING(s)->to_float(); STRING(s)->~string(); type = FLOAT_TYPE; f = float_val; return; } case ARRAY_TYPE: { php_warning ("Wrong convertion from array to float"); double float_val = ARRAY(a)->to_float(); ARRAY(a)->~array <var>(); type = FLOAT_TYPE; f = float_val; return; } case OBJECT_TYPE: php_warning ("Wrong convertion from object to float"); OBJECT(o)->~object(); type = FLOAT_TYPE; f = 1.0; return; default: php_assert (0); exit (1); } } void var::convert_to_string (void) { switch (type) { case NULL_TYPE: type = STRING_TYPE; new (&s) string(); return; case BOOLEAN_TYPE: type = STRING_TYPE; if (b) { new (&s) string ("1", 1); } else { new (&s) string(); } return; case INTEGER_TYPE: type = STRING_TYPE; new (&s) string (i); return; case FLOAT_TYPE: type = STRING_TYPE; new (&s) string (f); return; case STRING_TYPE: return; case ARRAY_TYPE: php_warning ("Converting from array to string"); ARRAY(a)->~array <var>(); type = STRING_TYPE; new (&s) string ("Array", 5); return; case OBJECT_TYPE: { string res = OBJECT(o)->to_string(); OBJECT(o)->~object(); type = STRING_TYPE; new (&s) string (res); return; } default: php_assert (0); exit (1); } } void var::safe_convert_to_int (void) { switch (type) { case NULL_TYPE: type = INTEGER_TYPE; i = 0; return; case BOOLEAN_TYPE: type = INTEGER_TYPE; i = (int)b; return; case INTEGER_TYPE: return; case FLOAT_TYPE: type = INTEGER_TYPE; if (fabs (f) > 2147483648) { php_warning ("Wrong convertion from double %.6lf to int", f); } i = (int)f; return; case STRING_TYPE: { int int_val = STRING(s)->safe_to_int(); STRING(s)->~string(); type = INTEGER_TYPE; i = int_val; return; } case ARRAY_TYPE: { php_warning ("Wrong convertion from array to int"); int int_val = ARRAY(a)->to_int(); ARRAY(a)->~array <var>(); type = INTEGER_TYPE; i = int_val; return; } case OBJECT_TYPE: php_warning ("Wrong convertion from object to int"); OBJECT(o)->~object(); type = INTEGER_TYPE; i = 1; return; default: php_assert (0); exit (1); } } const bool& var::as_bool (const char *function, int parameter_num) const { switch (type) { case NULL_TYPE: case INTEGER_TYPE: case FLOAT_TYPE: case STRING_TYPE: case ARRAY_TYPE: case OBJECT_TYPE: php_warning ("%s() expects parameter %d to be boolean, %s is given", function, parameter_num, get_type_c_str()); empty_bool = false; return empty_bool; case BOOLEAN_TYPE: return b; default: php_assert (0); exit (1); } } const int& var::as_int (const char *function, int parameter_num) const { switch (type) { case NULL_TYPE: case BOOLEAN_TYPE: case FLOAT_TYPE: case STRING_TYPE: case ARRAY_TYPE: case OBJECT_TYPE: php_warning ("%s() expects parameter %d to be int, %s is given", function, parameter_num, get_type_c_str()); empty_int = 0; return empty_int; case INTEGER_TYPE: return i; default: php_assert (0); exit (1); } } const double& var::as_float (const char *function, int parameter_num) const { switch (type) { case NULL_TYPE: case BOOLEAN_TYPE: case INTEGER_TYPE: case STRING_TYPE: case ARRAY_TYPE: case OBJECT_TYPE: php_warning ("%s() expects parameter %d to be float, %s is given", function, parameter_num, get_type_c_str()); empty_float = 0; return empty_float; case FLOAT_TYPE: return f; default: php_assert (0); exit (1); } } const string& var::as_string (const char *function, int parameter_num) const { switch (type) { case NULL_TYPE: case BOOLEAN_TYPE: case INTEGER_TYPE: case FLOAT_TYPE: case ARRAY_TYPE: case OBJECT_TYPE: php_warning ("%s() expects parameter %d to be string, %s is given", function, parameter_num, get_type_c_str()); empty_string = string(); return empty_string; case STRING_TYPE: return *STRING(s); default: php_assert (0); exit (1); } } const array <var>& var::as_array (const char *function, int parameter_num) const { switch (type) { case NULL_TYPE: case BOOLEAN_TYPE: case INTEGER_TYPE: case FLOAT_TYPE: case STRING_TYPE: case OBJECT_TYPE: php_warning ("%s() expects parameter %d to be array, %s is given", function, parameter_num, get_type_c_str()); *empty_array_var = array <var>(); return *empty_array_var; case ARRAY_TYPE: return *ARRAY(a); default: php_assert (0); exit (1); } } bool& var::as_bool (const char *function, int parameter_num) { switch (type) { case INTEGER_TYPE: case FLOAT_TYPE: case STRING_TYPE: case ARRAY_TYPE: case OBJECT_TYPE: php_warning ("%s() expects parameter %d to be boolean, %s is given", function, parameter_num, get_type_c_str()); empty_bool = false; return empty_bool; case NULL_TYPE: convert_to_bool(); case BOOLEAN_TYPE: return b; default: php_assert (0); exit (1); } } int& var::as_int (const char *function, int parameter_num) { switch (type) { case ARRAY_TYPE: case OBJECT_TYPE: php_warning ("%s() expects parameter %d to be int, %s is given", function, parameter_num, get_type_c_str()); empty_int = 0; return empty_int; case NULL_TYPE: case BOOLEAN_TYPE: case FLOAT_TYPE: case STRING_TYPE: convert_to_int(); case INTEGER_TYPE: return i; default: php_assert (0); exit (1); } } double& var::as_float (const char *function, int parameter_num) { switch (type) { case NULL_TYPE: case BOOLEAN_TYPE: case INTEGER_TYPE: case STRING_TYPE: convert_to_float(); case FLOAT_TYPE: return f; case ARRAY_TYPE: case OBJECT_TYPE: php_warning ("%s() expects parameter %d to be float, %s is given", function, parameter_num, get_type_c_str()); empty_float = 0; return empty_float; default: php_assert (0); exit (1); } } string& var::as_string (const char *function, int parameter_num) { switch (type) { case NULL_TYPE: case BOOLEAN_TYPE: case INTEGER_TYPE: case FLOAT_TYPE: convert_to_string(); case STRING_TYPE: return *STRING(s); case ARRAY_TYPE: case OBJECT_TYPE: php_warning ("%s() expects parameter %d to be string, %s is given", function, parameter_num, get_type_c_str()); empty_string = string(); return empty_string; default: php_assert (0); exit (1); } } array <var>& var::as_array (const char *function, int parameter_num) { switch (type) { case NULL_TYPE: case BOOLEAN_TYPE: case INTEGER_TYPE: case FLOAT_TYPE: case STRING_TYPE: case OBJECT_TYPE: php_warning ("%s() expects parameter %d to be array, %s is given", function, parameter_num, get_type_c_str()); *empty_array_var = array <var>(); return *empty_array_var; case ARRAY_TYPE: return *ARRAY(a); default: php_assert (0); exit (1); } } bool var::is_numeric (void) const { switch (type) { case NULL_TYPE: case BOOLEAN_TYPE: return false; case INTEGER_TYPE: case FLOAT_TYPE: return true; case STRING_TYPE: return STRING(s)->is_numeric(); case ARRAY_TYPE: case OBJECT_TYPE: return false; default: php_assert (0); exit (1); } } bool var::is_scalar (void) const { return type != NULL_TYPE && type != ARRAY_TYPE && type != OBJECT_TYPE; } bool var::is_null (void) const { return type == NULL_TYPE; } bool var::is_bool (void) const { return type == BOOLEAN_TYPE; } bool var::is_int (void) const { return type == INTEGER_TYPE; } bool var::is_float (void) const { return type == FLOAT_TYPE; } bool var::is_string (void) const { return type == STRING_TYPE; } bool var::is_array (void) const { return type == ARRAY_TYPE; } bool var::is_object (void) const { return type == OBJECT_TYPE; } inline const char *var::get_type_c_str (void) const { switch (type) { case NULL_TYPE: return "NULL"; case BOOLEAN_TYPE: return "boolean"; case INTEGER_TYPE: return "integer"; case FLOAT_TYPE: return "double"; case STRING_TYPE: return "string"; case ARRAY_TYPE: return "array"; case OBJECT_TYPE: return "object"; default: php_assert (0); exit (1); } } inline const string var::get_type (void) const { const char *result = get_type_c_str(); return string (result, (dl::size_type)strlen (result)); } bool var::empty (void) const { return !to_bool(); } int var::count (void) const { switch (type) { case NULL_TYPE: return 0; case BOOLEAN_TYPE: case INTEGER_TYPE: case FLOAT_TYPE: case STRING_TYPE: return 1; case ARRAY_TYPE: return ARRAY(a)->count(); case OBJECT_TYPE: return 1; default: php_assert (0); exit (1); } } void var::swap (var &other) { ::swap (type, other.type); ::swap (f, other.f); } var& var::operator[] (int int_key) { if (unlikely (type != ARRAY_TYPE)) { if (type == STRING_TYPE) { php_warning ("Lvalue string offset doesn't supported"); empty_var = var(); return empty_var; } if (type == NULL_TYPE || (type == BOOLEAN_TYPE && !b)) { type = ARRAY_TYPE; new (&a) array <var>(); } else { php_warning ("Cannot use a value \"%s\" of type %s as an array, index = %d", to_string().c_str(), get_type_c_str(), int_key); empty_var = var(); return empty_var; } } return (*ARRAY(a))[int_key]; } var& var::operator[] (const string &string_key) { if (unlikely (type != ARRAY_TYPE)) { if (type == STRING_TYPE) { php_warning ("Lvalue string offset doesn't supported"); empty_var = var(); return empty_var; } if (type == NULL_TYPE || (type == BOOLEAN_TYPE && !b)) { type = ARRAY_TYPE; new (&a) array <var>(); } else { php_warning ("Cannot use a value \"%s\" of type %s as an array, index = %s", to_string().c_str(), get_type_c_str(), string_key.c_str()); empty_var = var(); return empty_var; } } return (*ARRAY(a))[string_key]; } var& var::operator[] (const var &v) { switch (v.type) { case NULL_TYPE: return (*this)[string()]; case BOOLEAN_TYPE: return (*this)[v.b]; case INTEGER_TYPE: return (*this)[v.i]; case FLOAT_TYPE: return (*this)[(int)v.f]; case STRING_TYPE: return (*this)[*STRING(v.s)]; case ARRAY_TYPE: php_warning ("Illegal offset type %s", v.get_type_c_str()); return (*this)[ARRAY(v.a)->to_int()]; case OBJECT_TYPE: php_warning ("Illegal offset type %s", v.get_type_c_str()); return (*this)[1]; default: php_assert (0); exit (1); } } var& var::operator[] (const array <var>::const_iterator &it) { return (*ARRAY(a))[it]; } var& var::operator[] (const array <var>::iterator &it) { return (*ARRAY(a))[it]; } void var::set_value (int int_key, const var &v) { if (unlikely (type != ARRAY_TYPE)) { if (type == STRING_TYPE) { char c = (v.to_string())[0]; if (int_key >= 0) { int l = STRING(s)->size(); if (int_key >= l) { STRING(s)->append (int_key + 1 - l, ' '); } else { STRING(s)->make_not_shared(); } (*STRING(s))[int_key] = c; } else { php_warning ("Illegal string offset %d", int_key); } return; } if (type == NULL_TYPE || (type == BOOLEAN_TYPE && !b)) { type = ARRAY_TYPE; new (&a) array <var>(); } else { php_warning ("Cannot use a value \"%s\" of type %s as an array, index = %d", to_string().c_str(), get_type_c_str(), int_key); return; } } return ARRAY(a)->set_value (int_key, v); } void var::set_value (const string &string_key, const var &v) { if (unlikely (type != ARRAY_TYPE)) { if (type == STRING_TYPE) { int int_val; if (!string_key.try_to_int (&int_val)) { php_warning ("Illegal string offset \"%s\"", string_key.c_str()); int_val = string_key.to_int(); } if (int_val < 0) { return; } char c = (v.to_string())[0]; int l = STRING(s)->size(); if (int_val >= l) { STRING(s)->append (int_val + 1 - l, ' '); } else { STRING(s)->make_not_shared(); } (*STRING(s))[int_val] = c; return; } if (type == NULL_TYPE || (type == BOOLEAN_TYPE && !b)) { type = ARRAY_TYPE; new (&a) array <var>(); } else { php_warning ("Cannot use a value \"%s\" of type %s as an array, index = %s", to_string().c_str(), get_type_c_str(), string_key.c_str()); return; } } return ARRAY(a)->set_value (string_key, v); } void var::set_value (const var &v, const var &value) { switch (v.type) { case NULL_TYPE: return set_value (string(), value); case BOOLEAN_TYPE: return set_value (v.b, value); case INTEGER_TYPE: return set_value (v.i, value); case FLOAT_TYPE: return set_value ((int)v.f, value); case STRING_TYPE: return set_value (*STRING(v.s), value); case ARRAY_TYPE: php_warning ("Illegal offset type array"); return; case OBJECT_TYPE: php_warning ("Illegal offset type object"); return; default: php_assert (0); exit (1); } } void var::set_value (const array <var>::const_iterator &it) { return ARRAY(a)->set_value (it); } void var::set_value (const array <var>::iterator &it) { return ARRAY(a)->set_value (it); } const var var::get_value (int int_key) const { if (unlikely (type != ARRAY_TYPE)) { if (type == STRING_TYPE) { if ((dl::size_type)int_key >= STRING(s)->size()) { return string(); } return string (1, (*STRING(s))[int_key]); } if (type != NULL_TYPE && (type != BOOLEAN_TYPE || b)) { php_warning ("Cannot use a value \"%s\" of type %s as an array, index = %d", to_string().c_str(), get_type_c_str(), int_key); } return var(); } return ARRAY(a)->get_value (int_key); } const var var::get_value (const string &string_key) const { if (unlikely (type != ARRAY_TYPE)) { if (type == STRING_TYPE) { int int_val; if (!string_key.try_to_int (&int_val)) { php_warning ("Illegal string offset \"%s\"", string_key.c_str()); int_val = string_key.to_int(); } if ((dl::size_type)int_val >= STRING(s)->size()) { return string(); } return string (1, (*STRING(s))[int_val]); } if (type != NULL_TYPE && (type != BOOLEAN_TYPE || b)) { php_warning ("Cannot use a value \"%s\" of type %s as an array, index = %s", to_string().c_str(), get_type_c_str(), string_key.c_str()); } return var(); } return ARRAY(a)->get_value (string_key); } const var var::get_value (const var &v) const { switch (v.type) { case NULL_TYPE: return get_value (string()); case BOOLEAN_TYPE: return get_value (v.b); case INTEGER_TYPE: return get_value (v.i); case FLOAT_TYPE: return get_value ((int)v.f); case STRING_TYPE: return get_value (*STRING(v.s)); case ARRAY_TYPE: php_warning ("Illegal offset type %s", v.get_type_c_str()); return var(); case OBJECT_TYPE: php_warning ("Illegal offset type %s", v.get_type_c_str()); return var(); default: php_assert (0); exit (1); } } const var var::get_value (const array <var>::const_iterator &it) const { return ARRAY(a)->get_value (it); } const var var::get_value (const array <var>::iterator &it) const { return ARRAY(a)->get_value (it); } void var::push_back (const var &v) { if (unlikely (type != ARRAY_TYPE)) { if (type == NULL_TYPE || (type == BOOLEAN_TYPE && !b)) { type = ARRAY_TYPE; new (&a) array <var>(); } else { php_warning ("[] operator not supported for type %s", get_type_c_str()); return; } } return ARRAY(a)->push_back (v); } const var var::push_back_return (const var &v) { if (unlikely (type != ARRAY_TYPE)) { if (type == NULL_TYPE || (type == BOOLEAN_TYPE && !b)) { type = ARRAY_TYPE; new (&a) array <var>(); } else { php_warning ("[] operator not supported for type %s", get_type_c_str()); empty_var = var(); return empty_var; } } return ARRAY(a)->push_back_return (v); } bool var::isset (int int_key) const { if (unlikely (type != ARRAY_TYPE)) { if (type == STRING_TYPE) { return (dl::size_type)int_key < STRING(s)->size(); } if (type != NULL_TYPE && (type != BOOLEAN_TYPE || b)) { php_warning ("Cannot use variable of type %s as array in isset", get_type_c_str()); } return false; } return ARRAY(a)->isset (int_key); } bool var::isset (const string &string_key) const { if (unlikely (type != ARRAY_TYPE)) { if (type == STRING_TYPE) { int int_val; if (!string_key.try_to_int (&int_val)) { php_warning ("Illegal string offset \"%s\"", string_key.c_str()); int_val = string_key.to_int(); } return (dl::size_type)int_val < STRING(s)->size(); } if (type != NULL_TYPE && (type != BOOLEAN_TYPE || b)) { php_warning ("Cannot use variable of type %s as array in isset", get_type_c_str()); } return false; } return ARRAY(a)->isset (string_key); } bool var::isset (const var &v) const { if (unlikely (type != ARRAY_TYPE)) { if (type == STRING_TYPE) { return (dl::size_type)(v.to_int()) < STRING(s)->size(); } if (type != NULL_TYPE && (type != BOOLEAN_TYPE || b)) { php_warning ("Cannot use variable of type %s as array in isset", get_type_c_str()); } return false; } switch (v.type) { case NULL_TYPE: return ARRAY(a)->isset (string()); case BOOLEAN_TYPE: return ARRAY(a)->isset (v.b); case INTEGER_TYPE: return ARRAY(a)->isset (v.i); case FLOAT_TYPE: return ARRAY(a)->isset ((int)v.f); case STRING_TYPE: return ARRAY(a)->isset (*STRING(v.s)); case ARRAY_TYPE: php_warning ("Illegal offset type array"); return false; case OBJECT_TYPE: php_warning ("Illegal offset type object"); return false; default: php_assert (0); exit (1); } } bool var::isset (const array <var>::const_iterator &it) const { return ARRAY(a)->isset (it); } bool var::isset (const array <var>::iterator &it) const { return ARRAY(a)->isset (it); } void var::unset (int int_key) { if (unlikely (type != ARRAY_TYPE)) { if (type != NULL_TYPE && (type != BOOLEAN_TYPE || b)) { php_warning ("Cannot use variable of type %s as array in unset", get_type_c_str()); } return; } return ARRAY(a)->unset (int_key); } void var::unset (const string &string_key) { if (unlikely (type != ARRAY_TYPE)) { if (type != NULL_TYPE && (type != BOOLEAN_TYPE || b)) { php_warning ("Cannot use variable of type %s as array in unset", get_type_c_str()); } return; } return ARRAY(a)->unset (string_key); } void var::unset (const var &v) { if (unlikely (type != ARRAY_TYPE)) { if (type != NULL_TYPE && (type != BOOLEAN_TYPE || b)) { php_warning ("Cannot use variable of type %s as array in unset", get_type_c_str()); } return; } switch (v.type) { case NULL_TYPE: return ARRAY(a)->unset (string()); case BOOLEAN_TYPE: return ARRAY(a)->unset (v.b); case INTEGER_TYPE: return ARRAY(a)->unset (v.i); case FLOAT_TYPE: return ARRAY(a)->unset ((int)v.f); case STRING_TYPE: return ARRAY(a)->unset (*STRING(v.s)); case ARRAY_TYPE: php_warning ("Illegal offset type array"); return; case OBJECT_TYPE: php_warning ("Illegal offset type object"); return; default: php_assert (0); exit (1); } } void var::unset (const array <var>::const_iterator &it) { return ARRAY(a)->unset (it); } void var::unset (const array <var>::iterator &it) { return ARRAY(a)->unset (it); } array <var>::const_iterator var::begin (void) const { if (likely (type == ARRAY_TYPE)) { return CONST_ARRAY(a)->begin(); } php_warning ("Invalid argument supplied for foreach(), %s \"%s\" is given", get_type_c_str(), to_string().c_str()); return array <var>::const_iterator(); } array <var>::const_iterator var::end (void) const { if (likely (type == ARRAY_TYPE)) { return CONST_ARRAY(a)->end(); } return array <var>::const_iterator(); } array <var>::iterator var::begin (void) { if (likely (type == ARRAY_TYPE)) { return ARRAY(a)->begin(); } php_warning ("Invalid argument supplied for foreach(), %s \"%s\" is given", get_type_c_str(), to_string().c_str()); return array <var>::iterator(); } array <var>::iterator var::end (void) { if (likely (type == ARRAY_TYPE)) { return ARRAY(a)->end(); } return array <var>::iterator(); } int var::get_reference_counter (void) const { switch (type) { case NULL_TYPE: return -1; case BOOLEAN_TYPE: return -2; case INTEGER_TYPE: return -3; case FLOAT_TYPE: return -4; case STRING_TYPE: return STRING(s)->get_reference_counter(); case ARRAY_TYPE: return ARRAY(a)->get_reference_counter(); case OBJECT_TYPE: return OBJECT(o)->get_reference_counter(); default: php_assert (0); exit (1); } } const var operator + (const var &lhs, const var &rhs) { if (likely (lhs.type == var::INTEGER_TYPE && rhs.type == var::INTEGER_TYPE)) { return lhs.i + rhs.i; } if (lhs.type == var::ARRAY_TYPE && rhs.type == var::ARRAY_TYPE) { return *ARRAY(lhs.a) + *ARRAY(rhs.a); } const var arg1 = lhs.to_numeric(); const var arg2 = rhs.to_numeric(); if (arg1.type == var::INTEGER_TYPE) { if (arg2.type == var::INTEGER_TYPE) { return arg1.i + arg2.i; } else { return arg1.i + arg2.f; } } else { if (arg2.type == var::INTEGER_TYPE) { return arg1.f + arg2.i; } else { return arg1.f + arg2.f; } } } const var operator - (const var &lhs, const var &rhs) { if (likely (lhs.type == var::INTEGER_TYPE && rhs.type == var::INTEGER_TYPE)) { return lhs.i - rhs.i; } const var arg1 = lhs.to_numeric(); const var arg2 = rhs.to_numeric(); if (arg1.type == var::INTEGER_TYPE) { if (arg2.type == var::INTEGER_TYPE) { return arg1.i - arg2.i; } else { return arg1.i - arg2.f; } } else { if (arg2.type == var::INTEGER_TYPE) { return arg1.f - arg2.i; } else { return arg1.f - arg2.f; } } } const var operator * (const var &lhs, const var &rhs) { if (likely (lhs.type == var::INTEGER_TYPE && rhs.type == var::INTEGER_TYPE)) { return lhs.i * rhs.i; } const var arg1 = lhs.to_numeric(); const var arg2 = rhs.to_numeric(); if (arg1.type == var::INTEGER_TYPE) { if (arg2.type == var::INTEGER_TYPE) { return arg1.i * arg2.i; } else { return arg1.i * arg2.f; } } else { if (arg2.type == var::INTEGER_TYPE) { return arg1.f * arg2.i; } else { return arg1.f * arg2.f; } } } const var operator / (const var &lhs, const var &rhs) { if (likely (lhs.type == var::INTEGER_TYPE && rhs.type == var::INTEGER_TYPE)) { if (rhs.i == 0) { php_warning ("Integer division by zero"); return false; } if (lhs.i % rhs.i == 0) { return lhs.i / rhs.i; } return (double)lhs.i / rhs.i; } const var arg1 = lhs.to_numeric(); const var arg2 = rhs.to_numeric(); if (arg2.type == var::INTEGER_TYPE) { if (arg2.i == 0) { php_warning ("Integer division by zero"); return false; } if (arg1.type == var::INTEGER_TYPE) { if (arg1.i % arg2.i == 0) { return arg1.i / arg2.i; } return (double)arg1.i / arg2.i; } else { return arg1.f / arg2.i; } } else { if (arg2.f == 0.0) { php_warning ("Float division by zero"); return false; } if (arg1.type == var::INTEGER_TYPE) { return arg1.i / arg2.f; } else { return arg1.f / arg2.f; } } } const var operator % (const var &lhs, const var &rhs) { int div = rhs.to_int(); if (div == 0) { php_warning ("Modulo by zero"); return false; } return lhs.to_int() % div; } const var operator - (const string &lhs) { var arg1 = lhs.to_numeric(); if (arg1.type == var::INTEGER_TYPE) { arg1.i = -arg1.i; } else { arg1.f = -arg1.f; } return arg1; } const var operator + (const string &lhs) { return lhs.to_numeric(); } int operator & (const var &lhs, const var &rhs) { return lhs.to_int() & rhs.to_int(); } int operator | (const var &lhs, const var &rhs) { return lhs.to_int() | rhs.to_int(); } int operator ^ (const var &lhs, const var &rhs) { return lhs.to_int() ^ rhs.to_int(); } int operator << (const var &lhs, const var &rhs) { return lhs.to_int() << rhs.to_int(); } int operator >> (const var &lhs, const var &rhs) { return lhs.to_int() >> rhs.to_int(); } const var safe_add (const var &lhs, const var &rhs) { if (likely (lhs.type == var::INTEGER_TYPE && rhs.type == var::INTEGER_TYPE)) { return safe_add (lhs.i, rhs.i); } if (lhs.type == var::ARRAY_TYPE && rhs.type == var::ARRAY_TYPE) { return *ARRAY(lhs.a) + *ARRAY(rhs.a); } const var arg1 = lhs.to_numeric(); const var arg2 = rhs.to_numeric(); if (arg1.type == var::INTEGER_TYPE) { if (arg2.type == var::INTEGER_TYPE) { return safe_add (arg1.i, arg2.i); } else { return arg1.i + arg2.f; } } else { if (arg2.type == var::INTEGER_TYPE) { return arg1.f + arg2.i; } else { return arg1.f + arg2.f; } } } const var safe_sub (const var &lhs, const var &rhs) { if (likely (lhs.type == var::INTEGER_TYPE && rhs.type == var::INTEGER_TYPE)) { return safe_sub (lhs.i, rhs.i); } const var arg1 = lhs.to_numeric(); const var arg2 = rhs.to_numeric(); if (arg1.type == var::INTEGER_TYPE) { if (arg2.type == var::INTEGER_TYPE) { return safe_sub (arg1.i, arg2.i); } else { return arg1.i - arg2.f; } } else { if (arg2.type == var::INTEGER_TYPE) { return arg1.f - arg2.i; } else { return arg1.f - arg2.f; } } } const var safe_mul (const var &lhs, const var &rhs) { if (likely (lhs.type == var::INTEGER_TYPE && rhs.type == var::INTEGER_TYPE)) { return safe_mul (lhs.i, rhs.i); } const var arg1 = lhs.to_numeric(); const var arg2 = rhs.to_numeric(); if (arg1.type == var::INTEGER_TYPE) { if (arg2.type == var::INTEGER_TYPE) { return safe_mul (arg1.i, arg2.i); } else { return arg1.i * arg2.f; } } else { if (arg2.type == var::INTEGER_TYPE) { return arg1.f * arg2.i; } else { return arg1.f * arg2.f; } } } const var safe_shl (const var &lhs, const var &rhs) { return safe_shl (lhs.safe_to_int(), rhs.safe_to_int()); } bool eq2 (const var &lhs, const var &rhs) { if (unlikely (lhs.type == var::STRING_TYPE)) { if (likely (rhs.type == var::STRING_TYPE)) { return eq2 (*STRING(lhs.s), *STRING(rhs.s)); } else if (unlikely (rhs.type == var::NULL_TYPE)) { return STRING(lhs.s)->size() == 0; } } else if (unlikely (rhs.type == var::STRING_TYPE)) { if (unlikely (lhs.type == var::NULL_TYPE)) { return STRING(rhs.s)->size() == 0; } } if (lhs.type == var::BOOLEAN_TYPE || rhs.type == var::BOOLEAN_TYPE || lhs.type == var::NULL_TYPE || rhs.type == var::NULL_TYPE) { return lhs.to_bool() == rhs.to_bool(); } if (unlikely (lhs.type == var::ARRAY_TYPE || rhs.type == var::ARRAY_TYPE)) { if (likely (lhs.type == var::ARRAY_TYPE && rhs.type == var::ARRAY_TYPE)) { return eq2 (*ARRAY(lhs.a), *ARRAY(rhs.a)); } php_warning ("Unsupported operand types for operator == (%s and %s)", lhs.get_type_c_str(), rhs.get_type_c_str()); return false; } if (unlikely (lhs.type == var::OBJECT_TYPE || rhs.type == var::OBJECT_TYPE)) { if (likely (lhs.type == var::OBJECT_TYPE && rhs.type == var::OBJECT_TYPE)) { return eq2 (*OBJECT(lhs.o), *OBJECT(rhs.o)); } php_warning ("Unsupported operand types for operator == (%s and %s)", lhs.get_type_c_str(), rhs.get_type_c_str()); return false; } return lhs.to_float() == rhs.to_float(); } bool neq2 (const var &lhs, const var &rhs) { return !eq2 (lhs, rhs); } bool operator <= (const var &lhs, const var &rhs) { if (unlikely (lhs.type == var::STRING_TYPE)) { if (likely (rhs.type == var::STRING_TYPE)) { if (STRING(lhs.s)[0][0] <= '9' && STRING(rhs.s)[0][0] <= '9') { int lhs_int_val, rhs_int_val; if (STRING(lhs.s)->try_to_int (&lhs_int_val) && STRING(rhs.s)->try_to_int (&rhs_int_val)) { return lhs_int_val <= rhs_int_val; } double lhs_float_val, rhs_float_val; if (STRING(lhs.s)->try_to_float (&lhs_float_val) && STRING(rhs.s)->try_to_float (&rhs_float_val)) { STRING(lhs.s)->warn_on_float_conversion(); STRING(rhs.s)->warn_on_float_conversion(); if (is_ok_float (lhs_float_val) && is_ok_float (rhs_float_val)) { return lhs_float_val <= rhs_float_val; } } } return STRING(lhs.s)->compare (*STRING(rhs.s)) <= 0; } else if (unlikely (rhs.type == var::NULL_TYPE)) { return STRING(lhs.s)->size() == 0; } } else if (unlikely (rhs.type == var::STRING_TYPE)) { if (unlikely (lhs.type == var::NULL_TYPE)) { return true; } } if (lhs.type == var::BOOLEAN_TYPE || rhs.type == var::BOOLEAN_TYPE || lhs.type == var::NULL_TYPE || rhs.type == var::NULL_TYPE) { return lhs.to_bool() <= rhs.to_bool(); } if (unlikely (lhs.type == var::ARRAY_TYPE || rhs.type == var::ARRAY_TYPE)) { if (likely (lhs.type == var::ARRAY_TYPE && rhs.type == var::ARRAY_TYPE)) { return ARRAY(lhs.a)->count() <= ARRAY(rhs.a)->count(); } php_warning ("Unsupported operand types for operator <= (%s and %s)", lhs.get_type_c_str(), rhs.get_type_c_str()); return rhs.type == var::ARRAY_TYPE; } if (unlikely (lhs.type == var::OBJECT_TYPE || rhs.type == var::OBJECT_TYPE)) { php_warning ("Unsupported operand types for operator <= (%s and %s)", lhs.get_type_c_str(), rhs.get_type_c_str()); return rhs.type == var::OBJECT_TYPE; } return lhs.to_float() <= rhs.to_float(); } bool operator >= (const var &lhs, const var &rhs) { if (unlikely (lhs.type == var::STRING_TYPE)) { if (likely (rhs.type == var::STRING_TYPE)) { if (STRING(lhs.s)[0][0] <= '9' && STRING(rhs.s)[0][0] <= '9') { int lhs_int_val, rhs_int_val; if (STRING(lhs.s)->try_to_int (&lhs_int_val) && STRING(rhs.s)->try_to_int (&rhs_int_val)) { return lhs_int_val >= rhs_int_val; } double lhs_float_val, rhs_float_val; if (STRING(lhs.s)->try_to_float (&lhs_float_val) && STRING(rhs.s)->try_to_float (&rhs_float_val)) { STRING(lhs.s)->warn_on_float_conversion(); STRING(rhs.s)->warn_on_float_conversion(); if (is_ok_float (lhs_float_val) && is_ok_float (rhs_float_val)) { return lhs_float_val >= rhs_float_val; } } } return STRING(lhs.s)->compare (*STRING(rhs.s)) >= 0; } else if (unlikely (rhs.type == var::NULL_TYPE)) { return true; } } else if (unlikely (rhs.type == var::STRING_TYPE)) { if (unlikely (lhs.type == var::NULL_TYPE)) { return STRING(rhs.s)->size() == 0; } } if (lhs.type == var::BOOLEAN_TYPE || rhs.type == var::BOOLEAN_TYPE || lhs.type == var::NULL_TYPE || rhs.type == var::NULL_TYPE) { return lhs.to_bool() >= rhs.to_bool(); } if (unlikely (lhs.type == var::ARRAY_TYPE || rhs.type == var::ARRAY_TYPE)) { if (likely (lhs.type == var::ARRAY_TYPE && rhs.type == var::ARRAY_TYPE)) { return ARRAY(lhs.a)->count() >= ARRAY(rhs.a)->count(); } php_warning ("Unsupported operand types for operator >= (%s and %s)", lhs.get_type_c_str(), rhs.get_type_c_str()); return lhs.type == var::ARRAY_TYPE; } if (unlikely (lhs.type == var::OBJECT_TYPE || rhs.type == var::OBJECT_TYPE)) { php_warning ("Unsupported operand types for operator >= (%s and %s)", lhs.get_type_c_str(), rhs.get_type_c_str()); return lhs.type == var::OBJECT_TYPE; } return lhs.to_float() >= rhs.to_float(); } bool operator < (const var &lhs, const var &rhs) { if (unlikely (lhs.type == var::STRING_TYPE)) { if (likely (rhs.type == var::STRING_TYPE)) { if (STRING(lhs.s)[0][0] <= '9' && STRING(rhs.s)[0][0] <= '9') { int lhs_int_val, rhs_int_val; if (STRING(lhs.s)->try_to_int (&lhs_int_val) && STRING(rhs.s)->try_to_int (&rhs_int_val)) { return lhs_int_val < rhs_int_val; } double lhs_float_val, rhs_float_val; if (STRING(lhs.s)->try_to_float (&lhs_float_val) && STRING(rhs.s)->try_to_float (&rhs_float_val)) { STRING(lhs.s)->warn_on_float_conversion(); STRING(rhs.s)->warn_on_float_conversion(); if (is_ok_float (lhs_float_val) && is_ok_float (rhs_float_val)) { return lhs_float_val < rhs_float_val; } } } return STRING(lhs.s)->compare (*STRING(rhs.s)) < 0; } else if (unlikely (rhs.type == var::NULL_TYPE)) { return false; } } else if (unlikely (rhs.type == var::STRING_TYPE)) { if (unlikely (lhs.type == var::NULL_TYPE)) { return STRING(rhs.s)->size() != 0; } } if (lhs.type == var::BOOLEAN_TYPE || rhs.type == var::BOOLEAN_TYPE || lhs.type == var::NULL_TYPE || rhs.type == var::NULL_TYPE) { return lhs.to_bool() < rhs.to_bool(); } if (unlikely (lhs.type == var::ARRAY_TYPE || rhs.type == var::ARRAY_TYPE)) { if (likely (lhs.type == var::ARRAY_TYPE && rhs.type == var::ARRAY_TYPE)) { return ARRAY(lhs.a)->count() < ARRAY(rhs.a)->count(); } php_warning ("Unsupported operand types for operator < (%s and %s)", lhs.get_type_c_str(), rhs.get_type_c_str()); return lhs.type != var::ARRAY_TYPE; } if (unlikely (lhs.type == var::OBJECT_TYPE || rhs.type == var::OBJECT_TYPE)) { php_warning ("Unsupported operand types for operator < (%s and %s)", lhs.get_type_c_str(), rhs.get_type_c_str()); return lhs.type != var::OBJECT_TYPE; } return lhs.to_float() < rhs.to_float(); } bool operator > (const var &lhs, const var &rhs) { if (unlikely (lhs.type == var::STRING_TYPE)) { if (likely (rhs.type == var::STRING_TYPE)) { if (STRING(lhs.s)[0][0] <= '9' && STRING(rhs.s)[0][0] <= '9') { int lhs_int_val, rhs_int_val; if (STRING(lhs.s)->try_to_int (&lhs_int_val) && STRING(rhs.s)->try_to_int (&rhs_int_val)) { return lhs_int_val > rhs_int_val; } double lhs_float_val, rhs_float_val; if (STRING(lhs.s)->try_to_float (&lhs_float_val) && STRING(rhs.s)->try_to_float (&rhs_float_val)) { STRING(lhs.s)->warn_on_float_conversion(); STRING(rhs.s)->warn_on_float_conversion(); if (is_ok_float (lhs_float_val) && is_ok_float (rhs_float_val)) { return lhs_float_val > rhs_float_val; } } } return STRING(lhs.s)->compare (*STRING(rhs.s)) > 0; } else if (unlikely (rhs.type == var::NULL_TYPE)) { return STRING(lhs.s)->size() != 0; } } else if (unlikely (rhs.type == var::STRING_TYPE)) { if (unlikely (lhs.type == var::NULL_TYPE)) { return false; } } if (lhs.type == var::BOOLEAN_TYPE || rhs.type == var::BOOLEAN_TYPE || lhs.type == var::NULL_TYPE || rhs.type == var::NULL_TYPE) { return lhs.to_bool() > rhs.to_bool(); } if (unlikely (lhs.type == var::ARRAY_TYPE || rhs.type == var::ARRAY_TYPE)) { if (likely (lhs.type == var::ARRAY_TYPE && rhs.type == var::ARRAY_TYPE)) { return ARRAY(lhs.a)->count() > ARRAY(rhs.a)->count(); } php_warning ("Unsupported operand types for operator > (%s and %s)", lhs.get_type_c_str(), rhs.get_type_c_str()); return rhs.type != var::ARRAY_TYPE; } if (unlikely (lhs.type == var::OBJECT_TYPE || rhs.type == var::OBJECT_TYPE)) { php_warning ("Unsupported operand types for operator > (%s and %s)", lhs.get_type_c_str(), rhs.get_type_c_str()); return rhs.type != var::OBJECT_TYPE; } return lhs.to_float() > rhs.to_float(); } bool equals (const var &lhs, const var &rhs) { if (lhs.type != rhs.type) { return false; } switch (lhs.type) { case var::NULL_TYPE: return true; case var::BOOLEAN_TYPE: return lhs.b == rhs.b; case var::INTEGER_TYPE: return lhs.i == rhs.i; case var::FLOAT_TYPE: return lhs.f == rhs.f; case var::STRING_TYPE: return *STRING(lhs.s) == *STRING(rhs.s); case var::ARRAY_TYPE: return equals (*ARRAY(lhs.a), *ARRAY(rhs.a)); case var::OBJECT_TYPE: return equals (*OBJECT(lhs.o), *OBJECT(rhs.o)); default: php_assert (0); exit (1); } } bool not_equals (const var &lhs, const var &rhs) { return !equals (lhs, rhs); } void swap (var &lhs, var &rhs) { lhs.swap (rhs); } template <class T, class T1> array <T>& safe_set_add (array <T> &lhs, const array <T1> &rhs) { return lhs += rhs; } template <class T> array <T> safe_add (const array <T> &lhs, const array <T> &rhs) { return lhs + rhs; } var& safe_set_add (var &lhs, const var &rhs) { return lhs.safe_set_add (rhs); } var& safe_set_sub (var &lhs, const var &rhs) { return lhs.safe_set_sub (rhs); } var& safe_set_mul (var &lhs, const var &rhs) { return lhs.safe_set_mul (rhs); } var& safe_set_shl (var &lhs, const var &rhs) { return lhs.safe_set_shl (rhs); } int& safe_set_add (int &lhs, int rhs) { return lhs = safe_add (lhs, rhs); } int& safe_set_sub (int &lhs, int rhs) { return lhs = safe_sub (lhs, rhs); } int& safe_set_mul (int &lhs, int rhs) { return lhs = safe_mul (lhs, rhs); } int& safe_set_shl (int &lhs, int rhs) { return lhs = safe_shl (lhs, rhs); } int safe_add (int lhs, int rhs) { long long res = (long long)lhs + rhs; int resi = (int)res; if (resi != res) { php_warning ("Integer overflow in %d + %d", lhs, rhs); } return resi; } int safe_sub (int lhs, int rhs) { long long res = (long long)lhs - rhs; int resi = (int)res; if (resi != res) { php_warning ("Integer overflow in %d - %d", lhs, rhs); } return resi; } int safe_mul (int lhs, int rhs) { long long res = (long long)lhs * rhs; int resi = (int)res; if (resi != res) { php_warning ("Integer overflow in %d * %d", lhs, rhs); } return resi; } int safe_shl (int lhs, int rhs) { if ((unsigned int)rhs >= 32u) { php_warning ("Wrong right parameter %d in << operator", rhs); rhs = 0; } int res = lhs << rhs; if ((res >> rhs) != lhs) { php_warning ("Integer overflow in %d << %d", lhs, rhs); } return res; } double& safe_set_add (double &lhs, double rhs) { return lhs += rhs; } double& safe_set_sub (double &lhs, double rhs) { return lhs -= rhs; } double& safe_set_mul (double &lhs, double rhs) { return lhs *= rhs; } int safe_add (bool lhs, bool rhs) { return lhs + rhs; } int safe_add (bool lhs, int rhs) { return lhs + rhs; } double safe_add (bool lhs, double rhs) { return lhs + rhs; } int safe_add (int lhs, bool rhs) { return lhs + rhs; } double safe_add (int lhs, double rhs) { return lhs + rhs; } double safe_add (double lhs, bool rhs) { return lhs + rhs; } double safe_add (double lhs, int rhs) { return lhs + rhs; } double safe_add (double lhs, double rhs) { return lhs + rhs; } int safe_sub (bool lhs, bool rhs) { return lhs - rhs; } int safe_sub (bool lhs, int rhs) { return lhs - rhs; } double safe_sub (bool lhs, double rhs) { return lhs - rhs; } int safe_sub (int lhs, bool rhs) { return lhs - rhs; } double safe_sub (int lhs, double rhs) { return lhs - rhs; } double safe_sub (double lhs, bool rhs) { return lhs - rhs; } double safe_sub (double lhs, int rhs) { return lhs - rhs; } double safe_sub (double lhs, double rhs) { return lhs - rhs; } int safe_mul (bool lhs, bool rhs) { return lhs * rhs; } int safe_mul (bool lhs, int rhs) { return lhs * rhs; } double safe_mul (bool lhs, double rhs) { return lhs * rhs; } int safe_mul (int lhs, bool rhs) { return lhs * rhs; } double safe_mul (int lhs, double rhs) { return lhs * rhs; } double safe_mul (double lhs, bool rhs) { return lhs * rhs; } double safe_mul (double lhs, int rhs) { return lhs * rhs; } double safe_mul (double lhs, double rhs) { return lhs * rhs; } int& safe_incr_pre (int &lhs) { if (lhs == INT_MAX) { php_warning ("Integer overflow in ++%d", lhs); } return ++lhs; } int& safe_decr_pre (int &lhs) { if (lhs == INT_MIN) { php_warning ("Integer overflow in --%d", lhs); } return --lhs; } int safe_incr_post (int &lhs) { if (lhs == INT_MAX) { php_warning ("Integer overflow in %d++", lhs); } return lhs++; } int safe_decr_post (int &lhs) { if (lhs == INT_MIN) { php_warning ("Integer overflow in %d--", lhs); } return lhs--; } double& safe_incr_pre (double &lhs) { return ++lhs; } double& safe_decr_pre (double &lhs) { return --lhs; } double safe_incr_post (double &lhs) { return lhs++; } double safe_decr_post (double &lhs) { return lhs--; } var& safe_incr_pre (var &lhs) { return lhs.safe_incr_pre(); } var& safe_decr_pre (var &lhs) { return lhs.safe_decr_pre(); } var safe_incr_post (var &lhs) { return lhs.safe_incr_post(); } var safe_decr_post (var &lhs) { return lhs.safe_decr_post(); } bool eq2 (bool lhs, bool rhs) { return lhs == rhs; } bool eq2 (int lhs, int rhs) { return lhs == rhs; } bool eq2 (double lhs, double rhs) { return lhs == rhs; } bool eq2 (bool lhs, int rhs) { return lhs != !rhs; } bool eq2 (bool lhs, double rhs) { return lhs != (rhs == 0.0); } bool eq2 (int lhs, bool rhs) { return rhs != !lhs; } bool eq2 (double lhs, bool rhs) { return rhs != (lhs == 0.0); } bool eq2 (int lhs, double rhs) { return lhs == rhs; } bool eq2 (double lhs, int rhs) { return lhs == rhs; } bool eq2 (bool lhs, const string &rhs) { return lhs == rhs.to_bool(); } bool eq2 (int lhs, const string &rhs) { return lhs == rhs.to_float(); } bool eq2 (double lhs, const string &rhs) { return lhs == rhs.to_float(); } bool eq2 (const string &lhs, bool rhs) { return rhs == lhs.to_bool(); } bool eq2 (const string &lhs, int rhs) { return rhs == lhs.to_float(); } bool eq2 (const string &lhs, double rhs) { return rhs == lhs.to_float(); } template <class T> bool eq2 (bool lhs, const array <T> &rhs) { return lhs == !rhs.empty(); } template <class T> bool eq2 (int lhs, const array <T> &rhs) { php_warning ("Unsupported operand types for operator == (int and array)"); return false; } template <class T> bool eq2 (double lhs, const array <T> &rhs) { php_warning ("Unsupported operand types for operator == (float and array)"); return false; } template <class T> bool eq2 (const string &lhs, const array <T> &rhs) { php_warning ("Unsupported operand types for operator == (string and array)"); return false; } template <class T> bool eq2 (const array <T> &lhs, bool rhs) { return rhs == !lhs.empty(); } template <class T> bool eq2 (const array <T> &lhs, int rhs) { php_warning ("Unsupported operand types for operator == (array and int)"); return false; } template <class T> bool eq2 (const array <T> &lhs, double rhs) { php_warning ("Unsupported operand types for operator == (array and float)"); return false; } template <class T> bool eq2 (const array <T> &lhs, const string &rhs) { php_warning ("Unsupported operand types for operator == (array and string)"); return false; } template <class T> bool eq2 (bool lhs, const object_ptr <T> &rhs) { return lhs; } template <class T> bool eq2 (int lhs, const object_ptr <T> &rhs) { php_warning ("Unsupported operand types for operator == (int and object)"); return false; } template <class T> bool eq2 (double lhs, const object_ptr <T> &rhs) { php_warning ("Unsupported operand types for operator == (float and object)"); return false; } template <class T> bool eq2 (const string &lhs, const object_ptr <T> &rhs) { php_warning ("Unsupported operand types for operator == (string and object)"); return false; } template <class T, class T1> bool eq2 (const array <T1> &lhs, const object_ptr <T> &rhs) { php_warning ("Unsupported operand types for operator == (array and object)"); return false; } template <class T> bool eq2 (const object_ptr <T> &lhs, bool rhs) { return rhs; } template <class T> bool eq2 (const object_ptr <T> &lhs, int rhs) { php_warning ("Unsupported operand types for operator == (object and int)"); return false; } template <class T> bool eq2 (const object_ptr <T> &lhs, double rhs) { php_warning ("Unsupported operand types for operator == (object and float)"); return false; } template <class T> bool eq2 (const object_ptr <T> &lhs, const string &rhs) { php_warning ("Unsupported operand types for operator == (object and string)"); return false; } template <class T, class T1> bool eq2 (const object_ptr <T> &lhs, const array <T1> &rhs) { php_warning ("Unsupported operand types for operator == (object and array)"); return false; } bool eq2 (bool lhs, const var &rhs) { return lhs == rhs.to_bool(); } bool eq2 (int lhs, const var &rhs) { switch (rhs.type) { case var::NULL_TYPE: return lhs == 0; case var::BOOLEAN_TYPE: return !!lhs == rhs.b; case var::INTEGER_TYPE: return lhs == rhs.i; case var::FLOAT_TYPE: return lhs == rhs.f; case var::STRING_TYPE: return lhs == STRING(rhs.s)->to_float(); case var::ARRAY_TYPE: php_warning ("Unsupported operand types for operator == (int and array)"); return false; case var::OBJECT_TYPE: php_warning ("Unsupported operand types for operator == (int and object)"); return false; default: php_assert (0); exit (1); } } bool eq2 (double lhs, const var &rhs) { switch (rhs.type) { case var::NULL_TYPE: return lhs == 0.0; case var::BOOLEAN_TYPE: return (lhs != 0.0) == rhs.b; case var::INTEGER_TYPE: return lhs == rhs.i; case var::FLOAT_TYPE: return lhs == rhs.f; case var::STRING_TYPE: return lhs == STRING(rhs.s)->to_float(); case var::ARRAY_TYPE: php_warning ("Unsupported operand types for operator == (float and array)"); return false; case var::OBJECT_TYPE: php_warning ("Unsupported operand types for operator == (float and object)"); return false; default: php_assert (0); exit (1); } } bool eq2 (const string &lhs, const var &rhs) { return eq2 (var (lhs), rhs); } template <class T> bool eq2 (const array <T> &lhs, const var &rhs) { if (likely (rhs.is_array())) { return eq2 (lhs, *ARRAY(rhs.a)); } if (rhs.is_bool()) { return lhs.empty() != rhs.b; } if (rhs.is_null()) { return lhs.empty(); } php_warning ("Unsupported operand types for operator == (array and %s)", rhs.get_type_c_str()); return false; } template <class T> bool eq2 (const object_ptr <T> &lhs, const var &rhs) { if (likely (rhs.is_object())) { return eq2 (lhs, *OBJECT(rhs.o)); } if (rhs.is_bool()) { return rhs.b; } if (rhs.is_null()) { return false; } php_warning ("Unsupported operand types for operator == (object and %s)", rhs.get_type_c_str()); return false; } bool eq2 (const var &lhs, bool rhs) { return rhs == lhs.to_bool(); } bool eq2 (const var &lhs, int rhs) { switch (lhs.type) { case var::NULL_TYPE: return rhs == 0; case var::BOOLEAN_TYPE: return !!rhs == lhs.b; case var::INTEGER_TYPE: return rhs == lhs.i; case var::FLOAT_TYPE: return rhs == lhs.f; case var::STRING_TYPE: return rhs == STRING(lhs.s)->to_float(); case var::ARRAY_TYPE: php_warning ("Unsupported operand types for operator == (array and int)"); return false; case var::OBJECT_TYPE: php_warning ("Unsupported operand types for operator == (object and int)"); return false; default: php_assert (0); exit (1); } } bool eq2 (const var &lhs, double rhs) { switch (lhs.type) { case var::NULL_TYPE: return rhs == 0.0; case var::BOOLEAN_TYPE: return (rhs != 0.0) == lhs.b; case var::INTEGER_TYPE: return rhs == lhs.i; case var::FLOAT_TYPE: return rhs == lhs.f; case var::STRING_TYPE: return rhs == STRING(lhs.s)->to_float(); case var::ARRAY_TYPE: php_warning ("Unsupported operand types for operator == (array and float)"); return false; case var::OBJECT_TYPE: php_warning ("Unsupported operand types for operator == (object and float)"); return false; default: php_assert (0); exit (1); } } bool eq2 (const var &lhs, const string &rhs) { return eq2 (var (rhs), lhs); } template <class T> bool eq2 (const var &lhs, const array <T> &rhs) { if (likely (lhs.is_array())) { return eq2 (*ARRAY(lhs.a), rhs); } if (lhs.is_bool()) { return rhs.empty() != lhs.b; } if (lhs.is_null()) { return rhs.empty(); } php_warning ("Unsupported operand types for operator == (%s and array)", lhs.get_type_c_str()); return false; } template <class T> bool eq2 (const var &lhs, const object_ptr <T> &rhs) { if (likely (lhs.is_object())) { return eq2 (*OBJECT(lhs.o), rhs); } if (lhs.is_bool()) { return lhs.b; } if (lhs.is_null()) { return false; } php_warning ("Unsupported operand types for operator == (%s and object)", lhs.get_type_c_str()); return false; } template <class T1, class T2> bool neq2 (const T1 &lhs, const T2 &rhs) { return !eq2 (lhs, rhs); } bool equals (bool lhs, const var &rhs) { return rhs.is_bool() && equals (lhs, rhs.b); } bool equals (int lhs, const var &rhs) { return rhs.is_int() && equals (lhs, rhs.i); } bool equals (double lhs, const var &rhs) { return rhs.is_float() && equals (lhs, rhs.f); } bool equals (const string &lhs, const var &rhs) { return rhs.is_string() && equals (lhs, *STRING(rhs.s)); } template <class T> bool equals (const array <T> &lhs, const var &rhs) { return rhs.is_array() && equals (lhs, *ARRAY(rhs.a)); } template <class T> bool equals (const object_ptr <T> &lhs, const var &rhs) { return rhs.is_object() && equals (lhs, *OBJECT(rhs.o)); } bool equals (const var &lhs, bool rhs) { return lhs.is_bool() && equals (rhs, lhs.b); } bool equals (const var &lhs, int rhs) { return lhs.is_int() && equals (rhs, lhs.i); } bool equals (const var &lhs, double rhs) { return lhs.is_float() && equals (rhs, lhs.f); } bool equals (const var &lhs, const string &rhs) { return lhs.is_string() && equals (rhs, *STRING(lhs.s)); } template <class T> bool equals (const var &lhs, const array <T> &rhs) { return lhs.is_array() && equals (rhs, *ARRAY(lhs.a)); } template <class T> bool equals (const var &lhs, const object_ptr <T> &rhs) { return lhs.is_object() && equals (rhs, *OBJECT(lhs.o)); } template <class T> bool equals (const T &lhs, const T &rhs) { return lhs == rhs; } template <class T1, class T2> bool equals (const T1 &lhs, const T2 &rhs) { return false; } template <class T1, class T2> bool not_equals (const T1 &lhs, const T2 &rhs) { return !equals (lhs, rhs); } template <class T> bool eq2 (const var &v, const OrFalse <T> &value) { return likely (value.bool_value) ? eq2 (value.value, v) : eq2 (false, v); } template <class T> bool eq2 (const OrFalse <T> &value, const var &v) { return likely (value.bool_value) ? eq2 (value.value, v) : eq2 (false, v); } template <class T> bool equals (const OrFalse <T> &value, const var &v) { return likely (value.bool_value) ? equals (value.value, v) : equals (false, v); } template <class T> bool equals (const var &v, const OrFalse <T> &value) { return likely (value.bool_value) ? equals (value.value, v) : equals (false, v); } template <class T> bool not_equals (const OrFalse <T> &value, const var &v) { return likely (value.bool_value) ? not_equals (value.value, v) : not_equals (false, v); } template <class T> bool not_equals (const var &v, const OrFalse <T> &value) { return likely (value.bool_value) ? not_equals (value.value, v) : not_equals (false, v); }
23.255866
142
0.58576
redm-pro
f5cfafb744c7a053234516e2b4e10677edfc6c9f
9,424
cpp
C++
src/models/bwc/stsu_data_istream.cpp
steptosky/3DsMax-X-Obj-Exporter
c70f5a60056ee71aba1569f1189c38b9e01d2f0e
[ "BSD-3-Clause" ]
20
2017-07-07T06:07:30.000Z
2022-03-09T12:00:57.000Z
src/models/bwc/stsu_data_istream.cpp
steptosky/3DsMax-X-Obj-Exporter
c70f5a60056ee71aba1569f1189c38b9e01d2f0e
[ "BSD-3-Clause" ]
28
2017-07-07T06:08:27.000Z
2022-03-09T12:09:23.000Z
src/models/bwc/stsu_data_istream.cpp
steptosky/3DsMax-X-Obj-Exporter
c70f5a60056ee71aba1569f1189c38b9e01d2f0e
[ "BSD-3-Clause" ]
7
2018-01-24T19:43:22.000Z
2020-01-06T00:05:40.000Z
/* ** Copyright(C) 2017, StepToSky ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are met: ** ** 1.Redistributions of source code must retain the above copyright notice, this ** list of conditions and the following disclaimer. ** 2.Redistributions in binary form must reproduce the above copyright notice, ** this list of conditions and the following disclaimer in the documentation ** and / or other materials provided with the distribution. ** 3.Neither the name of StepToSky nor the names of its contributors ** may be used to endorse or promote products derived from this software ** without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ** DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** ** Contacts: www.steptosky.com */ #include "stsu_data_istream.h" namespace sts_bwc { // backward compatibility /********************************************************************************************************/ ///////////////////////////////////////* Constructors/Destructor *//////////////////////////////////////// /********************************************************************************************************/ DataStreamI::DataStreamI(std::istream & inStream) : mStream(&inStream), mError(DataStreamI::eErrors::ok) {} DataStreamI::DataStreamI() : mStream(nullptr), mError(DataStreamI::eErrors::ok) { } DataStreamI::~DataStreamI() { } /********************************************************************************************************/ //////////////////////////////////////////////* Operators */////////////////////////////////////////////// /********************************************************************************************************/ DataStreamI & DataStreamI::operator>>(char & outVal) { outVal = 0; if (!mStream->read(&outVal, sizeof(char))) { outVal = 0; mError = eErrors::readError; } return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(int8_t & outVal) { outVal = 0; if (!mStream->read(reinterpret_cast<char *>(&outVal), sizeof(int8_t))) { outVal = 0; mError = eErrors::readError; } return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(uint8_t & outVal) { outVal = 0; if (!mStream->read(reinterpret_cast<char *>(&outVal), sizeof(uint8_t))) { outVal = 0; mError = eErrors::readError; } return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(int16_t & outVal) { outVal = 0; if (!mStream->read(reinterpret_cast<char *>(&outVal), sizeof(int16_t))) { outVal = 0; mError = eErrors::readError; } return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(uint16_t & outVal) { outVal = 0; if (!mStream->read(reinterpret_cast<char *>(&outVal), sizeof(uint16_t))) { outVal = 0; mError = eErrors::readError; } return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(int32_t & outVal) { outVal = 0; if (!mStream->read(reinterpret_cast<char *>(&outVal), sizeof(int32_t))) { outVal = 0; mError = eErrors::readError; } return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(uint32_t & outVal) { outVal = 0; if (!mStream->read(reinterpret_cast<char *>(&outVal), sizeof(uint32_t))) { outVal = 0; mError = eErrors::readError; } return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(int64_t & outVal) { outVal = 0; if (!mStream->read(reinterpret_cast<char *>(&outVal), sizeof(int64_t))) { outVal = 0; mError = eErrors::readError; } return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(uint64_t & outVal) { outVal = 0; if (!mStream->read(reinterpret_cast<char *>(&outVal), sizeof(uint64_t))) { outVal = 0; mError = eErrors::readError; } return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(bool & outVal) { outVal = 0; if (!mStream->read(reinterpret_cast<char *>(&outVal), sizeof(bool))) { outVal = 0; mError = eErrors::readError; } return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(float & outVal) { outVal = 0.0f; if (!mStream->read(reinterpret_cast<char *>(&outVal), sizeof(float))) { outVal = 0; mError = eErrors::readError; } return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(double & outVal) { outVal = 0.0; if (!mStream->read(reinterpret_cast<char *>(&outVal), sizeof(double))) { outVal = 0; mError = eErrors::readError; } return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(char *& outVal) { uint64_t len = 0; return readBytes(outVal, len); } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(wchar_t *& outVal) { uint64_t len = 0; return readBytes(outVal, len); } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(std::string & outVal) { uint64_t len; char * str; readBytes(str, len); outVal = std::string(str, len); return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::operator>>(std::wstring & outVal) { uint64_t len; char * str; readBytes(str, len); outVal = std::wstring(reinterpret_cast<wchar_t*>(str), len / sizeof(wchar_t)); return *this; } /********************************************************************************************************/ //////////////////////////////////////////////* Functions */////////////////////////////////////////////// /********************************************************************************************************/ DataStreamI & DataStreamI::readBytes(wchar_t *& outVal, uint64_t & outLen) { outVal = nullptr; outLen = 0; uint64_t byteCount; *this >> byteCount; if (byteCount == 0) { mError = eErrors::readZerroBytes; return *this; } uint64_t len = byteCount / sizeof(wchar_t); outVal = new wchar_t[len + 1]; if (!mStream->read(reinterpret_cast<char *>(outVal), byteCount)) { mError = eErrors::readError; delete[] outVal; return *this; } outVal[len] = L'\0'; outLen = byteCount; return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::readBytes(char *& outVal, uint64_t & outLen) { outVal = nullptr; outLen = 0; uint64_t len; *this >> len; if (len == 0) { mError = eErrors::readZerroBytes; return *this; } outVal = new char[len + 1]; if (!mStream->read(outVal, len)) { mError = eErrors::readError; delete[] outVal; return *this; } outVal[len] = '\0'; outLen = len; return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::readRawData(char * outVal, uint64_t inLen) { if (!mStream->read(outVal, inLen)) { mError = eErrors::readError; } return *this; } //------------------------------------------------------------------------- DataStreamI & DataStreamI::skipRawBytes(uint64_t inLen) { if (!mStream->seekg(inLen, mStream->cur)) { mError = eErrors::seekError; } return *this; } /********************************************************************************************************/ ////////////////////////////////////////////////////////////////////////////////////////////////////////// /********************************************************************************************************/ } // namespace sts
32.608997
106
0.463073
steptosky
f5d718cde2194d572b700cd9ed350c21a449b747
17,638
cpp
C++
src/qt/blocknetquicksend.cpp
mraksoll4/scalaris1
f6e677780f51d570ff1ad8177e003fb8936aacc0
[ "MIT" ]
2
2021-04-11T15:25:15.000Z
2021-10-01T17:37:19.000Z
src/qt/blocknetquicksend.cpp
mraksoll4/scalaris1
f6e677780f51d570ff1ad8177e003fb8936aacc0
[ "MIT" ]
null
null
null
src/qt/blocknetquicksend.cpp
mraksoll4/scalaris1
f6e677780f51d570ff1ad8177e003fb8936aacc0
[ "MIT" ]
5
2021-03-24T11:53:45.000Z
2021-11-24T00:49:08.000Z
// Copyright (c) 2018-2019 The Blocknet developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <qt/blocknetquicksend.h> #include <qt/blocknetaddressbook.h> #include <qt/blocknethdiv.h> #include <qt/blockneticonbtn.h> #include <qt/blocknetsendfundsrequest.h> #include <qt/blocknetsendfundsutil.h> #include <qt/addresstablemodel.h> #include <qt/optionsmodel.h> #include <qt/sendcoinsdialog.h> #include <amount.h> #include <base58.h> #include <wallet/coincontrol.h> #include <validation.h> #include <QMessageBox> #include <QKeyEvent> BlocknetQuickSend::BlocknetQuickSend(WalletModel *w, QWidget *parent) : QFrame(parent), walletModel(w), layout(new QVBoxLayout) { // this->setStyleSheet("border: 1px solid red"); this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); this->setLayout(layout); layout->setContentsMargins(BGU::spi(45), BGU::spi(10), BGU::spi(45), BGU::spi(30)); displayUnit = walletModel->getOptionsModel()->getDisplayUnit(); auto displayUnitName = BitcoinUnits::longName(displayUnit); titleLbl = new QLabel(tr("Quick Send")); titleLbl->setObjectName("h4"); auto *subtitleLbl = new QLabel(tr("Who would you like to send funds to?")); subtitleLbl->setObjectName("h2"); auto *addrBox = new QFrame; addrBox->setContentsMargins(QMargins()); auto *addrBoxLayout = new QHBoxLayout; addrBoxLayout->setContentsMargins(QMargins()); addrBox->setLayout(addrBoxLayout); addressTi = new BlocknetLineEdit(BGU::spi(400)); addressTi->setObjectName("address"); addressTi->setPlaceholderText(tr("Enter Scalaris Address...")); addressTi->setFocusPolicy(Qt::FocusPolicy::StrongFocus); addressTi->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9]{33,35}"), this)); auto *addAddressBtn = new BlocknetIconBtn(QString(), ":/redesign/QuickActions/AddressBookIcon.png"); addrBoxLayout->addWidget(addressTi, 0, Qt::AlignTop); addrBoxLayout->addSpacing(BGU::spi(20)); addrBoxLayout->addWidget(addAddressBtn, 0, Qt::AlignTop); auto *amountLbl = new QLabel(tr("How much would you like to send?")); amountLbl->setObjectName("h2"); auto *amountBox = new QFrame; auto *amountBoxLayout = new QHBoxLayout; amountBoxLayout->setContentsMargins(QMargins()); amountBox->setLayout(amountBoxLayout); amountTi = new BlocknetLineEdit; amountTi->setPlaceholderText(tr("Enter Amount...")); amountTi->setValidator(new BlocknetNumberValidator(0, BLOCKNETGUI_FUNDS_MAX, BitcoinUnits::decimals(displayUnit))); amountTi->setMaxLength(BLOCKNETGUI_MAXCHARS); auto *coinLbl = new QLabel(displayUnitName); coinLbl->setObjectName("coin"); coinLbl->setFixedHeight(amountTi->minimumHeight()); amountBoxLayout->addWidget(amountTi, 0, Qt::AlignLeft); amountBoxLayout->addWidget(coinLbl, 0, Qt::AlignLeft); amountBoxLayout->addStretch(1); // address div auto *div1 = new BlocknetHDiv; // grid divs auto *gdiv1 = new BlocknetHDiv; auto *gdiv2 = new BlocknetHDiv; auto *gdiv3 = new BlocknetHDiv; // Display total auto *totalGrid = new QFrame; // totalGrid->setStyleSheet("border: 1px solid red"); totalGrid->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); auto *totalsLayout = new QGridLayout; totalsLayout->setContentsMargins(QMargins()); totalsLayout->setSpacing(BGU::spi(50)); totalsLayout->setVerticalSpacing(0); totalGrid->setLayout(totalsLayout); auto *feeLbl = new QLabel(tr("Transaction Fee")); feeLbl->setObjectName("header"); feeValueLbl = new QLabel; feeValueLbl->setObjectName("standard"); auto *feeCol3 = new QLabel; auto *totalLbl = new QLabel(tr("Total")); totalLbl->setObjectName("header"); totalValueLbl = new QLabel(BitcoinUnits::formatWithUnit(displayUnit, 0)); totalValueLbl->setObjectName("header"); auto *totalCol3 = new QLabel; warningLbl = new QLabel; warningLbl->setObjectName("warning"); // Grid rows and columns (in order of rows and columns) totalsLayout->addWidget(gdiv1, 0, 0, 1, 3, Qt::AlignVCenter); totalsLayout->addWidget(feeLbl, 1, 0, Qt::AlignLeft | Qt::AlignVCenter); totalsLayout->addWidget(feeValueLbl, 1, 1, Qt::AlignLeft | Qt::AlignVCenter); totalsLayout->addWidget(feeCol3, 1, 2 ); totalsLayout->addWidget(gdiv2, 2, 0, 1, 3, Qt::AlignVCenter); totalsLayout->addWidget(totalLbl, 3, 0, Qt::AlignLeft | Qt::AlignVCenter); totalsLayout->addWidget(totalValueLbl, 3, 1, Qt::AlignLeft | Qt::AlignVCenter); totalsLayout->addWidget(totalCol3, 3, 2 ); totalsLayout->addWidget(gdiv3, 4, 0, 1, 3, Qt::AlignVCenter); totalsLayout->addWidget(warningLbl, 5, 0, 1, 3, Qt::AlignLeft); totalsLayout->setColumnStretch(2, 1); // 3rd column totalsLayout->setRowMinimumHeight(0, BGU::spi(15)); // div 1 totalsLayout->setRowMinimumHeight(1, BGU::spi(40)); // fee totalsLayout->setRowMinimumHeight(2, BGU::spi(15)); // div 2 totalsLayout->setRowMinimumHeight(3, BGU::spi(40)); // total totalsLayout->setRowMinimumHeight(4, BGU::spi(15)); // div 3 totalsLayout->setRowMinimumHeight(5, BGU::spi(30)); // warning confirmBtn = new BlocknetFormBtn; confirmBtn->setText(tr("Confirm Payment")); confirmBtn->setFocusPolicy(Qt::TabFocus); cancelBtn = new BlocknetFormBtn; cancelBtn->setObjectName("cancel"); cancelBtn->setText(tr("Cancel")); auto *btnBox = new QFrame; auto *btnBoxLayout = new QHBoxLayout; btnBoxLayout->setContentsMargins(QMargins()); btnBoxLayout->setSpacing(BGU::spi(15)); btnBox->setLayout(btnBoxLayout); btnBoxLayout->addWidget(cancelBtn, 0, Qt::AlignLeft); btnBoxLayout->addWidget(confirmBtn, 0, Qt::AlignLeft); btnBoxLayout->addStretch(1); layout->addWidget(titleLbl, 0, Qt::AlignTop | Qt::AlignLeft); layout->addSpacing(BGU::spi(40)); layout->addWidget(subtitleLbl, 0, Qt::AlignTop); layout->addSpacing(BGU::spi(20)); layout->addWidget(addrBox, 0, Qt::AlignLeft); layout->addSpacing(BGU::spi(10)); layout->addWidget(div1, 0); layout->addSpacing(BGU::spi(20)); layout->addWidget(amountLbl, 0); layout->addSpacing(BGU::spi(20)); layout->addWidget(amountBox, 0); layout->addSpacing(BGU::spi(20)); layout->addWidget(totalGrid, 0); layout->addSpacing(BGU::spi(20)); layout->addWidget(btnBox); layout->addStretch(1); connect(amountTi, &BlocknetLineEdit::textEdited, this, [this](const QString & text) { onAmountChanged(); }); connect(cancelBtn, &BlocknetFormBtn::clicked, this, &BlocknetQuickSend::onCancel); connect(confirmBtn, &BlocknetFormBtn::clicked, this, &BlocknetQuickSend::onSubmit); connect(addAddressBtn, &BlocknetIconBtn::clicked, this, &BlocknetQuickSend::openAddressBook); } bool BlocknetQuickSend::validated() { return walletModel->validateAddress(addressTi->text()) && !amountTi->text().isEmpty() && BlocknetSendFundsModel::stringToInt(amountTi->text(), displayUnit) > 0; } void BlocknetQuickSend::keyPressEvent(QKeyEvent *event) { QWidget::keyPressEvent(event); if (this->isHidden()) return; if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) onSubmit(); } bool BlocknetQuickSend::focusNextPrevChild(bool next) { if (next && amountTi->hasFocus()) { amountTi->clearFocus(); this->setFocus(Qt::FocusReason::ActiveWindowFocusReason); return true; } return QFrame::focusNextPrevChild(next); } void BlocknetQuickSend::mouseReleaseEvent(QMouseEvent *event) { QWidget::mouseReleaseEvent(event); if (this->amountTi->hasFocus() && !this->amountTi->rect().contains(event->pos())) { this->amountTi->clearFocus(); this->setFocus(Qt::FocusReason::ActiveWindowFocusReason); } } void BlocknetQuickSend::showEvent(QShowEvent *event) { QWidget::showEvent(event); if (!addressTi->hasFocus() && !amountTi->hasFocus()) addressTi->setFocus(Qt::FocusReason::ActiveWindowFocusReason); connect(walletModel, &WalletModel::encryptionStatusChanged, this, &BlocknetQuickSend::onEncryptionStatus); connect(walletModel->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &BlocknetQuickSend::onDisplayUnit); } void BlocknetQuickSend::hideEvent(QHideEvent *event) { QWidget::hideEvent(event); disconnect(walletModel, &WalletModel::encryptionStatusChanged, this, &BlocknetQuickSend::onEncryptionStatus); disconnect(walletModel->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &BlocknetQuickSend::onDisplayUnit); } void BlocknetQuickSend::addAddress(const QString &address) { addressTi->setText(address); } void BlocknetQuickSend::openAddressBook() { BlocknetAddressBookDialog dlg(walletModel, Qt::WindowSystemMenuHint | Qt::WindowTitleHint); dlg.singleShotMode(); connect(&dlg, &BlocknetAddressBookDialog::send, [this](const QString &address) { addAddress(address); }); dlg.exec(); } void BlocknetQuickSend::onAmountChanged() { BlocknetSendFundsModel model; const auto addrLabel = walletModel->getAddressTableModel()->labelForAddress(addressTi->text()); model.addRecipient(addressTi->text(), BlocknetSendFundsModel::stringToInt(amountTi->text(), displayUnit), addrLabel); CCoinControl cc = model.getCoinControl(walletModel); if (!walletModel->wallet().isLocked()) { // if the wallet is unlocked, calculate exact fees auto status = model.prepareFunds(walletModel, cc); QString feeAmount = BitcoinUnits::formatWithUnit(displayUnit, model.txFees()); feeValueLbl->setText(feeAmount); // Display or clear the warning message according to the wallet status if (status.status != WalletModel::OK) warningLbl->setText(BlocknetSendFundsPage::processSendCoinsReturn(walletModel, status).first); else warningLbl->clear(); } else if (cc.HasSelected()) { // estimate b/c wallet is locked here const auto feeInfo = BlocknetEstimateFee(walletModel, cc, model.subtractFee(), model.txRecipients()); QString feeAmount = BitcoinUnits::formatWithUnit(displayUnit, std::get<0>(feeInfo)); feeValueLbl->setText(QString("%1 %2").arg(feeAmount, tr("(estimated)"))); model.setEstimatedFees(std::get<0>(feeInfo)); } else { // estimate b/c wallet is locked here cc.m_feerate.reset(); // explicitly use only fee estimation rate for smart fee labels int estimatedConfirmations; FeeReason reason; CFeeRate feeRate = CFeeRate(walletModel->wallet().getMinimumFee(1000, cc, &estimatedConfirmations, &reason)); QString feeAmount = BitcoinUnits::formatWithUnit(displayUnit, feeRate.GetFeePerK()) + "/kB"; feeValueLbl->setText(QString("%1 %2").arg(feeAmount, tr("(estimated)"))); model.setEstimatedFees(feeRate.GetFeePerK()); } CAmount fees = walletModel->wallet().isLocked() ? model.estimatedFees() : model.txFees(); if (model.subtractFee()) fees *= -1; totalValueLbl->setText(BitcoinUnits::formatWithUnit(displayUnit, (walletModel->wallet().isLocked() ? fees : 0) + model.txTotalAmount())); } void BlocknetQuickSend::onSubmit() { if (!this->validated()) { QMessageBox::warning(this->parentWidget(), tr("Issue"), tr("Please specify a send address and an amount larger than %1") .arg(BitcoinUnits::formatWithUnit(displayUnit, ::minRelayTxFee.GetFeePerK()))); return; } // Unlock wallet context (for relock) WalletModel::EncryptionStatus encStatus = walletModel->getEncryptionStatus(); if (encStatus == WalletModel::EncryptionStatus::Locked || util::unlockedForStakingOnly) { const bool stateUnlockForStaking = util::unlockedForStakingOnly; WalletModel::UnlockContext ctx(walletModel->requestUnlock()); if (!ctx.isValid() || util::unlockedForStakingOnly) { QMessageBox::warning(this->parentWidget(), tr("Issue"), tr("Failed to unlock the wallet")); } else { submitFunds(); util::unlockedForStakingOnly = stateUnlockForStaking; // restore unlocked for staking state } return; } submitFunds(); } WalletModel::SendCoinsReturn BlocknetQuickSend::submitFunds() { QList<SendCoinsRecipient> recipients; const auto addrLabel = walletModel->getAddressTableModel()->labelForAddress(addressTi->text()); recipients.push_back(SendCoinsRecipient{ addressTi->text(), addrLabel, BlocknetSendFundsModel::stringToInt(amountTi->text(), displayUnit), QString() }); WalletModelTransaction currentTransaction(recipients); CCoinControl ctrl; WalletModel::SendCoinsReturn prepareStatus = walletModel->prepareTransaction(currentTransaction, ctrl); const auto feeMsg = BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()); if (prepareStatus.status != WalletModel::OK) { // process prepareStatus and on error generate message shown to user auto res = BlocknetSendFundsPage::processSendCoinsReturn(walletModel, prepareStatus, feeMsg); updateLabels(prepareStatus); if (res.second) QMessageBox::critical(this->parentWidget(), tr("Issue"), res.first); else QMessageBox::warning(this->parentWidget(), tr("Issue"), res.first); return prepareStatus; } const auto txFee = currentTransaction.getTransactionFee(); const auto totalAmt = currentTransaction.getTotalTransactionAmount() + txFee; // Update labels feeValueLbl->setText(BitcoinUnits::formatWithUnit(displayUnit, txFee)); totalValueLbl->setText(BitcoinUnits::formatWithUnit(displayUnit, totalAmt)); // Format confirmation message QStringList formatted; QString questionString = tr("Are you sure you want to send?"); questionString.append("<br /><span style='font-size:10pt;'>"); questionString.append(tr("Please, review your transaction.")); questionString.append("</span><br />%1"); if (txFee > 0) { // append fee string if a fee is required questionString.append("<hr /><b>"); questionString.append(tr("Transaction fee")); questionString.append("</b>"); // append transaction size questionString.append(" (" + QString::number((double)currentTransaction.getTransactionSize() / 1000) + " kB): "); // append transaction fee value questionString.append("<span style='color:#aa0000; font-weight:bold;'>"); questionString.append(BitcoinUnits::formatHtmlWithUnit(displayUnit, txFee)); questionString.append("</span><br />"); } // add total amount in all subdivision units questionString.append("<hr />"); questionString.append(QString("<b>%1</b>: <b>%2</b>").arg(tr("Total Amount")) .arg(BitcoinUnits::formatHtmlWithUnit(displayUnit, totalAmt))); SendConfirmationDialog confirmationDialog(tr("Confirm send coins"), questionString.arg(formatted.join("<br />")), SEND_CONFIRM_DELAY, this); confirmationDialog.exec(); WalletModel::SendCoinsReturn sendStatus(WalletModel::StatusCode::TransactionCommitFailed); bool canceledSend{false}; auto retval = static_cast<QMessageBox::StandardButton>(confirmationDialog.result()); if (retval == QMessageBox::Yes) { // now send the prepared transaction sendStatus = walletModel->sendCoins(currentTransaction); // process sendStatus and on error generate message shown to user auto res = BlocknetSendFundsPage::processSendCoinsReturn(walletModel, sendStatus, feeMsg); if (sendStatus.status == WalletModel::OK) Q_EMIT submit(); else { updateLabels(sendStatus); if (res.second) QMessageBox::critical(this->parentWidget(), tr("Issue"), res.first); else QMessageBox::warning(this->parentWidget(), tr("Issue"), res.first); } } else canceledSend = true; // Display warning message if necessary if (!canceledSend && sendStatus.status != WalletModel::OK && warningLbl) warningLbl->setText(BlocknetSendFundsRequest::sendStatusMsg(sendStatus, "", displayUnit)); return sendStatus; } void BlocknetQuickSend::onEncryptionStatus() { if (walletModel->getEncryptionStatus() == WalletModel::Unlocked && !addressTi->text().isEmpty()) onAmountChanged(); } void BlocknetQuickSend::onDisplayUnit(int unit) { displayUnit = unit; amountTi->setValidator(new BlocknetNumberValidator(0, BLOCKNETGUI_FUNDS_MAX, BitcoinUnits::decimals(displayUnit))); onAmountChanged(); } void BlocknetQuickSend::updateLabels(const WalletModel::SendCoinsReturn & result) { // Handle errors if (result.status != WalletModel::OK) warningLbl->setText(BlocknetSendFundsRequest::sendStatusMsg(result, "", displayUnit)); else warningLbl->clear(); feeValueLbl->setText(QString("%1 %2").arg(BitcoinUnits::formatWithUnit(displayUnit, txFees), tr("(estimated)"))); totalValueLbl->setText(BitcoinUnits::formatWithUnit(displayUnit, totalAmount)); }
46.052219
141
0.688003
mraksoll4
f5d75d5299d2004eb65463fa93108348b0cf7f4c
20,819
cpp
C++
src/storage/data_table.cpp
hjhhsy120/terrier
c53e1ac9de629ec340c42e9797a7460fdf2a56dc
[ "MIT" ]
1
2019-03-08T18:59:57.000Z
2019-03-08T18:59:57.000Z
src/storage/data_table.cpp
LiuXiaoxuanPKU/terrier
35916e9435201016903d8a01e3f587b8edb36f0b
[ "MIT" ]
34
2019-03-21T20:47:59.000Z
2019-05-17T06:06:46.000Z
src/storage/data_table.cpp
LiuXiaoxuanPKU/terrier
35916e9435201016903d8a01e3f587b8edb36f0b
[ "MIT" ]
null
null
null
#include "storage/data_table.h" #include <pthread.h> #include <cstring> #include <list> #include <unordered_map> #include "common/allocator.h" #include "storage/block_access_controller.h" #include "storage/storage_util.h" #include "transaction/transaction_context.h" #include "transaction/transaction_util.h" namespace terrier::storage { DataTable::DataTable(BlockStore *const store, const BlockLayout &layout, const layout_version_t layout_version) : block_store_(store), layout_version_(layout_version), accessor_(layout) { TERRIER_ASSERT(layout.AttrSize(VERSION_POINTER_COLUMN_ID) == 8, "First column must have size 8 for the version chain."); TERRIER_ASSERT(layout.NumColumns() > NUM_RESERVED_COLUMNS, "First column is reserved for version info, second column is reserved for logical delete."); if (block_store_ != nullptr) { RawBlock *new_block = NewBlock(); // insert block blocks_.push_back(new_block); } insertion_head_ = blocks_.begin(); } DataTable::~DataTable() { common::SpinLatch::ScopedSpinLatch guard(&blocks_latch_); for (RawBlock *block : blocks_) { StorageUtil::DeallocateVarlens(block, accessor_); for (col_id_t i : accessor_.GetBlockLayout().Varlens()) accessor_.GetArrowBlockMetadata(block).GetColumnInfo(accessor_.GetBlockLayout(), i).Deallocate(); block_store_->Release(block); } } bool DataTable::Select(terrier::transaction::TransactionContext *txn, terrier::storage::TupleSlot slot, terrier::storage::ProjectedRow *out_buffer) const { data_table_counter_.IncrementNumSelect(1); return SelectIntoBuffer(txn, slot, out_buffer); } void DataTable::Scan(transaction::TransactionContext *const txn, SlotIterator *const start_pos, ProjectedColumns *const out_buffer) const { // TODO(Tianyu): So far this is not that much better than tuple-at-a-time access, // but can be improved if block is read-only, or if we implement version synopsis, to just use std::memcpy when it's // safe uint32_t filled = 0; while (filled < out_buffer->MaxTuples() && *start_pos != end()) { ProjectedColumns::RowView row = out_buffer->InterpretAsRow(filled); const TupleSlot slot = **start_pos; // Only fill the buffer with valid, visible tuples if (SelectIntoBuffer(txn, slot, &row)) { out_buffer->TupleSlots()[filled] = slot; filled++; } ++(*start_pos); } out_buffer->SetNumTuples(filled); } DataTable::SlotIterator &DataTable::SlotIterator::operator++() { common::SpinLatch::ScopedSpinLatch guard(&table_->blocks_latch_); // Jump to the next block if already the last slot in the block. if (current_slot_.GetOffset() == table_->accessor_.GetBlockLayout().NumSlots() - 1) { ++block_; // Cannot dereference if the next block is end(), so just use nullptr to denote current_slot_ = {block_ == table_->blocks_.end() ? nullptr : *block_, 0}; } else { current_slot_ = {*block_, current_slot_.GetOffset() + 1}; } return *this; } DataTable::SlotIterator DataTable::end() const { // NOLINT for STL name compability common::SpinLatch::ScopedSpinLatch guard(&blocks_latch_); // TODO(Tianyu): Need to look in detail at how this interacts with compaction when that gets in. // The end iterator could either point to an unfilled slot in a block, or point to nothing if every block in the // table is full. In the case that it points to nothing, we will use the end-iterator of the blocks list and // 0 to denote that this is the case. This solution makes increment logic simple and natural. if (blocks_.empty()) return {this, blocks_.end(), 0}; auto last_block = --blocks_.end(); uint32_t insert_head = (*last_block)->GetInsertHead(); // Last block is full, return the default end iterator that doesn't point to anything if (insert_head == accessor_.GetBlockLayout().NumSlots()) return {this, blocks_.end(), 0}; // Otherwise, insert head points to the slot that will be inserted next, which would be exactly what we want. return {this, last_block, insert_head}; } bool DataTable::Update(transaction::TransactionContext *const txn, const TupleSlot slot, const ProjectedRow &redo) { TERRIER_ASSERT(redo.NumColumns() <= accessor_.GetBlockLayout().NumColumns() - NUM_RESERVED_COLUMNS, "The input buffer cannot change the reserved columns, so it should have fewer attributes."); TERRIER_ASSERT(redo.NumColumns() > 0, "The input buffer should modify at least one attribute."); UndoRecord *const undo = txn->UndoRecordForUpdate(this, slot, redo); slot.GetBlock()->controller_.WaitUntilHot(); UndoRecord *version_ptr; do { version_ptr = AtomicallyReadVersionPtr(slot, accessor_); // Since we disallow write-write conflicts, the version vector pointer is essentially an implicit // write lock on the tuple. if (HasConflict(*txn, version_ptr) || !Visible(slot, accessor_)) { // Mark this UndoRecord as never installed by setting the table pointer to nullptr. This is inspected in the // TransactionManager's Rollback() and GC's Unlink logic undo->Table() = nullptr; return false; } // Store before-image before making any changes or grabbing lock for (uint16_t i = 0; i < undo->Delta()->NumColumns(); i++) StorageUtil::CopyAttrIntoProjection(accessor_, slot, undo->Delta(), i); // Update the next pointer of the new head of the version chain undo->Next() = version_ptr; } while (!CompareAndSwapVersionPtr(slot, accessor_, version_ptr, undo)); // Update in place with the new value. for (uint16_t i = 0; i < redo.NumColumns(); i++) { TERRIER_ASSERT(redo.ColumnIds()[i] != VERSION_POINTER_COLUMN_ID, "Input buffer should not change the version pointer column."); // TODO(Matt): It would be nice to check that a ProjectedRow that modifies the logical delete column only originated // from the DataTable calling Update() within Delete(), rather than an outside soure modifying this column, but // that's difficult with this implementation StorageUtil::CopyAttrFromProjection(accessor_, slot, redo, i); } data_table_counter_.IncrementNumUpdate(1); return true; } void DataTable::CheckMoveHead(std::list<RawBlock *>::iterator block) { // Assume block is full common::SpinLatch::ScopedSpinLatch guard_head(&header_latch_); if (block == insertion_head_) { // If the header block is full, move the header to point to the next block insertion_head_++; } // If there are no more free blocks, create a new empty block and point the insertion_head to it if (insertion_head_ == blocks_.end()) { RawBlock *new_block = NewBlock(); // take latch common::SpinLatch::ScopedSpinLatch guard_block(&blocks_latch_); // insert block blocks_.push_back(new_block); // set insertion header to --end() insertion_head_ = --blocks_.end(); } } TupleSlot DataTable::Insert(transaction::TransactionContext *const txn, const ProjectedRow &redo) { TERRIER_ASSERT(redo.NumColumns() == accessor_.GetBlockLayout().NumColumns() - NUM_RESERVED_COLUMNS, "The input buffer never changes the version pointer column, so it should have exactly 1 fewer " "attribute than the DataTable's layout."); // Insertion header points to the first block that has free tuple slots // Once a txn arrives, it will start from the insertion header to find the first // idle (no other txn is trying to get tuple slots in that block) and non-full block. // If no such block is found, the txn will create a new block. // Before the txn writes to the block, it will set block status to busy. // The first bit of block insert_head_ is used to indicate if the block is busy // If the first bit is 1, it indicates one txn is writing to the block. TupleSlot result; auto block = insertion_head_; while (true) { // No free block left if (block == blocks_.end()) { RawBlock *new_block = NewBlock(); TERRIER_ASSERT(accessor_.SetBlockBusyStatus(new_block), "Status of new block should not be busy"); // No need to flip the busy status bit accessor_.Allocate(new_block, &result); // take latch common::SpinLatch::ScopedSpinLatch guard(&blocks_latch_); // insert block blocks_.push_back(new_block); block = --blocks_.end(); break; } if (accessor_.SetBlockBusyStatus(*block)) { // No one is inserting into this block if (accessor_.Allocate(*block, &result)) { // The block is not full, succeed break; } // Fail to insert into the block, flip back the status bit accessor_.ClearBlockBusyStatus(*block); // if the full block is the insertion_header, move the insertion_header // Next insert txn will search from the new insertion_header CheckMoveHead(block); } // The block is full or the block is being inserted by other txn, try next block ++block; } // Do not need to wait unit finish inserting, // can flip back the status bit once the thread gets the allocated tuple slot accessor_.ClearBlockBusyStatus(*block); InsertInto(txn, redo, result); data_table_counter_.IncrementNumInsert(1); return result; } void DataTable::InsertInto(transaction::TransactionContext *txn, const ProjectedRow &redo, TupleSlot dest) { TERRIER_ASSERT(accessor_.Allocated(dest), "destination slot must already be allocated"); TERRIER_ASSERT(accessor_.IsNull(dest, VERSION_POINTER_COLUMN_ID), "The slot needs to be logically deleted to every running transaction"); // At this point, sequential scan down the block can still see this, except it thinks it is logically deleted if we 0 // the primary key column UndoRecord *undo = txn->UndoRecordForInsert(this, dest); TERRIER_ASSERT(dest.GetBlock()->controller_.GetBlockState()->load() == BlockState::HOT, "Should only be able to insert into hot blocks"); AtomicallyWriteVersionPtr(dest, accessor_, undo); // Set the logically deleted bit to present as the undo record is ready accessor_.AccessForceNotNull(dest, VERSION_POINTER_COLUMN_ID); // Update in place with the new value. for (uint16_t i = 0; i < redo.NumColumns(); i++) { TERRIER_ASSERT(redo.ColumnIds()[i] != VERSION_POINTER_COLUMN_ID, "Insert buffer should not change the version pointer column."); StorageUtil::CopyAttrFromProjection(accessor_, dest, redo, i); } } bool DataTable::Delete(transaction::TransactionContext *const txn, const TupleSlot slot) { data_table_counter_.IncrementNumDelete(1); UndoRecord *const undo = txn->UndoRecordForDelete(this, slot); slot.GetBlock()->controller_.WaitUntilHot(); UndoRecord *version_ptr; do { version_ptr = AtomicallyReadVersionPtr(slot, accessor_); // Since we disallow write-write conflicts, the version vector pointer is essentially an implicit // write lock on the tuple. if (HasConflict(*txn, version_ptr) || !Visible(slot, accessor_)) { // Mark this UndoRecord as never installed by setting the table pointer to nullptr. This is inspected in the // TransactionManager's Rollback() and GC's Unlink logic undo->Table() = nullptr; return false; } // Update the next pointer of the new head of the version chain undo->Next() = version_ptr; } while (!CompareAndSwapVersionPtr(slot, accessor_, version_ptr, undo)); // We have the write lock. Go ahead and flip the logically deleted bit to true accessor_.SetNull(slot, VERSION_POINTER_COLUMN_ID); return true; } template <class RowType> bool DataTable::SelectIntoBuffer(transaction::TransactionContext *const txn, const TupleSlot slot, RowType *const out_buffer) const { TERRIER_ASSERT(out_buffer->NumColumns() <= accessor_.GetBlockLayout().NumColumns() - NUM_RESERVED_COLUMNS, "The output buffer never returns the version pointer columns, so it should have " "fewer attributes."); TERRIER_ASSERT(out_buffer->NumColumns() > 0, "The output buffer should return at least one attribute."); // This cannot be visible if it's already deallocated. if (!accessor_.Allocated(slot)) return false; UndoRecord *version_ptr; bool visible; do { version_ptr = AtomicallyReadVersionPtr(slot, accessor_); // Copy the current (most recent) tuple into the output buffer. These operations don't need to be atomic, // because so long as we set the version ptr before updating in place, the reader will know if a conflict // can potentially happen, and chase the version chain before returning anyway, for (uint16_t i = 0; i < out_buffer->NumColumns(); i++) { TERRIER_ASSERT(out_buffer->ColumnIds()[i] != VERSION_POINTER_COLUMN_ID, "Output buffer should not read the version pointer column."); StorageUtil::CopyAttrIntoProjection(accessor_, slot, out_buffer, i); } // We still need to check the allocated bit because GC could have flipped it since last check visible = Visible(slot, accessor_); // Here we will need to check that the version pointer did not change during our read. If it did, the content // we have read might have been rolled back and an abort has already unlinked the associated undo-record, // we will have to loop around to avoid a dirty read. // // There is still an a-b-a problem if aborting transactions unlink themselves. Thus, in the system aborting // transactions still check out a timestamp and "commit" after rolling back their changes to guard against this, // The exact interleaving is this: // // transaction 1 transaction 2 // begin // read version_ptr // begin // write a -> a1 // read a1 // rollback a1 -> a // check version_ptr // return a1 // // For this to manifest, there has to be high contention on a given tuple slot, and insufficient CPU resources // (way more threads than there are cores, around 8x seems to work) such that threads are frequently swapped // out. compare-and-swap along with the pointer reduces the probability of this happening to be essentially // infinitesimal, but it's still a probabilistic fix. To 100% prevent this race, we have to wait until no // concurrent transaction with the abort that could have had a dirty read is alive to unlink this. The easiest // way to achieve that is to take a timestamp as well when all changes have been rolled back for an aborted // transaction, and let GC handle the unlinking. } while (version_ptr != AtomicallyReadVersionPtr(slot, accessor_)); // Nullptr in version chain means no other versions visible to any transaction alive at this point. // Alternatively, if the current transaction holds the write lock, it should be able to read its own updates. if (version_ptr == nullptr || version_ptr->Timestamp().load() == txn->FinishTime()) { return visible; } // Apply deltas until we reconstruct a version safe for us to read while (version_ptr != nullptr && transaction::TransactionUtil::NewerThan(version_ptr->Timestamp().load(), txn->StartTime())) { switch (version_ptr->Type()) { case DeltaRecordType::UPDATE: // Normal delta to be applied. Does not modify the logical delete column. StorageUtil::ApplyDelta(accessor_.GetBlockLayout(), *(version_ptr->Delta()), out_buffer); break; case DeltaRecordType::INSERT: visible = false; break; case DeltaRecordType::DELETE: visible = true; break; default: throw std::runtime_error("unexpected delta record type"); } version_ptr = version_ptr->Next(); } return visible; } template bool DataTable::SelectIntoBuffer<ProjectedRow>(transaction::TransactionContext *txn, const TupleSlot slot, ProjectedRow *const out_buffer) const; template bool DataTable::SelectIntoBuffer<ProjectedColumns::RowView>(transaction::TransactionContext *txn, const TupleSlot slot, ProjectedColumns::RowView *const out_buffer) const; UndoRecord *DataTable::AtomicallyReadVersionPtr(const TupleSlot slot, const TupleAccessStrategy &accessor) const { // Okay to ignore presence bit, because we use that for logical delete, not for validity of the version pointer value byte *ptr_location = accessor.AccessWithoutNullCheck(slot, VERSION_POINTER_COLUMN_ID); return reinterpret_cast<std::atomic<UndoRecord *> *>(ptr_location)->load(); } void DataTable::AtomicallyWriteVersionPtr(const TupleSlot slot, const TupleAccessStrategy &accessor, UndoRecord *const desired) { // Okay to ignore presence bit, because we use that for logical delete, not for validity of the version pointer value byte *ptr_location = accessor.AccessWithoutNullCheck(slot, VERSION_POINTER_COLUMN_ID); reinterpret_cast<std::atomic<UndoRecord *> *>(ptr_location)->store(desired); } bool DataTable::Visible(const TupleSlot slot, const TupleAccessStrategy &accessor) const { const bool present = accessor.Allocated(slot); const bool not_deleted = !accessor.IsNull(slot, VERSION_POINTER_COLUMN_ID); return present && not_deleted; } bool DataTable::HasConflict(const transaction::TransactionContext &txn, UndoRecord *const version_ptr) const { if (version_ptr == nullptr) return false; // Nobody owns this tuple's write lock, no older version visible const transaction::timestamp_t version_timestamp = version_ptr->Timestamp().load(); const transaction::timestamp_t txn_id = txn.FinishTime(); const transaction::timestamp_t start_time = txn.StartTime(); const bool owned_by_other_txn = (!transaction::TransactionUtil::Committed(version_timestamp) && version_timestamp != txn_id); const bool newer_committed_version = transaction::TransactionUtil::Committed(version_timestamp) && transaction::TransactionUtil::NewerThan(version_timestamp, start_time); return owned_by_other_txn || newer_committed_version; } bool DataTable::CompareAndSwapVersionPtr(const TupleSlot slot, const TupleAccessStrategy &accessor, UndoRecord *expected, UndoRecord *const desired) { // Okay to ignore presence bit, because we use that for logical delete, not for validity of the version pointer value byte *ptr_location = accessor.AccessWithoutNullCheck(slot, VERSION_POINTER_COLUMN_ID); return reinterpret_cast<std::atomic<UndoRecord *> *>(ptr_location)->compare_exchange_strong(expected, desired); } RawBlock *DataTable::NewBlock() { RawBlock *new_block = block_store_->Get(); accessor_.InitializeRawBlock(this, new_block, layout_version_); data_table_counter_.IncrementNumNewBlock(1); return new_block; } bool DataTable::HasConflict(const transaction::TransactionContext &txn, const TupleSlot slot) const { UndoRecord *const version_ptr = AtomicallyReadVersionPtr(slot, accessor_); return HasConflict(txn, version_ptr); } bool DataTable::IsVisible(const transaction::TransactionContext &txn, const TupleSlot slot) const { UndoRecord *version_ptr; bool visible; do { version_ptr = AtomicallyReadVersionPtr(slot, accessor_); // Here we will need to check that the version pointer did not change during our read. If it did, the visibility of // this tuple might have changed and we should check again. visible = Visible(slot, accessor_); } while (version_ptr != AtomicallyReadVersionPtr(slot, accessor_)); // Nullptr in version chain means no other versions visible to any transaction alive at this point. // Alternatively, if the current transaction holds the write lock, it should be able to read its own updates. if (version_ptr == nullptr || version_ptr->Timestamp().load() == txn.FinishTime()) { return visible; } // Apply deltas until we determine a version safe for us to read while (version_ptr != nullptr && transaction::TransactionUtil::NewerThan(version_ptr->Timestamp().load(), txn.StartTime())) { switch (version_ptr->Type()) { case DeltaRecordType::UPDATE: // Normal delta to be applied. Does not modify the logical delete column. break; case DeltaRecordType::INSERT: visible = false; break; case DeltaRecordType::DELETE: visible = true; } version_ptr = version_ptr->Next(); } return visible; } } // namespace terrier::storage
48.870892
120
0.706662
hjhhsy120
f5d9a478ce87317c90a39a2bb45891a397feaf34
14,016
cpp
C++
tilefetcher.cpp
ateijelo/steps
85392492fd6011c7af8f2de1604abee6f6f4b9df
[ "Apache-2.0" ]
1
2019-06-03T21:20:49.000Z
2019-06-03T21:20:49.000Z
tilefetcher.cpp
ateijelo/steps
85392492fd6011c7af8f2de1604abee6f6f4b9df
[ "Apache-2.0" ]
null
null
null
tilefetcher.cpp
ateijelo/steps
85392492fd6011c7af8f2de1604abee6f6f4b9df
[ "Apache-2.0" ]
1
2018-11-12T12:35:18.000Z
2018-11-12T12:35:18.000Z
/* * tilefetcher.cpp -- part of Steps, a simple maps app * * Copyright 2009-2016 Andy Teijelo <www.ateijelo.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <QApplication> #include <QtAlgorithms> #include <QByteArray> #include <QSettings> #include <QtEndian> #include <QtDebug> #include <QFile> #include <QDir> #include <QSqlError> #include <QSqlQuery> #include "disktask.h" #include "networktask.h" #include "tilefetcher.h" #include "constants.h" #include "debug.h" TileFetcher::TileFetcher(QObject *parent) : QObject(parent) { for (int i=0; i<2; i++) { QThread *t = new QThread(this); idleDiskThreads.insert(t); t->start(); } for (int i=0; i<1; i++) { QThread *t = new QThread(this); idleNetworkThreads.insert(t); t->start(); } wakeUpEvent = QEvent::Type(QEvent::registerEventType()); pendingWakeUp = false; } TileFetcher::~TileFetcher() { foreach (QThread *t, idleDiskThreads+activeDiskThreads+idleNetworkThreads+activeNetworkThreads) { t->quit(); t->wait(); } } void TileFetcher::customEvent(QEvent *event) { fDebug(DEBUG_FETCHREQUESTS) << "TileFetcher::customEvent()"; if (event->type() == wakeUpEvent) { fDebug(DEBUG_FETCHREQUESTS) << " wakeUpEvent"; pendingWakeUp = false; work(); } } void TileFetcher::wakeUp() { fDebug(DEBUG_FETCHREQUESTS) << "TileFetcher::wakeUp()"; if (!pendingWakeUp) { pendingWakeUp = true; qApp->postEvent(this, new QEvent(wakeUpEvent)); } } void TileFetcher::fetchTile(const QString &maptype, int x, int y, int zoom) { fDebug(DEBUG_FETCHREQUESTS) << "TileFetcher::fetchTile" << maptype << x << y << zoom; // QMutexLocker l(&mutex); TileId r(maptype,x,y,zoom); if (requests.contains(r)) { fDebug(DEBUG_FETCHREQUESTS) << " request already queued."; return; } if (diskRequests.contains(r)) { fDebug(DEBUG_FETCHREQUESTS) << " request already in disk queue."; return; } if (networkRequests.contains(r)) { fDebug(DEBUG_FETCHREQUESTS) << " request already in network queue."; return; } requests.insert(r); wakeUp(); } void TileFetcher::forgetRequest(const QString &type, int x, int y, int zoom) { fDebug(DEBUG_FETCHREQUESTS) << "TileFetcher::forgetRequest" << type << x << y << zoom; // QMutexLocker l(&mutex); TileId r(type,x,y,zoom); QSet<TileId>::iterator i; i = requests.find(r); if (i != requests.end()) { requests.erase(i); } i = diskRequests.find(r); if (i != diskRequests.end()) { diskRequests.erase(i); } i = networkRequests.find(r); if (i != networkRequests.end()) { networkRequests.erase(i); } } void TileFetcher::networkTileData(const QString &type, int x, int y, int z, const QByteArray &data) { TileId tile(type,x,y,z); if (!data.isEmpty()) { emit tileData(type,x,y,z,data); memCache.insert(tile,data); diskWriteRequests.insert(tile,data); } activeNetworkRequests.remove(tile); wakeUp(); } void TileFetcher::diskTaskFinished(Task *task) { QThread* thread = task->thread(); QSet<QThread*>::iterator i = activeDiskThreads.find(thread); if (i == activeDiskThreads.end()) { fDebug(DEBUG_DISK) << "The thread of the disk task that just finished is not in the active list!"; exit(EXIT_FAILURE); } activeDiskThreads.erase(i); idleDiskThreads.insert(thread); task->deleteLater(); wakeUp(); } void TileFetcher::networkTaskFinished(Task *task) { QThread* thread = task->thread(); QSet<QThread*>::iterator i = activeNetworkThreads.find(thread); if (i == activeNetworkThreads.end()) { fDebug(DEBUG_NETWORK) << "The thread of the network task just finished is not in the active list!"; exit(EXIT_FAILURE); } activeNetworkThreads.erase(i); idleNetworkThreads.insert(thread); NetworkTask *n = static_cast<NetworkTask*>(task); activeNetworkRequests.remove(n->tileId()); task->deleteLater(); wakeUp(); } void TileFetcher::reload() { memCache.clear(); db.close(); } void TileFetcher::readMgm(const TileId& tile) { int mgm_x = tile.x >> 3; int mgm_y = tile.y >> 3; QSettings settings; QString filename = QString("%1/%2_%3/%4_%5.mgm") .arg(settings.value(SettingsKeys::CachePath,"").toString()) .arg(tile.type) .arg(tile.zoom) .arg(mgm_x) .arg(mgm_y); fDebug(DEBUG_DISK) << this << "started. Fetching" << tile.x << tile.y << "from" << filename; QFile mgm(filename); QHash<TileId,QPair<quint32,quint32> > mgmTiles; if (mgm.open(QIODevice::ReadOnly)) { quint64 r = 0; quint32 tile_start = 64*6 + 2; quint32 tile_end; quint16 no_tiles; r += mgm.read((char*)(&no_tiles),2); if (r != 2) { fDebug(DEBUG_DISK) << "error reading no_tiles"; no_tiles = 0; } no_tiles = qFromBigEndian(no_tiles); for (int i=0; i<no_tiles; i++) { quint8 tx,ty; r = mgm.read((char*)(&tx),1); r += mgm.read((char*)(&ty),1); r += mgm.read((char*)(&tile_end),4); if (r != 6) { fDebug(DEBUG_DISK) << "error reading tile entry " << i; break; } tile_end = qFromBigEndian(tile_end); TileId t(tile.type,tx + (mgm_x << 3),ty + (mgm_y << 3),tile.zoom); if (diskRequests.contains(t)) { mgmTiles.insert(t,qMakePair(tile_start,tile_end - tile_start)); diskRequests.remove(t); } tile_start = tile_end; } } if (!mgmTiles.contains(tile)) { diskRequests.remove(tile); networkRequests.insert(tile); } /* QSet<TileId>::iterator i = diskRequests.begin(); while (i != diskRequests.end()) { TileId t = *i; bool tBelongsHere = ((t.type == tile.type) && ((t.x >> 3) == mgm_x) && ((t.y >> 3) == mgm_y) && (t.zoom == tile.zoom)); if (tBelongsHere) { fDebug(DEBUG_DISK) << "tile" << t << "in queue, in the range of the mgm, but absent."; i = diskRequests.erase(i); networkRequests.insert(t); } else { i++; } } */ for (QHash<TileId,QPair<quint32,quint32> >::iterator i = mgmTiles.begin(); i != mgmTiles.end(); i++) { TileId t = i.key(); QPair<quint32,quint32> p = i.value(); quint32 tile_start = p.first; quint32 tile_size = p.second; mgm.seek(tile_start); QByteArray data = mgm.read(tile_size); if (static_cast<quint32>(data.size()) != tile_size) { fDebug(DEBUG_DISK) << "error reading tile " << tile.x << "," << tile.y << "data"; networkRequests.insert(t); continue; } else { fDebug(DEBUG_DISK) << "found tile" << t << "in mgm"; emit tileData(t.type,t.x,t.y,t.zoom,data); memCache.insert(t,data); } } } QByteArray TileFetcher::readMBTile(const TileId &tile) { QByteArray nothing; QSettings settings; QString path = settings.value(SettingsKeys::MBTilesPath,"").toString(); fDebug(DEBUG_DATABASE) << "readMBTile: " << tile; if (path.isEmpty()) { return nothing; } fDebug(DEBUG_DATABASE) << "db path:" << path; if (!db.isOpen()) { db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(path); if (!db.open()) return nothing; emit loadedMBTiles(path); fDebug(DEBUG_DATABASE) << "opened database:" << path; } //fDebug(DEBUG_DATABASE) << "db.hostName:" << db.hostName(); QSqlQuery q; q.prepare("SELECT tile_data FROM tiles WHERE " "zoom_level = :zoom AND " "tile_column = :x AND " "tile_row = :y LIMIT 1"); // .arg(tile.zoom) // .arg(tile.x) // .arg(tile.y) // ); q.bindValue(":zoom", tile.zoom); q.bindValue(":x", tile.x); q.bindValue(":y", tile.y); bool b = q.exec(); fDebug(DEBUG_DATABASE) << "exec returned" << b; //fDebug(DEBUG_DATABASE) << "x:" << tile.x << "y:" << tile.y << "zoom:" << tile.zoom; while (q.next()) { QByteArray r = q.value(0).toByteArray(); fDebug(DEBUG_DATABASE) << " query returned" << r.size() << "bytes"; return r; } fDebug(DEBUG_DATABASE) << " returned nothing"; return nothing; } bool TileFetcher::readSingleFile(const TileId& tile) { QSettings settings; QDir d(settings.value(SettingsKeys::CachePath,"").toString()); QFile f(d.absoluteFilePath(QString("cache/%1/%2/%3_%4").arg(tile.type).arg(tile.zoom).arg(tile.x).arg(tile.y))); fDebug(DEBUG_DISK) << "opening" << f.fileName(); if (f.open(QIODevice::ReadOnly)) { QByteArray data = f.readAll(); emit tileData(tile.type,tile.x,tile.y,tile.zoom,data); memCache.insert(tile,data); diskRequests.remove(tile); return true; } fDebug(DEBUG_DISK) << " failed"; return false; } void TileFetcher::work() { debug("TileFetcher::work"); while (requests.count() > 0) { QSet<TileId>::iterator i = requests.begin(); TileId r = *i; QByteArray a = memCache.getTileData(r); if (!a.isEmpty()) { emit tileData(r.type,r.x,r.y,r.zoom,a); requests.erase(i); continue; } requests.erase(i); diskRequests.insert(r); } while (diskRequests.count() > 0) { debug("while (diskRequests.count() > 0):"); QSet<TileId>::iterator i = diskRequests.begin(); TileId tile = *i; if (readSingleFile(tile)) continue; QByteArray data = readMBTile(tile); diskRequests.remove(tile); if (data.isNull()) { //fDebug(DEBUG_DISK) << "error reading tile " << tile.x << "," << tile.y << "data"; networkRequests.insert(tile); } else { //fDebug(DEBUG_DISK) << "found tile" << t << "in mgm"; emit tileData(tile.type,tile.x,tile.y,tile.zoom,data); memCache.insert(tile,data); } //readMgm(tile); } while (qMin(idleDiskThreads.count(),diskWriteRequests.count()) > 0) { QHash<TileId,QByteArray>::iterator i = diskWriteRequests.begin(); TileId r = i.key(); QByteArray a = i.value(); DiskTask *task = new DiskTask(); task->storeTile(r,a); connect(task,SIGNAL(finished(Task*)),this,SLOT(diskTaskFinished(Task*))); QSet<QThread*>::iterator j = idleDiskThreads.begin(); QThread *thread = *j; activeDiskThreads.insert(thread); idleDiskThreads.erase(j); task->moveToThread(thread); task->start(); diskWriteRequests.erase(i); } while (qMin(idleNetworkThreads.count(),networkRequests.count()) > 0) { QList<TileId> l = networkRequests.values(); qSort(l.begin(),l.end(),fetchOrder); QSet<TileId>::iterator i = networkRequests.find(l.at(0)); TileId r = *i; NetworkTask *task = new NetworkTask(r); connect(task,SIGNAL(tileData(QString,int,int,int,QByteArray)), this,SLOT(networkTileData(QString,int,int,int,QByteArray))); connect(task,SIGNAL(finished(Task*)), this,SLOT(networkTaskFinished(Task*))); QSet<QThread*>::iterator j = idleNetworkThreads.begin(); QThread *thread = *j; activeNetworkThreads.insert(thread); idleNetworkThreads.erase(j); task->moveToThread(thread); task->start(); networkRequests.erase(i); activeNetworkRequests.insert(r); } } bool fetchOrder(const TileId& t1, const TileId& t2) { if (t1.zoom < t2.zoom) return true; if (t1.zoom > t2.zoom) return false; if (t1.y < t2.y) return true; if (t1.y > t2.y) return false; if (t1.x < t2.x) return true; if (t1.x > t2.x) return false; return false; } void TileFetcher::debug(const QString& header) { if fEnabled(DEBUG_FETCHQUEUES) { qDebug() << header; // qDebug() << " idleDiskThreads:" << idleDiskThreads; qDebug() << " requests:"; foreach (const TileId& r, requests) qDebug() << " " << r.type << r.x << r.y << r.zoom; qDebug() << " diskRequests:"; foreach (const TileId& r, diskRequests) qDebug() << " " << r.type << r.x << r.y << r.zoom; qDebug() << " networkRequests:"; foreach (const TileId& r, networkRequests) qDebug() << " " << r.type << r.x << r.y << r.zoom; qDebug() << " activeNetworkRequests:"; foreach (const TileId& r, activeNetworkRequests) qDebug() << " " << r.type << r.x << r.y << r.zoom; } }
28.37247
116
0.560859
ateijelo
f5d9d030b9be8ddae444348af6c7a5ba2a530626
49,061
cpp
C++
Direct3D/ShadowMap/shadowmap.cpp
walbourn/directx-sdk-legacy-samples
93e8cc554b5ecb5cd574a06071ed784b6cb73fc5
[ "MIT" ]
27
2021-03-01T23:50:39.000Z
2022-03-04T03:27:17.000Z
Direct3D/ShadowMap/shadowmap.cpp
walbourn/directx-sdk-legacy-samples
93e8cc554b5ecb5cd574a06071ed784b6cb73fc5
[ "MIT" ]
3
2021-03-02T00:39:56.000Z
2021-12-02T19:50:03.000Z
Direct3D/ShadowMap/shadowmap.cpp
walbourn/directx-sdk-legacy-samples
93e8cc554b5ecb5cd574a06071ed784b6cb73fc5
[ "MIT" ]
3
2021-03-29T16:23:54.000Z
2022-03-05T08:35:05.000Z
//-------------------------------------------------------------------------------------- // File: ShadowMap.cpp // // Starting point for new Direct3D applications // // Copyright (c) Microsoft Corporation. // Licensed under the MIT License (MIT). //-------------------------------------------------------------------------------------- #include "DXUT.h" #include "DXUTcamera.h" #include "DXUTsettingsdlg.h" #include "SDKmisc.h" #include "SDKmesh.h" #include "resource.h" //#define DEBUG_VS // Uncomment this line to debug vertex shaders //#define DEBUG_PS // Uncomment this line to debug pixel shaders #define SHADOWMAP_SIZE 512 #define HELPTEXTCOLOR D3DXCOLOR( 0.0f, 1.0f, 0.3f, 1.0f ) LPCWSTR g_aszMeshFile[] = { L"room.x", L"airplane\\airplane 2.x", L"misc\\car.x", L"misc\\sphere.x", L"UI\\arrow.x", L"UI\\arrow.x", L"UI\\arrow.x", L"UI\\arrow.x", L"UI\\arrow.x", L"UI\\arrow.x", L"UI\\arrow.x", L"UI\\arrow.x", L"ring.x", L"ring.x", }; #define NUM_OBJ (sizeof(g_aszMeshFile)/sizeof(g_aszMeshFile[0])) D3DXMATRIXA16 g_amInitObjWorld[NUM_OBJ] = { D3DXMATRIXA16( 3.5f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f ), D3DXMATRIXA16( 0.43301f, 0.25f, 0.0f, 0.0f, -0.25f, 0.43301f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 5.0f, 1.33975f, 0.0f, 1.0f ), D3DXMATRIXA16( 0.8f, 0.0f, 0.0f, 0.0f, 0.0f, 0.8f, 0.0f, 0.0f, 0.0f, 0.0f, 0.8f, 0.0f, -14.5f, -7.1f, 0.0f, 1.0f ), D3DXMATRIXA16( 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, 0.0f, 0.0f, -7.0f, 0.0f, 1.0f ), D3DXMATRIXA16( 5.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.5f, 0.0f, 0.0f, -9.0f, 0.0f, 0.0f, 5.0f, 0.2f, 5.0f, 1.0f ), D3DXMATRIXA16( 5.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.5f, 0.0f, 0.0f, -9.0f, 0.0f, 0.0f, 5.0f, 0.2f, -5.0f, 1.0f ), D3DXMATRIXA16( 5.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.5f, 0.0f, 0.0f, -9.0f, 0.0f, 0.0f, -5.0f, 0.2f, 5.0f, 1.0f ), D3DXMATRIXA16( 5.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.5f, 0.0f, 0.0f, -9.0f, 0.0f, 0.0f, -5.0f, 0.2f, -5.0f, 1.0f ), D3DXMATRIXA16( 5.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.5f, 0.0f, 0.0f, -9.0f, 0.0f, 0.0f, 14.0f, 0.2f, 14.0f, 1.0f ), D3DXMATRIXA16( 5.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.5f, 0.0f, 0.0f, -9.0f, 0.0f, 0.0f, 14.0f, 0.2f, -14.0f, 1.0f ), D3DXMATRIXA16( 5.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.5f, 0.0f, 0.0f, -9.0f, 0.0f, 0.0f, -14.0f, 0.2f, 14.0f, 1.0f ), D3DXMATRIXA16( 5.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.5f, 0.0f, 0.0f, -9.0f, 0.0f, 0.0f, -14.0f, 0.2f, -14.0f, 1.0f ), D3DXMATRIXA16( 0.9f, 0.0f, 0.0f, 0.0f, 0.0f, 0.9f, 0.0f, 0.0f, 0.0f, 0.0f, 0.9f, 0.0f, -14.5f, -9.0f, 0.0f, 1.0f ), D3DXMATRIXA16( 0.9f, 0.0f, 0.0f, 0.0f, 0.0f, 0.9f, 0.0f, 0.0f, 0.0f, 0.0f, 0.9f, 0.0f, 14.5f, -9.0f, 0.0f, 1.0f ), }; D3DVERTEXELEMENT9 g_aVertDecl[] = { { 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, { 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 }, { 0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, D3DDECL_END() }; //----------------------------------------------------------------------------- // Name: class CObj // Desc: Encapsulates a mesh object in the scene by grouping its world matrix // with the mesh. //----------------------------------------------------------------------------- #pragma warning( disable : 4324 ) struct CObj { CDXUTXFileMesh m_Mesh; D3DXMATRIXA16 m_mWorld; }; //----------------------------------------------------------------------------- // Name: class CViewCamera // Desc: A camera class derived from CFirstPersonCamera. The arrow keys and // numpad keys are disabled for this type of camera. //----------------------------------------------------------------------------- class CViewCamera : public CFirstPersonCamera { protected: virtual D3DUtil_CameraKeys MapKey( UINT nKey ) { // Provide custom mapping here. // Same as default mapping but disable arrow keys. switch( nKey ) { case 'A': return CAM_STRAFE_LEFT; case 'D': return CAM_STRAFE_RIGHT; case 'W': return CAM_MOVE_FORWARD; case 'S': return CAM_MOVE_BACKWARD; case 'Q': return CAM_MOVE_DOWN; case 'E': return CAM_MOVE_UP; case VK_HOME: return CAM_RESET; } return CAM_UNKNOWN; } }; //----------------------------------------------------------------------------- // Name: class CLightCamera // Desc: A camera class derived from CFirstPersonCamera. The letter keys // are disabled for this type of camera. This class is intended for use // by the spot light. //----------------------------------------------------------------------------- class CLightCamera : public CFirstPersonCamera { protected: virtual D3DUtil_CameraKeys MapKey( UINT nKey ) { // Provide custom mapping here. // Same as default mapping but disable arrow keys. switch( nKey ) { case VK_LEFT: return CAM_STRAFE_LEFT; case VK_RIGHT: return CAM_STRAFE_RIGHT; case VK_UP: return CAM_MOVE_FORWARD; case VK_DOWN: return CAM_MOVE_BACKWARD; case VK_PRIOR: return CAM_MOVE_UP; // pgup case VK_NEXT: return CAM_MOVE_DOWN; // pgdn case VK_NUMPAD4: return CAM_STRAFE_LEFT; case VK_NUMPAD6: return CAM_STRAFE_RIGHT; case VK_NUMPAD8: return CAM_MOVE_FORWARD; case VK_NUMPAD2: return CAM_MOVE_BACKWARD; case VK_NUMPAD9: return CAM_MOVE_UP; case VK_NUMPAD3: return CAM_MOVE_DOWN; case VK_HOME: return CAM_RESET; } return CAM_UNKNOWN; } }; //-------------------------------------------------------------------------------------- // Global variables //-------------------------------------------------------------------------------------- ID3DXFont* g_pFont = NULL; // Font for drawing text ID3DXFont* g_pFontSmall = NULL; // Font for drawing text ID3DXSprite* g_pTextSprite = NULL; // Sprite for batching draw text calls ID3DXEffect* g_pEffect = NULL; // D3DX effect interface bool g_bShowHelp = true; // If true, it renders the UI control text CDXUTDialogResourceManager g_DialogResourceManager; // manager for shared resources of dialogs CD3DSettingsDlg g_SettingsDlg; // Device settings dialog CDXUTDialog g_HUD; // dialog for standard controls CFirstPersonCamera g_VCamera; // View camera CFirstPersonCamera g_LCamera; // Camera obj to help adjust light CObj g_Obj[NUM_OBJ]; // Scene object meshes LPDIRECT3DVERTEXDECLARATION9 g_pVertDecl = NULL;// Vertex decl for the sample LPDIRECT3DTEXTURE9 g_pTexDef = NULL; // Default texture for objects D3DLIGHT9 g_Light; // The spot light in the scene CDXUTXFileMesh g_LightMesh; LPDIRECT3DTEXTURE9 g_pShadowMap = NULL; // Texture to which the shadow map is rendered LPDIRECT3DSURFACE9 g_pDSShadow = NULL; // Depth-stencil buffer for rendering to shadow map float g_fLightFov; // FOV of the spot light (in radian) D3DXMATRIXA16 g_mShadowProj; // Projection matrix for shadow map bool g_bRightMouseDown = false;// Indicates whether right mouse button is held bool g_bCameraPerspective // Indicates whether we should render view from = true; // the camera's or the light's perspective bool g_bFreeLight = true; // Whether the light is freely moveable. //-------------------------------------------------------------------------------------- // UI control IDs //-------------------------------------------------------------------------------------- #define IDC_TOGGLEFULLSCREEN 1 #define IDC_TOGGLEREF 3 #define IDC_CHANGEDEVICE 4 #define IDC_CHECKBOX 5 #define IDC_LIGHTPERSPECTIVE 6 #define IDC_ATTACHLIGHTTOCAR 7 //-------------------------------------------------------------------------------------- // Forward declarations //-------------------------------------------------------------------------------------- void InitializeDialogs(); bool CALLBACK IsDeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext ); bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, void* pUserContext ); HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ); HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ); void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext ); void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext ); void RenderText(); LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing, void* pUserContext ); void CALLBACK KeyboardProc( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext ); void CALLBACK MouseProc( bool bLeftButtonDown, bool bRightButtonDown, bool bMiddleButtonDown, bool bSideButton1Down, bool bSideButton2Down, int nMouseWheelDelta, int xPos, int yPos, void* pUserContext ); void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ); void CALLBACK OnLostDevice( void* pUserContext ); void CALLBACK OnDestroyDevice( void* pUserContext ); void RenderScene( IDirect3DDevice9* pd3dDevice, bool bRenderShadow, float fElapsedTime, const D3DXMATRIX* pmView, const D3DXMATRIX* pmProj ); //-------------------------------------------------------------------------------------- // Entry point to the program. Initializes everything and goes into a message processing // loop. Idle time is used to render the scene. //-------------------------------------------------------------------------------------- INT WINAPI wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int ) { // Enable run-time memory check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // Initialize the camera g_VCamera.SetScalers( 0.01f, 15.0f ); g_LCamera.SetScalers( 0.01f, 8.0f ); g_VCamera.SetRotateButtons( true, false, false ); g_LCamera.SetRotateButtons( false, false, true ); // Set up the view parameters for the camera D3DXVECTOR3 vFromPt = D3DXVECTOR3( 0.0f, 5.0f, -18.0f ); D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, -1.0f, 0.0f ); g_VCamera.SetViewParams( &vFromPt, &vLookatPt ); vFromPt = D3DXVECTOR3( 0.0f, 0.0f, -12.0f ); vLookatPt = D3DXVECTOR3( 0.0f, -2.0f, 1.0f ); g_LCamera.SetViewParams( &vFromPt, &vLookatPt ); // Initialize the spot light g_fLightFov = D3DX_PI / 2.0f; g_Light.Diffuse.r = 1.0f; g_Light.Diffuse.g = 1.0f; g_Light.Diffuse.b = 1.0f; g_Light.Diffuse.a = 1.0f; g_Light.Position = D3DXVECTOR3( -8.0f, -8.0f, 0.0f ); g_Light.Direction = D3DXVECTOR3( 1.0f, -1.0f, 0.0f ); D3DXVec3Normalize( ( D3DXVECTOR3* )&g_Light.Direction, ( D3DXVECTOR3* )&g_Light.Direction ); g_Light.Range = 10.0f; g_Light.Theta = g_fLightFov / 2.0f; g_Light.Phi = g_fLightFov / 2.0f; // Set the callback functions. These functions allow DXUT to notify // the application about device changes, user input, and windows messages. The // callbacks are optional so you need only set callbacks for events you're interested // in. However, if you don't handle the device reset/lost callbacks then the sample // framework won't be able to reset your device since the application must first // release all device resources before resetting. Likewise, if you don't handle the // device created/destroyed callbacks then DXUT won't be able to // recreate your device resources. DXUTSetCallbackD3D9DeviceAcceptable( IsDeviceAcceptable ); DXUTSetCallbackD3D9DeviceCreated( OnCreateDevice ); DXUTSetCallbackD3D9DeviceReset( OnResetDevice ); DXUTSetCallbackD3D9FrameRender( OnFrameRender ); DXUTSetCallbackD3D9DeviceLost( OnLostDevice ); DXUTSetCallbackD3D9DeviceDestroyed( OnDestroyDevice ); DXUTSetCallbackMsgProc( MsgProc ); DXUTSetCallbackKeyboard( KeyboardProc ); DXUTSetCallbackMouse( MouseProc ); DXUTSetCallbackFrameMove( OnFrameMove ); DXUTSetCallbackDeviceChanging( ModifyDeviceSettings ); InitializeDialogs(); // Show the cursor and clip it when in full screen DXUTSetCursorSettings( true, true ); // Initialize DXUT and create the desired Win32 window and Direct3D // device for the application. Calling each of these functions is optional, but they // allow you to set several options which control the behavior of the framework. DXUTInit( true, true ); // Parse the command line and show msgboxes DXUTSetHotkeyHandling( true, true, true ); // handle the defaul hotkeys DXUTCreateWindow( L"ShadowMap" ); DXUTCreateDevice( true, 640, 480 ); // Pass control to DXUT for handling the message pump and // dispatching render calls. DXUT will call your FrameMove // and FrameRender callback when there is idle time between handling window messages. DXUTMainLoop(); // Perform any application-level cleanup here. Direct3D device resources are released within the // appropriate callback functions and therefore don't require any cleanup code here. return DXUTGetExitCode(); } //-------------------------------------------------------------------------------------- // Sets up the dialogs //-------------------------------------------------------------------------------------- void InitializeDialogs() { g_SettingsDlg.Init( &g_DialogResourceManager ); g_HUD.Init( &g_DialogResourceManager ); g_HUD.SetCallback( OnGUIEvent ); int iY = 10; g_HUD.AddButton( IDC_TOGGLEFULLSCREEN, L"Toggle full screen", 35, iY, 125, 22 ); g_HUD.AddButton( IDC_TOGGLEREF, L"Toggle REF (F3)", 35, iY += 24, 125, 22 ); g_HUD.AddButton( IDC_CHANGEDEVICE, L"Change device (F2)", 35, iY += 24, 125, 22, VK_F2 ); g_HUD.AddCheckBox( IDC_CHECKBOX, L"Display help text", 35, iY += 24, 125, 22, true, VK_F1 ); g_HUD.AddCheckBox( IDC_LIGHTPERSPECTIVE, L"View from light's perspective", 0, iY += 24, 160, 22, false, L'V' ); g_HUD.AddCheckBox( IDC_ATTACHLIGHTTOCAR, L"Attach light to car", 0, iY += 24, 160, 22, false, L'F' ); } //-------------------------------------------------------------------------------------- // Called during device initialization, this code checks the device for some // minimum set of capabilities, and rejects those that don't pass by returning false. //-------------------------------------------------------------------------------------- bool CALLBACK IsDeviceAcceptable( D3DCAPS9* pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void* pUserContext ) { // Skip backbuffer formats that don't support alpha blending IDirect3D9* pD3D = DXUTGetD3D9Object(); if( FAILED( pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, pCaps->DeviceType, AdapterFormat, D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, BackBufferFormat ) ) ) return false; // Must support pixel shader 2.0 if( pCaps->PixelShaderVersion < D3DPS_VERSION( 2, 0 ) ) return false; // need to support D3DFMT_R32F render target if( FAILED( pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, pCaps->DeviceType, AdapterFormat, D3DUSAGE_RENDERTARGET, D3DRTYPE_CUBETEXTURE, D3DFMT_R32F ) ) ) return false; // need to support D3DFMT_A8R8G8B8 render target if( FAILED( pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, pCaps->DeviceType, AdapterFormat, D3DUSAGE_RENDERTARGET, D3DRTYPE_CUBETEXTURE, D3DFMT_A8R8G8B8 ) ) ) return false; return true; } //-------------------------------------------------------------------------------------- // This callback function is called immediately before a device is created to allow the // application to modify the device settings. The supplied pDeviceSettings parameter // contains the settings that the framework has selected for the new device, and the // application can make any desired changes directly to this structure. Note however that // DXUT will not correct invalid device settings so care must be taken // to return valid device settings, otherwise IDirect3D9::CreateDevice() will fail. //-------------------------------------------------------------------------------------- bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, void* pUserContext ) { assert( DXUT_D3D9_DEVICE == pDeviceSettings->ver ); HRESULT hr; IDirect3D9* pD3D = DXUTGetD3D9Object(); D3DCAPS9 caps; V( pD3D->GetDeviceCaps( pDeviceSettings->d3d9.AdapterOrdinal, pDeviceSettings->d3d9.DeviceType, &caps ) ); // Turn vsync off pDeviceSettings->d3d9.pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; g_SettingsDlg.GetDialogControl()->GetComboBox( DXUTSETTINGSDLG_PRESENT_INTERVAL )->SetEnabled( false ); // If device doesn't support HW T&L or doesn't support 1.1 vertex shaders in HW // then switch to SWVP. if( ( caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT ) == 0 || caps.VertexShaderVersion < D3DVS_VERSION( 1, 1 ) ) { pDeviceSettings->d3d9.BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING; } // Debugging vertex shaders requires either REF or software vertex processing // and debugging pixel shaders requires REF. #ifdef DEBUG_VS if( pDeviceSettings->d3d9.DeviceType != D3DDEVTYPE_REF ) { pDeviceSettings->d3d9.BehaviorFlags &= ~D3DCREATE_HARDWARE_VERTEXPROCESSING; pDeviceSettings->d3d9.BehaviorFlags &= ~D3DCREATE_PUREDEVICE; pDeviceSettings->d3d9.BehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; } #endif #ifdef DEBUG_PS pDeviceSettings->d3d9.DeviceType = D3DDEVTYPE_REF; #endif // For the first device created if its a REF device, optionally display a warning dialog box static bool s_bFirstTime = true; if( s_bFirstTime ) { s_bFirstTime = false; if( pDeviceSettings->d3d9.DeviceType == D3DDEVTYPE_REF ) DXUTDisplaySwitchingToREFWarning( pDeviceSettings->ver ); } return true; } //-------------------------------------------------------------------------------------- // This callback function will be called immediately after the Direct3D device has been // created, which will happen during application initialization and windowed/full screen // toggles. This is the best location to create D3DPOOL_MANAGED resources since these // resources need to be reloaded whenever the device is destroyed. Resources created // here should be released in the OnDestroyDevice callback. //-------------------------------------------------------------------------------------- HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ) { HRESULT hr; V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) ); V_RETURN( g_SettingsDlg.OnD3D9CreateDevice( pd3dDevice ) ); // Initialize the font V_RETURN( D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Arial", &g_pFont ) ); V_RETURN( D3DXCreateFont( pd3dDevice, 12, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Arial", &g_pFontSmall ) ); // Define DEBUG_VS and/or DEBUG_PS to debug vertex and/or pixel shaders with the // shader debugger. Debugging vertex shaders requires either REF or software vertex // processing, and debugging pixel shaders requires REF. The // D3DXSHADER_FORCE_*_SOFTWARE_NOOPT flag improves the debug experience in the // shader debugger. It enables source level debugging, prevents instruction // reordering, prevents dead code elimination, and forces the compiler to compile // against the next higher available software target, which ensures that the // unoptimized shaders do not exceed the shader model limitations. Setting these // flags will cause slower rendering since the shaders will be unoptimized and // forced into software. See the DirectX documentation for more information about // using the shader debugger. DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE; #if defined( DEBUG ) || defined( _DEBUG ) // Set the D3DXSHADER_DEBUG flag to embed debug information in the shaders. // Setting this flag improves the shader debugging experience, but still allows // the shaders to be optimized and to run exactly the way they will run in // the release configuration of this program. dwShaderFlags |= D3DXSHADER_DEBUG; #endif #ifdef DEBUG_VS dwShaderFlags |= D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT; #endif #ifdef DEBUG_PS dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT; #endif // Read the D3DX effect file WCHAR str[MAX_PATH]; V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"ShadowMap.fx" ) ); // If this fails, there should be debug output as to // they the .fx file failed to compile V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags, NULL, &g_pEffect, NULL ) ); // Create vertex declaration V_RETURN( pd3dDevice->CreateVertexDeclaration( g_aVertDecl, &g_pVertDecl ) ); // Initialize the meshes for( int i = 0; i < NUM_OBJ; ++i ) { V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, g_aszMeshFile[i] ) ); if( FAILED( g_Obj[i].m_Mesh.Create( pd3dDevice, str ) ) ) return DXUTERR_MEDIANOTFOUND; V_RETURN( g_Obj[i].m_Mesh.SetVertexDecl( pd3dDevice, g_aVertDecl ) ); g_Obj[i].m_mWorld = g_amInitObjWorld[i]; } // Initialize the light mesh V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"spotlight.x" ) ); if( FAILED( g_LightMesh.Create( pd3dDevice, str ) ) ) return DXUTERR_MEDIANOTFOUND; V_RETURN( g_LightMesh.SetVertexDecl( pd3dDevice, g_aVertDecl ) ); // World transform to identity D3DXMATRIXA16 mIdent; D3DXMatrixIdentity( &mIdent ); V_RETURN( pd3dDevice->SetTransform( D3DTS_WORLD, &mIdent ) ); return S_OK; } //-------------------------------------------------------------------------------------- // This callback function will be called immediately after the Direct3D device has been // reset, which will happen after a lost device scenario. This is the best location to // create D3DPOOL_DEFAULT resources since these resources need to be reloaded whenever // the device is lost. Resources created here should be released in the OnLostDevice // callback. //-------------------------------------------------------------------------------------- HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ) { HRESULT hr; V_RETURN( g_DialogResourceManager.OnD3D9ResetDevice() ); V_RETURN( g_SettingsDlg.OnD3D9ResetDevice() ); if( g_pFont ) V_RETURN( g_pFont->OnResetDevice() ); if( g_pFontSmall ) V_RETURN( g_pFontSmall->OnResetDevice() ); if( g_pEffect ) V_RETURN( g_pEffect->OnResetDevice() ); // Create a sprite to help batch calls when drawing many lines of text V_RETURN( D3DXCreateSprite( pd3dDevice, &g_pTextSprite ) ); // Setup the camera's projection parameters float fAspectRatio = pBackBufferSurfaceDesc->Width / ( FLOAT )pBackBufferSurfaceDesc->Height; g_VCamera.SetProjParams( D3DX_PI / 4, fAspectRatio, 0.1f, 100.0f ); g_LCamera.SetProjParams( D3DX_PI / 4, fAspectRatio, 0.1f, 100.0f ); // Create the default texture (used when a triangle does not use a texture) V_RETURN( pd3dDevice->CreateTexture( 1, 1, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pTexDef, NULL ) ); D3DLOCKED_RECT lr; V_RETURN( g_pTexDef->LockRect( 0, &lr, NULL, 0 ) ); *( LPDWORD )lr.pBits = D3DCOLOR_RGBA( 255, 255, 255, 255 ); V_RETURN( g_pTexDef->UnlockRect( 0 ) ); // Restore the scene objects for( int i = 0; i < NUM_OBJ; ++i ) V_RETURN( g_Obj[i].m_Mesh.RestoreDeviceObjects( pd3dDevice ) ); V_RETURN( g_LightMesh.RestoreDeviceObjects( pd3dDevice ) ); // Restore the effect variables V_RETURN( g_pEffect->SetVector( "g_vLightDiffuse", ( D3DXVECTOR4* )&g_Light.Diffuse ) ); V_RETURN( g_pEffect->SetFloat( "g_fCosTheta", cosf( g_Light.Theta ) ) ); // Create the shadow map texture V_RETURN( pd3dDevice->CreateTexture( SHADOWMAP_SIZE, SHADOWMAP_SIZE, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R32F, D3DPOOL_DEFAULT, &g_pShadowMap, NULL ) ); // Create the depth-stencil buffer to be used with the shadow map // We do this to ensure that the depth-stencil buffer is large // enough and has correct multisample type/quality when rendering // the shadow map. The default depth-stencil buffer created during // device creation will not be large enough if the user resizes the // window to a very small size. Furthermore, if the device is created // with multisampling, the default depth-stencil buffer will not // work with the shadow map texture because texture render targets // do not support multisample. DXUTDeviceSettings d3dSettings = DXUTGetDeviceSettings(); V_RETURN( pd3dDevice->CreateDepthStencilSurface( SHADOWMAP_SIZE, SHADOWMAP_SIZE, d3dSettings.d3d9.pp.AutoDepthStencilFormat, D3DMULTISAMPLE_NONE, 0, TRUE, &g_pDSShadow, NULL ) ); // Initialize the shadow projection matrix D3DXMatrixPerspectiveFovLH( &g_mShadowProj, g_fLightFov, 1, 0.01f, 100.0f ); g_HUD.SetLocation( pBackBufferSurfaceDesc->Width - 170, 0 ); g_HUD.SetSize( 170, pBackBufferSurfaceDesc->Height ); CDXUTControl* pControl = g_HUD.GetControl( IDC_LIGHTPERSPECTIVE ); if( pControl ) pControl->SetLocation( 0, pBackBufferSurfaceDesc->Height - 50 ); pControl = g_HUD.GetControl( IDC_ATTACHLIGHTTOCAR ); if( pControl ) pControl->SetLocation( 0, pBackBufferSurfaceDesc->Height - 25 ); return S_OK; } //-------------------------------------------------------------------------------------- // This callback function will be called once at the beginning of every frame. This is the // best location for your application to handle updates to the scene, but is not // intended to contain actual rendering calls, which should instead be placed in the // OnFrameRender callback. //-------------------------------------------------------------------------------------- void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext ) { // Update the camera's position based on user input g_VCamera.FrameMove( fElapsedTime ); g_LCamera.FrameMove( fElapsedTime ); // Animate the plane, car and sphere meshes D3DXMATRIXA16 m; D3DXMatrixRotationY( &m, D3DX_PI * fElapsedTime / 4.0f ); D3DXMatrixMultiply( &g_Obj[1].m_mWorld, &g_Obj[1].m_mWorld, &m ); D3DXMatrixRotationY( &m, -D3DX_PI * fElapsedTime / 4.0f ); D3DXMatrixMultiply( &g_Obj[2].m_mWorld, &g_Obj[2].m_mWorld, &m ); D3DXVECTOR3 vR( 0.1f, 1.0f, -0.2f ); D3DXMatrixRotationAxis( &m, &vR, -D3DX_PI * fElapsedTime / 6.0f ); D3DXMatrixMultiply( &g_Obj[3].m_mWorld, &m, &g_Obj[3].m_mWorld ); } //-------------------------------------------------------------------------------------- // Renders the scene onto the current render target using the current // technique in the effect. //-------------------------------------------------------------------------------------- void RenderScene( IDirect3DDevice9* pd3dDevice, bool bRenderShadow, float fElapsedTime, const D3DXMATRIX* pmView, const D3DXMATRIX* pmProj ) { HRESULT hr; // Set the projection matrix V( g_pEffect->SetMatrix( "g_mProj", pmProj ) ); // Update the light parameters in the effect if( g_bFreeLight ) { // Freely moveable light. Get light parameter // from the light camera. D3DXVECTOR3 v = *g_LCamera.GetEyePt(); D3DXVECTOR4 v4; D3DXVec3Transform( &v4, &v, pmView ); V( g_pEffect->SetVector( "g_vLightPos", &v4 ) ); *( D3DXVECTOR3* )&v4 = *g_LCamera.GetWorldAhead(); v4.w = 0.0f; // Set w 0 so that the translation part doesn't come to play D3DXVec4Transform( &v4, &v4, pmView ); // Direction in view space D3DXVec3Normalize( ( D3DXVECTOR3* )&v4, ( D3DXVECTOR3* )&v4 ); V( g_pEffect->SetVector( "g_vLightDir", &v4 ) ); } else { // Light attached to car. Get the car's world position and direction. D3DXMATRIXA16 m = g_Obj[2].m_mWorld; D3DXVECTOR3 v( m._41, m._42, m._43 ); D3DXVECTOR4 vPos; D3DXVec3Transform( &vPos, &v, pmView ); D3DXVECTOR4 v4( 0.0f, 0.0f, -1.0f, 1.0f ); // In object space, car is facing -Z m._41 = m._42 = m._43 = 0.0f; // Remove the translation D3DXVec4Transform( &v4, &v4, &m ); // Obtain direction in world space v4.w = 0.0f; // Set w 0 so that the translation part doesn't come to play D3DXVec4Transform( &v4, &v4, pmView ); // Direction in view space D3DXVec3Normalize( ( D3DXVECTOR3* )&v4, ( D3DXVECTOR3* )&v4 ); V( g_pEffect->SetVector( "g_vLightDir", &v4 ) ); vPos += v4 * 4.0f; // Offset the center by 3 so that it's closer to the headlight. V( g_pEffect->SetVector( "g_vLightPos", &vPos ) ); } // Clear the render buffers V( pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0L ) ); if( bRenderShadow ) V( g_pEffect->SetTechnique( "RenderShadow" ) ); // Begin the scene if( SUCCEEDED( pd3dDevice->BeginScene() ) ) { if( !bRenderShadow ) V( g_pEffect->SetTechnique( "RenderScene" ) ); // Render the objects for( int obj = 0; obj < NUM_OBJ; ++obj ) { D3DXMATRIXA16 mWorldView = g_Obj[obj].m_mWorld; D3DXMatrixMultiply( &mWorldView, &mWorldView, pmView ); V( g_pEffect->SetMatrix( "g_mWorldView", &mWorldView ) ); LPD3DXMESH pMesh = g_Obj[obj].m_Mesh.GetMesh(); UINT cPass; V( g_pEffect->Begin( &cPass, 0 ) ); for( UINT p = 0; p < cPass; ++p ) { V( g_pEffect->BeginPass( p ) ); for( DWORD i = 0; i < g_Obj[obj].m_Mesh.m_dwNumMaterials; ++i ) { D3DXVECTOR4 vDif( g_Obj[obj].m_Mesh.m_pMaterials[i].Diffuse.r, g_Obj[obj].m_Mesh.m_pMaterials[i].Diffuse.g, g_Obj[obj].m_Mesh.m_pMaterials[i].Diffuse.b, g_Obj[obj].m_Mesh.m_pMaterials[i].Diffuse.a ); V( g_pEffect->SetVector( "g_vMaterial", &vDif ) ); if( g_Obj[obj].m_Mesh.m_pTextures[i] ) V( g_pEffect->SetTexture( "g_txScene", g_Obj[obj].m_Mesh.m_pTextures[i] ) ) else V( g_pEffect->SetTexture( "g_txScene", g_pTexDef ) ) V( g_pEffect->CommitChanges() ); V( pMesh->DrawSubset( i ) ); } V( g_pEffect->EndPass() ); } V( g_pEffect->End() ); } // Render light if( !bRenderShadow ) V( g_pEffect->SetTechnique( "RenderLight" ) ); D3DXMATRIXA16 mWorldView = *g_LCamera.GetWorldMatrix(); D3DXMatrixMultiply( &mWorldView, &mWorldView, pmView ); V( g_pEffect->SetMatrix( "g_mWorldView", &mWorldView ) ); UINT cPass; LPD3DXMESH pMesh = g_LightMesh.GetMesh(); V( g_pEffect->Begin( &cPass, 0 ) ); for( UINT p = 0; p < cPass; ++p ) { V( g_pEffect->BeginPass( p ) ); for( DWORD i = 0; i < g_LightMesh.m_dwNumMaterials; ++i ) { D3DXVECTOR4 vDif( g_LightMesh.m_pMaterials[i].Diffuse.r, g_LightMesh.m_pMaterials[i].Diffuse.g, g_LightMesh.m_pMaterials[i].Diffuse.b, g_LightMesh.m_pMaterials[i].Diffuse.a ); V( g_pEffect->SetVector( "g_vMaterial", &vDif ) ); V( g_pEffect->SetTexture( "g_txScene", g_LightMesh.m_pTextures[i] ) ); V( g_pEffect->CommitChanges() ); V( pMesh->DrawSubset( i ) ); } V( g_pEffect->EndPass() ); } V( g_pEffect->End() ); if( !bRenderShadow ) // Render stats and help text RenderText(); // Render the UI elements if( !bRenderShadow ) g_HUD.OnRender( fElapsedTime ); V( pd3dDevice->EndScene() ); } } //-------------------------------------------------------------------------------------- // This callback function will be called at the end of every frame to perform all the // rendering calls for the scene, and it will also be called if the window needs to be // repainted. After this function has returned, DXUT will call // IDirect3DDevice9::Present to display the contents of the next buffer in the swap chain //-------------------------------------------------------------------------------------- void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext ) { // If the settings dialog is being shown, then // render it instead of rendering the app's scene if( g_SettingsDlg.IsActive() ) { g_SettingsDlg.OnRender( fElapsedTime ); return; } HRESULT hr; // // Compute the view matrix for the light // This changes depending on the light mode // (free movement or attached) // D3DXMATRIXA16 mLightView; if( g_bFreeLight ) mLightView = *g_LCamera.GetViewMatrix(); else { // Light attached to car. mLightView = g_Obj[2].m_mWorld; D3DXVECTOR3 vPos( mLightView._41, mLightView._42, mLightView._43 ); // Offset z by -2 so that it's closer to headlight D3DXVECTOR4 vDir = D3DXVECTOR4( 0.0f, 0.0f, -1.0f, 1.0f ); // In object space, car is facing -Z mLightView._41 = mLightView._42 = mLightView._43 = 0.0f; // Remove the translation D3DXVec4Transform( &vDir, &vDir, &mLightView ); // Obtain direction in world space vDir.w = 0.0f; // Set w 0 so that the translation part below doesn't come to play D3DXVec4Normalize( &vDir, &vDir ); vPos.x += vDir.x * 4.0f; // Offset the center by 4 so that it's closer to the headlight vPos.y += vDir.y * 4.0f; vPos.z += vDir.z * 4.0f; vDir.x += vPos.x; // vDir denotes the look-at point vDir.y += vPos.y; vDir.z += vPos.z; D3DXVECTOR3 vUp( 0.0f, 1.0f, 0.0f ); D3DXMatrixLookAtLH( &mLightView, &vPos, ( D3DXVECTOR3* )&vDir, &vUp ); } // // Render the shadow map // LPDIRECT3DSURFACE9 pOldRT = NULL; V( pd3dDevice->GetRenderTarget( 0, &pOldRT ) ); LPDIRECT3DSURFACE9 pShadowSurf; if( SUCCEEDED( g_pShadowMap->GetSurfaceLevel( 0, &pShadowSurf ) ) ) { pd3dDevice->SetRenderTarget( 0, pShadowSurf ); SAFE_RELEASE( pShadowSurf ); } LPDIRECT3DSURFACE9 pOldDS = NULL; if( SUCCEEDED( pd3dDevice->GetDepthStencilSurface( &pOldDS ) ) ) pd3dDevice->SetDepthStencilSurface( g_pDSShadow ); { CDXUTPerfEventGenerator g( DXUT_PERFEVENTCOLOR, L"Shadow Map" ); RenderScene( pd3dDevice, true, fElapsedTime, &mLightView, &g_mShadowProj ); } if( pOldDS ) { pd3dDevice->SetDepthStencilSurface( pOldDS ); pOldDS->Release(); } pd3dDevice->SetRenderTarget( 0, pOldRT ); SAFE_RELEASE( pOldRT ); // // Now that we have the shadow map, render the scene. // const D3DXMATRIX* pmView = g_bCameraPerspective ? g_VCamera.GetViewMatrix() : &mLightView; // Initialize required parameter V( g_pEffect->SetTexture( "g_txShadow", g_pShadowMap ) ); // Compute the matrix to transform from view space to // light projection space. This consists of // the inverse of view matrix * view matrix of light * light projection matrix D3DXMATRIXA16 mViewToLightProj; mViewToLightProj = *pmView; D3DXMatrixInverse( &mViewToLightProj, NULL, &mViewToLightProj ); D3DXMatrixMultiply( &mViewToLightProj, &mViewToLightProj, &mLightView ); D3DXMatrixMultiply( &mViewToLightProj, &mViewToLightProj, &g_mShadowProj ); V( g_pEffect->SetMatrix( "g_mViewToLightProj", &mViewToLightProj ) ); { CDXUTPerfEventGenerator g( DXUT_PERFEVENTCOLOR, L"Scene" ); RenderScene( pd3dDevice, false, fElapsedTime, pmView, g_VCamera.GetProjMatrix() ); } g_pEffect->SetTexture( "g_txShadow", NULL ); } //-------------------------------------------------------------------------------------- // Render the help and statistics text. This function uses the ID3DXFont interface for // efficient text rendering. //-------------------------------------------------------------------------------------- void RenderText() { // The helper object simply helps keep track of text position, and color // and then it calls pFont->DrawText( m_pSprite, strMsg, -1, &rc, DT_NOCLIP, m_clr ); // If NULL is passed in as the sprite object, then it will work however the // pFont->DrawText() will not be batched together. Batching calls will improves performance. CDXUTTextHelper txtHelper( g_pFont, g_pTextSprite, 15 ); // Output statistics txtHelper.Begin(); txtHelper.SetInsertionPos( 5, 5 ); txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 0.0f, 1.0f ) ); txtHelper.DrawTextLine( DXUTGetFrameStats( DXUTIsVsyncEnabled() ) ); // Show FPS txtHelper.DrawTextLine( DXUTGetDeviceStats() ); txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) ); // Draw help if( g_bShowHelp ) { const D3DSURFACE_DESC* pd3dsdBackBuffer = DXUTGetD3D9BackBufferSurfaceDesc(); txtHelper.SetInsertionPos( 10, pd3dsdBackBuffer->Height - 15 * 10 ); txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 0.75f, 0.0f, 1.0f ) ); txtHelper.DrawTextLine( L"Controls:" ); txtHelper.SetInsertionPos( 15, pd3dsdBackBuffer->Height - 15 * 9 ); WCHAR text[512]; swprintf_s(text,L"Rotate camera\nMove camera\n" L"Rotate light\nMove light\n" L"Change light mode (Current: %s)\nChange view reference (Current: %s)\n" L"Hidehelp\nQuit", g_bFreeLight ? L"Free" : L"Car-attached", g_bCameraPerspective ? L"Camera" : L"Light" ); txtHelper.DrawTextLine(text); txtHelper.SetInsertionPos( 265, pd3dsdBackBuffer->Height - 15 * 9 ); txtHelper.DrawTextLine( L"Left drag mouse\nW,S,A,D,Q,E\n" L"Right drag mouse\nW,S,A,D,Q,E while holding right mouse\n" L"F\nV\nF1\nESC" ); } else { txtHelper.SetForegroundColor( D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) ); txtHelper.DrawTextLine( L"Press F1 for help" ); } txtHelper.End(); } //-------------------------------------------------------------------------------------- // Before handling window messages, DXUT passes incoming windows // messages to the application through this callback function. If the application sets // *pbNoFurtherProcessing to TRUE, then DXUT will not process this message. //-------------------------------------------------------------------------------------- LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing, void* pUserContext ) { // Always allow dialog resource manager calls to handle global messages // so GUI state is updated correctly *pbNoFurtherProcessing = g_DialogResourceManager.MsgProc( hWnd, uMsg, wParam, lParam ); if( *pbNoFurtherProcessing ) return 0; if( g_SettingsDlg.IsActive() ) { g_SettingsDlg.MsgProc( hWnd, uMsg, wParam, lParam ); return 0; } *pbNoFurtherProcessing = g_HUD.MsgProc( hWnd, uMsg, wParam, lParam ); if( *pbNoFurtherProcessing ) return 0; // Pass all windows messages to camera and dialogs so they can respond to user input if( WM_KEYDOWN != uMsg || g_bRightMouseDown ) g_LCamera.HandleMessages( hWnd, uMsg, wParam, lParam ); if( WM_KEYDOWN != uMsg || !g_bRightMouseDown ) { if( g_bCameraPerspective ) g_VCamera.HandleMessages( hWnd, uMsg, wParam, lParam ); else g_LCamera.HandleMessages( hWnd, uMsg, wParam, lParam ); } return 0; } //-------------------------------------------------------------------------------------- // As a convenience, DXUT inspects the incoming windows messages for // keystroke messages and decodes the message parameters to pass relevant keyboard // messages to the application. The framework does not remove the underlying keystroke // messages, which are still passed to the application's MsgProc callback. //-------------------------------------------------------------------------------------- void CALLBACK KeyboardProc( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext ) { } void CALLBACK MouseProc( bool bLeftButtonDown, bool bRightButtonDown, bool bMiddleButtonDown, bool bSideButton1Down, bool bSideButton2Down, int nMouseWheelDelta, int xPos, int yPos, void* pUserContext ) { g_bRightMouseDown = bRightButtonDown; } //-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_SettingsDlg.SetActive( !g_SettingsDlg.IsActive() ); break; case IDC_CHECKBOX: { CDXUTCheckBox* pCheck = ( CDXUTCheckBox* )pControl; g_bShowHelp = pCheck->GetChecked(); break; } case IDC_LIGHTPERSPECTIVE: { CDXUTCheckBox* pCheck = ( CDXUTCheckBox* )pControl; g_bCameraPerspective = !pCheck->GetChecked(); if( g_bCameraPerspective ) { g_VCamera.SetRotateButtons( true, false, false ); g_LCamera.SetRotateButtons( false, false, true ); } else { g_VCamera.SetRotateButtons( false, false, false ); g_LCamera.SetRotateButtons( true, false, true ); } break; } case IDC_ATTACHLIGHTTOCAR: { CDXUTCheckBox* pCheck = ( CDXUTCheckBox* )pControl; g_bFreeLight = !pCheck->GetChecked(); break; } } } //-------------------------------------------------------------------------------------- // This callback function will be called immediately after the Direct3D device has // entered a lost state and before IDirect3DDevice9::Reset is called. Resources created // in the OnResetDevice callback should be released here, which generally includes all // D3DPOOL_DEFAULT resources. See the "Lost Devices" section of the documentation for // information about lost devices. //-------------------------------------------------------------------------------------- void CALLBACK OnLostDevice( void* pUserContext ) { g_DialogResourceManager.OnD3D9LostDevice(); g_SettingsDlg.OnD3D9LostDevice(); if( g_pFont ) g_pFont->OnLostDevice(); if( g_pFontSmall ) g_pFontSmall->OnLostDevice(); if( g_pEffect ) g_pEffect->OnLostDevice(); SAFE_RELEASE( g_pTextSprite ); SAFE_RELEASE( g_pDSShadow ); SAFE_RELEASE( g_pShadowMap ); SAFE_RELEASE( g_pTexDef ); for( int i = 0; i < NUM_OBJ; ++i ) g_Obj[i].m_Mesh.InvalidateDeviceObjects(); g_LightMesh.InvalidateDeviceObjects(); } //-------------------------------------------------------------------------------------- // This callback function will be called immediately after the Direct3D device has // been destroyed, which generally happens as a result of application termination or // windowed/full screen toggles. Resources created in the OnCreateDevice callback // should be released here, which generally includes all D3DPOOL_MANAGED resources. //-------------------------------------------------------------------------------------- void CALLBACK OnDestroyDevice( void* pUserContext ) { g_DialogResourceManager.OnD3D9DestroyDevice(); g_SettingsDlg.OnD3D9DestroyDevice(); SAFE_RELEASE( g_pEffect ); SAFE_RELEASE( g_pFont ); SAFE_RELEASE( g_pFontSmall ); SAFE_RELEASE( g_pVertDecl ); SAFE_RELEASE( g_pEffect ); for( int i = 0; i < NUM_OBJ; ++i ) g_Obj[i].m_Mesh.Destroy(); g_LightMesh.Destroy(); }
44.763686
128
0.573001
walbourn
f5da61636291a496c1598e7b1bfba63cad7ea3ce
1,970
cpp
C++
examples/Example5/Menu.cpp
hasaranga/RFC-Framework
9c1881d412db6f9f7670b910a0918a631208cfd1
[ "MIT" ]
9
2017-10-02T08:15:50.000Z
2021-08-09T21:29:46.000Z
examples/Example5/Menu.cpp
hasaranga/RFC-Framework
9c1881d412db6f9f7670b910a0918a631208cfd1
[ "MIT" ]
1
2021-09-18T07:38:53.000Z
2021-09-26T12:11:48.000Z
examples/Example5/Menu.cpp
hasaranga/RFC-Framework
9c1881d412db6f9f7670b910a0918a631208cfd1
[ "MIT" ]
8
2017-10-02T13:21:29.000Z
2021-07-30T09:35:31.000Z
#include "../../amalgamated/rfc_amalgamated.h" class MyWindow : public KFrame, public KMenuItemListener { protected: KMenuBar menuBar; KMenu mFile, mEdit, mHelp; KMenuItem miOpen, miExit, miCut, miCopy, miPaste, miAbout; public: MyWindow() { this->SetText(L"My Window"); this->Create(); miOpen.SetText(L"Open..."); miExit.SetText(L"Exit"); miCut.SetText(L"Cut"); miCopy.SetText(L"Copy"); miPaste.SetText(L"Paste"); miAbout.SetText(L"About..."); miOpen.SetListener(this); miExit.SetListener(this); miCut.SetListener(this); miCopy.SetListener(this); miPaste.SetListener(this); miAbout.SetListener(this); // add menu items into menu mFile.AddMenuItem(&miOpen); mFile.AddSeperator(); mFile.AddMenuItem(&miExit); mEdit.AddMenuItem(&miCut); mEdit.AddSeperator(); mEdit.AddMenuItem(&miCopy); mEdit.AddMenuItem(&miPaste); mHelp.AddMenuItem(&miAbout); // add menu into menubar menuBar.AddMenu(L"File", &mFile); menuBar.AddMenu(L"Edit", &mEdit); menuBar.AddMenu(L"Help", &mHelp); menuBar.AddToWindow(this); // add menubar into the window } void OnMenuItemPress(KMenuItem *menuItem) { if (menuItem == &miAbout) { ::MessageBoxW(this->GetHWND(), L"RFC Menu/Popup Example", L"About", MB_ICONINFORMATION); } else if (menuItem == &miExit) { this->OnClose(); // destroy window and quit from message loop! } } // macro to handle window messages... BEGIN_KMSG_HANDLER ON_KMSG(WM_RBUTTONUP, OnRClickWindow) // call OnRClickWindow method when WM_RBUTTONUP msg received END_KMSG_HANDLER(KFrame) // KFrame is our parent! LRESULT OnRClickWindow(WPARAM wParam, LPARAM lParam) { mEdit.PopUpMenu(this); // show mEdit menu as popup return 0; } }; class MyApplication : public KApplication { public: int Main(KString **argv, int argc) { MyWindow window; window.CenterScreen(); window.SetVisible(true); ::DoMessagePump(); return 0; } }; START_RFC_APPLICATION(MyApplication);
21.648352
100
0.706091
hasaranga
f5db9b1cd4ab5149de5c2222e5504e1d8fafbf02
2,726
cpp
C++
Day7/Day7.cpp
ATRI17Z/adventofcode18
5d743d7d277b416e3b5a287b0df598c4d5d67c6f
[ "MIT" ]
1
2018-12-05T18:32:50.000Z
2018-12-05T18:32:50.000Z
Day7/Day7.cpp
ATRI17Z/adventofcode18
5d743d7d277b416e3b5a287b0df598c4d5d67c6f
[ "MIT" ]
null
null
null
Day7/Day7.cpp
ATRI17Z/adventofcode18
5d743d7d277b416e3b5a287b0df598c4d5d67c6f
[ "MIT" ]
null
null
null
#include <iostream> #include <fstream> #include <sstream> #include <string> #include <vector> #include <map> #include <deque> #include <algorithm> #include <climits> #include <chrono> #include "InstructionScheduler.h" std::string getInputAsString(std::string); std::vector<std::string> getInputPerLines(std::string); /******************************************************** * Day 7 Puzzle: * Using an OO approach to have objects for each task * and each worker. To to its morphological creation * the solution is not clean at all but at least it works * at is. Many things should be improved in multiple ways */ int main() { auto start = std::chrono::high_resolution_clock::now(); std::string str; std::ifstream input; std::vector<std::string> lines; InstructionScheduler scheduler = InstructionScheduler(); // Load input as Single String //str = getInputAsString("input_Day7_test.txt"); // Get Input as vector of lines lines = getInputPerLines("input_Day7.txt"); for (int i = 0; i < lines.size(); ++i) { std::string before, after; before = lines[i][5]; after = lines[i][36]; // Create Instructions scheduler.addInstruction(before, after); //scheduler.printInstructions(); } // Schedule Instructions PART ONE std::cout << std::endl << "PART ONE: " << std::endl; scheduler.getSchedule(); auto finishONE = std::chrono::high_resolution_clock::now(); // Schedule Instructions PART TWO std::cout << std::endl << "PART TWO: " << std::endl; //scheduler.getTimedSchedule(2); // for testData scheduler.getTimedSchedule(5); auto finishTWO = std::chrono::high_resolution_clock::now(); std::chrono::duration<double> elapsedONE = finishONE - start; std::chrono::duration<double> elapsedTWO = finishTWO - finishONE; std::cout << "Elapsed time: P1: " << elapsedONE.count() * 1000 << "ms P2: " << elapsedTWO.count() * 1000 << "ms" << std::endl; return 0; } /****************************** * INPUT HELPER FUNCTIONS * ******************************/ std::string getInputAsString(std::string fileName) { std::string str; // Open File std::ifstream in(fileName); if (!in.is_open() || !in.good()) { std::cout << "Failed to open input" << std::endl; return 0; } // Create String str.assign((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>()); in.close(); return str; } std::vector<std::string> getInputPerLines(std::string fileName) { std::vector<std::string> lines; std::string line; // Open File std::ifstream in(fileName); if (!in.is_open() || !in.good()) { std::cout << "Failed to open input" << std::endl; } // Create Vector of lines while (getline(in, line)) { lines.push_back(line); } in.close(); return lines; }
26.211538
127
0.65077
ATRI17Z
f5dd62ffee22fc4d427e125832b5a72e4e6777dc
2,215
cpp
C++
test/test_stable_sort_large.cpp
pruthvistony/rocThrust
c986b97395d4a6cbacc7a4600d11bdf389de639a
[ "Apache-2.0" ]
null
null
null
test/test_stable_sort_large.cpp
pruthvistony/rocThrust
c986b97395d4a6cbacc7a4600d11bdf389de639a
[ "Apache-2.0" ]
null
null
null
test/test_stable_sort_large.cpp
pruthvistony/rocThrust
c986b97395d4a6cbacc7a4600d11bdf389de639a
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2008-2013 NVIDIA Corporation * Modifications Copyright© 2019 Advanced Micro Devices, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <thrust/functional.h> #include <thrust/sort.h> #include "test_header.hpp" template <typename T, unsigned int N> void _TestStableSortWithLargeKeys(void) { size_t n = (128 * 1024) / sizeof(FixedVector<T, N>); thrust::host_vector<FixedVector<T, N>> h_keys(n); for(size_t i = 0; i < n; i++) h_keys[i] = FixedVector<T, N>(rand()); thrust::device_vector<FixedVector<T, N>> d_keys = h_keys; thrust::stable_sort(h_keys.begin(), h_keys.end()); thrust::stable_sort(d_keys.begin(), d_keys.end()); ASSERT_EQ_QUIET(h_keys, d_keys); } TEST(StableSortLargeTests, TestStableSortWithLargeKeys) { _TestStableSortWithLargeKeys<int, 1>(); _TestStableSortWithLargeKeys<int, 2>(); _TestStableSortWithLargeKeys<int, 4>(); _TestStableSortWithLargeKeys<int, 8>(); // STREAM HPC investigate and fix `error: local memory limit exceeded` // (make block size smaller for large keys and values in rocPRIM) #if THRUST_DEVICE_SYSTEM != THRUST_DEVICE_SYSTEM_HIP _TestStableSortWithLargeKeys<int, 16>(); _TestStableSortWithLargeKeys<int, 32>(); _TestStableSortWithLargeKeys<int, 64>(); _TestStableSortWithLargeKeys<int, 128>(); _TestStableSortWithLargeKeys<int, 256>(); _TestStableSortWithLargeKeys<int, 512>(); _TestStableSortWithLargeKeys<int, 1024>(); // XXX these take too long to compile // _TestStableSortWithLargeKeys<int, 2048>(); // _TestStableSortWithLargeKeys<int, 4096>(); // _TestStableSortWithLargeKeys<int, 8192>(); #endif }
34.609375
83
0.722799
pruthvistony
f5def028edf9cc51d0028f1345017031b1c31b25
947
cpp
C++
#Preparation/Placement-Overview/PrepInsta/max-contiguos-array.cpp
sounishnath003/CPP-for-beginner
d4755ab4ae098d63c9a0666d8eb4d152106d4a20
[ "MIT" ]
4
2020-05-14T04:41:04.000Z
2021-06-13T06:42:03.000Z
#Preparation/Placement-Overview/PrepInsta/max-contiguos-array.cpp
sounishnath003/CPP-for-beginner
d4755ab4ae098d63c9a0666d8eb4d152106d4a20
[ "MIT" ]
null
null
null
#Preparation/Placement-Overview/PrepInsta/max-contiguos-array.cpp
sounishnath003/CPP-for-beginner
d4755ab4ae098d63c9a0666d8eb4d152106d4a20
[ "MIT" ]
null
null
null
#include<bits/stdc++.h> #define fo(i, n) for(int i = 1; i < n; i++) using namespace std ; #define deb(x) {cout << #x << " " << x << endl ;} int max_contiguos_subarray(vector<int> &nums) { stack<int> cached ; cached.push(nums[0]) ; int n = nums.size() ; int cnt = INT_MIN, t = 0 ; if(is_sorted(nums.begin(), nums.end(), less<int>{})) return nums.size() ; if(is_sorted(nums.begin(), nums.end(), greater<int>{})) return 0 ; fo(i, n) { if (cached.top() > nums[i] ) { t = cached.size() ; while(!cached.empty()) { cached.pop() ; } cached.push(nums[i]) ; } if (cached.top() < nums[i]) { cached.push(nums[i]) ; int l = cached.size() ; cnt = max(cnt, l) ; } } return max(cnt, t); } int main(int argc, char const *argv[]){ ios::sync_with_stdio(0) ; vector<int> nums{60, 45, 48, 52}; cout << go(nums) ; return 0; }
24.921053
77
0.510032
sounishnath003
f5df0e72004df1e45f4c36c00742299324900e40
1,209
hpp
C++
include/nodamushi/svd/value/void_value.hpp
nodamushi/nsvd-reader
cf3a840aaac78d5791df1cf045596ec20dc03257
[ "CC0-1.0" ]
null
null
null
include/nodamushi/svd/value/void_value.hpp
nodamushi/nsvd-reader
cf3a840aaac78d5791df1cf045596ec20dc03257
[ "CC0-1.0" ]
null
null
null
include/nodamushi/svd/value/void_value.hpp
nodamushi/nsvd-reader
cf3a840aaac78d5791df1cf045596ec20dc03257
[ "CC0-1.0" ]
null
null
null
/*! @brief value&lt;void&gt; @file nodamushi/svd/value/void_value.hpp */ /* * These codes are licensed under CC0. * http://creativecommons.org/publicdomain/zero/1.0/ */ #ifndef NODAMUSHI_SVD_VALUE_VOID_VALUE_HPP #define NODAMUSHI_SVD_VALUE_VOID_VALUE_HPP # include "nodamushi/svd/value.hpp" namespace nodamushi{ namespace svd{ // void template<bool attribute,bool r,char... name>struct value<void,attribute,r,name...> { using type = void; static constexpr bool REQUIRED=false; static constexpr bool ATTRIBUTE=attribute; constexpr bool empty()const noexcept{return true;} constexpr operator bool()const noexcept{return false;} constexpr bool check_require()const noexcept{return true;} constexpr bool is_required()const noexcept{return false;} constexpr bool is_attribute()const noexcept{return attribute;} int operator*()const noexcept{return 0;} int get()const noexcept{return 0;} NODAMUSHI_CONSTEXPR_STRING get_name()const noexcept { # if __cplusplus >= 201703 return get_const_string<name...>(); # else const char arr[] = {name...,'\0'}; return std::string(arr); # endif } }; }}// end namespace nodamushi::svd #endif // NODAMUSHI_SVD_VALUE_VOID_VALUE_HPP
26.866667
82
0.74359
nodamushi
f5e62da46a8c8e64f061e76cbf2b946a01371188
3,721
cpp
C++
aws-cpp-sdk-lambda/source/model/UpdateEventSourceMappingRequest.cpp
blinemedical/aws-sdk-cpp
c7c814b2d6862b4cb48f3fb3ac083a9e419674e8
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-lambda/source/model/UpdateEventSourceMappingRequest.cpp
blinemedical/aws-sdk-cpp
c7c814b2d6862b4cb48f3fb3ac083a9e419674e8
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-lambda/source/model/UpdateEventSourceMappingRequest.cpp
blinemedical/aws-sdk-cpp
c7c814b2d6862b4cb48f3fb3ac083a9e419674e8
[ "Apache-2.0" ]
1
2022-03-23T15:17:18.000Z
2022-03-23T15:17:18.000Z
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/lambda/model/UpdateEventSourceMappingRequest.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::Lambda::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; UpdateEventSourceMappingRequest::UpdateEventSourceMappingRequest() : m_uUIDHasBeenSet(false), m_functionNameHasBeenSet(false), m_enabled(false), m_enabledHasBeenSet(false), m_batchSize(0), m_batchSizeHasBeenSet(false), m_maximumBatchingWindowInSeconds(0), m_maximumBatchingWindowInSecondsHasBeenSet(false), m_destinationConfigHasBeenSet(false), m_maximumRecordAgeInSeconds(0), m_maximumRecordAgeInSecondsHasBeenSet(false), m_bisectBatchOnFunctionError(false), m_bisectBatchOnFunctionErrorHasBeenSet(false), m_maximumRetryAttempts(0), m_maximumRetryAttemptsHasBeenSet(false), m_parallelizationFactor(0), m_parallelizationFactorHasBeenSet(false), m_sourceAccessConfigurationsHasBeenSet(false), m_tumblingWindowInSeconds(0), m_tumblingWindowInSecondsHasBeenSet(false), m_functionResponseTypesHasBeenSet(false) { } Aws::String UpdateEventSourceMappingRequest::SerializePayload() const { JsonValue payload; if(m_functionNameHasBeenSet) { payload.WithString("FunctionName", m_functionName); } if(m_enabledHasBeenSet) { payload.WithBool("Enabled", m_enabled); } if(m_batchSizeHasBeenSet) { payload.WithInteger("BatchSize", m_batchSize); } if(m_maximumBatchingWindowInSecondsHasBeenSet) { payload.WithInteger("MaximumBatchingWindowInSeconds", m_maximumBatchingWindowInSeconds); } if(m_destinationConfigHasBeenSet) { payload.WithObject("DestinationConfig", m_destinationConfig.Jsonize()); } if(m_maximumRecordAgeInSecondsHasBeenSet) { payload.WithInteger("MaximumRecordAgeInSeconds", m_maximumRecordAgeInSeconds); } if(m_bisectBatchOnFunctionErrorHasBeenSet) { payload.WithBool("BisectBatchOnFunctionError", m_bisectBatchOnFunctionError); } if(m_maximumRetryAttemptsHasBeenSet) { payload.WithInteger("MaximumRetryAttempts", m_maximumRetryAttempts); } if(m_parallelizationFactorHasBeenSet) { payload.WithInteger("ParallelizationFactor", m_parallelizationFactor); } if(m_sourceAccessConfigurationsHasBeenSet) { Array<JsonValue> sourceAccessConfigurationsJsonList(m_sourceAccessConfigurations.size()); for(unsigned sourceAccessConfigurationsIndex = 0; sourceAccessConfigurationsIndex < sourceAccessConfigurationsJsonList.GetLength(); ++sourceAccessConfigurationsIndex) { sourceAccessConfigurationsJsonList[sourceAccessConfigurationsIndex].AsObject(m_sourceAccessConfigurations[sourceAccessConfigurationsIndex].Jsonize()); } payload.WithArray("SourceAccessConfigurations", std::move(sourceAccessConfigurationsJsonList)); } if(m_tumblingWindowInSecondsHasBeenSet) { payload.WithInteger("TumblingWindowInSeconds", m_tumblingWindowInSeconds); } if(m_functionResponseTypesHasBeenSet) { Array<JsonValue> functionResponseTypesJsonList(m_functionResponseTypes.size()); for(unsigned functionResponseTypesIndex = 0; functionResponseTypesIndex < functionResponseTypesJsonList.GetLength(); ++functionResponseTypesIndex) { functionResponseTypesJsonList[functionResponseTypesIndex].AsString(FunctionResponseTypeMapper::GetNameForFunctionResponseType(m_functionResponseTypes[functionResponseTypesIndex])); } payload.WithArray("FunctionResponseTypes", std::move(functionResponseTypesJsonList)); } return payload.View().WriteReadable(); }
28.189394
185
0.795485
blinemedical
f5e7fb6b5b4a64f49bd06875a5235830160f3ff3
46,697
cpp
C++
cmdstan/stan/lib/stan_math/test/unit/math/mix/mat/fun/operator_subtraction_test.cpp
yizhang-cae/torsten
dc82080ca032325040844cbabe81c9a2b5e046f9
[ "BSD-3-Clause" ]
null
null
null
cmdstan/stan/lib/stan_math/test/unit/math/mix/mat/fun/operator_subtraction_test.cpp
yizhang-cae/torsten
dc82080ca032325040844cbabe81c9a2b5e046f9
[ "BSD-3-Clause" ]
null
null
null
cmdstan/stan/lib/stan_math/test/unit/math/mix/mat/fun/operator_subtraction_test.cpp
yizhang-cae/torsten
dc82080ca032325040844cbabe81c9a2b5e046f9
[ "BSD-3-Clause" ]
null
null
null
#include <stan/math/mix/mat.hpp> #include <gtest/gtest.h> #include <test/unit/math/rev/mat/fun/util.hpp> using stan::math::fvar; TEST(AgradMixMatrixOperatorSubtraction,fv_scalar_matrix_1stDeriv) { using stan::math::subtract; using stan::math::matrix_fv; matrix_fv v(2,2); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; matrix_fv result; result = subtract(2.0,v); EXPECT_FLOAT_EQ(1.0,result(0,0).val_.val()); EXPECT_FLOAT_EQ(0.0,result(0,1).val_.val()); EXPECT_FLOAT_EQ(-1.0,result(1,0).val_.val()); EXPECT_FLOAT_EQ(-2.0,result(1,1).val_.val()); EXPECT_FLOAT_EQ(-1.0,result(0,0).d_.val()); EXPECT_FLOAT_EQ(-1.0,result(0,1).d_.val()); EXPECT_FLOAT_EQ(-1.0,result(1,0).d_.val()); EXPECT_FLOAT_EQ(-1.0,result(1,1).d_.val()); result = subtract(v,2.0); EXPECT_FLOAT_EQ(-1.0,result(0,0).val_.val()); EXPECT_FLOAT_EQ(0.0,result(0,1).val_.val()); EXPECT_FLOAT_EQ(1.0,result(1,0).val_.val()); EXPECT_FLOAT_EQ(2.0,result(1,1).val_.val()); EXPECT_FLOAT_EQ(1.0,result(0,0).d_.val()); EXPECT_FLOAT_EQ(1.0,result(0,1).d_.val()); EXPECT_FLOAT_EQ(1.0,result(1,0).d_.val()); EXPECT_FLOAT_EQ(1.0,result(1,1).d_.val()); AVEC q = createAVEC(v(0,0).val(),v(0,1).val(),v(1,0).val(),v(1,1).val()); VEC h; result(0,0).val_.grad(q,h); EXPECT_FLOAT_EQ(1,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,fv_scalar_matrix_2ndDeriv) { using stan::math::subtract; using stan::math::matrix_fv; matrix_fv v(2,2); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; matrix_fv result; result = subtract(v,2.0); AVEC q = createAVEC(v(0,0).val(),v(0,1).val(),v(1,0).val(),v(1,1).val()); VEC h; result(0,0).d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,fv_scalar_vector_1stDeriv) { using stan::math::subtract; using stan::math::vector_fv; vector_fv v(4); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; vector_fv result; result = subtract(2.0,v); EXPECT_FLOAT_EQ(1.0,result(0).val_.val()); EXPECT_FLOAT_EQ(0.0,result(1).val_.val()); EXPECT_FLOAT_EQ(-1.0,result(2).val_.val()); EXPECT_FLOAT_EQ(-2.0,result(3).val_.val()); EXPECT_FLOAT_EQ(-1.0,result(0).d_.val()); EXPECT_FLOAT_EQ(-1.0,result(1).d_.val()); EXPECT_FLOAT_EQ(-1.0,result(3).d_.val()); EXPECT_FLOAT_EQ(-1.0,result(3).d_.val()); result = subtract(v,2.0); EXPECT_FLOAT_EQ(-1.0,result(0).val_.val()); EXPECT_FLOAT_EQ(0.0,result(1).val_.val()); EXPECT_FLOAT_EQ(1.0,result(2).val_.val()); EXPECT_FLOAT_EQ(2.0,result(3).val_.val()); EXPECT_FLOAT_EQ(1.0,result(0).d_.val()); EXPECT_FLOAT_EQ(1.0,result(1).d_.val()); EXPECT_FLOAT_EQ(1.0,result(3).d_.val()); EXPECT_FLOAT_EQ(1.0,result(3).d_.val()); AVEC q = createAVEC(v(0).val(),v(1).val(),v(2).val(),v(3).val()); VEC h; result(0).val_.grad(q,h); EXPECT_FLOAT_EQ(1,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,fv_scalar_vector_2ndDeriv) { using stan::math::subtract; using stan::math::vector_fv; vector_fv v(4); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; vector_fv result; result = subtract(v,2.0); AVEC q = createAVEC(v(0).val(),v(1).val(),v(2).val(),v(3).val()); VEC h; result(0).d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,fv_scalar_rowvector_1stDeriv) { using stan::math::subtract; using stan::math::row_vector_fv; row_vector_fv v(4); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; row_vector_fv result; result = subtract(2.0,v); EXPECT_FLOAT_EQ(1.0,result(0).val_.val()); EXPECT_FLOAT_EQ(0.0,result(1).val_.val()); EXPECT_FLOAT_EQ(-1.0,result(2).val_.val()); EXPECT_FLOAT_EQ(-2.0,result(3).val_.val()); EXPECT_FLOAT_EQ(-1.0,result(0).d_.val()); EXPECT_FLOAT_EQ(-1.0,result(1).d_.val()); EXPECT_FLOAT_EQ(-1.0,result(3).d_.val()); EXPECT_FLOAT_EQ(-1.0,result(3).d_.val()); result = subtract(v,2.0); EXPECT_FLOAT_EQ(-1.0,result(0).val_.val()); EXPECT_FLOAT_EQ(0.0,result(1).val_.val()); EXPECT_FLOAT_EQ(1.0,result(2).val_.val()); EXPECT_FLOAT_EQ(2.0,result(3).val_.val()); EXPECT_FLOAT_EQ(1.0,result(0).d_.val()); EXPECT_FLOAT_EQ(1.0,result(1).d_.val()); EXPECT_FLOAT_EQ(1.0,result(3).d_.val()); EXPECT_FLOAT_EQ(1.0,result(3).d_.val()); AVEC q = createAVEC(v(0).val(),v(1).val(),v(2).val(),v(3).val()); VEC h; result(0).val_.grad(q,h); EXPECT_FLOAT_EQ(1,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,fv_scalar_rowvector_2ndDeriv) { using stan::math::subtract; using stan::math::row_vector_fv; row_vector_fv v(4); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; row_vector_fv result; result = subtract(v,2.0); AVEC q = createAVEC(v(0).val(),v(1).val(),v(2).val(),v(3).val()); VEC h; result(0).d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,fv_vector_vector_1stDeriv) { using stan::math::subtract; using stan::math::vector_d; using stan::math::vector_fv; vector_d expected_output(5); vector_fv output; vector_d output_d; vector_d vd_1(5), vd_2(5); vector_fv vv_1(5), vv_2(5); vd_1 << 0, 2, -6, 10, 6; vv_1 << 0, 2, -6, 10, 6; vv_1(0).d_ = 1.0; vv_1(1).d_ = 1.0; vv_1(2).d_ = 1.0; vv_1(3).d_ = 1.0; vv_1(4).d_ = 1.0; vd_2 << 2, 3, 4, 5, 6; vv_2 << 2, 3, 4, 5, 6; vv_2(0).d_ = 1.0; vv_2(1).d_ = 1.0; vv_2(2).d_ = 1.0; vv_2(3).d_ = 1.0; vv_2(4).d_ = 1.0; expected_output << -2, -1, -10, 5, 0; output_d = subtract(vd_1, vd_2); EXPECT_FLOAT_EQ(expected_output(0), output_d(0)); EXPECT_FLOAT_EQ(expected_output(1), output_d(1)); EXPECT_FLOAT_EQ(expected_output(2), output_d(2)); EXPECT_FLOAT_EQ(expected_output(3), output_d(3)); EXPECT_FLOAT_EQ(expected_output(4), output_d(4)); output = subtract(vv_1, vd_2); EXPECT_FLOAT_EQ(expected_output(0), output(0).val_.val()); EXPECT_FLOAT_EQ(expected_output(1), output(1).val_.val()); EXPECT_FLOAT_EQ(expected_output(2), output(2).val_.val()); EXPECT_FLOAT_EQ(expected_output(3), output(3).val_.val()); EXPECT_FLOAT_EQ(expected_output(4), output(4).val_.val()); EXPECT_FLOAT_EQ(1, output(0).d_.val()); EXPECT_FLOAT_EQ(1, output(1).d_.val()); EXPECT_FLOAT_EQ(1, output(2).d_.val()); EXPECT_FLOAT_EQ(1, output(3).d_.val()); EXPECT_FLOAT_EQ(1, output(4).d_.val()); output = subtract(vd_1, vv_2); EXPECT_FLOAT_EQ(expected_output(0), output(0).val_.val()); EXPECT_FLOAT_EQ(expected_output(1), output(1).val_.val()); EXPECT_FLOAT_EQ(expected_output(2), output(2).val_.val()); EXPECT_FLOAT_EQ(expected_output(3), output(3).val_.val()); EXPECT_FLOAT_EQ(expected_output(4), output(4).val_.val()); EXPECT_FLOAT_EQ(-1.0, output(0).d_.val()); EXPECT_FLOAT_EQ(-1.0, output(1).d_.val()); EXPECT_FLOAT_EQ(-1.0, output(2).d_.val()); EXPECT_FLOAT_EQ(-1.0, output(3).d_.val()); EXPECT_FLOAT_EQ(-1.0, output(4).d_.val()); output = subtract(vv_1, vv_2); EXPECT_FLOAT_EQ(expected_output(0), output(0).val_.val()); EXPECT_FLOAT_EQ(expected_output(1), output(1).val_.val()); EXPECT_FLOAT_EQ(expected_output(2), output(2).val_.val()); EXPECT_FLOAT_EQ(expected_output(3), output(3).val_.val()); EXPECT_FLOAT_EQ(expected_output(4), output(4).val_.val()); EXPECT_FLOAT_EQ(0, output(0).d_.val()); EXPECT_FLOAT_EQ(0, output(1).d_.val()); EXPECT_FLOAT_EQ(0, output(2).d_.val()); EXPECT_FLOAT_EQ(0, output(3).d_.val()); EXPECT_FLOAT_EQ(0, output(4).d_.val()); AVEC q = createAVEC(vv_1(0).val(),vv_1(1).val(),vv_1(2).val(),vv_1(3).val()); VEC h; output(0).val_.grad(q,h); EXPECT_FLOAT_EQ(1,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,fv_vector_vector_2ndDeriv) { using stan::math::subtract; using stan::math::vector_d; using stan::math::vector_fv; vector_d expected_output(5); vector_fv output; vector_d output_d; vector_d vd_1(5), vd_2(5); vector_fv vv_1(5), vv_2(5); vd_1 << 0, 2, -6, 10, 6; vv_1 << 0, 2, -6, 10, 6; vv_1(0).d_ = 1.0; vv_1(1).d_ = 1.0; vv_1(2).d_ = 1.0; vv_1(3).d_ = 1.0; vv_1(4).d_ = 1.0; vd_2 << 2, 3, 4, 5, 6; vv_2 << 2, 3, 4, 5, 6; vv_2(0).d_ = 1.0; vv_2(1).d_ = 1.0; vv_2(2).d_ = 1.0; vv_2(3).d_ = 1.0; vv_2(4).d_ = 1.0; output = subtract(vv_1, vv_2); AVEC q = createAVEC(vv_1(0).val(),vv_1(1).val(),vv_1(2).val(),vv_1(3).val()); VEC h; output(0).d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,fv_vector_vector_exception) { using stan::math::subtract; using stan::math::vector_d; using stan::math::vector_fv; vector_d d1(5), d2(1); vector_fv v1(5), v2(1); vector_fv output; EXPECT_THROW(subtract(d1, d2), std::invalid_argument); EXPECT_THROW(subtract(v1, d2), std::invalid_argument); EXPECT_THROW(subtract(d1, v2), std::invalid_argument); EXPECT_THROW(subtract(v1, v2), std::invalid_argument); } TEST(AgradMixMatrixOperatorSubtraction,fv_rowvector_rowvector_1stDeriv) { using stan::math::subtract; using stan::math::row_vector_d; using stan::math::row_vector_fv; row_vector_d expected_output(5); row_vector_d output_d; row_vector_fv output; row_vector_d rvd_1(5), rvd_2(5); row_vector_fv rvv_1(5), rvv_2(5); rvd_1 << 0, 2, -6, 10, 6; rvv_1 << 0, 2, -6, 10, 6; rvv_1(0).d_ = 1.0; rvv_1(1).d_ = 1.0; rvv_1(2).d_ = 1.0; rvv_1(3).d_ = 1.0; rvv_1(4).d_ = 1.0; rvd_2 << 2, 3, 4, 5, 6; rvv_2 << 2, 3, 4, 5, 6; rvv_2(0).d_ = 1.0; rvv_2(1).d_ = 1.0; rvv_2(2).d_ = 1.0; rvv_2(3).d_ = 1.0; rvv_2(4).d_ = 1.0; expected_output << -2, -1, -10, 5, 0; output_d = subtract(rvd_1, rvd_2); EXPECT_FLOAT_EQ(expected_output(0), output_d(0)); EXPECT_FLOAT_EQ(expected_output(1), output_d(1)); EXPECT_FLOAT_EQ(expected_output(2), output_d(2)); EXPECT_FLOAT_EQ(expected_output(3), output_d(3)); EXPECT_FLOAT_EQ(expected_output(4), output_d(4)); output = subtract(rvv_1, rvd_2); EXPECT_FLOAT_EQ(expected_output(0), output(0).val_.val()); EXPECT_FLOAT_EQ(expected_output(1), output(1).val_.val()); EXPECT_FLOAT_EQ(expected_output(2), output(2).val_.val()); EXPECT_FLOAT_EQ(expected_output(3), output(3).val_.val()); EXPECT_FLOAT_EQ(expected_output(4), output(4).val_.val()); EXPECT_FLOAT_EQ(1, output(0).d_.val()); EXPECT_FLOAT_EQ(1, output(1).d_.val()); EXPECT_FLOAT_EQ(1, output(2).d_.val()); EXPECT_FLOAT_EQ(1, output(3).d_.val()); EXPECT_FLOAT_EQ(1, output(4).d_.val()); output = subtract(rvd_1, rvv_2); EXPECT_FLOAT_EQ(expected_output(0), output(0).val_.val()); EXPECT_FLOAT_EQ(expected_output(1), output(1).val_.val()); EXPECT_FLOAT_EQ(expected_output(2), output(2).val_.val()); EXPECT_FLOAT_EQ(expected_output(3), output(3).val_.val()); EXPECT_FLOAT_EQ(expected_output(4), output(4).val_.val()); EXPECT_FLOAT_EQ(-1, output(0).d_.val()); EXPECT_FLOAT_EQ(-1, output(1).d_.val()); EXPECT_FLOAT_EQ(-1, output(2).d_.val()); EXPECT_FLOAT_EQ(-1, output(3).d_.val()); EXPECT_FLOAT_EQ(-1, output(4).d_.val()); output = subtract(rvv_1, rvv_2); EXPECT_FLOAT_EQ(expected_output(0), output(0).val_.val()); EXPECT_FLOAT_EQ(expected_output(1), output(1).val_.val()); EXPECT_FLOAT_EQ(expected_output(2), output(2).val_.val()); EXPECT_FLOAT_EQ(expected_output(3), output(3).val_.val()); EXPECT_FLOAT_EQ(expected_output(4), output(4).val_.val()); EXPECT_FLOAT_EQ(0, output(0).d_.val()); EXPECT_FLOAT_EQ(0, output(1).d_.val()); EXPECT_FLOAT_EQ(0, output(2).d_.val()); EXPECT_FLOAT_EQ(0, output(3).d_.val()); EXPECT_FLOAT_EQ(0, output(4).d_.val()); AVEC q = createAVEC(rvv_1(0).val(),rvv_1(1).val(),rvv_1(2).val(),rvv_1(3).val()); VEC h; output(0).val_.grad(q,h); EXPECT_FLOAT_EQ(1,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,fv_rowvector_rowvector_2ndDeriv) { using stan::math::subtract; using stan::math::row_vector_d; using stan::math::row_vector_fv; row_vector_d expected_output(5); row_vector_d output_d; row_vector_fv output; row_vector_d rvd_1(5), rvd_2(5); row_vector_fv rvv_1(5), rvv_2(5); rvd_1 << 0, 2, -6, 10, 6; rvv_1 << 0, 2, -6, 10, 6; rvv_1(0).d_ = 1.0; rvv_1(1).d_ = 1.0; rvv_1(2).d_ = 1.0; rvv_1(3).d_ = 1.0; rvv_1(4).d_ = 1.0; rvd_2 << 2, 3, 4, 5, 6; rvv_2 << 2, 3, 4, 5, 6; rvv_2(0).d_ = 1.0; rvv_2(1).d_ = 1.0; rvv_2(2).d_ = 1.0; rvv_2(3).d_ = 1.0; rvv_2(4).d_ = 1.0; output = subtract(rvv_1, rvv_2); AVEC q = createAVEC(rvv_1(0).val(),rvv_1(1).val(),rvv_1(2).val(),rvv_1(3).val()); VEC h; output(0).d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,fv_rowvector_rowvector_exception) { using stan::math::subtract; using stan::math::row_vector_d; using stan::math::row_vector_fv; row_vector_d d1(5), d2(2); row_vector_fv v1(5), v2(2); row_vector_fv output; EXPECT_THROW(subtract(d1, d2), std::invalid_argument); EXPECT_THROW(subtract(d1, v2), std::invalid_argument); EXPECT_THROW(subtract(v1, d2), std::invalid_argument); EXPECT_THROW(subtract(v1, v2), std::invalid_argument); } TEST(AgradMixMatrixOperatorSubtraction,fv_matrix_matrix_1stDeriv) { using stan::math::subtract; using stan::math::matrix_d; using stan::math::matrix_fv; matrix_d expected_output(2,2); matrix_fv output; matrix_d md_1(2,2), md_2(2,2); matrix_fv mv_1(2,2), mv_2(2,2); matrix_d md_mis (2, 3); matrix_fv mv_mis (1, 1); md_1 << -10, 1, 10, 0; mv_1 << -10, 1, 10, 0; mv_1(0,0).d_ = 1.0; mv_1(0,1).d_ = 1.0; mv_1(1,0).d_ = 1.0; mv_1(1,1).d_ = 1.0; md_2 << 10, -10, 1, 2; mv_2 << 10, -10, 1, 2; mv_2(0,0).d_ = 1.0; mv_2(0,1).d_ = 1.0; mv_2(1,0).d_ = 1.0; mv_2(1,1).d_ = 1.0; expected_output << -20, 11, 9, -2; matrix_d output_d = subtract(md_1, md_2); EXPECT_FLOAT_EQ(expected_output(0,0), output_d(0,0)); EXPECT_FLOAT_EQ(expected_output(0,1), output_d(0,1)); EXPECT_FLOAT_EQ(expected_output(1,0), output_d(1,0)); EXPECT_FLOAT_EQ(expected_output(1,1), output_d(1,1)); output = subtract(mv_1, md_2); EXPECT_FLOAT_EQ(expected_output(0,0), output(0,0).val_.val()); EXPECT_FLOAT_EQ(expected_output(0,1), output(0,1).val_.val()); EXPECT_FLOAT_EQ(expected_output(1,0), output(1,0).val_.val()); EXPECT_FLOAT_EQ(expected_output(1,1), output(1,1).val_.val()); EXPECT_FLOAT_EQ(1, output(0,0).d_.val()); EXPECT_FLOAT_EQ(1, output(0,1).d_.val()); EXPECT_FLOAT_EQ(1, output(1,0).d_.val()); EXPECT_FLOAT_EQ(1, output(1,1).d_.val()); output = subtract(md_1, mv_2); EXPECT_FLOAT_EQ(expected_output(0,0), output(0,0).val_.val()); EXPECT_FLOAT_EQ(expected_output(0,1), output(0,1).val_.val()); EXPECT_FLOAT_EQ(expected_output(1,0), output(1,0).val_.val()); EXPECT_FLOAT_EQ(expected_output(1,1), output(1,1).val_.val()); EXPECT_FLOAT_EQ(-1, output(0,0).d_.val()); EXPECT_FLOAT_EQ(-1, output(0,1).d_.val()); EXPECT_FLOAT_EQ(-1, output(1,0).d_.val()); EXPECT_FLOAT_EQ(-1, output(1,1).d_.val()); output = subtract(mv_1, mv_2); EXPECT_FLOAT_EQ(expected_output(0,0), output(0,0).val_.val()); EXPECT_FLOAT_EQ(expected_output(0,1), output(0,1).val_.val()); EXPECT_FLOAT_EQ(expected_output(1,0), output(1,0).val_.val()); EXPECT_FLOAT_EQ(expected_output(1,1), output(1,1).val_.val()); EXPECT_FLOAT_EQ(0, output(0,0).d_.val()); EXPECT_FLOAT_EQ(0, output(0,1).d_.val()); EXPECT_FLOAT_EQ(0, output(1,0).d_.val()); EXPECT_FLOAT_EQ(0, output(1,1).d_.val()); AVEC q = createAVEC(mv_1(0,0).val(),mv_1(0,1).val(),mv_1(1,0).val(),mv_1(1,1).val()); VEC h; output(0,0).val_.grad(q,h); EXPECT_FLOAT_EQ(1,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,fv_matrix_matrix_2ndDeriv) { using stan::math::subtract; using stan::math::matrix_d; using stan::math::matrix_fv; matrix_d expected_output(2,2); matrix_fv output; matrix_d md_1(2,2), md_2(2,2); matrix_fv mv_1(2,2), mv_2(2,2); matrix_d md_mis (2, 3); matrix_fv mv_mis (1, 1); md_1 << -10, 1, 10, 0; mv_1 << -10, 1, 10, 0; mv_1(0,0).d_ = 1.0; mv_1(0,1).d_ = 1.0; mv_1(1,0).d_ = 1.0; mv_1(1,1).d_ = 1.0; md_2 << 10, -10, 1, 2; mv_2 << 10, -10, 1, 2; mv_2(0,0).d_ = 1.0; mv_2(0,1).d_ = 1.0; mv_2(1,0).d_ = 1.0; mv_2(1,1).d_ = 1.0; output = subtract(mv_1, mv_2); AVEC q = createAVEC(mv_1(0,0).val(),mv_1(0,1).val(),mv_1(1,0).val(),mv_1(1,1).val()); VEC h; output(0,0).d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,fv_matrix_matrix_exception) { using stan::math::subtract; using stan::math::matrix_d; using stan::math::matrix_fv; matrix_d d1(2,2), d2(1,2); matrix_fv v1(2,2), v2(1,2); EXPECT_THROW(subtract(d1, d2), std::invalid_argument); EXPECT_THROW(subtract(d1, v2), std::invalid_argument); EXPECT_THROW(subtract(v1, d2), std::invalid_argument); EXPECT_THROW(subtract(v1, v2), std::invalid_argument); } TEST(AgradMixMatrixOperatorSubtraction,ffv_scalar_matrix_1stDeriv) { using stan::math::subtract; using stan::math::matrix_ffv; matrix_ffv v(2,2); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; matrix_ffv result; result = subtract(2.0,v); EXPECT_FLOAT_EQ(1.0,result(0,0).val_.val().val()); EXPECT_FLOAT_EQ(0.0,result(0,1).val_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(1,0).val_.val().val()); EXPECT_FLOAT_EQ(-2.0,result(1,1).val_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(0,0).d_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(0,1).d_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(1,0).d_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(1,1).d_.val().val()); result = subtract(v,2.0); EXPECT_FLOAT_EQ(-1.0,result(0,0).val_.val().val()); EXPECT_FLOAT_EQ(0.0,result(0,1).val_.val().val()); EXPECT_FLOAT_EQ(1.0,result(1,0).val_.val().val()); EXPECT_FLOAT_EQ(2.0,result(1,1).val_.val().val()); EXPECT_FLOAT_EQ(1.0,result(0,0).d_.val().val()); EXPECT_FLOAT_EQ(1.0,result(0,1).d_.val().val()); EXPECT_FLOAT_EQ(1.0,result(1,0).d_.val().val()); EXPECT_FLOAT_EQ(1.0,result(1,1).d_.val().val()); AVEC q = createAVEC(v(0,0).val().val(),v(0,1).val().val(),v(1,0).val().val(),v(1,1).val().val()); VEC h; result(0,0).val_.val().grad(q,h); EXPECT_FLOAT_EQ(1,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_scalar_matrix_2ndDeriv_1) { using stan::math::subtract; using stan::math::matrix_ffv; matrix_ffv v(2,2); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; matrix_ffv result; result = subtract(v,2.0); AVEC q = createAVEC(v(0,0).val().val(),v(0,1).val().val(),v(1,0).val().val(),v(1,1).val().val()); VEC h; result(0,0).val().d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_scalar_matrix_2ndDeriv_2) { using stan::math::subtract; using stan::math::matrix_ffv; matrix_ffv v(2,2); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; matrix_ffv result; result = subtract(v,2.0); AVEC q = createAVEC(v(0,0).val().val(),v(0,1).val().val(),v(1,0).val().val(),v(1,1).val().val()); VEC h; result(0,0).d_.val().grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_scalar_matrix_3rdDeriv) { using stan::math::subtract; using stan::math::matrix_ffv; matrix_ffv v(2,2); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; v(0).val_.d_ = 1.0; v(1).val_.d_ = 1.0; v(2).val_.d_ = 1.0; v(3).val_.d_ = 1.0; matrix_ffv result; result = subtract(v,2.0); AVEC q = createAVEC(v(0,0).val().val(),v(0,1).val().val(),v(1,0).val().val(),v(1,1).val().val()); VEC h; result(0,0).d_.d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_scalar_vector_1stDeriv) { using stan::math::subtract; using stan::math::vector_ffv; vector_ffv v(4); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; vector_ffv result; result = subtract(2.0,v); EXPECT_FLOAT_EQ(1.0,result(0).val_.val().val()); EXPECT_FLOAT_EQ(0.0,result(1).val_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(2).val_.val().val()); EXPECT_FLOAT_EQ(-2.0,result(3).val_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(0).d_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(1).d_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(3).d_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(3).d_.val().val()); result = subtract(v,2.0); EXPECT_FLOAT_EQ(-1.0,result(0).val_.val().val()); EXPECT_FLOAT_EQ(0.0,result(1).val_.val().val()); EXPECT_FLOAT_EQ(1.0,result(2).val_.val().val()); EXPECT_FLOAT_EQ(2.0,result(3).val_.val().val()); EXPECT_FLOAT_EQ(1.0,result(0).d_.val().val()); EXPECT_FLOAT_EQ(1.0,result(1).d_.val().val()); EXPECT_FLOAT_EQ(1.0,result(3).d_.val().val()); EXPECT_FLOAT_EQ(1.0,result(3).d_.val().val()); AVEC q = createAVEC(v(0).val().val(),v(1).val().val(),v(2).val().val(),v(3).val().val()); VEC h; result(0).val_.val().grad(q,h); EXPECT_FLOAT_EQ(1,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_scalar_vector_2ndDeriv_1) { using stan::math::subtract; using stan::math::vector_ffv; vector_ffv v(4); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; vector_ffv result; result = subtract(v,2.0); AVEC q = createAVEC(v(0).val().val(),v(1).val().val(),v(2).val().val(),v(3).val().val()); VEC h; result(0).val().d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_scalar_vector_2ndDeriv_2) { using stan::math::subtract; using stan::math::vector_ffv; vector_ffv v(4); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; vector_ffv result; result = subtract(v,2.0); AVEC q = createAVEC(v(0).val().val(),v(1).val().val(),v(2).val().val(),v(3).val().val()); VEC h; result(0).d_.val().grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_scalar_vector_3rdDeriv) { using stan::math::subtract; using stan::math::vector_ffv; vector_ffv v(4); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; v(0).val_.d_ = 1.0; v(1).val_.d_ = 1.0; v(2).val_.d_ = 1.0; v(3).val_.d_ = 1.0; vector_ffv result; result = subtract(v,2.0); AVEC q = createAVEC(v(0).val().val(),v(1).val().val(),v(2).val().val(),v(3).val().val()); VEC h; result(0).d_.d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_scalar_rowvector_1stDeriv) { using stan::math::subtract; using stan::math::row_vector_ffv; row_vector_ffv v(4); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; row_vector_ffv result; result = subtract(2.0,v); EXPECT_FLOAT_EQ(1.0,result(0).val_.val().val()); EXPECT_FLOAT_EQ(0.0,result(1).val_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(2).val_.val().val()); EXPECT_FLOAT_EQ(-2.0,result(3).val_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(0).d_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(1).d_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(3).d_.val().val()); EXPECT_FLOAT_EQ(-1.0,result(3).d_.val().val()); result = subtract(v,2.0); EXPECT_FLOAT_EQ(-1.0,result(0).val_.val().val()); EXPECT_FLOAT_EQ(0.0,result(1).val_.val().val()); EXPECT_FLOAT_EQ(1.0,result(2).val_.val().val()); EXPECT_FLOAT_EQ(2.0,result(3).val_.val().val()); EXPECT_FLOAT_EQ(1.0,result(0).d_.val().val()); EXPECT_FLOAT_EQ(1.0,result(1).d_.val().val()); EXPECT_FLOAT_EQ(1.0,result(3).d_.val().val()); EXPECT_FLOAT_EQ(1.0,result(3).d_.val().val()); AVEC q = createAVEC(v(0).val().val(),v(1).val().val(),v(2).val().val(),v(3).val().val()); VEC h; result(0).val_.val().grad(q,h); EXPECT_FLOAT_EQ(1,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_scalar_rowvector_2ndDeriv_1) { using stan::math::subtract; using stan::math::row_vector_ffv; row_vector_ffv v(4); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; row_vector_ffv result; result = subtract(v,2.0); AVEC q = createAVEC(v(0).val().val(),v(1).val().val(),v(2).val().val(),v(3).val().val()); VEC h; result(0).val().d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_scalar_rowvector_2ndDeriv_2) { using stan::math::subtract; using stan::math::row_vector_ffv; row_vector_ffv v(4); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; row_vector_ffv result; result = subtract(v,2.0); AVEC q = createAVEC(v(0).val().val(),v(1).val().val(),v(2).val().val(),v(3).val().val()); VEC h; result(0).d_.val().grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_scalar_rowvector_3rdDeriv) { using stan::math::subtract; using stan::math::row_vector_ffv; row_vector_ffv v(4); v << 1, 2, 3, 4; v(0).d_ = 1.0; v(1).d_ = 1.0; v(2).d_ = 1.0; v(3).d_ = 1.0; v(0).val_.d_ = 1.0; v(1).val_.d_ = 1.0; v(2).val_.d_ = 1.0; v(3).val_.d_ = 1.0; row_vector_ffv result; result = subtract(v,2.0); AVEC q = createAVEC(v(0).val().val(),v(1).val().val(),v(2).val().val(),v(3).val().val()); VEC h; result(0).d_.d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_vector_vector_1stDeriv) { using stan::math::subtract; using stan::math::vector_d; using stan::math::vector_ffv; vector_d expected_output(5); vector_ffv output; vector_d output_d; vector_d vd_1(5), vd_2(5); vector_ffv vv_1(5), vv_2(5); vd_1 << 0, 2, -6, 10, 6; vv_1 << 0, 2, -6, 10, 6; vv_1(0).d_ = 1.0; vv_1(1).d_ = 1.0; vv_1(2).d_ = 1.0; vv_1(3).d_ = 1.0; vv_1(4).d_ = 1.0; vd_2 << 2, 3, 4, 5, 6; vv_2 << 2, 3, 4, 5, 6; vv_2(0).d_ = 1.0; vv_2(1).d_ = 1.0; vv_2(2).d_ = 1.0; vv_2(3).d_ = 1.0; vv_2(4).d_ = 1.0; expected_output << -2, -1, -10, 5, 0; output_d = subtract(vd_1, vd_2); EXPECT_FLOAT_EQ(expected_output(0), output_d(0)); EXPECT_FLOAT_EQ(expected_output(1), output_d(1)); EXPECT_FLOAT_EQ(expected_output(2), output_d(2)); EXPECT_FLOAT_EQ(expected_output(3), output_d(3)); EXPECT_FLOAT_EQ(expected_output(4), output_d(4)); output = subtract(vv_1, vd_2); EXPECT_FLOAT_EQ(expected_output(0), output(0).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(1), output(1).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(2), output(2).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(3), output(3).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(4), output(4).val_.val().val()); EXPECT_FLOAT_EQ(1, output(0).d_.val().val()); EXPECT_FLOAT_EQ(1, output(1).d_.val().val()); EXPECT_FLOAT_EQ(1, output(2).d_.val().val()); EXPECT_FLOAT_EQ(1, output(3).d_.val().val()); EXPECT_FLOAT_EQ(1, output(4).d_.val().val()); output = subtract(vd_1, vv_2); EXPECT_FLOAT_EQ(expected_output(0), output(0).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(1), output(1).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(2), output(2).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(3), output(3).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(4), output(4).val_.val().val()); EXPECT_FLOAT_EQ(-1.0, output(0).d_.val().val()); EXPECT_FLOAT_EQ(-1.0, output(1).d_.val().val()); EXPECT_FLOAT_EQ(-1.0, output(2).d_.val().val()); EXPECT_FLOAT_EQ(-1.0, output(3).d_.val().val()); EXPECT_FLOAT_EQ(-1.0, output(4).d_.val().val()); output = subtract(vv_1, vv_2); EXPECT_FLOAT_EQ(expected_output(0), output(0).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(1), output(1).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(2), output(2).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(3), output(3).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(4), output(4).val_.val().val()); EXPECT_FLOAT_EQ(0, output(0).d_.val().val()); EXPECT_FLOAT_EQ(0, output(1).d_.val().val()); EXPECT_FLOAT_EQ(0, output(2).d_.val().val()); EXPECT_FLOAT_EQ(0, output(3).d_.val().val()); EXPECT_FLOAT_EQ(0, output(4).d_.val().val()); AVEC q = createAVEC(vv_1(0).val().val(),vv_1(1).val().val(),vv_1(2).val().val(),vv_1(3).val().val()); VEC h; output(0).val_.val().grad(q,h); EXPECT_FLOAT_EQ(1,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_vector_vector_2ndDeriv_1) { using stan::math::subtract; using stan::math::vector_d; using stan::math::vector_ffv; vector_d expected_output(5); vector_ffv output; vector_d output_d; vector_d vd_1(5), vd_2(5); vector_ffv vv_1(5), vv_2(5); vd_1 << 0, 2, -6, 10, 6; vv_1 << 0, 2, -6, 10, 6; vv_1(0).d_ = 1.0; vv_1(1).d_ = 1.0; vv_1(2).d_ = 1.0; vv_1(3).d_ = 1.0; vv_1(4).d_ = 1.0; vd_2 << 2, 3, 4, 5, 6; vv_2 << 2, 3, 4, 5, 6; vv_2(0).d_ = 1.0; vv_2(1).d_ = 1.0; vv_2(2).d_ = 1.0; vv_2(3).d_ = 1.0; vv_2(4).d_ = 1.0; output = subtract(vv_1, vv_2); AVEC q = createAVEC(vv_1(0).val().val(),vv_1(1).val().val(),vv_1(2).val().val(),vv_1(3).val().val()); VEC h; output(0).val().d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_vector_vector_2ndDeriv_2) { using stan::math::subtract; using stan::math::vector_d; using stan::math::vector_ffv; vector_d expected_output(5); vector_ffv output; vector_d output_d; vector_d vd_1(5), vd_2(5); vector_ffv vv_1(5), vv_2(5); vd_1 << 0, 2, -6, 10, 6; vv_1 << 0, 2, -6, 10, 6; vv_1(0).d_ = 1.0; vv_1(1).d_ = 1.0; vv_1(2).d_ = 1.0; vv_1(3).d_ = 1.0; vv_1(4).d_ = 1.0; vd_2 << 2, 3, 4, 5, 6; vv_2 << 2, 3, 4, 5, 6; vv_2(0).d_ = 1.0; vv_2(1).d_ = 1.0; vv_2(2).d_ = 1.0; vv_2(3).d_ = 1.0; vv_2(4).d_ = 1.0; output = subtract(vv_1, vv_2); AVEC q = createAVEC(vv_1(0).val().val(),vv_1(1).val().val(),vv_1(2).val().val(),vv_1(3).val().val()); VEC h; output(0).d_.val().grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_vector_vector_3rdDeriv) { using stan::math::subtract; using stan::math::vector_d; using stan::math::vector_ffv; vector_d expected_output(5); vector_ffv output; vector_d output_d; vector_d vd_1(5), vd_2(5); vector_ffv vv_1(5), vv_2(5); vd_1 << 0, 2, -6, 10, 6; vv_1 << 0, 2, -6, 10, 6; vv_1(0).d_ = 1.0; vv_1(1).d_ = 1.0; vv_1(2).d_ = 1.0; vv_1(3).d_ = 1.0; vv_1(4).d_ = 1.0; vv_1(0).val_.d_ = 1.0; vv_1(1).val_.d_ = 1.0; vv_1(2).val_.d_ = 1.0; vv_1(3).val_.d_ = 1.0; vv_1(4).val_.d_ = 1.0; vd_2 << 2, 3, 4, 5, 6; vv_2 << 2, 3, 4, 5, 6; vv_2(0).d_ = 1.0; vv_2(1).d_ = 1.0; vv_2(2).d_ = 1.0; vv_2(3).d_ = 1.0; vv_2(4).d_ = 1.0; vv_2(0).val_.d_ = 1.0; vv_2(1).val_.d_ = 1.0; vv_2(2).val_.d_ = 1.0; vv_2(3).val_.d_ = 1.0; vv_2(4).val_.d_ = 1.0; output = subtract(vv_1, vv_2); AVEC q = createAVEC(vv_1(0).val().val(),vv_1(1).val().val(),vv_1(2).val().val(),vv_1(3).val().val()); VEC h; output(0).d_.d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_vector_vector_exception) { using stan::math::subtract; using stan::math::vector_d; using stan::math::vector_ffv; vector_d d1(5), d2(1); vector_ffv v1(5), v2(1); vector_ffv output; EXPECT_THROW(subtract(d1, d2), std::invalid_argument); EXPECT_THROW(subtract(v1, d2), std::invalid_argument); EXPECT_THROW(subtract(d1, v2), std::invalid_argument); EXPECT_THROW(subtract(v1, v2), std::invalid_argument); } TEST(AgradMixMatrixOperatorSubtraction,ffv_rowvector_rowvector_1stDeriv) { using stan::math::subtract; using stan::math::row_vector_d; using stan::math::row_vector_ffv; row_vector_d expected_output(5); row_vector_d output_d; row_vector_ffv output; row_vector_d rvd_1(5), rvd_2(5); row_vector_ffv rvv_1(5), rvv_2(5); rvd_1 << 0, 2, -6, 10, 6; rvv_1 << 0, 2, -6, 10, 6; rvv_1(0).d_ = 1.0; rvv_1(1).d_ = 1.0; rvv_1(2).d_ = 1.0; rvv_1(3).d_ = 1.0; rvv_1(4).d_ = 1.0; rvd_2 << 2, 3, 4, 5, 6; rvv_2 << 2, 3, 4, 5, 6; rvv_2(0).d_ = 1.0; rvv_2(1).d_ = 1.0; rvv_2(2).d_ = 1.0; rvv_2(3).d_ = 1.0; rvv_2(4).d_ = 1.0; expected_output << -2, -1, -10, 5, 0; output_d = subtract(rvd_1, rvd_2); EXPECT_FLOAT_EQ(expected_output(0), output_d(0)); EXPECT_FLOAT_EQ(expected_output(1), output_d(1)); EXPECT_FLOAT_EQ(expected_output(2), output_d(2)); EXPECT_FLOAT_EQ(expected_output(3), output_d(3)); EXPECT_FLOAT_EQ(expected_output(4), output_d(4)); output = subtract(rvv_1, rvd_2); EXPECT_FLOAT_EQ(expected_output(0), output(0).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(1), output(1).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(2), output(2).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(3), output(3).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(4), output(4).val_.val().val()); EXPECT_FLOAT_EQ(1, output(0).d_.val().val()); EXPECT_FLOAT_EQ(1, output(1).d_.val().val()); EXPECT_FLOAT_EQ(1, output(2).d_.val().val()); EXPECT_FLOAT_EQ(1, output(3).d_.val().val()); EXPECT_FLOAT_EQ(1, output(4).d_.val().val()); output = subtract(rvd_1, rvv_2); EXPECT_FLOAT_EQ(expected_output(0), output(0).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(1), output(1).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(2), output(2).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(3), output(3).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(4), output(4).val_.val().val()); EXPECT_FLOAT_EQ(-1, output(0).d_.val().val()); EXPECT_FLOAT_EQ(-1, output(1).d_.val().val()); EXPECT_FLOAT_EQ(-1, output(2).d_.val().val()); EXPECT_FLOAT_EQ(-1, output(3).d_.val().val()); EXPECT_FLOAT_EQ(-1, output(4).d_.val().val()); output = subtract(rvv_1, rvv_2); EXPECT_FLOAT_EQ(expected_output(0), output(0).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(1), output(1).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(2), output(2).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(3), output(3).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(4), output(4).val_.val().val()); EXPECT_FLOAT_EQ(0, output(0).d_.val().val()); EXPECT_FLOAT_EQ(0, output(1).d_.val().val()); EXPECT_FLOAT_EQ(0, output(2).d_.val().val()); EXPECT_FLOAT_EQ(0, output(3).d_.val().val()); EXPECT_FLOAT_EQ(0, output(4).d_.val().val()); AVEC q = createAVEC(rvv_1(0).val().val(),rvv_1(1).val().val(),rvv_1(2).val().val(),rvv_1(3).val().val()); VEC h; output(0).val_.val().grad(q,h); EXPECT_FLOAT_EQ(1,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_rowvector_rowvector_2ndDeriv_1) { using stan::math::subtract; using stan::math::row_vector_d; using stan::math::row_vector_ffv; row_vector_d expected_output(5); row_vector_d output_d; row_vector_ffv output; row_vector_d rvd_1(5), rvd_2(5); row_vector_ffv rvv_1(5), rvv_2(5); rvd_1 << 0, 2, -6, 10, 6; rvv_1 << 0, 2, -6, 10, 6; rvv_1(0).d_ = 1.0; rvv_1(1).d_ = 1.0; rvv_1(2).d_ = 1.0; rvv_1(3).d_ = 1.0; rvv_1(4).d_ = 1.0; rvd_2 << 2, 3, 4, 5, 6; rvv_2 << 2, 3, 4, 5, 6; rvv_2(0).d_ = 1.0; rvv_2(1).d_ = 1.0; rvv_2(2).d_ = 1.0; rvv_2(3).d_ = 1.0; rvv_2(4).d_ = 1.0; output = subtract(rvv_1, rvv_2); AVEC q = createAVEC(rvv_1(0).val().val(),rvv_1(1).val().val(),rvv_1(2).val().val(),rvv_1(3).val().val()); VEC h; output(0).val().d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_rowvector_rowvector_2ndDeriv_2) { using stan::math::subtract; using stan::math::row_vector_d; using stan::math::row_vector_ffv; row_vector_d expected_output(5); row_vector_d output_d; row_vector_ffv output; row_vector_d rvd_1(5), rvd_2(5); row_vector_ffv rvv_1(5), rvv_2(5); rvd_1 << 0, 2, -6, 10, 6; rvv_1 << 0, 2, -6, 10, 6; rvv_1(0).d_ = 1.0; rvv_1(1).d_ = 1.0; rvv_1(2).d_ = 1.0; rvv_1(3).d_ = 1.0; rvv_1(4).d_ = 1.0; rvd_2 << 2, 3, 4, 5, 6; rvv_2 << 2, 3, 4, 5, 6; rvv_2(0).d_ = 1.0; rvv_2(1).d_ = 1.0; rvv_2(2).d_ = 1.0; rvv_2(3).d_ = 1.0; rvv_2(4).d_ = 1.0; output = subtract(rvv_1, rvv_2); AVEC q = createAVEC(rvv_1(0).val().val(),rvv_1(1).val().val(),rvv_1(2).val().val(),rvv_1(3).val().val()); VEC h; output(0).d_.val().grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_rowvector_rowvector_3rdDeriv) { using stan::math::subtract; using stan::math::row_vector_d; using stan::math::row_vector_ffv; row_vector_d expected_output(5); row_vector_d output_d; row_vector_ffv output; row_vector_d rvd_1(5), rvd_2(5); row_vector_ffv rvv_1(5), rvv_2(5); rvd_1 << 0, 2, -6, 10, 6; rvv_1 << 0, 2, -6, 10, 6; rvv_1(0).d_ = 1.0; rvv_1(1).d_ = 1.0; rvv_1(2).d_ = 1.0; rvv_1(3).d_ = 1.0; rvv_1(4).d_ = 1.0; rvv_1(0).val_.d_ = 1.0; rvv_1(1).val_.d_ = 1.0; rvv_1(2).val_.d_ = 1.0; rvv_1(3).val_.d_ = 1.0; rvv_1(4).val_.d_ = 1.0; rvd_2 << 2, 3, 4, 5, 6; rvv_2 << 2, 3, 4, 5, 6; rvv_2(0).d_ = 1.0; rvv_2(1).d_ = 1.0; rvv_2(2).d_ = 1.0; rvv_2(3).d_ = 1.0; rvv_2(4).d_ = 1.0; rvv_2(0).val_.d_ = 1.0; rvv_2(1).val_.d_ = 1.0; rvv_2(2).val_.d_ = 1.0; rvv_2(3).val_.d_ = 1.0; rvv_2(4).val_.d_ = 1.0; output = subtract(rvv_1, rvv_2); AVEC q = createAVEC(rvv_1(0).val().val(),rvv_1(1).val().val(),rvv_1(2).val().val(),rvv_1(3).val().val()); VEC h; output(0).d_.d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_rowvector_rowvector_exception) { using stan::math::subtract; using stan::math::row_vector_d; using stan::math::row_vector_ffv; row_vector_d d1(5), d2(2); row_vector_ffv v1(5), v2(2); row_vector_ffv output; EXPECT_THROW(subtract(d1, d2), std::invalid_argument); EXPECT_THROW(subtract(d1, v2), std::invalid_argument); EXPECT_THROW(subtract(v1, d2), std::invalid_argument); EXPECT_THROW(subtract(v1, v2), std::invalid_argument); } TEST(AgradMixMatrixOperatorSubtraction,ffv_matrix_matrix_1stDeriv) { using stan::math::subtract; using stan::math::matrix_d; using stan::math::matrix_ffv; matrix_d expected_output(2,2); matrix_ffv output; matrix_d md_1(2,2), md_2(2,2); matrix_ffv mv_1(2,2), mv_2(2,2); matrix_d md_mis (2, 3); matrix_ffv mv_mis (1, 1); md_1 << -10, 1, 10, 0; mv_1 << -10, 1, 10, 0; mv_1(0,0).d_ = 1.0; mv_1(0,1).d_ = 1.0; mv_1(1,0).d_ = 1.0; mv_1(1,1).d_ = 1.0; md_2 << 10, -10, 1, 2; mv_2 << 10, -10, 1, 2; mv_2(0,0).d_ = 1.0; mv_2(0,1).d_ = 1.0; mv_2(1,0).d_ = 1.0; mv_2(1,1).d_ = 1.0; expected_output << -20, 11, 9, -2; matrix_d output_d = subtract(md_1, md_2); EXPECT_FLOAT_EQ(expected_output(0,0), output_d(0,0)); EXPECT_FLOAT_EQ(expected_output(0,1), output_d(0,1)); EXPECT_FLOAT_EQ(expected_output(1,0), output_d(1,0)); EXPECT_FLOAT_EQ(expected_output(1,1), output_d(1,1)); output = subtract(mv_1, md_2); EXPECT_FLOAT_EQ(expected_output(0,0), output(0,0).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(0,1), output(0,1).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(1,0), output(1,0).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(1,1), output(1,1).val_.val().val()); EXPECT_FLOAT_EQ(1, output(0,0).d_.val().val()); EXPECT_FLOAT_EQ(1, output(0,1).d_.val().val()); EXPECT_FLOAT_EQ(1, output(1,0).d_.val().val()); EXPECT_FLOAT_EQ(1, output(1,1).d_.val().val()); output = subtract(md_1, mv_2); EXPECT_FLOAT_EQ(expected_output(0,0), output(0,0).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(0,1), output(0,1).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(1,0), output(1,0).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(1,1), output(1,1).val_.val().val()); EXPECT_FLOAT_EQ(-1, output(0,0).d_.val().val()); EXPECT_FLOAT_EQ(-1, output(0,1).d_.val().val()); EXPECT_FLOAT_EQ(-1, output(1,0).d_.val().val()); EXPECT_FLOAT_EQ(-1, output(1,1).d_.val().val()); output = subtract(mv_1, mv_2); EXPECT_FLOAT_EQ(expected_output(0,0), output(0,0).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(0,1), output(0,1).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(1,0), output(1,0).val_.val().val()); EXPECT_FLOAT_EQ(expected_output(1,1), output(1,1).val_.val().val()); EXPECT_FLOAT_EQ(0, output(0,0).d_.val().val()); EXPECT_FLOAT_EQ(0, output(0,1).d_.val().val()); EXPECT_FLOAT_EQ(0, output(1,0).d_.val().val()); EXPECT_FLOAT_EQ(0, output(1,1).d_.val().val()); AVEC q = createAVEC(mv_1(0,0).val().val(),mv_1(0,1).val().val(),mv_1(1,0).val().val(),mv_1(1,1).val().val()); VEC h; output(0,0).val_.val().grad(q,h); EXPECT_FLOAT_EQ(1,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_matrix_matrix_2ndDeriv_1) { using stan::math::subtract; using stan::math::matrix_d; using stan::math::matrix_ffv; matrix_d expected_output(2,2); matrix_ffv output; matrix_d md_1(2,2), md_2(2,2); matrix_ffv mv_1(2,2), mv_2(2,2); matrix_d md_mis (2, 3); matrix_ffv mv_mis (1, 1); md_1 << -10, 1, 10, 0; mv_1 << -10, 1, 10, 0; mv_1(0,0).d_ = 1.0; mv_1(0,1).d_ = 1.0; mv_1(1,0).d_ = 1.0; mv_1(1,1).d_ = 1.0; md_2 << 10, -10, 1, 2; mv_2 << 10, -10, 1, 2; mv_2(0,0).d_ = 1.0; mv_2(0,1).d_ = 1.0; mv_2(1,0).d_ = 1.0; mv_2(1,1).d_ = 1.0; output = subtract(mv_1, mv_2); AVEC q = createAVEC(mv_1(0,0).val().val(),mv_1(0,1).val().val(),mv_1(1,0).val().val(),mv_1(1,1).val().val()); VEC h; output(0,0).val().d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_matrix_matrix_2ndDeriv_2) { using stan::math::subtract; using stan::math::matrix_d; using stan::math::matrix_ffv; matrix_d expected_output(2,2); matrix_ffv output; matrix_d md_1(2,2), md_2(2,2); matrix_ffv mv_1(2,2), mv_2(2,2); matrix_d md_mis (2, 3); matrix_ffv mv_mis (1, 1); md_1 << -10, 1, 10, 0; mv_1 << -10, 1, 10, 0; mv_1(0,0).d_ = 1.0; mv_1(0,1).d_ = 1.0; mv_1(1,0).d_ = 1.0; mv_1(1,1).d_ = 1.0; md_2 << 10, -10, 1, 2; mv_2 << 10, -10, 1, 2; mv_2(0,0).d_ = 1.0; mv_2(0,1).d_ = 1.0; mv_2(1,0).d_ = 1.0; mv_2(1,1).d_ = 1.0; output = subtract(mv_1, mv_2); AVEC q = createAVEC(mv_1(0,0).val().val(),mv_1(0,1).val().val(),mv_1(1,0).val().val(),mv_1(1,1).val().val()); VEC h; output(0,0).d_.val().grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_matrix_matrix_3rdDeriv) { using stan::math::subtract; using stan::math::matrix_d; using stan::math::matrix_ffv; matrix_d expected_output(2,2); matrix_ffv output; matrix_d md_1(2,2), md_2(2,2); matrix_ffv mv_1(2,2), mv_2(2,2); matrix_d md_mis (2, 3); matrix_ffv mv_mis (1, 1); md_1 << -10, 1, 10, 0; mv_1 << -10, 1, 10, 0; mv_1(0,0).d_ = 1.0; mv_1(0,1).d_ = 1.0; mv_1(1,0).d_ = 1.0; mv_1(1,1).d_ = 1.0; mv_1(0,0).val_.d_ = 1.0; mv_1(0,1).val_.d_ = 1.0; mv_1(1,0).val_.d_ = 1.0; mv_1(1,1).val_.d_ = 1.0; md_2 << 10, -10, 1, 2; mv_2 << 10, -10, 1, 2; mv_2(0,0).d_ = 1.0; mv_2(0,1).d_ = 1.0; mv_2(1,0).d_ = 1.0; mv_2(1,1).d_ = 1.0; mv_2(0,0).val_.d_ = 1.0; mv_2(0,1).val_.d_ = 1.0; mv_2(1,0).val_.d_ = 1.0; mv_2(1,1).val_.d_ = 1.0; output = subtract(mv_1, mv_2); AVEC q = createAVEC(mv_1(0,0).val().val(),mv_1(0,1).val().val(),mv_1(1,0).val().val(),mv_1(1,1).val().val()); VEC h; output(0,0).d_.d_.grad(q,h); EXPECT_FLOAT_EQ(0,h[0]); EXPECT_FLOAT_EQ(0,h[1]); EXPECT_FLOAT_EQ(0,h[2]); EXPECT_FLOAT_EQ(0,h[3]); } TEST(AgradMixMatrixOperatorSubtraction,ffv_matrix_matrix_exception) { using stan::math::subtract; using stan::math::matrix_d; using stan::math::matrix_ffv; matrix_d d1(2,2), d2(1,2); matrix_ffv v1(2,2), v2(1,2); EXPECT_THROW(subtract(d1, d2), std::invalid_argument); EXPECT_THROW(subtract(d1, v2), std::invalid_argument); EXPECT_THROW(subtract(v1, d2), std::invalid_argument); EXPECT_THROW(subtract(v1, v2), std::invalid_argument); }
31.172897
111
0.635351
yizhang-cae
f5eb05845bb9112c7134f335fdd99bbdd7ccb202
2,507
cpp
C++
src/AppService.cpp
lan143/aqua_controller_esp8266
74a9a2a185037ae465898bcf797adfc7e560aebd
[ "MIT" ]
null
null
null
src/AppService.cpp
lan143/aqua_controller_esp8266
74a9a2a185037ae465898bcf797adfc7e560aebd
[ "MIT" ]
null
null
null
src/AppService.cpp
lan143/aqua_controller_esp8266
74a9a2a185037ae465898bcf797adfc7e560aebd
[ "MIT" ]
null
null
null
/** * MIT License * * Copyright (c) 2018-2019 Kravchenko Artyom * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include "AppService.h" AppService* AppService::_instance = 0; void AppService::init() { _serial = &Serial; _serial->begin(115200); _settingsService = new SettingsService(); _serialService = new SerialService(); _wifiService = new WifiService(); _wifiService->init(); _ntpUDP = new WiFiUDP(); _ntpClient = new NTPClient(*_ntpUDP); _ntpClient->setTimeOffset(3 * 3600); _ntpClient->begin(); _clockService = new ClockService(); _clockService->init(); _webServer = new WebServer(); _webServer->init(); _lightService = new LightService(); _heatingService = new HeatingService(); _aerationService = new AerationService(); _filterService = new FilterService(); _maintainTemperatureService = new MaintainTemperatureService(); _outerTemperatureService = new OuterTemperatureService(); _apiService = new ApiService(); } void AppService::update() { this->getSerialService()->update(); this->getWifiService()->update(); this->getClockService()->update(); this->getLightService()->update(); this->getHeatingService()->update(); this->getAerationService()->update(); this->getFilterService()->update(); this->getMaintainTemperatureService()->update(); this->getOuterTemperatureService()->update(); this->getApiService()->update(); }
31.734177
81
0.716394
lan143
f5f4b5d10ebf69721c7cacaaa442f4ff7f57d79c
128
cpp
C++
tensorflow-yolo-ios/dependencies/eigen/doc/snippets/SelfAdjointEigenSolver_compute_MatrixType2.cpp
initialz/tensorflow-yolo-face-ios
ba74cf39168d0128e91318e65a1b88ce4d65a167
[ "MIT" ]
27
2017-06-07T19:07:32.000Z
2020-10-15T10:09:12.000Z
tensorflow-yolo-ios/dependencies/eigen/doc/snippets/SelfAdjointEigenSolver_compute_MatrixType2.cpp
initialz/tensorflow-yolo-face-ios
ba74cf39168d0128e91318e65a1b88ce4d65a167
[ "MIT" ]
3
2017-08-25T17:39:46.000Z
2017-11-18T03:40:55.000Z
tensorflow-yolo-ios/dependencies/eigen/doc/snippets/SelfAdjointEigenSolver_compute_MatrixType2.cpp
initialz/tensorflow-yolo-face-ios
ba74cf39168d0128e91318e65a1b88ce4d65a167
[ "MIT" ]
10
2017-06-16T18:04:45.000Z
2018-07-05T17:33:01.000Z
version https://git-lfs.github.com/spec/v1 oid sha256:8aa5ed706dca5c634da572b1fb1bbb853d4587e7f5852d746790690c0ed3cd7e size 396
32
75
0.882813
initialz
f5f6075e06cee2818ca127e1d624ec7ff946fbc9
6,510
cpp
C++
Redneck/ReInstructionGenerator.cpp
MurielSoftware/Muriel
169ab5a96e1cf70b47f7892906a3dca2d6481ae3
[ "Apache-2.0" ]
1
2017-03-01T12:15:27.000Z
2017-03-01T12:15:27.000Z
Redneck/ReInstructionGenerator.cpp
MurielSoftware/Muriel
169ab5a96e1cf70b47f7892906a3dca2d6481ae3
[ "Apache-2.0" ]
1
2017-03-01T12:19:17.000Z
2017-03-01T12:19:52.000Z
Redneck/ReInstructionGenerator.cpp
MurielSoftware/Muriel
169ab5a96e1cf70b47f7892906a3dca2d6481ae3
[ "Apache-2.0" ]
null
null
null
#include "stdafx.h" #include "ReInstructionGenerator.h" #include "ReExpression.h" #include "ReInstruction.h" #include "ReBinaryOperationExpression.h" #include "ReIfExpression.h" #include "ReDeclarationExpression.h" #include "ReAssociationExpression.h" #include "ReValueExpression.h" #include "ReIdentifierExpression.h" #include "ReWhileExpression.h" namespace Redneck { InstructionGenerator::InstructionGenerator() { } InstructionGenerator::~InstructionGenerator() { } vector<Instruction*> InstructionGenerator::Generate(list<Expression*> expressions) { vector<Instruction*> instructions; DoGenerateInner(instructions, expressions, 0); return instructions; } void InstructionGenerator::DoGenerateInner(vector<Instruction*>& instructions, list<Expression*> expressions, unsigned depth) { for (Expression* expression : expressions) { DoGenerate(instructions, expression, depth); } } void InstructionGenerator::DoGenerate(vector<Instruction*>& instructions, Expression* expression, unsigned depth) { switch (expression->GetExpressionType()) { case ExpressionType::EXPRESSION_DECLARATION: GenerateDeclaration(instructions, expression, depth); break; case ExpressionType::EXPRESSION_ASSOCIATION: GenerateAssociation(instructions, expression, depth); break; case ExpressionType::EXPRESSION_VALUE: GenerateValue(instructions, expression, depth); break; case ExpressionType::EXPRESSION_IDENTIFIER: GenerateIdentifier(instructions, expression, depth); break; case ExpressionType::EXPRESSION_BIN_OPERATION: GenerateBinaryOperation(instructions, expression, depth); break; case ExpressionType::EXPRESSION_IF: GenerateIf(instructions, expression, depth); break; case ExpressionType::EXPRESSION_WHILE: GenerateWhile(instructions, expression, depth); break; } } void InstructionGenerator::GenerateDeclaration(vector<Instruction*>& instructions, Expression* expression, unsigned depth) { DeclarationExpression* declarationExpression = (DeclarationExpression*)expression; AddInstruction(instructions, ByteCode::VAR, declarationExpression->GetIdentifier()->GetValue()); DoGenerate(instructions, declarationExpression->GetDeclaration(), depth); AddInstruction(instructions, ByteCode::ASN, declarationExpression->GetIdentifier()->GetValue()); } void InstructionGenerator::GenerateAssociation(vector<Instruction*>& instructions, Expression* expression, unsigned depth) { AssociationExpression* associationExpression = (AssociationExpression*)expression; DoGenerate(instructions, associationExpression->GetDeclaration(), depth); AddInstruction(instructions, ByteCode::ASN, associationExpression->GetIdentifier()->GetValue()); } void InstructionGenerator::GenerateValue(vector<Instruction*>& instructions, Expression* expression, unsigned depth) { ValueExpression* valueExpression = (ValueExpression*)expression; AddInstruction(instructions, ByteCode::PUSH, valueExpression->GetValue()); } void InstructionGenerator::GenerateIdentifier(vector<Instruction*>& instructions, Expression* expression, unsigned depth) { IdentifierExpression* identifierExpression = (IdentifierExpression*)expression; AddInstruction(instructions, ByteCode::LOAD, identifierExpression->GetValue()); } void InstructionGenerator::GenerateBinaryOperation(vector<Instruction*>& instructions, Expression* expression, unsigned depth) { BinaryOperationExpression* binaryOperationExpression = (BinaryOperationExpression*)expression; DoGenerate(instructions, binaryOperationExpression->GetArg0(), depth); DoGenerate(instructions, binaryOperationExpression->GetArg1(), depth); if (binaryOperationExpression->GetOperator() == "+") { AddInstruction(instructions, ByteCode::ADD, EMPTY); } else if (binaryOperationExpression->GetOperator() == "-") { AddInstruction(instructions, ByteCode::SUB, EMPTY); } else if (binaryOperationExpression->GetOperator() == "*") { AddInstruction(instructions, ByteCode::MULT, EMPTY); } else if (binaryOperationExpression->GetOperator() == "/") { AddInstruction(instructions, ByteCode::DIV, EMPTY); } else if (binaryOperationExpression->GetOperator() == "==") { AddInstruction(instructions, ByteCode::EQUALS, EMPTY); } else if (binaryOperationExpression->GetOperator() == "!=") { AddInstruction(instructions, ByteCode::NEQUALS, EMPTY); } else if (binaryOperationExpression->GetOperator() == ">") { AddInstruction(instructions, ByteCode::GRT, EMPTY); } else if (binaryOperationExpression->GetOperator() == "<") { AddInstruction(instructions, ByteCode::LS, EMPTY); } else if (binaryOperationExpression->GetOperator() == ">=") { AddInstruction(instructions, ByteCode::GRTE, EMPTY); } else if (binaryOperationExpression->GetOperator() == "<=") { AddInstruction(instructions, ByteCode::LSE, EMPTY); } } void InstructionGenerator::GenerateIf(vector<Instruction*>& instructions, Expression* expression, unsigned depth) { //IfExpression* ifExpression = (IfExpression*)expression; //string jumpAddress = GetJumpAddress("cond", depth++); //DoGenerate(instructions, ifExpression->GetCondition(), depth); //AddInstruction(instructions, ByteCode::JZERO, jumpAddress); //DoGenerateInner(instructions, ifExpression->GetStatements(), depth); //AddInstruction(instructions, ByteCode::END, jumpAddress); } void InstructionGenerator::GenerateWhile(vector<Instruction*>& instructions, Expression* expression, unsigned depth) { //WhileExpression* whileExpression = (WhileExpression*)expression; //string jumpAddress = GetJumpAddress("loop", depth++); //AddInstruction(instructions, ByteCode::SKIP, jumpAddress); //DoGenerate(instructions, whileExpression->GetCondition(), depth); //AddInstruction(instructions, ByteCode::JZERO, EMPTY); //DoGenerateInner(instructions, whileExpression->GetStatements(), depth); //AddInstruction(instructions, ByteCode::LOOP, jumpAddress); } void InstructionGenerator::AddInstruction(vector<Instruction*>& instructions, ByteCode byteCode, const string& value) { instructions.push_back(new Instruction(byteCode, value)); } string InstructionGenerator::GetJumpAddress(const string& name, int depth) { stringstream sstream; sstream << name << depth; return sstream.str(); } }
36.988636
128
0.747773
MurielSoftware
f5fc7cad59b5ad1db760f6bee7dd14efb13c592d
8,377
cpp
C++
src/Selector.cpp
cppcooper/gumbo-query
f4c69278f09616e6275acd0dd2ea1d22f3785dc8
[ "MIT" ]
1
2022-02-28T15:51:39.000Z
2022-02-28T15:51:39.000Z
src/Selector.cpp
cppcooper/gumbo-query
f4c69278f09616e6275acd0dd2ea1d22f3785dc8
[ "MIT" ]
null
null
null
src/Selector.cpp
cppcooper/gumbo-query
f4c69278f09616e6275acd0dd2ea1d22f3785dc8
[ "MIT" ]
null
null
null
/*************************************************************************** * * $Id$ * **************************************************************************/ /** * @file $HeadURL$ * @author $Author$([email protected]) * @date $Date$ * @version $Revision$ * @brief * **/ #include <gumbo-query/Selector.h> #include <gumbo-query/QueryUtil.h> bool CSelector::match(GumboNode* apNode) { switch (mOp) { case EDummy: return true; case EEmpty: { if (apNode->type != GUMBO_NODE_ELEMENT) { return false; } GumboVector children = apNode->v.element.children; for (unsigned int i = 0; i < children.length; i++) { GumboNode* child = (GumboNode*) children.data[i]; if (child->type == GUMBO_NODE_TEXT || child->type == GUMBO_NODE_ELEMENT) { return false; } } return true; } case EOnlyChild: { if (apNode->type != GUMBO_NODE_ELEMENT) { return false; } GumboNode* parent = apNode->parent; if (parent == NULL) { return false; } unsigned int count = 0; for (unsigned int i = 0; i < parent->v.element.children.length; i++) { GumboNode* child = (GumboNode*) parent->v.element.children.data[i]; if (child->type != GUMBO_NODE_ELEMENT || (mOfType && apNode->v.element.tag == child->v.element.tag)) { continue; } count++; if (count > 1) { return false; } } return count == 1; } case ENthChild: { if (apNode->type != GUMBO_NODE_ELEMENT) { return false; } GumboNode* parent = apNode->parent; if (parent == NULL) { return false; } unsigned int i = 0; unsigned int count = 0; for (unsigned int j = 0; j < parent->v.element.children.length; j++) { GumboNode* child = (GumboNode*) parent->v.element.children.data[j]; if (child->type != GUMBO_NODE_ELEMENT || (mOfType && apNode->v.element.tag == child->v.element.tag)) { continue; } count++; if (apNode == child) { i = count; if (!mLast) { break; } } } if (mLast) { i = count - i + 1; } i -= mB; if (mA == 0) { return i == 0; } return i % mA == 0 && i / mA > 0; } case ETag: return apNode->type == GUMBO_NODE_ELEMENT && apNode->v.element.tag == mTag; default: return false; } } std::vector<GumboNode*> CSelector::filter(std::vector<GumboNode*> nodes) { std::vector<GumboNode*> ret; for (std::vector<GumboNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) { GumboNode* n = *it; if (match(n)) { ret.push_back(n); } } return ret; } std::vector<GumboNode*> CSelector::matchAll(GumboNode* apNode) { std::vector<GumboNode*> ret; matchAllInto(apNode, ret); return ret; } void CSelector::matchAllInto(GumboNode* apNode, std::vector<GumboNode*>& nodes) { if (match(apNode)) { nodes.push_back(apNode); } if (apNode->type != GUMBO_NODE_ELEMENT) { return; } for (unsigned int i = 0; i < apNode->v.element.children.length; i++) { GumboNode* child = (GumboNode*) apNode->v.element.children.data[i]; matchAllInto(child, nodes); } } CBinarySelector::CBinarySelector(TOperator aOp, CSelector* apS1, CSelector* apS2) { mpS1 = apS1; mpS1->retain(); mpS2 = apS2; mpS2->retain(); mOp = aOp; mAdjacent = false; } CBinarySelector::~CBinarySelector() { if (mpS1 != NULL) { mpS1->release(); mpS1 = NULL; } if (mpS2 != NULL) { mpS2->release(); mpS2 = NULL; } } CBinarySelector::CBinarySelector(CSelector* apS1, CSelector* apS2, bool aAdjacent) { mpS1 = apS1; mpS1->retain(); mpS2 = apS2; mpS2->retain(); mOp = EAdjacent; mAdjacent = aAdjacent; } bool CBinarySelector::match(GumboNode* apNode) { switch (mOp) { case EUnion: return mpS1->match(apNode) || mpS2->match(apNode); case EIntersection: return mpS1->match(apNode) && mpS2->match(apNode); case EChild: return mpS2->match(apNode) && apNode->parent != NULL && mpS1->match(apNode->parent); case EDescendant: { if (!mpS2->match(apNode)) { return false; } for (GumboNode* p = apNode->parent; p != NULL; p = p->parent) { if (mpS1->match(p)) { return true; } } return false; } case EAdjacent: { if (!mpS2->match(apNode)) { return false; } if (apNode->type != GUMBO_NODE_ELEMENT) { return false; } size_t pos = apNode->index_within_parent; GumboNode* parent = apNode->parent; if (mAdjacent) { for (long i = pos; i >= 0; i--) { GumboNode* sibling = (GumboNode*) parent->v.element.children.data[i]; if (sibling->type == GUMBO_NODE_TEXT || sibling->type == GUMBO_NODE_COMMENT) { continue; } return mpS1->match(sibling); } return false; } for (long i = pos; i >= 0; i--) { GumboNode* sibling = (GumboNode*) parent->v.element.children.data[i]; if (mpS1->match(sibling)) { return true; } } return false; } default: return false; } return false; } CAttributeSelector::CAttributeSelector(TOperator aOp, std::string aKey, std::string aValue) { mKey = aKey; mValue = aValue; mOp = aOp; } bool CAttributeSelector::match(GumboNode* apNode) { if (apNode->type != GUMBO_NODE_ELEMENT) { return false; } GumboVector attributes = apNode->v.element.attributes; for (unsigned int i = 0; i < attributes.length; i++) { GumboAttribute* attr = (GumboAttribute*) attributes.data[i]; if (mKey != attr->name) { continue; } std::string value = attr->value; switch (mOp) { case EExists: return true; case EEquals: return mValue == value; case EIncludes: for (unsigned int i = 0, j = 0; i < value.size(); i++) { if (value[i] == ' ' || value[i] == '\t' || value[i] == '\r' || value[i] == '\n' || value[i] == '\f' || i == value.size() - 1) { unsigned int length = i - j; if (i == value.size() - 1) { length++; } std::string segment = value.substr(j, length); if (segment == mValue) { return true; } j = i + 1; } } return false; case EDashMatch: if (mValue == value) { return true; } if (value.size() < mValue.size()) { return false; } return value.substr(0, mValue.size()) == mValue && value[mValue.size()] == '-'; case EPrefix: return value.size() >= mValue.size() && value.substr(0, mValue.size()) == mValue; case ESuffix: return value.size() >= mValue.size() && value.substr(value.size() - mValue.size(), mValue.size()) == mValue; case ESubString: return value.find(mValue) != std::string::npos; default: return false; } } return false; } CUnarySelector::CUnarySelector(TOperator aOp, CSelector* apS) { mpS = apS; mpS->retain(); mOp = aOp; } CUnarySelector::~CUnarySelector() { if (mpS != NULL) { mpS->release(); mpS = NULL; } } bool CUnarySelector::hasDescendantMatch(GumboNode* apNode, CSelector* apS) { for (unsigned int i = 0; i < apNode->v.element.children.length; i++) { GumboNode* child = (GumboNode*) apNode->v.element.children.data[i]; if (apS->match(child) || (child->type == GUMBO_NODE_ELEMENT && hasDescendantMatch(child, apS))) { return true; } } return false; } bool CUnarySelector::hasChildMatch(GumboNode* apNode, CSelector* apS) { for (unsigned int i = 0; i < apNode->v.element.children.length; i++) { GumboNode* child = (GumboNode*) apNode->v.element.children.data[i]; if (apS->match(child)) { return true; } } return false; } bool CUnarySelector::match(GumboNode* apNode) { switch (mOp) { case ENot: return !mpS->match(apNode); case EHasDescendant: if (apNode->type != GUMBO_NODE_ELEMENT) { return false; } return hasDescendantMatch(apNode, mpS); case EHasChild: if (apNode->type != GUMBO_NODE_ELEMENT) { return false; } return hasChildMatch(apNode, mpS); default: return false; } } bool CTextSelector::match(GumboNode* apNode) { std::string text; switch (mOp) { case EContains: text = CQueryUtil::nodeText(apNode); break; case EOwnContains: text = CQueryUtil::nodeOwnText(apNode); break; default: return false; } text = CQueryUtil::tolower(text); return text.find(mValue) != std::string::npos; } /* vim: set ts=4 sw=4 sts=4 tw=100 noet: */
19.34642
91
0.586726
cppcooper
f5fd1c55ef8abe98b3ce3a1103a32e218c189f88
2,257
cpp
C++
SysProgTemplate_SS_15/Buffer/src/Buffer.cpp
SystemOfAProg/SysProg
75cec3d856033b5bada8b9af2290c692cb2084da
[ "MIT" ]
null
null
null
SysProgTemplate_SS_15/Buffer/src/Buffer.cpp
SystemOfAProg/SysProg
75cec3d856033b5bada8b9af2290c692cb2084da
[ "MIT" ]
null
null
null
SysProgTemplate_SS_15/Buffer/src/Buffer.cpp
SystemOfAProg/SysProg
75cec3d856033b5bada8b9af2290c692cb2084da
[ "MIT" ]
1
2018-10-11T08:52:27.000Z
2018-10-11T08:52:27.000Z
/* * Buffer.cpp * * Created on: Sep 26, 2012 * Author: sofa1011 */ using namespace std; #include "../includes/Buffer.h" #include <iostream> #include <fstream> #include <stdlib.h> #include <unistd.h> Buffer::Buffer( int bufferSize) { size = bufferSize; buffer1 = new char[bufferSize]; buffer2 = new char[bufferSize]; next = buffer1; lastReadIndex = 0; fillUpBuffer(buffer1); } Buffer::~Buffer() { } char Buffer::getCurrentChar() { return *next; } char Buffer::getNextChar(){ char c; c= *next; if (*next == NULL) { if (next == &buffer1[(size-1)]) { fillUpBuffer(buffer2); next = buffer2; return getNextChar(); } else if (next == &buffer2[(size-1)]) { fillUpBuffer(buffer1); next = buffer1; return getNextChar(); } } else { next ++; } return c; } char Buffer::returnCurrentChar(){ char c; if (next == &buffer1[0]) { cout << "[Buffer]: Set pointer 'next' back to end of buffer2." << endl; next = &buffer2[(size-1)]; } else if (next == &buffer2[0]) { cout << "[Buffer]: Set pointer 'next' back to end of buffer1." << endl; next = &buffer2[(size-1)]; } else { next--; } c = *next; return c; } int Buffer::fillUpBuffer(char* bufferIndex) { ifstream is ("buffer-test-file.txt", ios::binary | ios::ate); if (is) { int length = is.tellg(); int distanceToRead; if((size-1) > (length - lastReadIndex)) { distanceToRead = (length - lastReadIndex); } else { distanceToRead = (size-1); } is.seekg (lastReadIndex, is.beg); is.read (bufferIndex, distanceToRead); bufferIndex[distanceToRead] = NULL; is.close(); lastReadIndex += distanceToRead; } return 0; } void Buffer::printDebugInfo() { cout << "[BUFFER-DEBUG-INFO]: The size of the buffer has been set to " << size << endl; cout << "[BUFFER-DEBUG-INFO]: Start-Address for buffer 1: " << ((void *) buffer1) << endl; cout << "[BUFFER-DEBUG-INFO]: Start-Address for buffer 2: " << ((void *) buffer2) << endl; cout << "[BUFFER-DEBUG-INFO]: Start-Address for next: " << ((void *) next ) << endl; } /** * For debug purposes. */ void Buffer::printCurrentDirectory() { char cwd[256]; getcwd(cwd, sizeof(cwd)); cout << endl; printf("[BUFFER-DEBUG-INFO]: Current working directory is: %s\n", cwd); }
21.701923
93
0.625609
SystemOfAProg
eb02baeea0b3dbeb7a460df319181fcff99baa62
2,278
cpp
C++
apps/settings/Settings.cpp
seldon1000/fairwindplusplus
26cf18e0ecf49c642e24cc504d56722eaddd1399
[ "Apache-2.0" ]
null
null
null
apps/settings/Settings.cpp
seldon1000/fairwindplusplus
26cf18e0ecf49c642e24cc504d56722eaddd1399
[ "Apache-2.0" ]
null
null
null
apps/settings/Settings.cpp
seldon1000/fairwindplusplus
26cf18e0ecf49c642e24cc504d56722eaddd1399
[ "Apache-2.0" ]
null
null
null
// // Created by __author__ on 18/01/2022. // #include <FairWindSdk/settings/FairComboBox.hpp> #include <FairWindSdk/settings/FairLineEdit.hpp> #include <FairWindSdk/settings/FairCheckBox.hpp> #include <FairWindSdk/settings/DisplaysBrowser.hpp> #include <FairWindSdk/settings/LayersBrowser.hpp> #include "Settings.hpp" #include "MainPage.hpp" #include "general/General.hpp" #include "extensions/Extensions.hpp" namespace fairwind::apps::settings { // Called when the app is loaded void Settings::onCreate() { // Call the framework onCreate() FairWindApp::onCreate(); // Get the FairWind singleton auto fairWind = fairwind::FairWind::getInstance(); // Register settings pages inside the FairWind singleton fairWind->registerSettingsTab(new general::General()); //fairWind->registerSettingsTab(new Connections()); fairWind->registerSettingsTab(new extensions::Extensions()); } //Called by the FairWind framework when the app is invoked for the first time void Settings::onStart() { // Call the framework onCreate() FairWindApp::onStart(); // Create the main page auto mainPage = new MainPage(nullptr, this); // Add the main page to the app pages as root page add(mainPage); // Show the root page show(); } // Called when the app is going to be in foreground void Settings::onResume() { // Call the framework onResume() FairWindApp::onResume(); } // Called when the app is going to be in background void Settings::onPause() { // Call the framework onPause() FairWindApp::onPause(); } // Called when the app is going to be stopped void Settings::onStop() { // Call the framework on onStop() FairWindApp::onStop(); } // Called when the app is going to be unloaded once and forever void Settings::onDestroy() { // Call the framework onDestroy() FairWindApp::onDestroy(); } // Called when the app is going to be unloaded once and forever void Settings::onConfigChanged() { // Call the framework onDestroy() FairWindApp::onConfigChanged(); } } // fairwind::apps::settings
27.119048
81
0.651888
seldon1000
eb04decdd2e600bf815af60cbb8d329c507c2a7f
14,982
cpp
C++
Matrix3x3.cpp
mbrandonw/opengl_physics_engine
422815999f0dc14335d1b4238c58ce7813d58038
[ "MIT" ]
1
2018-05-07T18:29:18.000Z
2018-05-07T18:29:18.000Z
Matrix3x3.cpp
mbrandonw/opengl_physics_engine
422815999f0dc14335d1b4238c58ce7813d58038
[ "MIT" ]
null
null
null
Matrix3x3.cpp
mbrandonw/opengl_physics_engine
422815999f0dc14335d1b4238c58ce7813d58038
[ "MIT" ]
null
null
null
/* --------------------------------------------------------------------------- * * Matrix2x2 class - Michael Brandon Williams * * Matrix2x2.cpp * * --------------------------------------------------------------------------- */ #include "Matrix3x3.h" Matrix3x3::Matrix3x3() { elements[0][0] = 1; elements[0][1] = 0; elements[0][2] = 0; elements[1][0] = 0; elements[1][1] = 1; elements[1][2] = 0; elements[2][0] = 0; elements[2][1] = 0; elements[2][2] = 1; } // constructor for when this matrix is to be intialized with // the same elements as another matrix Matrix3x3::Matrix3x3 (const Matrix3x3 &M) { elements[0][0] = M.elements[0][0]; elements[0][1] = M.elements[0][1]; elements[0][2] = M.elements[0][2]; elements[1][0] = M.elements[1][0]; elements[1][1] = M.elements[1][1]; elements[1][2] = M.elements[1][2]; elements[2][0] = M.elements[2][0]; elements[2][1] = M.elements[2][1]; elements[2][2] = M.elements[2][2]; } Matrix3x3::~Matrix3x3() { } // accessor float Matrix3x3::_e (const int j, const int k) const { return (elements[j][k]); } float Matrix3x3::operator () (const int j, const int k) const { return (elements[j][k]); } // modifier void Matrix3x3::set_e (const int j, const int k, const float e) { elements[j][k] = e; } // assignment const Matrix3x3& Matrix3x3::operator = (const Matrix3x3 &M) { elements[0][0] = M.elements[0][0]; elements[0][1] = M.elements[0][1]; elements[0][2] = M.elements[0][2]; elements[1][0] = M.elements[1][0]; elements[1][1] = M.elements[1][1]; elements[1][2] = M.elements[1][2]; elements[2][0] = M.elements[2][0]; elements[2][1] = M.elements[2][1]; elements[2][2] = M.elements[2][2]; return (*this); } // tests for equality const bool Matrix3x3::operator == (const Matrix3x3 &M) const { return ((elements[0][0] == M.elements[0][0]) && (elements[0][1] == M.elements[0][1]) && (elements[0][2] == M.elements[0][2]) && (elements[1][0] == M.elements[1][0]) && (elements[1][1] == M.elements[1][1]) && (elements[1][2] == M.elements[1][2]) && (elements[2][0] == M.elements[2][0]) && (elements[2][1] == M.elements[2][1]) && (elements[2][2] == M.elements[2][2])); } // tests for inequality const bool Matrix3x3::operator != (const Matrix3x3 &M) const { return ((elements[0][0] != M.elements[0][0]) && (elements[0][1] != M.elements[0][1]) && (elements[0][2] != M.elements[0][2]) && (elements[1][0] != M.elements[1][0]) && (elements[1][1] != M.elements[1][1]) && (elements[1][2] != M.elements[1][2]) && (elements[2][0] != M.elements[2][0]) && (elements[2][1] != M.elements[2][1]) && (elements[2][2] != M.elements[2][2])); } // checks if the matrix is a zero matrix bool Matrix3x3::Zero_Matrix () const { return ((elements[0][0] == 0.0f) && (elements[0][1] == 0.0f) && (elements[0][2] == 0.0f) && (elements[1][0] == 0.0f) && (elements[1][1] == 0.0f) && (elements[1][2] == 0.0f) && (elements[2][0] == 0.0f) && (elements[2][1] == 0.0f) && (elements[2][2] == 0.0f)); } // checks if the matrix is an identity matrix bool Matrix3x3::Identity_Matrix () const { return ((elements[0][0] == 1.0f) && (elements[0][1] == 0.0f) && (elements[0][2] == 0.0f) && (elements[1][0] == 0.0f) && (elements[1][1] == 1.0f) && (elements[1][2] == 0.0f) && (elements[2][0] == 0.0f) && (elements[2][1] == 0.0f) && (elements[2][2] == 1.0f)); } // turns the matrix into an identity matrix void Matrix3x3::Set_Identity_Matrix () { elements[0][0] = elements[1][1] = elements[2][2] = 1.0f; elements[0][1] = elements[0][2] = 0.0f; elements[1][0] = elements[1][2] = 0.0f; elements[2][0] = elements[2][1] = 0.0f; } // addition (+) const Matrix3x3 Matrix3x3::operator + (const Matrix3x3 &M) const { Matrix3x3 temp; temp.elements[0][0] = elements[0][0] + M.elements[0][0]; temp.elements[0][1] = elements[0][1] + M.elements[0][1]; temp.elements[0][2] = elements[0][2] + M.elements[0][2]; temp.elements[1][0] = elements[1][0] + M.elements[1][0]; temp.elements[1][1] = elements[1][1] + M.elements[1][1]; temp.elements[1][2] = elements[1][2] + M.elements[1][2]; temp.elements[2][0] = elements[2][0] + M.elements[2][0]; temp.elements[2][1] = elements[2][1] + M.elements[2][1]; temp.elements[2][2] = elements[2][2] + M.elements[2][2]; return (temp); } // addition (+=) const Matrix3x3& Matrix3x3::operator += (const Matrix3x3 &M) { elements[0][0] += M.elements[0][0]; elements[0][1] += M.elements[0][1]; elements[0][2] += M.elements[0][2]; elements[1][0] += M.elements[1][0]; elements[1][1] += M.elements[1][1]; elements[1][2] += M.elements[1][2]; elements[2][0] += M.elements[2][0]; elements[2][1] += M.elements[2][1]; elements[2][2] += M.elements[2][2]; return (*this); } // subtraction (-) const Matrix3x3 Matrix3x3::operator - (const Matrix3x3 &M) const { Matrix3x3 temp; temp.elements[0][0] = elements[0][0] - M.elements[0][0]; temp.elements[0][1] = elements[0][1] - M.elements[0][1]; temp.elements[0][2] = elements[0][2] - M.elements[0][2]; temp.elements[1][0] = elements[1][0] - M.elements[1][0]; temp.elements[1][1] = elements[1][1] - M.elements[1][1]; temp.elements[1][2] = elements[1][2] - M.elements[1][2]; temp.elements[2][0] = elements[2][0] - M.elements[2][0]; temp.elements[2][1] = elements[2][1] - M.elements[2][1]; temp.elements[2][2] = elements[2][2] - M.elements[2][2]; return (temp); } // subtraction (-=) const Matrix3x3& Matrix3x3::operator -= (const Matrix3x3 &M) { elements[0][0] -= M.elements[0][0]; elements[0][1] -= M.elements[0][1]; elements[0][2] -= M.elements[0][2]; elements[1][0] -= M.elements[1][0]; elements[1][1] -= M.elements[1][1]; elements[1][2] -= M.elements[1][2]; elements[2][0] -= M.elements[2][0]; elements[2][1] -= M.elements[2][1]; elements[2][2] -= M.elements[2][2]; return (*this); } // multiplication (*) const Matrix3x3 Matrix3x3::operator * (const Matrix3x3 &M) const { Matrix3x3 temp; temp.elements[0][0] = (elements[0][0] * M.elements[0][0]) + (elements[0][1] * M.elements[1][0]) + (elements[0][2] * M.elements[2][0]); temp.elements[1][0] = (elements[1][0] * M.elements[0][0]) + (elements[1][1] * M.elements[1][0]) + (elements[1][2] * M.elements[2][0]); temp.elements[2][0] = (elements[2][0] * M.elements[0][0]) + (elements[2][1] * M.elements[1][0]) + (elements[2][2] * M.elements[2][0]); temp.elements[0][1] = (elements[0][0] * M.elements[0][1]) + (elements[0][1] * M.elements[1][1]) + (elements[0][2] * M.elements[2][1]); temp.elements[1][1] = (elements[1][0] * M.elements[0][1]) + (elements[1][1] * M.elements[1][1]) + (elements[1][2] * M.elements[2][1]); temp.elements[2][1] = (elements[2][0] * M.elements[0][1]) + (elements[2][1] * M.elements[1][1]) + (elements[2][2] * M.elements[2][1]); temp.elements[0][2] = (elements[0][0] * M.elements[0][2]) + (elements[0][1] * M.elements[1][2]) + (elements[0][2] * M.elements[2][2]); temp.elements[1][2] = (elements[1][0] * M.elements[0][2]) + (elements[1][1] * M.elements[1][2]) + (elements[1][2] * M.elements[2][2]); temp.elements[2][2] = (elements[2][0] * M.elements[0][2]) + (elements[2][1] * M.elements[1][2]) + (elements[2][2] * M.elements[2][2]); return (temp); } // multiplcation (*=) const Matrix3x3& Matrix3x3::operator *= (const Matrix3x3 &M) { Matrix3x3 temp; temp = *this * M; *this = temp; return (*this); } // scalar-multiplication (*) const Matrix3x3 Matrix3x3::operator * (const float s) const { Matrix3x3 M; M.elements[0][0] = elements[0][0] * s; M.elements[0][1] = elements[0][1] * s; M.elements[0][2] = elements[0][2] * s; M.elements[1][0] = elements[1][0] * s; M.elements[1][1] = elements[1][1] * s; M.elements[1][2] = elements[1][2] * s; M.elements[2][0] = elements[2][0] * s; M.elements[2][1] = elements[2][1] * s; M.elements[2][2] = elements[2][2] * s; return (M); } // scalar-multiplication (*=) const Matrix3x3& Matrix3x3::operator *= (const float s) { elements[0][0] *= s; elements[0][1] *= s; elements[0][2] *= s; elements[1][0] *= s; elements[1][1] *= s; elements[1][2] *= s; elements[2][0] *= s; elements[2][1] *= s; elements[2][2] *= s; return (*this); } // vector-multiplication (*) const Vector3D Matrix3x3::operator * (const Vector3D &V) const { Vector3D temp; temp.x = (V.x * elements[0][0]) + (V.y * elements[0][1]) + (V.z * elements[0][2]); temp.y = (V.x * elements[1][0]) + (V.y * elements[1][1]) + (V.z * elements[1][2]); temp.z = (V.x * elements[2][0]) + (V.y * elements[2][1]) + (V.z * elements[2][2]); return (temp); } // matrix-division (/) const Matrix3x3 Matrix3x3::operator / (const Matrix3x3 &M) const { return (*this * M.Inverse ()); } // matrix-division (/=) const Matrix3x3& Matrix3x3::operator /= (const Matrix3x3 &M) { return (*this = *this * M.Inverse ()); } // scalar-division (/) const Matrix3x3 Matrix3x3::operator / (const float s) const { Matrix3x3 temp; temp.elements[0][0] = elements[0][0] / s; temp.elements[0][1] = elements[0][1] / s; temp.elements[0][2] = elements[0][2] / s; temp.elements[1][0] = elements[1][0] / s; temp.elements[1][1] = elements[1][1] / s; temp.elements[1][2] = elements[1][2] / s; temp.elements[2][0] = elements[2][0] / s; temp.elements[2][1] = elements[2][1] / s; temp.elements[2][2] = elements[2][2] / s; return (temp); } // scalar-division (/=) const Matrix3x3& Matrix3x3::operator /= (const float s) { elements[0][0] /= s; elements[0][1] /= s; elements[0][2] /= s; elements[1][0] /= s; elements[1][1] /= s; elements[1][2] /= s; elements[2][0] /= s; elements[2][1] /= s; elements[2][2] /= s; return (*this); } // matrix to an integer power const Matrix3x3 Matrix3x3::operator ^ (const int p) const { Matrix3x3 temp; for (int j = 0; j < p; j++) { temp *= *this; } return (temp); } // fills the matrix with random elements void Matrix3x3::Random_Elements (const int min, const int max) { Random_Number generator; for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { elements[j][k] = float (generator.Random (min, max)); } } } // sets the elements of the matrix to create a rotation matrix around the x-axis void Matrix3x3::Rotation_Matrix_X (const float sine, const float cosine) { elements[0][0] = 1; elements[0][1] = 0; elements[0][2] = 0; elements[1][0] = 0; elements[1][1] = cosine; elements[1][2] = -sine; elements[2][0] = 0; elements[2][1] = sine; elements[2][2] = cosine; } // sets the elements of the matrix to create a rotation matrix around the y-axis void Matrix3x3::Rotation_Matrix_Y (const float sine, const float cosine) { elements[0][0] = cosine; elements[0][1] = 0; elements[0][2] = sine; elements[1][0] = 0; elements[1][1] = 1; elements[1][2] = 0; elements[2][0] = -sine; elements[2][1] = 0; elements[2][2] = cosine; } // sets the elements of the matrix to create a rotation matrix around the z-axis void Matrix3x3::Rotation_Matrix_Z (const float sine, const float cosine) { elements[0][0] = cosine; elements[0][1] = -sine; elements[0][2] = 0; elements[1][0] = sine; elements[1][1] = cosine; elements[1][2] = 0; elements[2][0] = 0; elements[2][1] = 0; elements[2][2] = 1; } // sets the elements of the matrix to create a rotation matrix around an arbitrary axis void Matrix3x3::Rotation_Matrix_Axis (const float sine, const float cosine, const Vector3D &A) { float t = 1 - cosine; elements[0][0] = t * A.x * A.x + cosine; elements[0][1] = t * A.x * A.y - sine * A.z; elements[0][2] = t * A.x * A.z + sine * A.y; elements[1][0] = t * A.y * A.x + sine * A.z; elements[1][1] = t * A.y * A.y + cosine; elements[1][2] = t * A.y * A.z - sine * A.x; elements[2][0] = t * A.z * A.x - sine * A.y; elements[2][1] = t * A.z * A.y + sine * A.x; elements[2][2] = t * A.z * A.z + cosine; } // returns the inverse of an orthonormal matrix Matrix3x3 Matrix3x3::Orthonormal_Inverse () const { return (this->Transpose ()); } // returns the transpose of this matrix Matrix3x3 Matrix3x3::Transpose () const { Matrix3x3 temp; temp.elements[0][0] = elements[2][2]; temp.elements[0][1] = elements[2][1]; temp.elements[0][2] = elements[2][0]; temp.elements[1][0] = elements[1][2]; temp.elements[1][1] = elements[1][1]; temp.elements[1][2] = elements[1][0]; temp.elements[2][0] = elements[0][2]; temp.elements[2][1] = elements[0][1]; temp.elements[2][2] = elements[0][0]; return (temp); } // returns the determinant of the matrix float Matrix3x3::operator ! () const { return ((elements[0][0] * (elements[1][1] * elements[2][2] - elements[1][2] * elements[2][1])) - (elements[0][1] * (elements[1][0] * elements[2][2] - elements[1][2] * elements[2][0])) + (elements[0][2] * (elements[1][0] * elements[2][1] - elements[2][0] * elements[1][1]))); } // returns the inverse of the matrix Matrix3x3 Matrix3x3::Inverse () const { float det = !*this; Matrix3x3 temp; temp.elements[0][0] = (elements[1][1] * elements[2][2] - elements[1][2] * elements[2][1]) / det; temp.elements[0][1] = -(elements[0][1] * elements[2][2] - elements[2][1] * elements[0][2]) / det; temp.elements[0][2] = (elements[0][1] * elements[1][2] - elements[1][1] * elements[0][2]) / det; temp.elements[1][0] = -(elements[1][0] * elements[2][2] - elements[1][2] * elements[2][0]) / det; temp.elements[1][1] = (elements[0][0] * elements[2][2] - elements[2][0] * elements[0][2]) / det; temp.elements[1][2] = -(elements[0][0] * elements[1][2] - elements[1][0] * elements[0][2]) / det; temp.elements[2][0] = (elements[1][0] * elements[2][1] - elements[2][0] * elements[1][1]) / det; temp.elements[2][1] = -(elements[0][0] * elements[2][1] - elements[2][0] * elements[0][1]) / det; temp.elements[2][2] = (elements[0][0] * elements[1][1] - elements[0][1] * elements[1][0]) / det; return (temp); } // prints the properties of the maitrx void Matrix3x3::Matrix_Print (const char* name) const { cout << name << " :" << endl; cout << "[ " << elements[0][0] << " " << elements[0][1] << " " << elements[0][2] << " ]" << endl; cout << "[ " << elements[1][0] << " " << elements[1][1] << " " << elements[1][2] << " ]" << endl; cout << "[ " << elements[2][0] << " " << elements[2][1] << " " << elements[2][2] << " ]" << endl; cout << endl; }
26.376761
103
0.551128
mbrandonw
eb0b3574be11276e7637fc8ad52a432e7a735406
600
hpp
C++
ios/IOS/IPCLog.hpp
StarMKWii/saoirse
1acd4b2c56a30b6e105130cb6a58f95dd4d5d440
[ "MIT" ]
7
2022-02-16T18:21:22.000Z
2022-02-27T18:39:07.000Z
ios/IOS/IPCLog.hpp
StarMKWii/saoirse
1acd4b2c56a30b6e105130cb6a58f95dd4d5d440
[ "MIT" ]
2
2022-02-16T18:36:14.000Z
2022-02-21T02:10:42.000Z
ios/IOS/IPCLog.hpp
StarMKWii/saoirse
1acd4b2c56a30b6e105130cb6a58f95dd4d5d440
[ "MIT" ]
1
2022-02-16T18:32:08.000Z
2022-02-16T18:32:08.000Z
// IPCLog.hpp - IOS to PowerPC logging through IPC // Written by Palapeli // // Copyright (C) 2022 Team Saoirse // SPDX-License-Identifier: MIT #pragma once #include <System/OS.hpp> #include <System/Types.h> class IPCLog { public: static IPCLog* sInstance; static constexpr int printSize = 256; IPCLog(); void Run(); void Print(const char* buffer); void Notify(); void WaitForStartRequest(); protected: void HandleRequest(IOS::Request* req); Queue<IOS::Request*> m_ipcQueue; Queue<IOS::Request*> m_responseQueue; Queue<int> m_startRequestQueue; };
19.354839
50
0.683333
StarMKWii
eb0ca5d8f491f3ebc3d3e2104e38c20e89a3d41c
5,049
cc
C++
build/fuchsia/pkg/lib/vfs/cpp/service_unittest.cc
chinmaygarde/buildroot
6b69caa4c7a04b6e81709bedd52297f29c2b1a14
[ "BSD-3-Clause" ]
1
2020-12-04T02:06:21.000Z
2020-12-04T02:06:21.000Z
build/fuchsia/pkg/lib/vfs/cpp/service_unittest.cc
mdempsky/flutter_buildroot
765b0ea58a095374a73943ad78471b915c2d63e1
[ "BSD-3-Clause" ]
null
null
null
build/fuchsia/pkg/lib/vfs/cpp/service_unittest.cc
mdempsky/flutter_buildroot
765b0ea58a095374a73943ad78471b915c2d63e1
[ "BSD-3-Clause" ]
1
2019-08-26T02:16:11.000Z
2019-08-26T02:16:11.000Z
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "lib/vfs/cpp/service.h" #include <fidl/examples/echo/cpp/fidl.h> #include <lib/fdio/vfs.h> #include <lib/fidl/cpp/binding_set.h> #include "lib/gtest/real_loop_fixture.h" #include "lib/vfs/cpp/pseudo_dir.h" class ServiceTest : public gtest::RealLoopFixture, public fidl::examples::echo::Echo { void EchoString(fidl::StringPtr value, EchoStringCallback callback) override { callback(answer_); } protected: ServiceTest() : answer_("my_fake_ans"), service_name_("echo_service"), second_loop_(&kAsyncLoopConfigNoAttachToThread) { auto service = std::make_unique<vfs::Service>( bindings_.GetHandler(this, second_loop_.dispatcher())); dir_.Serve(0, dir_ptr_.NewRequest().TakeChannel(), second_loop_.dispatcher()); dir_.AddEntry(service_name_, std::move(service)); second_loop_.StartThread("vfs test thread"); } const std::string& answer() const { return answer_; } const std::string& service_name() const { return service_name_; } void AssertInValidOpen(uint32_t flag, uint32_t mode, zx_status_t expected_status) { SCOPED_TRACE("flag: " + std::to_string(flag) + ", mode: " + std::to_string(mode)); fuchsia::io::NodePtr node_ptr; dir_ptr()->Open(flag | fuchsia::io::OPEN_FLAG_DESCRIBE, mode, service_name(), node_ptr.NewRequest()); bool on_open_called = false; node_ptr.events().OnOpen = [&](zx_status_t status, std::unique_ptr<fuchsia::io::NodeInfo> unused) { EXPECT_FALSE(on_open_called); // should be called only once on_open_called = true; EXPECT_EQ(expected_status, status); }; ASSERT_TRUE(RunLoopUntil([&]() { return on_open_called; }, zx::msec(1))); } fuchsia::io::DirectoryPtr& dir_ptr() { return dir_ptr_; } private: std::string answer_; std::string service_name_; fidl::BindingSet<Echo> bindings_; vfs::PseudoDir dir_; fuchsia::io::DirectoryPtr dir_ptr_; async::Loop second_loop_; }; TEST_F(ServiceTest, CanOpenAsNodeReferenceAndTestGetAttr) { fuchsia::io::NodeSyncPtr ptr; dir_ptr()->Open(fuchsia::io::OPEN_FLAG_NODE_REFERENCE, 0, service_name(), ptr.NewRequest()); zx_status_t s; fuchsia::io::NodeAttributes attr; ptr->GetAttr(&s, &attr); EXPECT_EQ(ZX_OK, s); EXPECT_EQ(fuchsia::io::MODE_TYPE_SERVICE, attr.mode & fuchsia::io::MODE_TYPE_SERVICE); } TEST_F(ServiceTest, CanCloneNodeReference) { fuchsia::io::NodeSyncPtr cloned_ptr; { fuchsia::io::NodeSyncPtr ptr; dir_ptr()->Open(fuchsia::io::OPEN_FLAG_NODE_REFERENCE, 0, service_name(), ptr.NewRequest()); ptr->Clone(0, cloned_ptr.NewRequest()); } zx_status_t s; fuchsia::io::NodeAttributes attr; cloned_ptr->GetAttr(&s, &attr); EXPECT_EQ(ZX_OK, s); EXPECT_EQ(fuchsia::io::MODE_TYPE_SERVICE, attr.mode & fuchsia::io::MODE_TYPE_SERVICE); } TEST_F(ServiceTest, TestDescribe) { fuchsia::io::NodeSyncPtr ptr; dir_ptr()->Open(fuchsia::io::OPEN_FLAG_NODE_REFERENCE, 0, service_name(), ptr.NewRequest()); fuchsia::io::NodeInfo info; ptr->Describe(&info); EXPECT_TRUE(info.is_service()); } TEST_F(ServiceTest, CanOpenAsAService) { uint32_t flags[] = {0, fuchsia::io::OPEN_RIGHT_READABLE, fuchsia::io::OPEN_RIGHT_WRITABLE}; uint32_t modes[] = { 0, fuchsia::io::MODE_TYPE_SERVICE, V_IRWXU, V_IRUSR, V_IWUSR, V_IXUSR}; for (uint32_t mode : modes) { for (uint32_t flag : flags) { SCOPED_TRACE("flag: " + std::to_string(flag) + ", mode: " + std::to_string(mode)); fidl::examples::echo::EchoSyncPtr ptr; dir_ptr()->Open(flag, mode, service_name(), fidl::InterfaceRequest<fuchsia::io::Node>( ptr.NewRequest().TakeChannel())); fidl::StringPtr ans; ptr->EchoString("hello", &ans); EXPECT_EQ(answer(), ans); } } } TEST_F(ServiceTest, CannotOpenServiceWithInvalidFlags) { uint32_t flags[] = {fuchsia::io::OPEN_RIGHT_ADMIN, fuchsia::io::OPEN_FLAG_CREATE, fuchsia::io::OPEN_FLAG_CREATE_IF_ABSENT, fuchsia::io::OPEN_FLAG_TRUNCATE, fuchsia::io::OPEN_FLAG_APPEND, fuchsia::io::OPEN_FLAG_NO_REMOTE}; for (uint32_t flag : flags) { AssertInValidOpen(flag, 0, ZX_ERR_NOT_SUPPORTED); } AssertInValidOpen(fuchsia::io::OPEN_FLAG_DIRECTORY, 0, ZX_ERR_NOT_DIR); } TEST_F(ServiceTest, CannotOpenServiceWithInvalidMode) { uint32_t modes[] = { fuchsia::io::MODE_TYPE_DIRECTORY, fuchsia::io::MODE_TYPE_BLOCK_DEVICE, fuchsia::io::MODE_TYPE_FILE, fuchsia::io::MODE_TYPE_SOCKET}; for (uint32_t mode : modes) { AssertInValidOpen(0, mode, ZX_ERR_INVALID_ARGS); } }
33
80
0.655575
chinmaygarde
eb11c96949100356f0f01fb55f00ffa29279f7bf
584
cpp
C++
max7219/src/main.cpp
snakeye/stm32-projects
ed20e723dc1e50111c6b547fc142665b7db7843b
[ "MIT" ]
null
null
null
max7219/src/main.cpp
snakeye/stm32-projects
ed20e723dc1e50111c6b547fc142665b7db7843b
[ "MIT" ]
null
null
null
max7219/src/main.cpp
snakeye/stm32-projects
ed20e723dc1e50111c6b547fc142665b7db7843b
[ "MIT" ]
null
null
null
#include <SPI.h> #include "LedMatrix.h" #define NUMBER_OF_DEVICES 1 #define CS_PIN PB8 SPIClass SPI_2(PA7, PA6, PA5); LedMatrix ledMatrix = LedMatrix(NUMBER_OF_DEVICES, CS_PIN); int x = 0; void setup() { ledMatrix.init(); ledMatrix.setIntensity(3); ledMatrix.setText("MAX7219 Animation Demo"); ledMatrix.setNextText("Second text"); } void loop() { ledMatrix.clear(); ledMatrix.scrollTextLeft(); ledMatrix.drawText(); ledMatrix.commit(); delay(50); x = x + 1; if (x == 400) { ledMatrix.setNextText("Third text"); } }
16.222222
59
0.643836
snakeye
eb12579345dbf532985963fd617dd2411b575fe3
8,709
cpp
C++
src/layers/medWidgets/medWidgets.cpp
arthursw/medInria-public
d52af882c36f0d96cc433cc1a4082accaa1ca11a
[ "BSD-4-Clause" ]
61
2015-04-14T13:00:50.000Z
2022-03-09T22:22:18.000Z
src/layers/medWidgets/medWidgets.cpp
arthursw/medInria-public
d52af882c36f0d96cc433cc1a4082accaa1ca11a
[ "BSD-4-Clause" ]
510
2016-02-03T13:28:18.000Z
2022-03-23T10:23:44.000Z
src/layers/medWidgets/medWidgets.cpp
arthursw/medInria-public
d52af882c36f0d96cc433cc1a4082accaa1ca11a
[ "BSD-4-Clause" ]
36
2015-03-03T22:58:19.000Z
2021-12-28T18:19:23.000Z
/*========================================================================= medInria Copyright (c) INRIA 2013 - 2018. All rights reserved. See LICENSE.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =========================================================================*/ #include <medWidgets.h> namespace medWidgets { namespace pluginManager { void initialize(const QString& path, bool verbose) { for(QString const& realpath : path.split(';')) { if(realpath.isEmpty()) break; } } } namespace generic { namespace _private { medAbstractProcessPresenterFactory factory; } medAbstractProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace morphomathOperation { namespace erodeImage { namespace _private { medAbstractErodeImageProcessPresenterFactory factory; } medAbstractErodeImageProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace dilateImage { namespace _private { medAbstractDilateImageProcessPresenterFactory factory; } medAbstractDilateImageProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace openingImage { namespace _private { medAbstractOpeningImageProcessPresenterFactory factory; } medAbstractOpeningImageProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace closingImage { namespace _private { medAbstractClosingImageProcessPresenterFactory factory; } medAbstractClosingImageProcessPresenterFactory& presenterFactory() { return _private::factory; } } } namespace arithmeticOperation { namespace addImage { namespace _private { medAbstractAddImageProcessPresenterFactory factory; } medAbstractAddImageProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace subtractImage { namespace _private { medAbstractSubtractImageProcessPresenterFactory factory; } medAbstractSubtractImageProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace multiplyImage { namespace _private { medAbstractMultiplyImageProcessPresenterFactory factory; } medAbstractMultiplyImageProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace divideImage { namespace _private { medAbstractDivideImageProcessPresenterFactory factory; } medAbstractDivideImageProcessPresenterFactory& presenterFactory() { return _private::factory; } } } namespace maskImage { namespace _private { medAbstractMaskImageProcessPresenterFactory factory; } medAbstractMaskImageProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace dwiMasking { namespace _private { medAbstractDWIMaskingProcessPresenterFactory factory; } medAbstractDWIMaskingProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace diffusionModelEstimation { namespace _private { medAbstractDiffusionModelEstimationProcessPresenterFactory factory; } medAbstractDiffusionModelEstimationProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace diffusionScalarMaps { namespace _private { medAbstractDiffusionScalarMapsProcessPresenterFactory factory; } medAbstractDiffusionScalarMapsProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace tractography { namespace _private { medAbstractTractographyProcessPresenterFactory factory; } medAbstractTractographyProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace singleFilterOperation { namespace addFilter { namespace _private { medAbstractAddFilterProcessPresenterFactory factory; } medAbstractAddFilterProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace divideFilter { namespace _private { medAbstractDivideFilterProcessPresenterFactory factory; } medAbstractDivideFilterProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace gaussianFilter { namespace _private { medAbstractGaussianFilterProcessPresenterFactory factory; } medAbstractGaussianFilterProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace invertFilter { namespace _private { medAbstractInvertFilterProcessPresenterFactory factory; } medAbstractInvertFilterProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace medianFilter { namespace _private { medAbstractMedianFilterProcessPresenterFactory factory; } medAbstractMedianFilterProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace multiplyFilter { namespace _private { medAbstractMultiplyFilterProcessPresenterFactory factory; } medAbstractMultiplyFilterProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace normalizeFilter { namespace _private { medAbstractNormalizeFilterProcessPresenterFactory factory; } medAbstractNormalizeFilterProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace shrinkFilter { namespace _private { medAbstractShrinkFilterProcessPresenterFactory factory; } medAbstractShrinkFilterProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace subtractFilter { namespace _private { medAbstractSubtractFilterProcessPresenterFactory factory; } medAbstractSubtractFilterProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace windowingFilter { namespace _private { medAbstractWindowingFilterProcessPresenterFactory factory; } medAbstractWindowingFilterProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace imageDenoising { namespace _private { medAbstractImageDenoisingProcessPresenterFactory factory; } medAbstractImageDenoisingProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace relaxometryEstimation { namespace _private { medAbstractRelaxometryEstimationProcessPresenterFactory factory; } medAbstractRelaxometryEstimationProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace symmetryAlignment { namespace _private { medAbstractSymmetryPlaneAlignmentProcessPresenterFactory factory; } medAbstractSymmetryPlaneAlignmentProcessPresenterFactory& presenterFactory() { return _private::factory; } } namespace biasCorrection { namespace _private { medAbstractBiasCorrectionProcessPresenterFactory factory; } medAbstractBiasCorrectionProcessPresenterFactory& presenterFactory() { return _private::factory; } } } } // end of medWidgets
21.450739
84
0.620393
arthursw
eb12e8c106cc2023e2424f6bdea758c0671c1f82
1,152
cpp
C++
acm/siweishixun/F.cpp
xiaohuihuigh/cpp
c28bdb79ecb86f44a92971ac259910546dba29a7
[ "MIT" ]
17
2016-01-01T12:57:25.000Z
2022-02-06T09:55:12.000Z
acm/siweishixun/F.cpp
xiaohuihuigh/cpp
c28bdb79ecb86f44a92971ac259910546dba29a7
[ "MIT" ]
null
null
null
acm/siweishixun/F.cpp
xiaohuihuigh/cpp
c28bdb79ecb86f44a92971ac259910546dba29a7
[ "MIT" ]
8
2018-12-27T01:31:49.000Z
2022-02-06T09:55:12.000Z
#include <iostream> #include <sstream> #include <ios> #include <iomanip> #include <functional> #include <algorithm> #include <vector> #include <string> #include <list> #include <queue> #include <deque> #include <stack> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <climits> #include <cctype> using namespace std; #define XINF INT_ma #define INF 0x3FFFFFFF #define MP(X,Y) make_pair(X,Y) #define PB(X) push_back(X) #define REP(X,N) for(int X=0;X<N;X++) #define REP2(X,L,R) for(int X=L;X<=R;X++) #define DEP(X,R,L) for(int X=R;X>=L;X--) #define CLR(A,X) memset(A,X,sizeof(A)) #define INF 0x3FFFFFFF #define IT iterator typedef long long ll; typedef pair<int,int> PII; typedef vector<PII> VII; typedef vector<int> VI; //const int maN = 10010; int T; int n; double ma,mi,num,sum,ave; int main(){ cin>>T; while(T--){ cin>>n; mi = 1000; ma = -1000; num = 0;sum = 0;ave = 0; REP(i,n) { cin>>num; if(mi>num){mi = num;} if(ma<num){ma = num;} sum += num; } printf("%.2lf,%.2lf,%.2lf\n",mi,ma,(sum - mi - ma)/(n-2)); } return 0; }
12.659341
60
0.625
xiaohuihuigh
eb14d23764369379aee9cfa82cf6393c07699923
5,358
cpp
C++
stack/stackTest.cpp
hballaba/STL
d1064c102e87f6d871b61d251b9f383bead7b056
[ "Unlicense" ]
null
null
null
stack/stackTest.cpp
hballaba/STL
d1064c102e87f6d871b61d251b9f383bead7b056
[ "Unlicense" ]
null
null
null
stack/stackTest.cpp
hballaba/STL
d1064c102e87f6d871b61d251b9f383bead7b056
[ "Unlicense" ]
null
null
null
#include "stack.hpp" #include <stack> #include <vector> #include <deque> # define G "\e[92m\e[1m" # define D "\e[39m\e[0m" # define R "\e[91m" # define Y "\e[93m" int main() { try { /****** CONSTRUCTOR ********/ { std::cout << Y "My constructor\n" D; std::deque<int> mydeque1 (3,100); // deque with 3 elements std::vector<int> myvector1 (2,200); // vector with 2 elements ft::stack<int> first1; // empty stack ft::stack<int, std::deque<int> > second1(mydeque1); // stack initialized to copy of deque ft::stack<int,std::vector<int> > third1; // empty stack using vector ft::stack<int,std::vector<int> > fourth1 (myvector1); std::cout << "size of first: " << first1.size() << '\n'; std::cout << "size of second: " << second1.size() << '\n'; std::cout << "size of third: " << third1.size() << '\n'; std::cout << "size of fourth: " << fourth1.size() << '\n'; std::cout << Y"\nOriginal constructor\n"D; std::deque<int> origdeque (3,100); // deque with 3 elements std::vector<int> origvector (2,200); // vector with 2 elements std::stack<int> first; // empty stack std::stack<int> second (origdeque); // stack initialized to copy of deque std::stack<int,std::vector<int> > third; // empty stack using vector std::stack<int,std::vector<int> > fourth (origvector); std::cout << "size of first: " << first.size() << '\n'; std::cout << "size of second: " << second.size() << '\n'; std::cout << "size of third: " << third.size() << '\n'; std::cout << "size of fourth: " << fourth.size() << '\n'; } { std::cout << Y"My member function\n"D; std::stack<char> myStack; std::cout << "myStack empty = " << myStack.empty() << std::endl; myStack.push('A'); myStack.push('B'); myStack.push('C'); std::cout << "myStack empty = " << myStack.empty() << std::endl; std::cout << "size of myStack: " << myStack.size() << '\n'; std::cout << "top = " << myStack.top() << '\n'; myStack.top() += 5; //change top element + 5 std::cout << "top = " << myStack.top() << '\n'; myStack.pop(); std::cout << "After metod pop\n"; std::cout << "size of myStack: " << myStack.size() << '\n'; std::cout << "top = " << myStack.top() << '\n'; std::cout << "size of myStack: " << myStack.size() << '\n'; std::cout << Y"Original member function\n"D; std::stack<char> origStack; std::cout << "origStack empty = " << origStack.empty() << std::endl; origStack.push('A'); origStack.push('B'); origStack.push('C'); std::cout << "origStack empty = " << origStack.empty() << std::endl; std::cout << "size of origStack: " << origStack.size() << '\n'; std::cout << "top = " << origStack.top() << '\n'; origStack.top() += 5; std::cout << "top = " << origStack.top() << '\n'; origStack.pop(); std::cout << "After metod pop\n"; std::cout << "size of origStack: " << origStack.size() << '\n'; std::cout << "top = " << origStack.top() << '\n'; std::cout << "size of origStack: " << origStack.size() << '\n'; } { std::cout <<Y "My non-member function\n" D; ft::stack<int> myStack1; myStack1.push(5); ft::stack<int> myStack2; myStack1.push(3); std::cout << "'==' = " << (myStack1 == myStack2) << "\n"; std::cout << "'!=' = " << (myStack1 != myStack2) << "\n"; std::cout << "'>' = " << (myStack1 > myStack2) << "\n"; std::cout << "'>=' = " << (myStack1 >= myStack2) << "\n"; std::cout << "'<' = " << (myStack1 < myStack2) << "\n"; std::cout << "'<=' = " << (myStack1 == myStack2) << "\n"; std::cout <<Y "Original non-member function\n" D; std::stack<int> origStack1; origStack1.push(5); std::stack<int> origStack2; origStack2.push(3); std::cout << "'==' = " << (origStack1 == origStack2) << "\n"; std::cout << "'!=' = " << (origStack1 != origStack2) << "\n"; std::cout << "'>' = " << (origStack1 > origStack2) << "\n"; std::cout << "'>=' = " << (origStack1 >= origStack2) << "\n"; std::cout << "'<' = " << (origStack1 < origStack2) << "\n"; std::cout << "'<=' = " << (origStack1 == origStack2) << "\n"; std::cout << Y"Now you can check memory leaks, with leaks a.out in other terminal" << D"\n"; std::cout << G"To exit press Enter" << D"\n"; getchar(); std::cout << G"Good bye" << D"\n"; } } catch(const char * e) { std::cerr << e << '\n'; } catch(const std::exception& e) { std::cerr << e.what() << '\n'; } return 0; }
38.271429
109
0.447555
hballaba
a3e1fe9e435a8a803c5e1fa8f3443340cc22002a
11,551
hpp
C++
object_database/View.hpp
APrioriInvestments/object_database
d44b8432490b36b1ace67de0e23fb59f7ce9b529
[ "Apache-2.0" ]
2
2021-02-23T18:28:40.000Z
2021-04-18T03:00:53.000Z
object_database/View.hpp
APrioriInvestments/object_database
d44b8432490b36b1ace67de0e23fb59f7ce9b529
[ "Apache-2.0" ]
115
2019-10-08T18:32:58.000Z
2021-02-12T20:16:14.000Z
object_database/View.hpp
APrioriInvestments/object_database
d44b8432490b36b1ace67de0e23fb59f7ce9b529
[ "Apache-2.0" ]
null
null
null
/****************************************************************************** Copyright 2017-2019 object_database Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ******************************************************************************/ #pragma once #include "DatabaseConnectionState.hpp" #include "HashFunctions.hpp" #include <unordered_set> #include <unordered_map> /********** Views provide running (native)python threads with a snapshotted view of the current object-database's subscribed data. A view holds a reference to a collection of objects that have different representation at different transaction_ids, along with a single transaction_id. We show a coherent view of all the objects whose versions are <= the given transaction_id. We also track all objects and indices we read or write during execution. ***********/ class View { public: View(std::shared_ptr<DatabaseConnectionState> connection, transaction_id tid, bool allowWrites) : m_tid(tid), m_allow_writes(allowWrites), m_enclosing_view(nullptr), m_is_entered(false), m_ever_entered(false), m_versioned_objects(*connection->getVersionedObjects()), m_connection_state(connection) { m_connection_state->increfVersion(m_tid); m_serialization_context = m_connection_state->getContext(); } ~View() { if (!m_ever_entered) { m_connection_state->decrefVersion(m_tid); } } void setSerializationContext(std::shared_ptr<SerializationContext> context) { m_serialization_context = context; } std::shared_ptr<SerializationContext> getSerializationContext() { return m_serialization_context; } void enter() { if (m_is_entered || m_ever_entered) { throw std::runtime_error("Can't enter a view twice."); } m_ever_entered = true; m_is_entered = true; m_enclosing_view = s_current_view; s_current_view = this; } static View* currentView() { return s_current_view; } void exit() { if (!m_is_entered) { throw std::runtime_error("Can't exit an un-entered view."); } m_is_entered = false; s_current_view = m_enclosing_view; m_enclosing_view = nullptr; m_connection_state->decrefVersion(m_tid); } bool objectIsVisible(SchemaAndTypeName objType, object_id oid) { return m_connection_state->objectIsVisible(objType, oid, m_tid); } void loadLazyObjectIfNeeded(object_id oid) { m_connection_state->loadLazyObjectIfNeeded(oid); } void newObject(SchemaAndTypeName obType, object_id oid) { m_connection_state->markObjectSubscribed(obType, oid, m_tid); } // lookup the current value of an object. if we have written to it, use that value. // otherwise use the value in the view. If the value does not exist, returns a null pointer. // we also record what values were read instance_ptr getField(field_id field, object_id oid, Type* t, bool recordAccess=true) { auto delete_it = m_delete_cache.find(std::make_pair(field, oid)); if (delete_it != m_delete_cache.end()) { return nullptr; } auto write_it = m_write_cache.find(std::make_pair(field, oid)); if (write_it != m_write_cache.end()) { return write_it->second.data(); } instance_ptr i = m_versioned_objects.bestObjectVersion(t, m_serialization_context, field, oid, m_tid).first; if (recordAccess) { m_read_values.insert(std::make_pair(field, oid)); } return i; } bool fieldExists(field_id field, object_id oid, Type* t, bool recordAccess=true) { auto delete_it = m_delete_cache.find(std::make_pair(field, oid)); if (delete_it != m_delete_cache.end()) { return false; } auto write_it = m_write_cache.find(std::make_pair(field, oid)); if (write_it != m_write_cache.end()) { return true; } bool res = m_versioned_objects.existsAtTransaction(t, field, oid, m_tid); if (recordAccess) { m_read_values.insert(std::make_pair(field, oid)); } return res; } void setField(field_id field, object_id oid, Type* t, instance_ptr data) { if (!m_allow_writes) { throw std::runtime_error("Please use a transaction if you wish to write to object_database fields."); } auto delete_it = m_delete_cache.find(std::make_pair(field, oid)); if (delete_it != m_delete_cache.end()) { throw std::runtime_error("Value is deleted."); } if (data) { //if we're writing a new value, record whether this is a new object //that we're populating into 'm_new_writes' bool existsAlready = fieldExists(field, oid, t, false); if (!existsAlready) { m_new_writes.insert(std::make_pair(field, oid)); } m_write_cache[std::make_pair(field, oid)] = Instance(data, t); } else { bool wasNewWrite = m_new_writes.find(std::make_pair(field, oid)) != m_new_writes.end(); m_write_cache.erase(std::make_pair(field, oid)); if (!wasNewWrite) { //if the object already existed, we need to mark that we're deleting it m_delete_cache.insert(std::make_pair(field, oid)); } } } void indexAdd(field_id fid, index_value i, object_id o) { IndexKey key(fid, i); //check if we are adding something back to an index it was removed from already auto remove_it = m_set_removes.find(key); if (remove_it != m_set_removes.end()) { auto it = remove_it->second.find(o); if (it != remove_it->second.end()) { remove_it->second.erase(it); return; } } if (m_versioned_objects.indexContains(fid, i, m_tid, o)) { throw std::runtime_error("Index already contains this value."); } m_set_adds[key].insert(o); } void indexRemove(field_id fid, index_value i, object_id o) { IndexKey key(fid, i); //check if we are adding something back to an index it was removed from already auto add_it = m_set_adds.find(key); if (add_it != m_set_adds.end()) { auto it = add_it->second.find(o); if (it != add_it->second.end()) { add_it->second.erase(it); return; } } if (!m_versioned_objects.indexContains(fid, i, m_tid, o)) { throw std::runtime_error("Index doesn't contain this value."); } m_set_removes[key].insert(o); } bool shouldSuppressIndexValue(field_id fid, index_value i, object_id o) { auto remove_it = m_set_removes.find(IndexKey(fid, i)); if (remove_it == m_set_removes.end()) { return false; } return remove_it->second.find(o) != remove_it->second.end(); } object_id firstAddedIndexValue(field_id fid, index_value i) { auto add_it = m_set_adds.find(IndexKey(fid, i)); if (add_it == m_set_adds.end()) { return NO_OBJECT; } if (add_it->second.size() == 0) { return NO_OBJECT; } return *add_it->second.begin(); } object_id nextAddedIndexValue(field_id fid, index_value i, object_id o) { auto add_it = m_set_adds.find(IndexKey(fid, i)); if (add_it == m_set_adds.end()) { return NO_OBJECT; } auto next_ob_it = add_it->second.upper_bound(o); if (next_ob_it == add_it->second.end()) { return NO_OBJECT; } return *next_ob_it; } object_id indexLookupFirst(field_id fid, index_value i) { m_set_reads.insert(IndexKey(fid, i)); //we need to suppress anything in 'm_set_removes' and add anything in 'm_set_adds' object_id first = m_versioned_objects.indexLookupFirst(fid, i, m_tid); object_id firstAdded = firstAddedIndexValue(fid, i); if (first == NO_OBJECT) { return firstAdded; } //loop until we find a value in the main set that's lower than 'firstAdded' while (true) { if (firstAdded != NO_OBJECT && firstAdded < first) { return firstAdded; } if (!shouldSuppressIndexValue(fid, i, first)) { return first; } first = m_versioned_objects.indexLookupNext(fid, i, m_tid, first); if (first == NO_OBJECT) { return firstAdded; } } } object_id indexLookupNext(field_id fid, index_value i, object_id o) { m_set_reads.insert(IndexKey(fid, i)); object_id next = m_versioned_objects.indexLookupNext(fid, i, m_tid, o); object_id nextAdded = nextAddedIndexValue(fid, i, o); if (next == NO_OBJECT) { return nextAdded; } //loop until we find a value in the main set that's lower than 'firstAdded' while (true) { if (nextAdded != NO_OBJECT && nextAdded < next) { return nextAdded; } if (!shouldSuppressIndexValue(fid, i, next)) { return next; } next = m_versioned_objects.indexLookupNext(fid, i, m_tid, next); if (next == NO_OBJECT) { return nextAdded; } } } DatabaseConnectionState& getConnectionState() { return *m_connection_state; } bool isWriteable() const { return m_allow_writes; } const std::unordered_set<std::pair<field_id, object_id> >& getReadValues() const { return m_read_values; } const std::unordered_map<std::pair<field_id, object_id>, Instance>& getWriteCache() const { return m_write_cache; } const std::unordered_set<std::pair<field_id, object_id> >& getDeleteCache() const { return m_delete_cache; } const std::unordered_map<IndexKey, std::set<object_id> >& getSetAdds() const { return m_set_adds; } const std::unordered_map<IndexKey, std::set<object_id> >& getSetRemoves() const { return m_set_removes; } const std::unordered_set<IndexKey >& getSetReads() const { return m_set_reads; } transaction_id getTransactionId() const { return m_tid; } private: static thread_local View* s_current_view; //the transaction id that snapshots this view transaction_id m_tid; //is this a view or a transaction? bool m_allow_writes; View* m_enclosing_view; bool m_is_entered; bool m_ever_entered; std::unordered_set<std::pair<field_id, object_id> > m_read_values; std::unordered_map<std::pair<field_id, object_id>, Instance> m_write_cache; std::unordered_set<std::pair<field_id, object_id> > m_new_writes; std::unordered_set<std::pair<field_id, object_id> > m_delete_cache; std::unordered_map<IndexKey, std::set<object_id> > m_set_adds; std::unordered_map<IndexKey, std::set<object_id> > m_set_removes; std::unordered_set<IndexKey > m_set_reads; VersionedObjects& m_versioned_objects; std::shared_ptr<DatabaseConnectionState> m_connection_state; std::shared_ptr<SerializationContext> m_serialization_context; };
30.23822
114
0.644793
APrioriInvestments
a3e4539f4971a33311c2b5d816d06f0e2708ab7e
1,121
hpp
C++
include/SSVOpenHexagon/Global/Version.hpp
PKPenguin321/SSVOpenHexagon
1fcc25fea8f0ef6845d9b5502455a76563df91c3
[ "AFL-3.0" ]
20
2021-12-02T17:49:54.000Z
2022-03-26T05:52:26.000Z
include/SSVOpenHexagon/Global/Version.hpp
PKPenguin321/SSVOpenHexagon
1fcc25fea8f0ef6845d9b5502455a76563df91c3
[ "AFL-3.0" ]
4
2022-01-07T19:06:01.000Z
2022-03-28T01:26:16.000Z
include/SSVOpenHexagon/Global/Version.hpp
PKPenguin321/SSVOpenHexagon
1fcc25fea8f0ef6845d9b5502455a76563df91c3
[ "AFL-3.0" ]
1
2022-01-27T09:18:06.000Z
2022-01-27T09:18:06.000Z
// Copyright (c) 2013-2020 Vittorio Romeo // License: Academic Free License ("AFL") v. 3.0 // AFL License page: https://opensource.org/licenses/AFL-3.0 #pragma once namespace hg { // Allow us to represent the game's version in a major.minor.micro format struct GameVersion { int major; int minor; int micro; [[nodiscard]] constexpr bool operator<( const GameVersion& rhs) const noexcept { if(major != rhs.major) { return major < rhs.major; } if(minor != rhs.minor) { return minor < rhs.minor; } return micro < rhs.micro; } [[nodiscard]] constexpr bool operator==( const GameVersion& other) const noexcept { return (major == other.major) && (minor == other.minor) && (micro == other.micro); } [[nodiscard]] constexpr bool operator!=( const GameVersion& other) const noexcept { return !(*this == other); } }; inline constexpr GameVersion GAME_VERSION{2, 1, 4}; inline constexpr auto& GAME_VERSION_STR = "2.1.4"; } // namespace hg
22.42
73
0.58876
PKPenguin321
a3eebe0c006811c0ed4bb8aed14a43b19205af91
432
cpp
C++
Firmware/unit_tests/tests/LcdBacklightTest/LcdBacklightTest.cpp
zukaitis/midi-grid
527ad37348983f481511fef52d1645eab3a2f60e
[ "BSD-3-Clause" ]
59
2018-03-17T10:32:48.000Z
2022-03-19T17:59:29.000Z
Firmware/unit_tests/tests/LcdBacklightTest/LcdBacklightTest.cpp
zukaitis/midi-grid
527ad37348983f481511fef52d1645eab3a2f60e
[ "BSD-3-Clause" ]
3
2019-11-12T09:49:59.000Z
2020-12-09T11:55:00.000Z
Firmware/unit_tests/tests/LcdBacklightTest/LcdBacklightTest.cpp
zukaitis/midi-grid
527ad37348983f481511fef52d1645eab3a2f60e
[ "BSD-3-Clause" ]
10
2019-03-14T22:53:39.000Z
2021-12-26T13:42:20.000Z
#include <gtest/gtest.h> #include "lcd/backlight/Backlight.h" #include "hardware/lcd/MockBacklightDriver.h" #include "freertos/MockThread.h" int main( int argc, char **argv) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } TEST( BacklightConstructor, Create ) { hardware::lcd::MockBacklightDriver mockBacklightDriver; const lcd::Backlight backlight( mockBacklightDriver ); SUCCEED(); }
20.571429
59
0.722222
zukaitis
a3f449eedbe5c0a195b2ab24f722062600fb5af9
28,928
cc
C++
attestation/server/pkcs11_key_store_test.cc
kalyankondapally/chromiumos-platform2
5e5337009a65b1c9aa9e0ea565f567438217e91f
[ "BSD-3-Clause" ]
null
null
null
attestation/server/pkcs11_key_store_test.cc
kalyankondapally/chromiumos-platform2
5e5337009a65b1c9aa9e0ea565f567438217e91f
[ "BSD-3-Clause" ]
null
null
null
attestation/server/pkcs11_key_store_test.cc
kalyankondapally/chromiumos-platform2
5e5337009a65b1c9aa9e0ea565f567438217e91f
[ "BSD-3-Clause" ]
1
2020-11-04T22:31:45.000Z
2020-11-04T22:31:45.000Z
// Copyright 2015 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "attestation/server/pkcs11_key_store.h" #include <map> #include <string> #include <vector> #include <base/logging.h> #include <base/strings/string_number_conversions.h> #include <chaps/attributes.h> #include <chaps/chaps_proxy_mock.h> #include <chaps/token_manager_client_mock.h> #include <brillo/cryptohome.h> #include <brillo/map_utils.h> #include <gmock/gmock.h> #include <gtest/gtest.h> using ::testing::_; using ::testing::DoAll; using ::testing::Invoke; using ::testing::NiceMock; using ::testing::Return; using ::testing::SetArgPointee; namespace { const uint64_t kSession = 7; // Arbitrary non-zero value. const char kDefaultUser[] = "test_user"; const char kValidRsaPublicKeyHex[] = "3082010A0282010100" "961037BC12D2A298BEBF06B2D5F8C9B64B832A2237F8CF27D5F96407A6041A4D" "AD383CB5F88E625F412E8ACD5E9D69DF0F4FA81FCE7955829A38366CBBA5A2B1" "CE3B48C14B59E9F094B51F0A39155874C8DE18A0C299EBF7A88114F806BE4F25" "3C29A509B10E4B19E31675AFE3B2DA77077D94F43D8CE61C205781ED04D183B4" "C349F61B1956C64B5398A3A98FAFF17D1B3D9120C832763EDFC8F4137F6EFBEF" "46D8F6DE03BD00E49DEF987C10BDD5B6F8758B6A855C23C982DDA14D8F0F2B74" "E6DEFA7EEE5A6FC717EB0FF103CB8049F693A2C8A5039EF1F5C025DC44BD8435" "E8D8375DADE00E0C0F5C196E04B8483CC98B1D5B03DCD7E0048B2AB343FFC11F" "0203" "010001"; const char kValidRsaCertificateHex[] = "3082040f308202f7a003020102020900bd0f8fd6bf496b67300d06092a864886" "f70d01010b050030819d310b3009060355040613025553311330110603550408" "0c0a43616c69666f726e69613116301406035504070c0d4d6f756e7461696e20" "5669657731133011060355040a0c0a4368726f6d69756d4f533111300f060355" "040b0c08556e6974546573743117301506035504030c0e506b637331314b6579" "53746f72653120301e06092a864886f70d010901161174657374406368726f6d" "69756d2e6f7267301e170d3135303231383137303132345a170d313731313133" "3137303132345a30819d310b3009060355040613025553311330110603550408" "0c0a43616c69666f726e69613116301406035504070c0d4d6f756e7461696e20" "5669657731133011060355040a0c0a4368726f6d69756d4f533111300f060355" "040b0c08556e6974546573743117301506035504030c0e506b637331314b6579" "53746f72653120301e06092a864886f70d010901161174657374406368726f6d" "69756d2e6f726730820122300d06092a864886f70d01010105000382010f0030" "82010a0282010100a8fb9e12b1e5298b9a24fabc3901d00c32057392c763836e" "0b55cff8e67d39b9b9853920fd615688b3e13c03a10cb5668187819172d1d269" "70f0ff8d4371ac581f6970a0e43a1d0d61a94741a771fe86aee45ab0ca059b1f" "c067f7416f08544cc4d08ec884b6d4327bb3ec0dc0789639375bd159df0efd87" "1cf4d605778c7a68c96b94cf0a6c29f9a23bc027e8250084eb2dfca817b20f57" "a6fe09513f884389db7b90788aea70c6e1638f24e39553ac0f859e585965c425" "9ed7b9680fde3e059f254d8c9494f6ab425ede80d63366dfcb7cc311f5bc6fb0" "1c27d81f4c5112d04b7614c37ba19c014916816372c773e4e44564fac34565ad" "ebf38fe56c1413170203010001a350304e301d0603551d0e04160414fe13c7db" "459bd2881e9113198e1f072e16cea144301f0603551d23041830168014fe13c7" "db459bd2881e9113198e1f072e16cea144300c0603551d13040530030101ff30" "0d06092a864886f70d01010b05000382010100a163d636ac64bd6f67eca53708" "5f92abc993a40fd0c0222a56b262c29f88057a3edf9abac024756ad85d7453d8" "4782e0be65d176aecfb0fbfc88ca567d17124fa190cb5ce832264360dd6daee1" "e121428de28dda0b8ba117a1be3cf438efd060a3b5fc812e7eba70cec12cb609" "738fc7d0912546c42b5aaadb142adce2167c7f30cd9e0049687d384334335aff" "72aebd1745a0aac4be816365969347f064f36f7fdec69f970f28b87061650470" "c63be8475bb23d0485985fb77c7cdd9d9fe008211a9ddd0fe68efb0b47cf629c" "941d31e3c2f88e670e7e4ef1129febad000e6a16222779fbfe34641e5243ca38" "74e2ad06f9585a00bec014744d3175ecc4808d"; constexpr char kValidEccPublicKeyHex[] = "3059301306072A8648CE3D020106082A8648CE3D030107034200045C9633047E7518B3E0DF" "6C019BAA7CC8D0CB1F18DB781B382E02273054A304CCBEEAD2ED273DA1D6FCDFAB8B55DE4E" "830FF43899F82DB6104381615992542F3D"; constexpr char kValidEccCertificateHex[] = "3082032930820211a00302010202160174fb9852da9f991b7fd47ebd190000000000001418" "300d06092a864886f70d01010505003081853120301e060355040313175072697661637920" "434120496e7465726d65646961746531123010060355040b13094368726f6d65204f533113" "3011060355040a130a476f6f676c6520496e63311630140603550407130d4d6f756e746169" "6e2056696577311330110603550408130a43616c69666f726e6961310b3009060355040613" "025553301e170d3230313030363034313032395a170d3232313030363034313032395a303d" "31183016060355040b130f73746174653a646576656c6f7065723121301f060355040a1318" "4368726f6d652044657669636520456e74657270726973653059301306072a8648ce3d0201" "06082a8648ce3d030107034200045c9633047e7518b3e0df6c019baa7cc8d0cb1f18db781b" "382e02273054a304ccbeead2ed273da1d6fcdfab8b55de4e830ff43899f82db61043816159" "92542f3da381a030819d30290603551d0e04220420837f40ecb000f7ffccda6dab8cd526d9" "43b6fe8ce56c84be5dc70cd3ed8f7410302b0603551d23042430228020f420b6d9d862f68b" "0915ce8b57a4fc574eb8c17ca5f9e656dbd0529429bd6d7f300e0603551d0f0101ff040403" "020780300c0603551d130101ff0402300030110603551d20040a300830060604551d200030" "12060a2b06010401d679020113040404020802300d06092a864886f70d0101050500038201" "010028a2e3a90c10a850cbee4e575da068bee21753212cc551b0f09eb327a15df01dffec87" "2509dedf06c9f34a5e9c987fb5c0d0878a400056c082f015d3153159a38dd71b6dd73e8dad" "2f1ce6ac43ed7cf550e8627b5d21dcf41661fcbc58075be7993b8cd7c06941b712ae052609" "6a20e559c9fb0cf3da807d261563cdddc74c18998ebd2859b26156d0c8bee2784dc8d6aeff" "d5400331466bdec5f6384cdad7f5e5eb620a246eb0e0ac8624e2f76d70207a4574adb53277" "4974ef08aedfb8dd3c05979b126414d17a7c1ad5bbc13f0bf95b1cded312837839aa344979" "151dc4f70ad86c842091d305a9b667b4e4bd67d6b2e3aa1df385a09553ae2028c9f18b45"; std::string HexDecode(const std::string hex) { std::vector<uint8_t> output; CHECK(base::HexStringToBytes(hex, &output)); return std::string(reinterpret_cast<char*>(output.data()), output.size()); } class ScopedFakeSalt { public: ScopedFakeSalt() : salt_(128, 0) { brillo::cryptohome::home::SetSystemSalt(&salt_); } ~ScopedFakeSalt() { brillo::cryptohome::home::SetSystemSalt(nullptr); } private: std::string salt_; }; class ScopedDisableVerboseLogging { public: ScopedDisableVerboseLogging() : original_severity_(logging::GetMinLogLevel()) { logging::SetMinLogLevel(logging::LOG_INFO); } ~ScopedDisableVerboseLogging() { logging::SetMinLogLevel(original_severity_); } private: logging::LogSeverity original_severity_; }; } // namespace namespace attestation { typedef chaps::ChapsProxyMock Pkcs11Mock; // Implements a fake PKCS #11 object store. Labeled data blobs can be stored // and later retrieved. The mocked interface is ChapsInterface so these // tests must be linked with the Chaps PKCS #11 library. The mock class itself // is part of the Chaps package; it is reused here to avoid duplication (see // chaps_proxy_mock.h). class KeyStoreTest : public testing::Test { public: KeyStoreTest() : pkcs11_(false), // Do not pre-initialize the mock PKCS #11 library. // This just controls whether the first call to // C_Initialize returns 'already initialized'. next_handle_(1) {} ~KeyStoreTest() override = default; void SetUp() override { std::vector<uint64_t> slot_list = {0, 1}; ON_CALL(pkcs11_, GetSlotList(_, _, _)) .WillByDefault(DoAll(SetArgPointee<2>(slot_list), Return(0))); ON_CALL(pkcs11_, OpenSession(_, _, _, _)) .WillByDefault(DoAll(SetArgPointee<3>(kSession), Return(0))); ON_CALL(pkcs11_, CloseSession(_, _)).WillByDefault(Return(0)); ON_CALL(pkcs11_, CreateObject(_, _, _, _)) .WillByDefault(Invoke(this, &KeyStoreTest::CreateObject)); ON_CALL(pkcs11_, DestroyObject(_, _, _)) .WillByDefault(Invoke(this, &KeyStoreTest::DestroyObject)); ON_CALL(pkcs11_, GetAttributeValue(_, _, _, _, _)) .WillByDefault(Invoke(this, &KeyStoreTest::GetAttributeValue)); ON_CALL(pkcs11_, SetAttributeValue(_, _, _, _)) .WillByDefault(Invoke(this, &KeyStoreTest::SetAttributeValue)); ON_CALL(pkcs11_, FindObjectsInit(_, _, _)) .WillByDefault(Invoke(this, &KeyStoreTest::FindObjectsInit)); ON_CALL(pkcs11_, FindObjects(_, _, _, _)) .WillByDefault(Invoke(this, &KeyStoreTest::FindObjects)); ON_CALL(pkcs11_, FindObjectsFinal(_, _)).WillByDefault(Return(0)); base::FilePath system_path("/var/lib/chaps"); ON_CALL(token_manager_, GetTokenPath(_, 0, _)) .WillByDefault(DoAll(SetArgPointee<2>(system_path), Return(true))); base::FilePath user_path( brillo::cryptohome::home::GetDaemonStorePath(kDefaultUser, "chaps")); ON_CALL(token_manager_, GetTokenPath(_, 1, _)) .WillByDefault(DoAll(SetArgPointee<2>(user_path), Return(true))); } // Stores a new labeled object, only CKA_LABEL and CKA_VALUE are relevant. virtual uint32_t CreateObject(const brillo::SecureBlob& isolate, uint64_t session_id, const std::vector<uint8_t>& attributes, uint64_t* new_object_handle) { *new_object_handle = next_handle_++; std::string label = GetValue(attributes, CKA_LABEL); handles_[*new_object_handle] = label; values_[label] = GetValue(attributes, CKA_VALUE); labels_[label] = *new_object_handle; return CKR_OK; } // Deletes a labeled object. virtual uint32_t DestroyObject(const brillo::SecureBlob& isolate, uint64_t session_id, uint64_t object_handle) { std::string label = handles_[object_handle]; handles_.erase(object_handle); values_.erase(label); labels_.erase(label); return CKR_OK; } // Supports reading CKA_VALUE. virtual uint32_t GetAttributeValue(const brillo::SecureBlob& isolate, uint64_t session_id, uint64_t object_handle, const std::vector<uint8_t>& attributes_in, std::vector<uint8_t>* attributes_out) { std::string label = handles_[object_handle]; std::string value = values_[label]; chaps::Attributes parsed; parsed.Parse(attributes_in); if (parsed.num_attributes() == 1 && parsed.attributes()[0].type == CKA_LABEL) value = label; if (parsed.num_attributes() != 1 || (parsed.attributes()[0].type != CKA_VALUE && parsed.attributes()[0].type != CKA_LABEL) || (parsed.attributes()[0].pValue && parsed.attributes()[0].ulValueLen != value.size())) return CKR_GENERAL_ERROR; parsed.attributes()[0].ulValueLen = value.size(); if (parsed.attributes()[0].pValue) memcpy(parsed.attributes()[0].pValue, value.data(), value.size()); parsed.Serialize(attributes_out); return CKR_OK; } // Supports writing CKA_VALUE. virtual uint32_t SetAttributeValue(const brillo::SecureBlob& isolate, uint64_t session_id, uint64_t object_handle, const std::vector<uint8_t>& attributes) { values_[handles_[object_handle]] = GetValue(attributes, CKA_VALUE); return CKR_OK; } // Finds stored objects by CKA_LABEL or CKA_VALUE. If no CKA_LABEL or // CKA_VALUE, find all objects. virtual uint32_t FindObjectsInit(const brillo::SecureBlob& isolate, uint64_t session_id, const std::vector<uint8_t>& attributes) { std::string label = GetValue(attributes, CKA_LABEL); std::string value = GetValue(attributes, CKA_VALUE); found_objects_.clear(); if (label.empty() && value.empty()) { // Find all objects. found_objects_ = brillo::GetMapKeysAsVector(handles_); } else if (!label.empty() && labels_.count(label) > 0) { // Find only the object with |label|. found_objects_.push_back(labels_[label]); } else { // Find all objects with |value|. for (const auto& item : values_) { if (item.second == value && labels_.count(item.first) > 0) { found_objects_.push_back(labels_[item.first]); } } } return CKR_OK; } // Reports a 'found' object based on find_status_. virtual uint32_t FindObjects(const brillo::SecureBlob& isolate, uint64_t session_id, uint64_t max_object_count, std::vector<uint64_t>* object_list) { while (!found_objects_.empty() && object_list->size() < max_object_count) { object_list->push_back(found_objects_.back()); found_objects_.pop_back(); } return CKR_OK; } protected: NiceMock<Pkcs11Mock> pkcs11_; NiceMock<chaps::TokenManagerClientMock> token_manager_; private: // A helper to pull the value for a given attribute out of a serialized // template. std::string GetValue(const std::vector<uint8_t>& attributes, CK_ATTRIBUTE_TYPE type) { chaps::Attributes parsed; parsed.Parse(attributes); CK_ATTRIBUTE_PTR array = parsed.attributes(); for (CK_ULONG i = 0; i < parsed.num_attributes(); ++i) { if (array[i].type == type) { if (!array[i].pValue) return ""; return std::string(reinterpret_cast<char*>(array[i].pValue), array[i].ulValueLen); } } return ""; } std::map<std::string, std::string> values_; // The fake store: label->value std::map<uint64_t, std::string> handles_; // The fake store: handle->label std::map<std::string, uint64_t> labels_; // The fake store: label->handle std::vector<uint64_t> found_objects_; // The most recent search results uint64_t next_handle_; // Tracks handle assignment ScopedFakeSalt fake_system_salt_; // We want to avoid all the Chaps verbose logging. ScopedDisableVerboseLogging no_verbose_logging; DISALLOW_COPY_AND_ASSIGN(KeyStoreTest); }; // This test assumes that chaps in not available on the system running the test. // The purpose of this test is to exercise the C_Initialize failure code path. // Without a mock, the Chaps library will attempt to connect to the Chaps daemon // unsuccessfully, resulting in a C_Initialize failure. TEST(KeyStoreTest_NoMock, Pkcs11NotAvailable) { chaps::TokenManagerClient token_manager; Pkcs11KeyStore key_store(&token_manager); std::string blob; EXPECT_FALSE(key_store.Read(kDefaultUser, "test", &blob)); EXPECT_FALSE(key_store.Write(kDefaultUser, "test", blob)); EXPECT_FALSE(key_store.Read("", "test", &blob)); EXPECT_FALSE(key_store.Write("", "test", blob)); } // Exercises the key store when PKCS #11 returns success. This exercises all // non-error-handling code paths. TEST_F(KeyStoreTest, Pkcs11Success) { Pkcs11KeyStore key_store(&token_manager_); std::string blob; EXPECT_FALSE(key_store.Read(kDefaultUser, "test", &blob)); EXPECT_TRUE(key_store.Write(kDefaultUser, "test", "test_data")); EXPECT_TRUE(key_store.Read(kDefaultUser, "test", &blob)); EXPECT_EQ("test_data", blob); // Try with a different key name. EXPECT_FALSE(key_store.Read(kDefaultUser, "test2", &blob)); EXPECT_TRUE(key_store.Write(kDefaultUser, "test2", "test_data2")); EXPECT_TRUE(key_store.Read(kDefaultUser, "test2", &blob)); EXPECT_EQ("test_data2", blob); // Read the original key again. EXPECT_TRUE(key_store.Read(kDefaultUser, "test", &blob)); EXPECT_EQ("test_data", blob); // Replace key data. EXPECT_TRUE(key_store.Write(kDefaultUser, "test", "test_data3")); EXPECT_TRUE(key_store.Read(kDefaultUser, "test", &blob)); EXPECT_EQ("test_data3", blob); // Delete key data. EXPECT_TRUE(key_store.Delete(kDefaultUser, "test2")); EXPECT_FALSE(key_store.Read(kDefaultUser, "test2", &blob)); EXPECT_TRUE(key_store.Read(kDefaultUser, "test", &blob)); } TEST_F(KeyStoreTest, Pkcs11Success_NoUser) { Pkcs11KeyStore key_store(&token_manager_); std::string blob; EXPECT_FALSE(key_store.Read("", "test", &blob)); EXPECT_TRUE(key_store.Write("", "test", "test_data")); EXPECT_TRUE(key_store.Read("", "test", &blob)); EXPECT_EQ("test_data", blob); // Try with a different key name. EXPECT_FALSE(key_store.Read("", "test2", &blob)); EXPECT_TRUE(key_store.Write("", "test2", "test_data2")); EXPECT_TRUE(key_store.Read("", "test2", &blob)); EXPECT_EQ("test_data2", blob); // Read the original key again. EXPECT_TRUE(key_store.Read("", "test", &blob)); EXPECT_EQ("test_data", blob); // Replace key data. EXPECT_TRUE(key_store.Write("", "test", "test_data3")); EXPECT_TRUE(key_store.Read("", "test", &blob)); EXPECT_EQ("test_data3", blob); // Delete key data. EXPECT_TRUE(key_store.Delete("", "test2")); EXPECT_FALSE(key_store.Read("", "test2", &blob)); EXPECT_TRUE(key_store.Read("", "test", &blob)); } // Tests the key store when PKCS #11 has no token for the given user. TEST_F(KeyStoreTest, TokenNotAvailable) { EXPECT_CALL(token_manager_, GetTokenPath(_, _, _)) .WillRepeatedly(Return(false)); Pkcs11KeyStore key_store(&token_manager_); std::string blob; EXPECT_FALSE(key_store.Read(kDefaultUser, "test", &blob)); EXPECT_FALSE(key_store.Write(kDefaultUser, "test", blob)); EXPECT_FALSE(key_store.Read("", "test", &blob)); EXPECT_FALSE(key_store.Write("", "test", blob)); } // Tests the key store when PKCS #11 fails to open a session. TEST_F(KeyStoreTest, NoSession) { EXPECT_CALL(pkcs11_, OpenSession(_, _, _, _)) .WillRepeatedly(Return(CKR_GENERAL_ERROR)); Pkcs11KeyStore key_store(&token_manager_); std::string blob; EXPECT_FALSE(key_store.Write(kDefaultUser, "test", "test_data")); EXPECT_FALSE(key_store.Read(kDefaultUser, "test", &blob)); } // Tests the key store when PKCS #11 fails to create an object. TEST_F(KeyStoreTest, CreateObjectFail) { EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)) .WillRepeatedly(Return(CKR_GENERAL_ERROR)); Pkcs11KeyStore key_store(&token_manager_); std::string blob; EXPECT_FALSE(key_store.Write(kDefaultUser, "test", "test_data")); EXPECT_FALSE(key_store.Read(kDefaultUser, "test", &blob)); } // Tests the key store when PKCS #11 fails to read attribute values. TEST_F(KeyStoreTest, ReadValueFail) { EXPECT_CALL(pkcs11_, GetAttributeValue(_, _, _, _, _)) .WillRepeatedly(Return(CKR_GENERAL_ERROR)); Pkcs11KeyStore key_store(&token_manager_); std::string blob; EXPECT_TRUE(key_store.Write(kDefaultUser, "test", "test_data")); EXPECT_FALSE(key_store.Read(kDefaultUser, "test", &blob)); } // Tests the key store when PKCS #11 fails to delete key data. TEST_F(KeyStoreTest, DeleteValueFail) { EXPECT_CALL(pkcs11_, DestroyObject(_, _, _)) .WillRepeatedly(Return(CKR_GENERAL_ERROR)); Pkcs11KeyStore key_store(&token_manager_); EXPECT_TRUE(key_store.Write(kDefaultUser, "test", "test_data")); EXPECT_FALSE(key_store.Write(kDefaultUser, "test", "test_data2")); EXPECT_FALSE(key_store.Delete(kDefaultUser, "test")); } // Tests the key store when PKCS #11 fails to find objects. Tests each part of // the multi-part find operation individually. TEST_F(KeyStoreTest, FindFail) { EXPECT_CALL(pkcs11_, FindObjectsInit(_, _, _)) .WillRepeatedly(Return(CKR_GENERAL_ERROR)); Pkcs11KeyStore key_store(&token_manager_); std::string blob; EXPECT_TRUE(key_store.Write(kDefaultUser, "test", "test_data")); EXPECT_FALSE(key_store.Read(kDefaultUser, "test", &blob)); EXPECT_CALL(pkcs11_, FindObjectsInit(_, _, _)).WillRepeatedly(Return(CKR_OK)); EXPECT_CALL(pkcs11_, FindObjects(_, _, _, _)) .WillRepeatedly(Return(CKR_GENERAL_ERROR)); EXPECT_TRUE(key_store.Write(kDefaultUser, "test", "test_data")); EXPECT_FALSE(key_store.Read(kDefaultUser, "test", &blob)); EXPECT_CALL(pkcs11_, FindObjects(_, _, _, _)).WillRepeatedly(Return(CKR_OK)); EXPECT_CALL(pkcs11_, FindObjectsFinal(_, _)) .WillRepeatedly(Return(CKR_GENERAL_ERROR)); EXPECT_TRUE(key_store.Write(kDefaultUser, "test", "test_data")); EXPECT_FALSE(key_store.Read(kDefaultUser, "test", &blob)); } // Tests the key store when PKCS #11 successfully finds zero objects. TEST_F(KeyStoreTest, FindNoObjects) { std::vector<uint64_t> empty; EXPECT_CALL(pkcs11_, FindObjects(_, _, _, _)) .WillRepeatedly(DoAll(SetArgPointee<3>(empty), Return(CKR_OK))); Pkcs11KeyStore key_store(&token_manager_); std::string blob; EXPECT_TRUE(key_store.Write(kDefaultUser, "test", "test_data")); EXPECT_FALSE(key_store.Read(kDefaultUser, "test", &blob)); } TEST_F(KeyStoreTest, RegisterKeyWithoutCertificate) { Pkcs11KeyStore key_store(&token_manager_); // Try with a malformed public key. EXPECT_FALSE(key_store.Register(kDefaultUser, "test_label", KEY_TYPE_RSA, KEY_USAGE_SIGN, "private_key_blob", "bad_pubkey", "")); // Try with a well-formed public key. std::string public_key_der = HexDecode(kValidRsaPublicKeyHex); EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)) .Times(2) // Public, private (no certificate). .WillRepeatedly(Return(CKR_OK)); EXPECT_TRUE(key_store.Register(kDefaultUser, "test_label", KEY_TYPE_RSA, KEY_USAGE_SIGN, "private_key_blob", public_key_der, "")); } TEST_F(KeyStoreTest, RegisterKeyWithCertificate) { EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)) .Times(3) // Public, private, and certificate. .WillRepeatedly(Return(CKR_OK)); Pkcs11KeyStore key_store(&token_manager_); std::string public_key_der = HexDecode(kValidRsaPublicKeyHex); std::string certificate_der = HexDecode(kValidRsaCertificateHex); EXPECT_TRUE(key_store.Register(kDefaultUser, "test_label", KEY_TYPE_RSA, KEY_USAGE_SIGN, "private_key_blob", public_key_der, certificate_der)); // Also try with the system token. EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)) .Times(3) // Public, private, and certificate. .WillRepeatedly(Return(CKR_OK)); EXPECT_TRUE(key_store.Register(kDefaultUser, "test_label", KEY_TYPE_RSA, KEY_USAGE_SIGN, "private_key_blob", public_key_der, certificate_der)); } TEST_F(KeyStoreTest, RegisterEccKeyWithoutCertificate) { Pkcs11KeyStore key_store(&token_manager_); // Try with a malformed public key. EXPECT_FALSE(key_store.Register(kDefaultUser, "test_label", KEY_TYPE_ECC, KEY_USAGE_SIGN, "private_key_blob", "bad_pubkey", "")); // Try with a well-formed public key. std::string public_key_der = HexDecode(kValidEccPublicKeyHex); EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)) .Times(2) // Public, private (no certificate). .WillRepeatedly(Return(CKR_OK)); EXPECT_TRUE(key_store.Register(kDefaultUser, "test_label", KEY_TYPE_ECC, KEY_USAGE_SIGN, "private_key_blob", public_key_der, "")); } TEST_F(KeyStoreTest, RegisterEccKeyWithCertificate) { EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)) .Times(3) // Public, private, and certificate. .WillRepeatedly(Return(CKR_OK)); Pkcs11KeyStore key_store(&token_manager_); std::string public_key_der = HexDecode(kValidEccPublicKeyHex); std::string certificate_der = HexDecode(kValidEccCertificateHex); EXPECT_TRUE(key_store.Register(kDefaultUser, "test_label", KEY_TYPE_ECC, KEY_USAGE_SIGN, "private_key_blob", public_key_der, certificate_der)); // Also try with the system token. EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)) .Times(3) // Public, private, and certificate. .WillRepeatedly(Return(CKR_OK)); EXPECT_TRUE(key_store.Register(kDefaultUser, "test_label", KEY_TYPE_ECC, KEY_USAGE_SIGN, "private_key_blob", public_key_der, certificate_der)); } TEST_F(KeyStoreTest, RegisterKeyWithBadCertificate) { EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)) .Times(3) // Public, private, and certificate. .WillRepeatedly(Return(CKR_OK)); Pkcs11KeyStore key_store(&token_manager_); std::string public_key_der = HexDecode(kValidRsaPublicKeyHex); EXPECT_TRUE(key_store.Register(kDefaultUser, "test_label", KEY_TYPE_RSA, KEY_USAGE_SIGN, "private_key_blob", public_key_der, "bad_certificate")); } TEST_F(KeyStoreTest, RegisterWithWrongKeyType) { Pkcs11KeyStore key_store(&token_manager_); std::string public_key_der = HexDecode(kValidRsaPublicKeyHex); EXPECT_FALSE(key_store.Register(kDefaultUser, "test_label", KEY_TYPE_ECC, KEY_USAGE_SIGN, "private_key_blob", public_key_der, "")); } TEST_F(KeyStoreTest, RegisterDecryptionKey) { EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)).WillRepeatedly(Return(CKR_OK)); Pkcs11KeyStore key_store(&token_manager_); std::string public_key_der = HexDecode(kValidRsaPublicKeyHex); EXPECT_TRUE(key_store.Register(kDefaultUser, "test_label", KEY_TYPE_RSA, KEY_USAGE_DECRYPT, "private_key_blob", public_key_der, "")); } TEST_F(KeyStoreTest, RegisterCertificate) { Pkcs11KeyStore key_store(&token_manager_); std::string certificate_der = HexDecode(kValidRsaCertificateHex); EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)) .Times(2); // Once for valid, once for invalid. // Try with a valid certificate (hit multiple times to check dup logic). EXPECT_TRUE(key_store.RegisterCertificate(kDefaultUser, certificate_der)); EXPECT_TRUE(key_store.RegisterCertificate(kDefaultUser, certificate_der)); EXPECT_TRUE(key_store.RegisterCertificate(kDefaultUser, certificate_der)); // Try with an invalid certificate. EXPECT_TRUE(key_store.RegisterCertificate(kDefaultUser, "bad_certificate")); } TEST_F(KeyStoreTest, RegisterCertificateError) { Pkcs11KeyStore key_store(&token_manager_); std::string certificate_der = HexDecode(kValidRsaCertificateHex); // Handle an error from PKCS #11. EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)) .WillOnce(Return(CKR_GENERAL_ERROR)); EXPECT_FALSE(key_store.RegisterCertificate(kDefaultUser, certificate_der)); } TEST_F(KeyStoreTest, RegisterCertificateSystemToken) { Pkcs11KeyStore key_store(&token_manager_); std::string certificate_der = HexDecode(kValidRsaCertificateHex); // Try with the system token. EXPECT_CALL(pkcs11_, CreateObject(_, _, _, _)).WillOnce(Return(CKR_OK)); EXPECT_TRUE(key_store.RegisterCertificate(kDefaultUser, certificate_der)); } // Tests that the DeleteByPrefix() method removes the correct objects and only // the correct objects. TEST_F(KeyStoreTest, DeleteByPrefix) { Pkcs11KeyStore key_store(&token_manager_); // Test with no keys. ASSERT_TRUE(key_store.DeleteByPrefix(kDefaultUser, "prefix")); // Test with a single matching key. ASSERT_TRUE(key_store.Write(kDefaultUser, "prefix_test", "test")); ASSERT_TRUE(key_store.DeleteByPrefix(kDefaultUser, "prefix")); std::string blob; EXPECT_FALSE(key_store.Read(kDefaultUser, "prefix_test", &blob)); // Test with a single non-matching key. ASSERT_TRUE(key_store.Write(kDefaultUser, "_prefix_", "test")); ASSERT_TRUE(key_store.DeleteByPrefix(kDefaultUser, "prefix")); EXPECT_TRUE(key_store.Read(kDefaultUser, "_prefix_", &blob)); // Test with an empty prefix. ASSERT_TRUE(key_store.DeleteByPrefix(kDefaultUser, "")); EXPECT_FALSE(key_store.Read(kDefaultUser, "_prefix_", &blob)); // Test with multiple matching and non-matching keys. const int kNumKeys = 110; // Pkcs11KeyStore max is 100 for FindObjects. key_store.Write(kDefaultUser, "other1", "test"); for (int i = 0; i < kNumKeys; ++i) { std::string key_name = std::string("prefix") + base::NumberToString(i); key_store.Write(kDefaultUser, key_name, std::string(key_name)); } ASSERT_TRUE(key_store.Write(kDefaultUser, "other2", "test")); ASSERT_TRUE(key_store.DeleteByPrefix(kDefaultUser, "prefix")); EXPECT_TRUE(key_store.Read(kDefaultUser, "other1", &blob)); EXPECT_TRUE(key_store.Read(kDefaultUser, "other2", &blob)); for (int i = 0; i < kNumKeys; ++i) { std::string key_name = std::string("prefix") + base::NumberToString(i); EXPECT_FALSE(key_store.Read(kDefaultUser, key_name, &blob)); } } } // namespace attestation
45.05919
80
0.723106
kalyankondapally
a3f58ec8fd42d988fae022d5766d218c5ed405b7
6,695
cpp
C++
sources/GeoElementSide.cpp
Kauehenrik/FemCourseEigenClass2021
d4927d92b541fdd2b2aa1fa424a413dd561ae96e
[ "MIT" ]
1
2021-06-12T13:21:51.000Z
2021-06-12T13:21:51.000Z
sources/GeoElementSide.cpp
Kauehenrik/FemCourseEigenClass2021
d4927d92b541fdd2b2aa1fa424a413dd561ae96e
[ "MIT" ]
null
null
null
sources/GeoElementSide.cpp
Kauehenrik/FemCourseEigenClass2021
d4927d92b541fdd2b2aa1fa424a413dd561ae96e
[ "MIT" ]
null
null
null
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ #include "GeoMesh.h" #include "GeoElementSide.h" ///\cond #include <stdio.h> #include <algorithm> ///\endcond GeoElementSide::GeoElementSide() { } GeoElementSide::GeoElementSide(const GeoElementSide& copy) { fElement = copy.fElement; fSide = copy.fSide; } GeoElementSide& GeoElementSide::operator=(const GeoElementSide& copy) { fElement = copy.fElement; fSide = copy.fSide; return *this; } GeoElementSide GeoElementSide::Neighbour() const { return fElement ? fElement->Neighbour(fSide) : GeoElementSide(); } void GeoElementSide::SetNeighbour(const GeoElementSide& neighbour) { fElement->SetNeighbour(fSide, neighbour); } bool GeoElementSide::IsNeighbour(const GeoElementSide& candidate) const { if (candidate == *this) return true; GeoElementSide neighbour = Neighbour(); if (!(neighbour.Element() != 0 && neighbour.Side() > -1)) return false; while ((neighbour == *this) == false) { if (candidate == neighbour) return true; neighbour = neighbour.Neighbour(); } return false; } void GeoElementSide::IsertConnectivity(GeoElementSide& candidate) { if (this->IsNeighbour(candidate)) return; GeoElementSide neigh1 = Neighbour(); GeoElementSide neigh2 = candidate.Neighbour(); SetNeighbour(neigh2); candidate.SetNeighbour(neigh1); } void GeoElementSide::AllNeighbours(std::vector<GeoElementSide>& allneigh) const { if (fElement->NSideNodes(fSide) != 1) DebugStop(); GeoElementSide neigh = Neighbour(); int nodeindex = fElement->SideNodeIndex(fSide, 0); while (neigh != *this) { int neighnode = neigh.fElement->SideNodeIndex(neigh.fSide, 0); if (neighnode != nodeindex) DebugStop(); allneigh.push_back(neigh); neigh = neigh.Neighbour(); } } void GeoElementSide::ComputeNeighbours(std::vector<GeoElementSide>& compneigh) { if (fSide < fElement->NCornerNodes()) { AllNeighbours(compneigh); return; } int nsnodes = fElement->NSideNodes(fSide); std::vector<GeoElementSide> GeoElSideSet; std::vector<std::vector<int> > GeoElSet; GeoElSet.resize(nsnodes); int in; VecInt nodeindexes(nsnodes); for (in = 0; in < nsnodes; in++) { int nodeindex = fElement->SideNodeIndex(fSide, in); nodeindexes[in] = nodeindex; } // compute the neighbours along the cornernodes for (in = 0; in < nsnodes; in++) { int locindex = fElement->SideNodeLocIndex(fSide, in); int nodeindex = fElement->SideNodeIndex(fSide, in); GeoElSideSet.resize(0); GeoElementSide locside(fElement, locindex); int nodeindex_again = locside.Element()->SideNodeIndex(locside.Side(), 0); if (nodeindex != nodeindex_again) DebugStop(); locside.AllNeighbours(GeoElSideSet); for (auto& gelside : GeoElSideSet) { int node = gelside.Element()->SideNodeIndex(gelside.Side(), 0); if (node != nodeindex) DebugStop(); } int nel = GeoElSideSet.size(); int el; for (el = 0; el < nel; el++) { GeoElSet[in].push_back(GeoElSideSet[el].Element()->GetIndex()); } std::sort(GeoElSet[in].begin(), GeoElSet[in].end()); } std::vector<int> result; std::vector<int> result_aux; // build the neighbours along the higher dimension sides switch (nsnodes) { case 1: { result = GeoElSet[0]; } break; case 2: std::set_intersection(GeoElSet[0].begin(), GeoElSet[0].end(), GeoElSet[1].begin(), GeoElSet[1].end(), std::back_inserter(result)); break; case 3: std::set_intersection(GeoElSet[0].begin(), GeoElSet[0].end(), GeoElSet[1].begin(), GeoElSet[1].end(), std::back_inserter(result_aux)); std::set_intersection(result_aux.begin(), result_aux.end(), GeoElSet[2].begin(), GeoElSet[2].end(), std::back_inserter(result)); break; case 4: { std::vector<int> inter1, inter2; std::set_intersection(GeoElSet[0].begin(), GeoElSet[0].end(), GeoElSet[2].begin(), GeoElSet[2].end(), std::back_inserter(inter1)); if (inter1.size() == 0) break; std::set_intersection(GeoElSet[1].begin(), GeoElSet[1].end(), GeoElSet[3].begin(), GeoElSet[3].end(), std::back_inserter(inter2)); if (inter2.size() == 0) break; std::set_intersection(inter1.begin(), inter1.end(), inter2.begin(), inter2.end(), std::back_inserter(result)); inter1.clear(); inter2.clear(); } break; default: { std::vector<int> inter1, inter2; inter1 = GeoElSet[0]; for (in = 0; in < nsnodes - 1; in++) { std::set_intersection(inter1.begin(), inter1.end(), GeoElSet[in + 1].begin(), GeoElSet[in + 1].end(), std::back_inserter(inter2)); if (inter2.size() == 0) break; inter1 = inter2; } inter1.clear(); inter2.clear(); result = inter2; } } int el, nel = result.size(); GeoMesh* geoMesh = fElement->GetMesh(); for (el = 0; el < nel; el++) { GeoElement* gelResult = geoMesh->Element(result[el]); int whichSd = gelResult->WhichSide(nodeindexes); if (whichSd < 0) { std::cout << "nodeindexes " << nodeindexes << std::endl; std::cout << "neighbouring element index " << gelResult->GetIndex() << std::endl; std::cout << "neighbouring element nodes "; for (int i = 0; i < gelResult->NNodes(); i++) std::cout << gelResult->NodeIndex(i) << " "; std::cout << std::endl; for (int i = 0; i < nsnodes; i++) { auto gelset = GeoElSet[i]; std::cout << "GeoElSet along node " << i << " is "; for (auto g : gelset) std::cout << g << " "; std::cout << std::endl; } DebugStop(); } GeoElementSide gelside(gelResult, whichSd); if (gelside == *this) continue; if (whichSd > 0) { compneigh.push_back(GeoElementSide(gelResult, whichSd)); } } GeoElSideSet.clear(); GeoElSet.clear(); nodeindexes.resize(0); result.clear(); result_aux.clear(); } // Print the element index and side void GeoElementSide::Print(std::ostream& out) const { if (!fElement) { out << "GeoElSide empty\n"; } else { out << "elid " << fElement->GetIndex() << " side " << fSide << std::endl; } }
33.143564
142
0.603137
Kauehenrik
4300268d0f5301e77ea9c96dfab712a5cc04d5c6
3,084
cpp
C++
msv_main/src/msv_main_node.cpp
daconjurer/ros_msv
dbf70083588b869172ac74f187b81166e78c8da1
[ "BSD-3-Clause" ]
2
2021-07-13T22:02:43.000Z
2022-03-10T15:46:58.000Z
msv_main/src/msv_main_node.cpp
daconjurer/ros_msv
dbf70083588b869172ac74f187b81166e78c8da1
[ "BSD-3-Clause" ]
null
null
null
msv_main/src/msv_main_node.cpp
daconjurer/ros_msv
dbf70083588b869172ac74f187b81166e78c8da1
[ "BSD-3-Clause" ]
null
null
null
/********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2019, Robótica de la Mixteca * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of Universidad Tecnológica de la Mixteca nor * the names of its contributors may be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ ///////////////////////////////////////////////////////////////////////////////////////// /// @file ROS msv_main node of the MSV-01 rescue robot for general control using the ROS /// Joy messages. The node publishes the teleoperation commands, as well as the control /// commands for the robotic arm and an orientation system for the RGBD sensor. /// @author Victor Esteban Sandoval-Luna /// /// Based on the "rescue" ROS metapackage from José Armando Sánchez-Rojas. /// Based on the Modbus protocol "lightmodbus" library (RTU) from Jacek Wieczorek, /// please see https://github.com/Jacajack/liblightmodbus. ///////////////////////////////////////////////////////////////////////////////////////// #include <msv_main/msv_main.h> #include <boost/asio.hpp> int main (int argc, char **argv) { //Initialize ROS ros::init(argc, argv, "msv_main"); try { //Create an object of class MsvMain that will do the job MsvMain *robot; MsvMain msv01; robot = &msv01; ros::Rate loop_rate(10); while (ros::ok()) { // Node callbacks handling ros::spinOnce(); loop_rate.sleep(); } return 0; } catch (boost::system::system_error ex) { ROS_ERROR("Error instantiating msv_main object. Error: %s", ex.what()); return -1; } }
40.578947
89
0.652724
daconjurer
4300b783305b277b46054bd480c590ebb58db0e2
5,015
hpp
C++
include/System/Net/NetworkCredential.hpp
darknight1050/BeatSaber-Quest-Codegen
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
[ "Unlicense" ]
null
null
null
include/System/Net/NetworkCredential.hpp
darknight1050/BeatSaber-Quest-Codegen
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
[ "Unlicense" ]
null
null
null
include/System/Net/NetworkCredential.hpp
darknight1050/BeatSaber-Quest-Codegen
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
[ "Unlicense" ]
null
null
null
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include "extern/beatsaber-hook/shared/utils/typedefs.h" // Including type: System.Net.ICredentials #include "System/Net/ICredentials.hpp" #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp" #include "extern/beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp" #include "extern/beatsaber-hook/shared/utils/utils.h" // Completed includes // Begin forward declares // Forward declaring namespace: System::Security namespace System::Security { // Forward declaring type: SecureString class SecureString; } // Forward declaring namespace: System namespace System { // Forward declaring type: Uri class Uri; } // Completed forward declares // Type namespace: System.Net namespace System::Net { // Size: 0x28 #pragma pack(push, 1) // Autogenerated type: System.Net.NetworkCredential class NetworkCredential : public ::Il2CppObject/*, public System::Net::ICredentials*/ { public: // private System.String m_domain // Size: 0x8 // Offset: 0x10 ::Il2CppString* m_domain; // Field size check static_assert(sizeof(::Il2CppString*) == 0x8); // private System.String m_userName // Size: 0x8 // Offset: 0x18 ::Il2CppString* m_userName; // Field size check static_assert(sizeof(::Il2CppString*) == 0x8); // private System.Security.SecureString m_password // Size: 0x8 // Offset: 0x20 System::Security::SecureString* m_password; // Field size check static_assert(sizeof(System::Security::SecureString*) == 0x8); // Creating value type constructor for type: NetworkCredential NetworkCredential(::Il2CppString* m_domain_ = {}, ::Il2CppString* m_userName_ = {}, System::Security::SecureString* m_password_ = {}) noexcept : m_domain{m_domain_}, m_userName{m_userName_}, m_password{m_password_} {} // Creating interface conversion operator: operator System::Net::ICredentials operator System::Net::ICredentials() noexcept { return *reinterpret_cast<System::Net::ICredentials*>(this); } // public System.Void .ctor(System.String userName, System.String password) // Offset: 0x164634C template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary> static NetworkCredential* New_ctor(::Il2CppString* userName, ::Il2CppString* password) { static auto ___internal__logger = ::Logger::get().WithContext("System::Net::NetworkCredential::.ctor"); return THROW_UNLESS((::il2cpp_utils::New<NetworkCredential*, creationType>(userName, password))); } // public System.Void .ctor(System.String userName, System.String password, System.String domain) // Offset: 0x16463BC template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary> static NetworkCredential* New_ctor(::Il2CppString* userName, ::Il2CppString* password, ::Il2CppString* domain) { static auto ___internal__logger = ::Logger::get().WithContext("System::Net::NetworkCredential::.ctor"); return THROW_UNLESS((::il2cpp_utils::New<NetworkCredential*, creationType>(userName, password, domain))); } // public System.String get_UserName() // Offset: 0x16465A8 ::Il2CppString* get_UserName(); // public System.Void set_UserName(System.String value) // Offset: 0x164649C void set_UserName(::Il2CppString* value); // public System.String get_Password() // Offset: 0x16465B0 ::Il2CppString* get_Password(); // public System.Void set_Password(System.String value) // Offset: 0x164650C void set_Password(::Il2CppString* value); // public System.String get_Domain() // Offset: 0x16465C8 ::Il2CppString* get_Domain(); // public System.Void set_Domain(System.String value) // Offset: 0x1646538 void set_Domain(::Il2CppString* value); // System.String InternalGetUserName() // Offset: 0x16465D0 ::Il2CppString* InternalGetUserName(); // System.String InternalGetPassword() // Offset: 0x16465BC ::Il2CppString* InternalGetPassword(); // System.String InternalGetDomain() // Offset: 0x16465D8 ::Il2CppString* InternalGetDomain(); // public System.Net.NetworkCredential GetCredential(System.Uri uri, System.String authType) // Offset: 0x16465E0 System::Net::NetworkCredential* GetCredential(System::Uri* uri, ::Il2CppString* authType); }; // System.Net.NetworkCredential #pragma pack(pop) static check_size<sizeof(NetworkCredential), 32 + sizeof(System::Security::SecureString*)> __System_Net_NetworkCredentialSizeCheck; static_assert(sizeof(NetworkCredential) == 0x28); } DEFINE_IL2CPP_ARG_TYPE(System::Net::NetworkCredential*, "System.Net", "NetworkCredential");
46.869159
222
0.700698
darknight1050
430245be8e7100d866ddb34000ed7c0890073a00
396
cpp
C++
bracket.cpp
W-YXN/MyNOIPProjects
0269a8385a6c8d87511236146f374f39dcdd2b82
[ "Apache-2.0" ]
null
null
null
bracket.cpp
W-YXN/MyNOIPProjects
0269a8385a6c8d87511236146f374f39dcdd2b82
[ "Apache-2.0" ]
null
null
null
bracket.cpp
W-YXN/MyNOIPProjects
0269a8385a6c8d87511236146f374f39dcdd2b82
[ "Apache-2.0" ]
1
2019-01-19T01:05:07.000Z
2019-01-19T01:05:07.000Z
/* #include <iostream> #include <cstdlib> #include <cmath> #include <algorithm> #include <stack> #include <string> #include <cstring> using namespace std; stack<int> st; int main(){ string s; cin>>s; //cout<<"F@ck you"; for(int i=0;i<s.length();i++){ if(s[i]=='(') st.push(i); if(s[i]==')') st.pop(); if(s[i]=='*') cout<<st.size(); } return 0; } */
18
38
0.527778
W-YXN
430397d271dd238409778828ff1bf6fc5a793d68
4,759
cpp
C++
Runtime/MP1/CSamusFaceReflection.cpp
Jcw87/urde
fb9ea9092ad00facfe957ece282a86c194e9cbda
[ "MIT" ]
267
2016-03-10T21:59:16.000Z
2021-03-28T18:21:03.000Z
Runtime/MP1/CSamusFaceReflection.cpp
cobalt2727/metaforce
3bb05c0ee5dd9b1b8eaa861fc49713aef62c844a
[ "MIT" ]
129
2016-03-12T10:17:32.000Z
2021-04-05T20:45:19.000Z
Runtime/MP1/CSamusFaceReflection.cpp
cobalt2727/metaforce
3bb05c0ee5dd9b1b8eaa861fc49713aef62c844a
[ "MIT" ]
31
2016-03-20T00:20:11.000Z
2021-03-10T21:14:11.000Z
#include "Runtime/MP1/CSamusFaceReflection.hpp" #include "Runtime/CStateManager.hpp" #include "Runtime/GameGlobalObjects.hpp" #include "Runtime/Camera/CFirstPersonCamera.hpp" #include "Runtime/World/CPlayer.hpp" #include "Runtime/World/CWorld.hpp" #include "TCastTo.hpp" // Generated file, do not modify include path namespace metaforce::MP1 { static const zeus::CTransform PreXf = zeus::CTransform::Scale(0.3f) * zeus::CTransform::Translate(0.f, 0.5f, 0.f); CSamusFaceReflection::CSamusFaceReflection(CStateManager& stateMgr) : x0_modelData(CAnimRes(g_ResFactory->GetResourceIdByName("ACS_SamusFace")->id, 0, zeus::skOne3f, 0, true)) , x4c_lights(std::make_unique<CActorLights>(8, zeus::skZero3f, 4, 4, false, false, false, 0.1f)) { x60_lookDir = zeus::skForward; constexpr CAnimPlaybackParms parms(0, -1, 1.f, true); x0_modelData.GetAnimationData()->SetAnimation(parms, false); } void CSamusFaceReflection::PreDraw(const CStateManager& mgr) { if (x6c_ != 2 && (x4c_lights->GetActiveLightCount() >= 1 || (x6c_ != 0 && x6c_ != 3))) { if (!TCastToConstPtr<CFirstPersonCamera>(mgr.GetCameraManager()->GetCurrentCamera(mgr))) { x70_hidden = true; } else { x70_hidden = false; x0_modelData.GetAnimationData()->PreRender(); } } } void CSamusFaceReflection::Draw(const CStateManager& mgr) { if (x70_hidden) return; if (TCastToConstPtr<CFirstPersonCamera> fpCam = (mgr.GetCameraManager()->GetCurrentCamera(mgr))) { SCOPED_GRAPHICS_DEBUG_GROUP("CSamusFaceReflection::Draw", zeus::skBlue); zeus::CQuaternion camRot(fpCam->GetTransform().basis); float dist = ITweakGui::FaceReflectionDistanceDebugValueToActualValue(g_tweakGui->GetFaceReflectionDistance()); float height = ITweakGui::FaceReflectionHeightDebugValueToActualValue(g_tweakGui->GetFaceReflectionHeight()); float aspect = ITweakGui::FaceReflectionAspectDebugValueToActualValue(g_tweakGui->GetFaceReflectionAspect()); float orthoWidth = ITweakGui::FaceReflectionOrthoWidthDebugValueToActualValue(g_tweakGui->GetFaceReflectionOrthoWidth()); float orthoHeight = ITweakGui::FaceReflectionOrthoHeightDebugValueToActualValue(g_tweakGui->GetFaceReflectionOrthoHeight()); zeus::CTransform modelXf = zeus::CTransform(camRot * x50_lookRot, fpCam->GetTransform().basis[1] * dist + fpCam->GetTransform().origin + fpCam->GetTransform().basis[2] * height) * PreXf; CGraphics::SetViewPointMatrix(fpCam->GetTransform()); CGraphics::SetOrtho(aspect * -orthoWidth, aspect * orthoWidth, orthoHeight, -orthoHeight, -10.f, 10.f); CActorLights* lights = x6c_ == 1 ? nullptr : x4c_lights.get(); if (x6c_ == 3) { x0_modelData.Render(mgr, modelXf, lights, CModelFlags(0, 0, 3, zeus::skWhite)); } else { float transFactor; if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::Combat) transFactor = mgr.GetPlayerState()->GetVisorTransitionFactor(); else transFactor = 0.f; if (transFactor > 0.f) { x0_modelData.Render(mgr, modelXf, nullptr, CModelFlags(7, 0, 3, zeus::skBlack)); x0_modelData.Render(mgr, modelXf, lights, CModelFlags(7, 0, 1, zeus::CColor(1.f, transFactor))); } } } } void CSamusFaceReflection::Update(float dt, const CStateManager& mgr, CRandom16& rand) { if (TCastToConstPtr<CFirstPersonCamera> fpCam = (mgr.GetCameraManager()->GetCurrentCamera(mgr))) { x0_modelData.AdvanceAnimationIgnoreParticles(dt, rand, true); x4c_lights->SetFindShadowLight(false); TAreaId areaId = mgr.GetPlayer().GetAreaIdAlways(); if (areaId == kInvalidAreaId) return; zeus::CAABox aabb(fpCam->GetTranslation() - 0.125f, fpCam->GetTranslation() + 0.125f); const CGameArea* area = mgr.GetWorld()->GetAreaAlways(areaId); x4c_lights->BuildFaceLightList(mgr, *area, aabb); zeus::CUnitVector3f lookDir(fpCam->GetTransform().basis[1]); zeus::CUnitVector3f xfLook = zeus::CQuaternion::lookAt(lookDir, zeus::skForward, 2.f * M_PIF).transform(x60_lookDir); zeus::CQuaternion xfLook2 = zeus::CQuaternion::lookAt(zeus::skForward, xfLook, 2.f * M_PIF); xfLook2 *= xfLook2; zeus::CMatrix3f newXf(xfLook2); zeus::CMatrix3f prevXf(x50_lookRot); float lookDot = prevXf[1].dot(newXf[1]); if (std::fabs(lookDot) > 1.f) lookDot = lookDot > 0.f ? 1.f : -1.f; float lookAng = std::acos(lookDot); x50_lookRot = zeus::CQuaternion::slerp( x50_lookRot, xfLook2, zeus::clamp(0.f, 18.f * dt * ((lookAng > 0.f) ? 0.5f * dt * g_tweakPlayer->GetFreeLookSpeed() / lookAng : 0.f), 1.f)); x60_lookDir = lookDir; } } } // namespace metaforce::MP1
44.896226
119
0.699517
Jcw87
4304992ce677ed0a51c999f03119555651941668
5,160
cpp
C++
AIPDebug/Out-Moc/moc_pic.cpp
Bluce-Song/Master-AIP
1757ab392504d839de89460da17630d268ff3eed
[ "Apache-2.0" ]
null
null
null
AIPDebug/Out-Moc/moc_pic.cpp
Bluce-Song/Master-AIP
1757ab392504d839de89460da17630d268ff3eed
[ "Apache-2.0" ]
null
null
null
AIPDebug/Out-Moc/moc_pic.cpp
Bluce-Song/Master-AIP
1757ab392504d839de89460da17630d268ff3eed
[ "Apache-2.0" ]
null
null
null
/**************************************************************************** ** Meta object code from reading C++ file 'pic.h' ** ** Created by: The Qt Meta Object Compiler version 63 (Qt 4.8.5) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../External-Interface/pic.h" #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'pic.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 63 #error "This file was generated using the moc from 4.8.5. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE static const uint qt_meta_data_pic[] = { // content: 6, // revision 0, // classname 0, 0, // classinfo 10, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 3, // signalCount // signals: signature, parameters, type, tag, flags 12, 5, 4, 4, 0x05, 38, 35, 4, 4, 0x05, 74, 35, 4, 4, 0x05, // slots: signature, parameters, type, tag, flags 110, 35, 4, 4, 0x0a, 146, 35, 4, 4, 0x0a, 184, 4, 4, 4, 0x08, 201, 4, 4, 4, 0x08, 220, 4, 4, 4, 0x08, 239, 4, 4, 4, 0x08, 260, 4, 4, 4, 0x08, 0 // eod }; static const char qt_meta_stringdata_pic[] = { "pic\0\0frame,\0canSend(can_frame,int)\0" ",,\0Signal_pic_to_Test(QString,int,int)\0" "Signal_pic_to_Main(QString,int,int)\0" "Pubs_from_main(QStringList,int,int)\0" "Pubs_from_Switchover(int,int32_t,int)\0" "Timer_Order_Go()\0L_Cylinder_Up_Go()\0" "R_Cylinder_Up_Go()\0Cylinder_Real_Back()\0" "IO_Join_Reset()\0" }; void pic::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { Q_ASSERT(staticMetaObject.cast(_o)); pic *_t = static_cast<pic *>(_o); switch (_id) { case 0: _t->canSend((*reinterpret_cast< can_frame(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 1: _t->Signal_pic_to_Test((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 2: _t->Signal_pic_to_Main((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 3: _t->Pubs_from_main((*reinterpret_cast< QStringList(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 4: _t->Pubs_from_Switchover((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int32_t(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 5: _t->Timer_Order_Go(); break; case 6: _t->L_Cylinder_Up_Go(); break; case 7: _t->R_Cylinder_Up_Go(); break; case 8: _t->Cylinder_Real_Back(); break; case 9: _t->IO_Join_Reset(); break; default: ; } } } const QMetaObjectExtraData pic::staticMetaObjectExtraData = { 0, qt_static_metacall }; const QMetaObject pic::staticMetaObject = { { &QObject::staticMetaObject, qt_meta_stringdata_pic, qt_meta_data_pic, &staticMetaObjectExtraData } }; #ifdef Q_NO_DATA_RELOCATION const QMetaObject &pic::getStaticMetaObject() { return staticMetaObject; } #endif //Q_NO_DATA_RELOCATION const QMetaObject *pic::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; } void *pic::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_pic)) return static_cast<void*>(const_cast< pic*>(this)); return QObject::qt_metacast(_clname); } int pic::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 10) qt_static_metacall(this, _c, _id, _a); _id -= 10; } return _id; } // SIGNAL 0 void pic::canSend(can_frame _t1, int _t2) { void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)), const_cast<void*>(reinterpret_cast<const void*>(&_t2)) }; QMetaObject::activate(this, &staticMetaObject, 0, _a); } // SIGNAL 1 void pic::Signal_pic_to_Test(QString _t1, int _t2, int _t3) { void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)), const_cast<void*>(reinterpret_cast<const void*>(&_t2)), const_cast<void*>(reinterpret_cast<const void*>(&_t3)) }; QMetaObject::activate(this, &staticMetaObject, 1, _a); } // SIGNAL 2 void pic::Signal_pic_to_Main(QString _t1, int _t2, int _t3) { void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)), const_cast<void*>(reinterpret_cast<const void*>(&_t2)), const_cast<void*>(reinterpret_cast<const void*>(&_t3)) }; QMetaObject::activate(this, &staticMetaObject, 2, _a); } QT_END_MOC_NAMESPACE
36.595745
191
0.609496
Bluce-Song
430643a9b2aaca52dc58d619aad3b73e7f160d38
1,423
cpp
C++
Source/SumoUE4Editor/Private/Factories/SumoNetworkAssetFactory.cpp
iwer/SumoUE4
8f2e5281a0b94e46cff97e1e2b535eca0f021dd6
[ "MIT" ]
4
2021-08-31T09:40:18.000Z
2022-02-07T02:48:25.000Z
Source/SumoUE4Editor/Private/Factories/SumoNetworkAssetFactory.cpp
iwer/SumoUE4
8f2e5281a0b94e46cff97e1e2b535eca0f021dd6
[ "MIT" ]
null
null
null
Source/SumoUE4Editor/Private/Factories/SumoNetworkAssetFactory.cpp
iwer/SumoUE4
8f2e5281a0b94e46cff97e1e2b535eca0f021dd6
[ "MIT" ]
2
2021-07-18T02:29:21.000Z
2022-02-07T02:48:28.000Z
// Copyright (c) Iwer Petersen. All rights reserved. #include "SumoNetworkAssetFactory.h" #include "SumoNetworkAsset.h" #include "SumoNetworkParser.h" USumoNetworkAssetFactory::USumoNetworkAssetFactory( const FObjectInitializer& ObjectInitializer ) : Super(ObjectInitializer) { SupportedClass = USumoNetworkAsset::StaticClass(); bCreateNew = false; bEditorImport = true; Formats.Add(TEXT("xml;Sumo network definition file")); } UObject * USumoNetworkAssetFactory::FactoryCreateFile(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, const FString& Filename, const TCHAR* Parms, FFeedbackContext* Warn, bool& bOutOperationCanceled) { USumoNetworkAsset* Asset = NewObject<USumoNetworkAsset>(InParent, InClass, InName, Flags); // populate Asset USumoNetworkParser parser; parser.ParseFile(Filename, Asset); return Asset; } bool USumoNetworkAssetFactory::FactoryCanImport(const FString & Filename) { if(!Filename.EndsWith(TEXT(".net.xml"))){ return false; } return true; }
34.707317
97
0.556571
iwer
430739accc1c4d49b2f5740770d83ca719f25717
15,341
cpp
C++
Developments/solidity-develop/libsolidity/interface/StandardCompiler.cpp
jansenbarabona/NFT-Game-Development
49bf6593925123f0212dac13badd609be3866561
[ "MIT" ]
null
null
null
Developments/solidity-develop/libsolidity/interface/StandardCompiler.cpp
jansenbarabona/NFT-Game-Development
49bf6593925123f0212dac13badd609be3866561
[ "MIT" ]
null
null
null
Developments/solidity-develop/libsolidity/interface/StandardCompiler.cpp
jansenbarabona/NFT-Game-Development
49bf6593925123f0212dac13badd609be3866561
[ "MIT" ]
null
null
null
/* This file is part of solidity. solidity 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. solidity 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 solidity. If not, see <http://www.gnu.org/licenses/>. */ /** * @author Alex Beregszaszi * @date 2016 * Standard JSON compiler interface. */ #include <libsolidity/interface/StandardCompiler.h> #include <libsolidity/interface/SourceReferenceFormatter.h> #include <libsolidity/ast/ASTJsonConverter.h> #include <libevmasm/Instruction.h> #include <libdevcore/JSON.h> #include <libdevcore/SHA3.h> using namespace std; using namespace dev; using namespace dev::solidity; namespace { Json::Value formatError( bool _warning, string const& _type, string const& _component, string const& _message, string const& _formattedMessage = "", Json::Value const& _sourceLocation = Json::Value() ) { Json::Value error = Json::objectValue; error["type"] = _type; error["component"] = _component; error["severity"] = _warning ? "warning" : "error"; error["message"] = _message; error["formattedMessage"] = (_formattedMessage.length() > 0) ? _formattedMessage : _message; if (_sourceLocation.isObject()) error["sourceLocation"] = _sourceLocation; return error; } Json::Value formatFatalError(string const& _type, string const& _message) { Json::Value output = Json::objectValue; output["errors"] = Json::arrayValue; output["errors"].append(formatError(false, _type, "general", _message)); return output; } Json::Value formatErrorWithException( Exception const& _exception, bool const& _warning, string const& _type, string const& _component, string const& _message, function<Scanner const&(string const&)> const& _scannerFromSourceName ) { string message; string formattedMessage = SourceReferenceFormatter::formatExceptionInformation(_exception, _type, _scannerFromSourceName); // NOTE: the below is partially a copy from SourceReferenceFormatter SourceLocation const* location = boost::get_error_info<errinfo_sourceLocation>(_exception); if (string const* description = boost::get_error_info<errinfo_comment>(_exception)) message = ((_message.length() > 0) ? (_message + ":") : "") + *description; else message = _message; if (location && location->sourceName) { Json::Value sourceLocation = Json::objectValue; sourceLocation["file"] = *location->sourceName; sourceLocation["start"] = location->start; sourceLocation["end"] = location->end; } return formatError(_warning, _type, _component, message, formattedMessage, location); } set<string> requestedContractNames(Json::Value const& _outputSelection) { set<string> names; for (auto const& sourceName: _outputSelection.getMemberNames()) { for (auto const& contractName: _outputSelection[sourceName].getMemberNames()) { /// Consider the "all sources" shortcuts as requesting everything. if (contractName == "*" || contractName == "") return set<string>(); names.insert((sourceName == "*" ? "" : sourceName) + ":" + contractName); } } return names; } /// Returns true iff @a _hash (hex with 0x prefix) is the Keccak256 hash of the binary data in @a _content. bool hashMatchesContent(string const& _hash, string const& _content) { try { return dev::h256(_hash) == dev::keccak256(_content); } catch (dev::BadHexCharacter) { return false; } } StringMap createSourceList(Json::Value const& _input) { StringMap sources; Json::Value const& jsonSources = _input["sources"]; if (jsonSources.isObject()) for (auto const& sourceName: jsonSources.getMemberNames()) sources[sourceName] = jsonSources[sourceName]["content"].asString(); return sources; } Json::Value formatLinkReferences(std::map<size_t, std::string> const& linkReferences) { Json::Value ret(Json::objectValue); for (auto const& ref: linkReferences) { string const& fullname = ref.second; size_t colon = fullname.find(':'); solAssert(colon != string::npos, ""); string file = fullname.substr(0, colon); string name = fullname.substr(colon + 1); Json::Value fileObject = ret.get(file, Json::objectValue); Json::Value libraryArray = fileObject.get(name, Json::arrayValue); Json::Value entry = Json::objectValue; entry["start"] = Json::UInt(ref.first); entry["length"] = 20; libraryArray.append(entry); fileObject[name] = libraryArray; ret[file] = fileObject; } return ret; } Json::Value collectEVMObject(eth::LinkerObject const& _object, string const* _sourceMap) { Json::Value output = Json::objectValue; output["object"] = _object.toHex(); output["opcodes"] = solidity::disassemble(_object.bytecode); output["sourceMap"] = _sourceMap ? *_sourceMap : ""; output["linkReferences"] = formatLinkReferences(_object.linkReferences); return output; } } Json::Value StandardCompiler::compileInternal(Json::Value const& _input) { m_compilerStack.reset(false); if (!_input.isObject()) return formatFatalError("JSONError", "Input is not a JSON object."); if (_input["language"] != "Solidity") return formatFatalError("JSONError", "Only \"Solidity\" is supported as a language."); Json::Value const& sources = _input["sources"]; if (!sources) return formatFatalError("JSONError", "No input sources specified."); Json::Value errors = Json::arrayValue; for (auto const& sourceName: sources.getMemberNames()) { string hash; if (!sources[sourceName].isObject()) return formatFatalError("JSONError", "Source input is not a JSON object."); if (sources[sourceName]["keccak256"].isString()) hash = sources[sourceName]["keccak256"].asString(); if (sources[sourceName]["content"].isString()) { string content = sources[sourceName]["content"].asString(); if (!hash.empty() && !hashMatchesContent(hash, content)) errors.append(formatError( false, "IOError", "general", "Mismatch between content and supplied hash for \"" + sourceName + "\"" )); else m_compilerStack.addSource(sourceName, content); } else if (sources[sourceName]["urls"].isArray()) { if (!m_readFile) return formatFatalError("JSONError", "No import callback supplied, but URL is requested."); bool found = false; vector<string> failures; for (auto const& url: sources[sourceName]["urls"]) { ReadCallback::Result result = m_readFile(url.asString()); if (result.success) { if (!hash.empty() && !hashMatchesContent(hash, result.responseOrErrorMessage)) errors.append(formatError( false, "IOError", "general", "Mismatch between content and supplied hash for \"" + sourceName + "\" at \"" + url.asString() + "\"" )); else { m_compilerStack.addSource(sourceName, result.responseOrErrorMessage); found = true; break; } } else failures.push_back("Cannot import url (\"" + url.asString() + "\"): " + result.responseOrErrorMessage); } for (auto const& failure: failures) { /// If the import succeeded, let mark all the others as warnings, otherwise all of them are errors. errors.append(formatError( found ? true : false, "IOError", "general", failure )); } } else return formatFatalError("JSONError", "Invalid input source specified."); } Json::Value const& settings = _input.get("settings", Json::Value()); vector<string> remappings; for (auto const& remapping: settings.get("remappings", Json::Value())) remappings.push_back(remapping.asString()); m_compilerStack.setRemappings(remappings); Json::Value optimizerSettings = settings.get("optimizer", Json::Value()); bool const optimize = optimizerSettings.get("enabled", Json::Value(false)).asBool(); unsigned const optimizeRuns = optimizerSettings.get("runs", Json::Value(200u)).asUInt(); m_compilerStack.setOptimiserSettings(optimize, optimizeRuns); map<string, h160> libraries; Json::Value jsonLibraries = settings.get("libraries", Json::Value()); for (auto const& sourceName: jsonLibraries.getMemberNames()) { auto const& jsonSourceName = jsonLibraries[sourceName]; for (auto const& library: jsonSourceName.getMemberNames()) // @TODO use libraries only for the given source libraries[library] = h160(jsonSourceName[library].asString()); } m_compilerStack.setLibraries(libraries); Json::Value metadataSettings = settings.get("metadata", Json::Value()); m_compilerStack.useMetadataLiteralSources(metadataSettings.get("useLiteralContent", Json::Value(false)).asBool()); Json::Value outputSelection = settings.get("outputSelection", Json::Value()); m_compilerStack.setRequestedContractNames(requestedContractNames(outputSelection)); auto scannerFromSourceName = [&](string const& _sourceName) -> solidity::Scanner const& { return m_compilerStack.scanner(_sourceName); }; try { m_compilerStack.compile(); for (auto const& error: m_compilerStack.errors()) { Error const& err = dynamic_cast<Error const&>(*error); errors.append(formatErrorWithException( *error, err.type() == Error::Type::Warning, err.typeName(), "general", "", scannerFromSourceName )); } } /// This is only thrown in a very few locations. catch (Error const& _error) { errors.append(formatErrorWithException( _error, false, _error.typeName(), "general", "Uncaught error: ", scannerFromSourceName )); } /// This should not be leaked from compile(). catch (FatalError const& _exception) { errors.append(formatError( false, "FatalError", "general", "Uncaught fatal error: " + boost::diagnostic_information(_exception) )); } catch (CompilerError const& _exception) { errors.append(formatErrorWithException( _exception, false, "CompilerError", "general", "Compiler error (" + _exception.lineInfo() + ")", scannerFromSourceName )); } catch (InternalCompilerError const& _exception) { errors.append(formatErrorWithException( _exception, false, "InternalCompilerError", "general", "Internal compiler error (" + _exception.lineInfo() + ")", scannerFromSourceName )); } catch (UnimplementedFeatureError const& _exception) { errors.append(formatErrorWithException( _exception, false, "UnimplementedFeatureError", "general", "Unimplemented feature (" + _exception.lineInfo() + ")", scannerFromSourceName )); } catch (Exception const& _exception) { errors.append(formatError( false, "Exception", "general", "Exception during compilation: " + boost::diagnostic_information(_exception) )); } catch (...) { errors.append(formatError( false, "Exception", "general", "Unknown exception during compilation." )); } bool const analysisSuccess = m_compilerStack.state() >= CompilerStack::State::AnalysisSuccessful; bool const compilationSuccess = m_compilerStack.state() == CompilerStack::State::CompilationSuccessful; /// Inconsistent state - stop here to receive error reports from users if (!compilationSuccess && (errors.size() == 0)) return formatFatalError("InternalCompilerError", "No error reported, but compilation failed."); Json::Value output = Json::objectValue; if (errors.size() > 0) output["errors"] = errors; output["sources"] = Json::objectValue; unsigned sourceIndex = 0; for (string const& sourceName: analysisSuccess ? m_compilerStack.sourceNames() : vector<string>()) { Json::Value sourceResult = Json::objectValue; sourceResult["id"] = sourceIndex++; sourceResult["ast"] = ASTJsonConverter(false, m_compilerStack.sourceIndices()).toJson(m_compilerStack.ast(sourceName)); sourceResult["legacyAST"] = ASTJsonConverter(true, m_compilerStack.sourceIndices()).toJson(m_compilerStack.ast(sourceName)); output["sources"][sourceName] = sourceResult; } Json::Value contractsOutput = Json::objectValue; for (string const& contractName: compilationSuccess ? m_compilerStack.contractNames() : vector<string>()) { size_t colon = contractName.find(':'); solAssert(colon != string::npos, ""); string file = contractName.substr(0, colon); string name = contractName.substr(colon + 1); // ABI, documentation and metadata Json::Value contractData(Json::objectValue); contractData["abi"] = m_compilerStack.contractABI(contractName); contractData["metadata"] = m_compilerStack.metadata(contractName); contractData["userdoc"] = m_compilerStack.natspecUser(contractName); contractData["devdoc"] = m_compilerStack.natspecDev(contractName); // EVM Json::Value evmData(Json::objectValue); // @TODO: add ir evmData["assembly"] = m_compilerStack.assemblyString(contractName, createSourceList(_input)); evmData["legacyAssembly"] = m_compilerStack.assemblyJSON(contractName, createSourceList(_input)); evmData["methodIdentifiers"] = m_compilerStack.methodIdentifiers(contractName); evmData["gasEstimates"] = m_compilerStack.gasEstimates(contractName); evmData["bytecode"] = collectEVMObject( m_compilerStack.object(contractName), m_compilerStack.sourceMapping(contractName) ); evmData["deployedBytecode"] = collectEVMObject( m_compilerStack.runtimeObject(contractName), m_compilerStack.runtimeSourceMapping(contractName) ); contractData["evm"] = evmData; if (!contractsOutput.isMember(file)) contractsOutput[file] = Json::objectValue; contractsOutput[file][name] = contractData; } output["contracts"] = contractsOutput; return output; } Json::Value StandardCompiler::compile(Json::Value const& _input) { try { return compileInternal(_input); } catch (Json::LogicError const& _exception) { return formatFatalError("InternalCompilerError", string("JSON logic exception: ") + _exception.what()); } catch (Json::RuntimeError const& _exception) { return formatFatalError("InternalCompilerError", string("JSON runtime exception: ") + _exception.what()); } catch (Exception const& _exception) { return formatFatalError("InternalCompilerError", "Internal exception in StandardCompiler::compileInternal: " + boost::diagnostic_information(_exception)); } catch (...) { return formatFatalError("InternalCompilerError", "Internal exception in StandardCompiler::compileInternal"); } } string StandardCompiler::compile(string const& _input) { Json::Value input; Json::Reader reader; try { if (!reader.parse(_input, input, false)) return jsonCompactPrint(formatFatalError("JSONError", reader.getFormattedErrorMessages())); } catch(...) { return "{\"errors\":\"[{\"type\":\"JSONError\",\"component\":\"general\",\"severity\":\"error\",\"message\":\"Error parsing input JSON.\"}]}"; } // cout << "Input: " << input.toStyledString() << endl; Json::Value output = compile(input); // cout << "Output: " << output.toStyledString() << endl; try { return jsonCompactPrint(output); } catch(...) { return "{\"errors\":\"[{\"type\":\"JSONError\",\"component\":\"general\",\"severity\":\"error\",\"message\":\"Error writing output JSON.\"}]}"; } }
30.620758
156
0.715338
jansenbarabona
43080d177f46fb72ce682e4cbc4d4d59f9ab2773
12,463
cpp
C++
black-scholes-omp/blackScholesAnalyticEngine.cpp
BeauJoh/HeCBench
594b845171d686dc951971ce36ed59cf114dd2b4
[ "BSD-3-Clause" ]
58
2020-08-06T18:53:44.000Z
2021-10-01T07:59:46.000Z
black-scholes-omp/blackScholesAnalyticEngine.cpp
BeauJoh/HeCBench
594b845171d686dc951971ce36ed59cf114dd2b4
[ "BSD-3-Clause" ]
2
2020-12-04T12:35:02.000Z
2021-03-04T22:49:25.000Z
black-scholes-omp/blackScholesAnalyticEngine.cpp
BeauJoh/HeCBench
594b845171d686dc951971ce36ed59cf114dd2b4
[ "BSD-3-Clause" ]
13
2020-08-19T13:44:18.000Z
2021-09-08T04:25:34.000Z
//blackScholesAnalyticEngine.cpp //Functions for running black scholes using the analytic engine (from Quantlib) on the GPU #include <stdio.h> #include <stdlib.h> #include <math.h> #include <sys/time.h> #include <time.h> #define NUM_DIFF_SETTINGS 37 //needed for optionInputStruct #include "blackScholesAnalyticEngineStructs.h" //needed for the kernel(s) to run on the GPU #include "blackScholesAnalyticEngineKernels.cpp" #include "blackScholesAnalyticEngineKernelsCpu.cpp" //function to run the black scholes analytic engine on the gpu void runBlackScholesAnalyticEngine() { int numberOfSamples = 50000000; { int numVals = numberOfSamples;//nSamplesArray[numTime]; optionInputStruct* values = new optionInputStruct[numVals]; for (int numOption = 0; numOption < numVals; numOption++) { if ((numOption % NUM_DIFF_SETTINGS) == 0) { optionInputStruct currVal = { CALL, 40.00, 42.00, 0.08, 0.04, 0.75, 0.35, 5.0975, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 1) { optionInputStruct currVal = { CALL, 100.00, 90.00, 0.10, 0.10, 0.10, 0.15, 0.0205, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 2) { optionInputStruct currVal = { CALL, 100.00, 100.00, 0.10, 0.10, 0.10, 0.15, 1.8734, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 3) { optionInputStruct currVal = { CALL, 100.00, 110.00, 0.10, 0.10, 0.10, 0.15, 9.9413, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 4) { optionInputStruct currVal = { CALL, 100.00, 90.00, 0.10, 0.10, 0.10, 0.25, 0.3150, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 5) { optionInputStruct currVal = { CALL, 100.00, 100.00, 0.10, 0.10, 0.10, 0.25, 3.1217, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 6) { optionInputStruct currVal = { CALL, 100.00, 110.00, 0.10, 0.10, 0.10, 0.25, 10.3556, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 7) { optionInputStruct currVal = { CALL, 100.00, 90.00, 0.10, 0.10, 0.10, 0.35, 0.9474, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 8) { optionInputStruct currVal = { CALL, 100.00, 100.00, 0.10, 0.10, 0.10, 0.35, 4.3693, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 9) { optionInputStruct currVal = { CALL, 100.00, 110.00, 0.10, 0.10, 0.10, 0.35, 11.1381, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 10) { optionInputStruct currVal = { CALL, 100.00, 90.00, 0.10, 0.10, 0.50, 0.15, 0.8069, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 11) { optionInputStruct currVal = { CALL, 100.00, 100.00, 0.10, 0.10, 0.50, 0.15, 4.0232, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 12) { optionInputStruct currVal = { CALL, 100.00, 110.00, 0.10, 0.10, 0.50, 0.15, 10.5769, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 13) { optionInputStruct currVal = { CALL, 100.00, 90.00, 0.10, 0.10, 0.50, 0.25, 2.7026, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 14) { optionInputStruct currVal = { CALL, 100.00, 100.00, 0.10, 0.10, 0.50, 0.25, 6.6997, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 15) { optionInputStruct currVal = { CALL, 100.00, 110.00, 0.10, 0.10, 0.50, 0.25, 12.7857, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 16) { optionInputStruct currVal = { CALL, 100.00, 90.00, 0.10, 0.10, 0.50, 0.35, 4.9329, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 17) { optionInputStruct currVal = { CALL, 100.00, 100.00, 0.10, 0.10, 0.50, 0.35, 9.3679, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 18) { optionInputStruct currVal = { CALL, 100.00, 110.00, 0.10, 0.10, 0.50, 0.35, 15.3086, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 19) { optionInputStruct currVal = { PUT, 100.00, 90.00, 0.10, 0.10, 0.10, 0.15, 9.9210, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 20) { optionInputStruct currVal = { PUT, 100.00, 100.00, 0.10, 0.10, 0.10, 0.15, 1.8734, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 21) { optionInputStruct currVal = { PUT, 100.00, 110.00, 0.10, 0.10, 0.10, 0.15, 0.0408, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 22) { optionInputStruct currVal = { PUT, 100.00, 90.00, 0.10, 0.10, 0.10, 0.25, 10.2155, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 23) { optionInputStruct currVal = { PUT, 100.00, 100.00, 0.10, 0.10, 0.10, 0.25, 3.1217, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 24) { optionInputStruct currVal = { PUT, 100.00, 110.00, 0.10, 0.10, 0.10, 0.25, 0.4551, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 25) { optionInputStruct currVal = { PUT, 100.00, 90.00, 0.10, 0.10, 0.10, 0.35, 10.8479, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 26) { optionInputStruct currVal = { PUT, 100.00, 100.00, 0.10, 0.10, 0.10, 0.35, 4.3693, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 27) { optionInputStruct currVal = { PUT, 100.00, 110.00, 0.10, 0.10, 0.10, 0.35, 1.2376, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 28) { optionInputStruct currVal = { PUT, 100.00, 90.00, 0.10, 0.10, 0.50, 0.15, 10.3192, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 29) { optionInputStruct currVal = { PUT, 100.00, 100.00, 0.10, 0.10, 0.50, 0.15, 4.0232, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 30) { optionInputStruct currVal = { PUT, 100.00, 110.00, 0.10, 0.10, 0.50, 0.15, 1.0646, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 31) { optionInputStruct currVal = { PUT, 100.00, 90.00, 0.10, 0.10, 0.50, 0.25, 12.2149, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 32) { optionInputStruct currVal = { PUT, 100.00, 100.00, 0.10, 0.10, 0.50, 0.25, 6.6997, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 33) { optionInputStruct currVal = { PUT, 100.00, 110.00, 0.10, 0.10, 0.50, 0.25, 3.2734, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 34) { optionInputStruct currVal = { PUT, 100.00, 90.00, 0.10, 0.10, 0.50, 0.35, 14.4452, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 35) { optionInputStruct currVal = { PUT, 100.00, 100.00, 0.10, 0.10, 0.50, 0.35, 9.3679, 1.0e-4}; values[numOption] = currVal; } if ((numOption % NUM_DIFF_SETTINGS) == 36) { optionInputStruct currVal = { PUT, 100.00, 110.00, 0.10, 0.10, 0.50, 0.35, 5.7963, 1.0e-4}; values[numOption] = currVal; } } // Run GPU code //initialize the arrays //declare and allocate the input and output data on the CPU float* outputVals = (float*)malloc(numVals * sizeof(float)); printf("Number of options: %d\n\n", numVals); long seconds, useconds; float mtimeCpu, mtimeGpu; struct timeval start; gettimeofday(&start, NULL); #pragma omp target map(to: values[0:numVals]) map(from: outputVals[0:numVals]) { #pragma omp teams distribute parallel for simd thread_limit(THREAD_BLOCK_SIZE) for (int optionNum = 0; optionNum < numVals; optionNum++) { optionInputStruct threadOption = values[optionNum]; payoffStruct currPayoff; currPayoff.type = threadOption.type; currPayoff.strike = threadOption.strike; yieldTermStruct qTS; qTS.timeYearFraction = threadOption.t; qTS.forward = threadOption.q; yieldTermStruct rTS; rTS.timeYearFraction = threadOption.t; rTS.forward = threadOption.r; blackVolStruct volTS; volTS.timeYearFraction = threadOption.t; volTS.volatility = threadOption.vol; blackScholesMertStruct stochProcess; stochProcess.x0 = threadOption.spot; stochProcess.dividendTS = qTS; stochProcess.riskFreeTS = rTS; stochProcess.blackVolTS = volTS; optionStruct currOption; currOption.payoff = currPayoff; currOption.yearFractionTime = threadOption.t; currOption.pricingEngine = stochProcess; float variance = getBlackVolBlackVar(currOption.pricingEngine.blackVolTS); float dividendDiscount = getDiscountOnDividendYield(currOption.yearFractionTime, currOption.pricingEngine.dividendTS); float riskFreeDiscount = getDiscountOnRiskFreeRate(currOption.yearFractionTime, currOption.pricingEngine.riskFreeTS); float spot = currOption.pricingEngine.x0; float forwardPrice = spot * dividendDiscount / riskFreeDiscount; //declare the blackCalcStruct blackCalcStruct blackCalc; //initialize the calculator initBlackCalculator(blackCalc, currOption.payoff, forwardPrice, sqrtf(variance), riskFreeDiscount); //retrieve the results values float resultVal = getResultVal(blackCalc); //write the resulting value to global memory outputVals[optionNum] = resultVal; } } struct timeval end; gettimeofday(&end, NULL); seconds = end.tv_sec - start.tv_sec; useconds = end.tv_usec - start.tv_usec; mtimeGpu = ((seconds) * 1000 + ((float)useconds)/1000.0) + 0.5f; printf("Run on GPU\n"); printf("Processing time on GPU: %f (ms)\n", mtimeGpu); float totResult = 0.0f; for (int i=0; i<numVals; i++) { totResult += outputVals[i]; } printf("Summation of output prices on GPU: %f\n", totResult); printf("Output price at index %d on GPU: %f\n\n", numVals/2, outputVals[numVals/2]); //run on CPU gettimeofday(&start, NULL); for (size_t numOption=0; numOption < numVals; numOption++) { getOutValOptionCpu(values, outputVals, numOption, numVals); } gettimeofday(&end, NULL); seconds = end.tv_sec - start.tv_sec; useconds = end.tv_usec - start.tv_usec; mtimeCpu = ((seconds) * 1000 + ((float)useconds)/1000.0) + 0.5f; printf("Run on CPU\n"); printf("Processing time on CPU: %f (ms)\n", mtimeCpu); totResult = 0.0f; for (int i=0; i<numVals; i++) { totResult += outputVals[i]; } printf("Summation of output prices on CPU: %f\n", totResult); printf("Output price at index %d on CPU:: %f\n\n", numVals/2, outputVals[numVals/2]); printf("Speedup on GPU: %f\n", mtimeCpu / mtimeGpu); delete [] values; free(outputVals); } } //////////////////////////////////////////////////////////////////////////////// // Program main //////////////////////////////////////////////////////////////////////////////// int main( int argc, char** argv) { runBlackScholesAnalyticEngine(); return 0; }
36.229651
126
0.584209
BeauJoh
430e66876b32f5d02868476d2af6e5bb3895cfd5
19,921
cpp
C++
authkeys.cpp
lool/bootgen
6bea30996979f085701542d8905966240545cd8e
[ "Apache-2.0", "CC0-1.0" ]
null
null
null
authkeys.cpp
lool/bootgen
6bea30996979f085701542d8905966240545cd8e
[ "Apache-2.0", "CC0-1.0" ]
null
null
null
authkeys.cpp
lool/bootgen
6bea30996979f085701542d8905966240545cd8e
[ "Apache-2.0", "CC0-1.0" ]
null
null
null
/****************************************************************************** * Copyright 2015-2020 Xilinx, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ /* ------------------------------------------------------------------------------- *********************************************** H E A D E R F I L E S *** ------------------------------------------------------------------------------- */ #include <iomanip> #include <iostream> #include "authkeys.h" #include "authentication.h" #include "options.h" /* ------------------------------------------------------------------------------- ***************************************************** F U N C T I O N S *** ------------------------------------------------------------------------------- */ /******************************************************************************/ Key::Key(const std::string& name0) : Loaded(false) , isSecret(false) , name(name0) { keySize = AuthenticationContext::GetRsaKeyLength(); N = new uint8_t [keySize]; N_ext = new uint8_t [keySize]; D = new uint8_t [keySize]; E = new uint8_t [WORD_SIZE_IN_BYTES]; P = new uint8_t [keySize/2]; Q = new uint8_t [keySize/2]; memset(N, 0, keySize); memset(N_ext, 0, keySize); memset(E, 0, WORD_SIZE_IN_BYTES); memset(P, 0, keySize/2); memset(Q, 0, keySize/2); memset(D, 0, keySize); } /******************************************************************************/ Key::Key(const Key& otherKey) { keySize = AuthenticationContext::GetRsaKeyLength(); N = new uint8_t [keySize]; N_ext = new uint8_t [keySize]; D = new uint8_t [keySize]; E = new uint8_t [WORD_SIZE_IN_BYTES]; P = new uint8_t [keySize/2]; Q = new uint8_t [keySize/2]; memcpy(this,&otherKey,sizeof(Key)); } /******************************************************************************/ Key::~Key() { if(N != NULL) { delete[] N; } if(N_ext != NULL) { delete[] N_ext; } if(D != NULL) { delete[] D; } if(E != NULL) { delete[] E; } if(P != NULL) { delete[] P; } if(Q != NULL) { delete[] Q; } } /******************************************************************************/ void Key::ParsePublic(const std::string& filename) { Parse(filename,false); } /******************************************************************************/ void Key::ParseSecret(const std::string& filename) { Parse(filename,true); } /******************************************************************************/ void Key::Parse(const std::string& filename, bool isSecret0) { uint8_t errCode = 0; isSecret = isSecret0; std::string basefile = StringUtils::BaseName(filename); FILE* f; f = fopen(filename.c_str(),"r"); if (f == NULL) { LOG_ERROR("Cannot open key %s", filename.c_str()); } try { int name; do { name = getc(f); } while (name >= 0 && isspace(name)); fseek(f,0,0); /* If the file starts with 'N', then it is Xilinx Format If it starts with '-', then it is OpenSSL format */ if (name == 'N') { errCode = ParseXilinxRsaKey(f); } else if (name == '-') { errCode = ParseOpenSSLKey(f); } else { LOG_ERROR("Unsupported key file - %s\n Supported key formats: Xilinx Format & OpenSSL format", basefile.c_str()); } fclose(f); if(errCode != 0) { LOG_ERROR("RSA authentication key parsing failed - %s", basefile.c_str()); } /* Calculate the modulus extension, i.e. Montgomery Reduction term RR and some sanity check for the keys passed */ { BIGNUM m; m.d = (BN_ULONG*)N; m.dmax = keySize / sizeof(BN_ULONG); m.top = keySize / sizeof(BN_ULONG); m.flags = 0; m.neg = 0; BN_CTX_Class ctxInst; BN_MONT_CTX_Class montClass(ctxInst); montClass.Set(m); montClass.GetModulusExtension(N_ext, m, keySize); } Loaded = true; } catch(...) { fclose(f); throw; } } /******************************************************************************/ uint8_t Key::ParseOpenSSLKey(FILE* f) { RSA_Class rsaInst; OpenSSL_add_all_algorithms(); uint32_t keySzRd; if (isSecret) { rsaInst.rsa = PEM_read_RSAPrivateKey(f, NULL, NULL, NULL); if(rsaInst.rsa == NULL) { return 1; } #if OPENSSL_VERSION_NUMBER > 0x10100000L keySzRd = BN_num_bytes(RSA_get0_n(rsaInst.rsa)); #else keySzRd = BN_num_bytes(rsaInst.rsa->n); #endif if (keySzRd != keySize) { LOG_ERROR("Incorrect Key Size !!!\n\t Key Size is %d bits. Expected key size is %d bits", keySzRd * 8, keySize * 8); } #if OPENSSL_VERSION_NUMBER > 0x10100000L memcpy(D, RSA_get0_d(rsaInst.rsa)->d, keySize); #else memcpy(D, rsaInst.rsa->d->d, keySize); #endif } else { rsaInst.rsa = PEM_read_RSA_PUBKEY(f, NULL, NULL, NULL); if(rsaInst.rsa == NULL) { return 1; } #if OPENSSL_VERSION_NUMBER > 0x10100000L keySzRd = BN_num_bytes(RSA_get0_n(rsaInst.rsa)); #else keySzRd = BN_num_bytes(rsaInst.rsa->n); #endif if (keySzRd != keySize) { LOG_ERROR("Incorrect Key Size !!!\n\t Key Size is %d bits. Expected key size is %d bits", keySzRd * 8, keySize * 8); } memset(D,0,keySize); } #if OPENSSL_VERSION_NUMBER > 0x10100000L memcpy(N, RSA_get0_n(rsaInst.rsa)->d, keySize); memcpy(E, RSA_get0_e(rsaInst.rsa)->d, sizeof(uint32_t)); #else memcpy(N, rsaInst.rsa->n->d, keySize); memcpy(E, rsaInst.rsa->e->d, sizeof(uint32_t)); #endif return 0; } /******************************************************************************/ uint8_t Key::ParseXilinxRsaKey(FILE* f) { int name; /* Check for N in the key file followed by '=', Once got, parse the value of N */ do { name = getc(f); } while (name >= 0 && isspace(name)); if (name != 'N') { LOG_DEBUG(DEBUG_STAMP, "Bad Key file, expected N, got %c", name); return 1; } do { name = getc(f); } while (name >= 0 && isspace(name)); if (name != '=') { LOG_DEBUG(DEBUG_STAMP, "Bad Key file, expected =, got %c", name); return 1; } LOG_TRACE("Parsing 'N' from key file"); Hex2Byte(f, N, keySize); /* Check for E in the key file followed by '=' Once got, parse the value of E */ do { name = getc(f); } while (name >= 0 && isspace(name)); if (name != 'E') { LOG_DEBUG(DEBUG_STAMP, "Bad Key file, expected E, got %c",name); return 1; } do { name = getc(f); } while (name >= 0 && isspace(name)); if (name != '=') { LOG_DEBUG(DEBUG_STAMP, "Bad Key file, expected =, got %c",name); return 1; } uint32_t temp; LOG_TRACE("Parsing 'E' from key file"); if(EOF != fscanf(f,"%X",&temp)) { E[0] = (uint8_t)(temp); E[1] = (uint8_t)(temp>>8); E[2] = (uint8_t)(temp>>16); E[3] = (uint8_t)(temp>>24); } if (isSecret) { /* Check for D in the key file followed by '=' Once got, parse the value of D */ do { name = getc(f); } while (name >= 0 && isspace(name)); if(name != 'D') { LOG_DEBUG(DEBUG_STAMP, "Bad Key file, expected D, got %c",name); return 1; } do { name = getc(f); } while (name >= 0 && isspace(name)); if (name != '=') { LOG_DEBUG(DEBUG_STAMP, "Bad Key file, expected =, got %c",name); return 1; } LOG_TRACE("Parsing 'D' from key file"); Hex2Byte(f, D, keySize); /* The rest of parsing is for sanity checking purpose Not used for signing or verfication */ /* Check for P in the key file followed by '=' Once got, parse the value of P */ do { name = getc(f); } while (name >= 0 && isspace(name)); if(name == 'P') { do { name = getc(f); } while (name >= 0 && isspace(name)); if (name != '=') { LOG_DEBUG(DEBUG_STAMP, "Bad Key file, expected =, got %c",name); return 1; } LOG_TRACE("Parsing 'P' from key file"); Hex2Byte(f, P, keySize/2); /* Check for Q in the key file followed by '=' Once got, parse the value of Q */ do { name = getc(f); } while (name >= 0 && isspace(name)); if(name != 'Q') { LOG_DEBUG(DEBUG_STAMP, "Bad Key file, expected Q, got %c",name); return 1; } do { name = getc(f); } while (name >= 0 && isspace(name)); if(name != '=') { LOG_DEBUG(DEBUG_STAMP, "Bad Key file, expected =, got %c",name); return 1; } LOG_TRACE("Parsing 'Q' from key file"); Hex2Byte(f, Q, keySize/2); /* Sanity check block, N = PxQ */ { uint8_t *Ncheck = new uint8_t [keySize]; Multiply_p_q(P, Q, Ncheck); if (memcmp(N, Ncheck, keySize)) { delete[] Ncheck; LOG_DEBUG(DEBUG_STAMP, "Inconsistency found in key file, P * Q != N"); return 1; } delete[] Ncheck; } } } else { /* If it is a public key, D=0 */ memset(D, 0, keySize); } return 0; } /******************************************************************************/ void Key::WriteRsaFile(std::ofstream& file, const RSA* rsa, bool secret, uint16_t keyLength) { uint8_t *temp = new uint8_t [keyLength]; file << "N = "; #if OPENSSL_VERSION_NUMBER > 0x10100000L memcpy(temp, RSA_get0_n(rsa)->d, keyLength); #else memcpy(temp, rsa->n->d, keyLength); #endif for (uint32_t index = keyLength; index != 0; index--) { file << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << int(temp[index-1]); } file << "\n\nE = "; #if OPENSSL_VERSION_NUMBER > 0x10100000L uint32_t* temp_e = (uint32_t*)RSA_get0_e(rsa)->d; #else uint32_t* temp_e = (uint32_t*)rsa->e->d; #endif file << std::uppercase << std::hex << std::setfill('0') << std::setw(8) << *temp_e; if (secret) { file << "\n\nD = "; #if OPENSSL_VERSION_NUMBER > 0x10100000L memcpy(temp, RSA_get0_d(rsa)->d, keyLength); #else memcpy(temp, rsa->d->d, keyLength); #endif for (uint32_t index = keyLength; index != 0; index--) { file << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << int(temp[index - 1]); } } delete[] temp; } /******************************************************************************/ void Key::GenerateRsaKeys(KeyGenerationStruct* keygen) { RSA *rsa = NULL; bool publicKeyGenerated = false; bool privateKeyGenerated = false; OpenSSL_add_all_algorithms(); FILE* file; if ((rsa = RSA_generate_key(keygen->keyLength*8, RSA_F4, NULL, NULL)) == NULL) { LOG_ERROR("Failure creating authentication Keys"); } else { if(keygen->format == GenAuthKeys::PEM) { if(keygen->ppk_file != "") { file = fopen(keygen->ppk_file.c_str(), "wb"); PEM_write_RSA_PUBKEY(file, rsa); fclose(file); LOG_INFO("PPK generation in PEM format successful"); publicKeyGenerated = true; } if(keygen->psk_file != "") { file = fopen(keygen->psk_file.c_str(), "wb"); PEM_write_RSAPrivateKey(file, rsa, NULL, NULL, 0, NULL, NULL); fclose(file); LOG_INFO("PSK generation in PEM format successful"); publicKeyGenerated = true; } } else { if(keygen->ppk_file != "") { std::ofstream file1(keygen->ppk_file.c_str()); WriteRsaFile(file1, rsa, false, keygen->keyLength); file1.close(); LOG_INFO("PPK generation in RSA format successful"); publicKeyGenerated = true; } if(keygen->psk_file != "") { std::ofstream file2(keygen->psk_file.c_str()); WriteRsaFile(file2, rsa, true, keygen->keyLength); file2.close(); LOG_INFO("PSK generation in RSA format successful"); publicKeyGenerated = true; } } } rsa=NULL; if ((rsa=RSA_generate_key(keygen->keyLength*8, RSA_F4, NULL, NULL)) == NULL) { LOG_ERROR("Failure creating authentication Keys"); } else { if(keygen->format == GenAuthKeys::PEM) { if(keygen->spk_file != "") { file = fopen(keygen->spk_file.c_str(), "wb"); PEM_write_RSA_PUBKEY(file, rsa); fclose(file); LOG_INFO("SPK generation in PEM format successful"); privateKeyGenerated = true; } if(keygen->ssk_file != "") { file = fopen(keygen->ssk_file.c_str(), "wb"); PEM_write_RSAPrivateKey(file, rsa, NULL, NULL, 0, NULL, NULL); fclose(file); LOG_INFO("SSK generation in PEM format successful"); privateKeyGenerated = true; } } else { if(keygen->spk_file != "") { std::ofstream file3(keygen->spk_file.c_str()); WriteRsaFile(file3, rsa, false, keygen->keyLength); file3.close(); LOG_INFO("SPK generation in RSA format successful"); privateKeyGenerated = true; } if(keygen->ssk_file != "") { std::ofstream file4(keygen->ssk_file.c_str()); WriteRsaFile(file4, rsa, true, keygen->keyLength); file4.close(); LOG_INFO("SSK generation in RSA format successful"); privateKeyGenerated = true; } } } if(!publicKeyGenerated && !privateKeyGenerated) { LOG_DEBUG(DEBUG_STAMP, "Key paths are not specified in the BIF file"); LOG_ERROR("Failed to generate authentication keys. Please specify the key paths in BIF file"); } } /******************************************************************************/ void Key2048::Export(void* acKey) { ACKey2048* key = (ACKey2048*)acKey; if (!Loaded) { std::string pubsec = (isSecret) ? " (Secret)" : " (Public)"; LOG_ERROR("%s - $s is not loaded", name.c_str(), pubsec.c_str()); } memset(key,0,sizeof(ACKey2048)); memcpy(key->N, N, 256); memcpy(key->N_extension, N_ext, 256); memcpy(key->E, E, 4); } /******************************************************************************/ void Key2048::Import(const void* acKey, const std::string& name0) { ACKey2048* key = (ACKey2048*)acKey; Loaded = true; isSecret = false; name = name0; memcpy(N,key->N,keySize); memcpy(N_ext,key->N_extension,keySize); memcpy(E,key->E,sizeof(uint32_t)); memset(P,0,keySize/2); memset(Q,0,keySize/2); /* Fill secret exponent with zeros */ memset(D,0,keySize); } /******************************************************************************/ void Key4096::Export(void* acKey) { ACKey4096* key = (ACKey4096*)acKey; if (!Loaded) { std::string pubsec = (isSecret) ? " (Secret)" : " (Public)"; LOG_ERROR("%s - $s is not loaded", name.c_str(), pubsec.c_str()); } memset(key, 0, sizeof(ACKey4096)); memcpy(key->N, N, keySize); memcpy(key->N_extension, N_ext, keySize); memcpy(key->E, E, 4); } /******************************************************************************/ void Key4096::Import(const void* acKey, const std::string& name0) { ACKey4096* key = (ACKey4096*)acKey; Loaded = true; isSecret = false; name = name0; memcpy(N, key->N, keySize); memcpy(N_ext, key->N_extension, keySize); memcpy(E, key->E, sizeof(uint32_t)); memset(P, 0, keySize/2); memset(Q, 0, keySize/2); /* Fill secret exponent with zeros */ memset(D, 0, keySize); } /******************************************************************************/ void Key::SetKeyName(std::string keyname) { name = keyname; } /******************************************************************************/ void Key::Multiply_p_q(uint8_t p[], uint8_t q[], uint8_t n[]) { memset(n,0,256); /* Multiply p * q, and store in n */ for(int i = 0; i < 128; i++) { for(int j = 0; j < 128; j++) { uint16_t prod = p[i] * q[j]; int k = i+j; while (prod && k < 256) { uint16_t sum = n[k] + (prod & 0xFF); n[k] = sum & 0xFF; prod >>= 8; sum >>= 8; prod = (prod + sum); k++; } } } } /******************************************************************************/ void Key::Hex2Byte(FILE* f, uint8_t* data, int count) { char *buf; buf = (char *) malloc(2000); if (buf != NULL) { char *tempbuf = buf; if (fscanf(f, "%s", tempbuf) != 1) { LOG_ERROR("Error parsing key"); } int len = strlen(tempbuf)/2; if(len != count) { LOG_ERROR("Key size is %d bytes, expected size is %d bytes", len, count); } for(int i = count-1; i >= 0; i--) { int v; if (sscanf(tempbuf, "%2X", &v) != 1) { LOG_DEBUG(DEBUG_STAMP, "Failure reading the authentication key file"); LOG_ERROR("Failure in key parsing !!!"); } if (v < 0 || v > 255) { LOG_DEBUG(DEBUG_STAMP, "Failure converting the hex characters from key file"); LOG_ERROR("Failure in key parsing !!!"); } if(i > 0) { tempbuf += 2; } data[i] = v; } } else { LOG_DEBUG(DEBUG_STAMP, "Memory Allocation error while reading keys"); LOG_ERROR("Failure in key parsing !!!"); } free(buf); }
29.468935
135
0.460268
lool
43101b0ae11df976c4f2821f837e019a0c5d5c96
8,242
cpp
C++
apps/log/src/main_log.cpp
ShmFw/shmfw
d386841f8b1425cbeca8c8a3fc6919bf8d83c38e
[ "BSD-3-Clause" ]
1
2016-02-06T14:57:32.000Z
2016-02-06T14:57:32.000Z
apps/log/src/main_log.cpp
ShmFw/shmfw
d386841f8b1425cbeca8c8a3fc6919bf8d83c38e
[ "BSD-3-Clause" ]
null
null
null
apps/log/src/main_log.cpp
ShmFw/shmfw
d386841f8b1425cbeca8c8a3fc6919bf8d83c38e
[ "BSD-3-Clause" ]
1
2018-11-07T02:45:24.000Z
2018-11-07T02:45:24.000Z
/*************************************************************************** * Software License Agreement (BSD License) * * Copyright (C) 2012 by Markus Bader <[email protected]> * * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted provided that the following conditions * * are met: * * * * 1. Redistributions of source code must retain the above copyright * * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * * notice, this list of conditions and the following disclaimer in * * the documentation and/or other materials provided with the * * distribution. * * 3. Neither the name of the copyright holder nor the names of its * * contributors may be used to endorse or promote products derived * * from this software without specific prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY * * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * ***************************************************************************/ #include <iostream> #include <stdlib.h> #include <signal.h> #include "shmfw/variable.h" #include "shmfw/vector.h" #include "shmfw/log.h" #include <boost/program_options.hpp> #include <boost/thread.hpp> #include <ncurses.h> bool loop_program = true; struct Prarmeters { bool clear; std::string shm_memory_name; unsigned int shm_memory_size; std::string variable_name; std::string log_file; int process_cout_level; int source; int file_level; int cout_level; bool timeout_msg; bool pull; bool buffer; bool timestamp; int timeout; }; Prarmeters readArgs ( int argc, char **argv ) { namespace po = boost::program_options; Prarmeters params; po::options_description desc ( "Allowed Parameters" ); desc.add_options() ( "help", "get this help message" ) ( "clear", "clears the shared memory" ) ( "msg_off,o", "switches the timeout message off" ) ( "buffer", "shows the buffer id" ) ( "timestamp_off", "switches the timestamp off" ) ( "pull,p", "pulls for log messages (no trigger needed)" ) ( "timeout,t", po::value<int> ( &params.timeout )->default_value ( 2000 ), "timeout for timeout message in ms" ) ( "source,s", po::value<int> ( &params.source )->default_value ( -1 ), "source filter (-1 off)" ) ( "process_cout_level", po::value<int> ( &params.process_cout_level )->default_value ( ShmFw::Message::NA ), "level of message to be printed by the meassage creating process" ) ( "cout_level", po::value<int> ( &params.cout_level )->default_value ( ShmFw::Message::NA ), "level of message to be printed by this process" ) ( "file_level", po::value<int> ( &params.file_level )->default_value ( ShmFw::Message::NA ), "level of message to be stored" ) ( "file,f", po::value<std::string> ( &params.log_file )->default_value ( "/tmp/log" ), "log file prefix, if empty it will print of cout" ) ( "shm_log,l", po::value<std::string> ( &params.variable_name )->default_value ( "log" ), "shared variable name of the logger" ) ( "shm_memory_name", po::value<std::string> ( &params.shm_memory_name )->default_value ( ShmFw::DEFAULT_LOG_SEGMENT_NAME() ), "shared memory segment name" ) ( "shm_memory_size", po::value<unsigned int> ( &params.shm_memory_size )->default_value ( ShmFw::DEFAULT_LOG_SEGMENT_SIZE() ), "shared memory segment size" ); po::variables_map vm; try { po::store ( po::parse_command_line ( argc, argv, desc ), vm ); } catch ( const std::exception &ex ) { std::cout << desc << std::endl;; exit ( 1 ); } po::notify ( vm ); if ( vm.count ( "help" ) ) { std::cout << desc << std::endl; exit ( 1 ); } params.clear = ( vm.count ( "clear" ) > 0 ); params.timeout_msg = ! ( vm.count ( "msg_off" ) > 0 ); params.pull = ( vm.count ( "pull" ) > 0 ); params.buffer = ( vm.count ( "buffer" ) > 0 ); params.timestamp = !( vm.count ( "timestamp_off" ) > 0 ); return params; } void printMsgs ( std::vector<ShmFw::Message> &msgs, std::ofstream &file, const Prarmeters &params ) { for ( unsigned int i = 0; i < msgs.size(); i++ ) { ShmFw::Message &msg = msgs[i]; if ( !params.log_file.empty() ) { file << std::setw ( 4 ) << i << ": " << msg << std::endl; } //source log level/type filter if ( msg.getType() >= params.cout_level ) { if ( params.buffer ) std::cout << std::setw ( 4 ) << i << ": "; if ( params.timestamp ) std::cout << boost::posix_time::to_simple_string ( msg.getTime() ).substr(12,26) << ": "; if ( msg.getType() != ShmFw::Message::NA ) std::cout << ": " << std::setw ( 8 ) << msg.typeStr() << ": "; std::cout << msg.getMsg(); std::cout << std::endl; } } } void dequeLog ( ShmFw::Log &log, const Prarmeters &params ) { std::vector<ShmFw::Message> msgs; std::ofstream file; boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time(); std::string datedFileName = params.log_file + std::string ( "_" ) + boost::posix_time::to_iso_string ( now ) + std::string ( ".txt" ); if ( !params.log_file.empty() ) { file.open ( datedFileName.c_str(), std::ios::out | std::ios::binary ); } while ( loop_program ) { bool wait_ones = true; while ( ( log.timed_wait ( params.timeout ) == false ) && loop_program && wait_ones ) { if ( params.timeout_msg ) std::cout << "waited " << params.timeout << " ms" << std::endl; if ( params.pull ) wait_ones = false; } msgs.clear(); log.lock(); #if BOOST_VERSION / 100 % 1000 <= 55 for ( ShmFw::Log::Iterator it = log->begin(); it != log->end(); it++ ) { //source filter if ( (params.source < 0) || (params.source == ( *it ).getSource())) { msgs.push_back ( *it ); log.pop_front(); } } #else #endif log.unlock(); printMsgs ( msgs, file, params ); } if ( !params.log_file.empty() ) file.close(); } void terminate ( int param ) { std::cout << "Closing program!" << std::endl; loop_program = false; } int main ( int argc, char *argv[] ) { signal ( SIGINT, terminate ); signal ( SIGKILL, terminate ); Prarmeters params = readArgs ( argc, argv ); if ( params.clear ) { ShmFw::Handler::removeSegment ( params.shm_memory_name ); std::cout << "Shared Memory " << params.shm_memory_name << " cleared" << std::endl; exit ( 1 ); } ShmFw::HandlerPtr shmHdl = ShmFw::Handler::create ( params.shm_memory_name, params.shm_memory_size ); ShmFw::Log log ( shmHdl, params.variable_name ); log.process_cout_level ( params.process_cout_level ); log.unlock(); dequeLog ( log, params ); log.unlock(); exit ( 0 ); }
43.378947
180
0.575467
ShmFw
4310b7e363a524d20b0f5c04306fecfce32c5f94
59,237
cc
C++
deps/exokit-bindings/glfw/src/glfw.cc
Palmer-JC/exokit
55ee5a36d97c6bda5d380780632631b13ba0c8d2
[ "MIT" ]
547
2019-04-07T14:34:01.000Z
2022-03-25T08:58:50.000Z
deps/exokit-bindings/glfw/src/glfw.cc
TizenTeam/exokit
7734835a71cf5dff4575aafb2ecd9c9ad339977c
[ "MIT" ]
514
2018-03-22T00:31:38.000Z
2019-04-06T21:16:45.000Z
deps/exokit-bindings/glfw/src/glfw.cc
TizenTeam/exokit
7734835a71cf5dff4575aafb2ecd9c9ad339977c
[ "MIT" ]
120
2019-04-15T18:36:25.000Z
2022-03-03T01:11:34.000Z
#include <glfw/include/glfw.h> #include <windowsystem.h> #include <webgl.h> #include "canvas/src/stb_image.h" #include <exout> #if defined(TARGET_OS_MAC) || defined(__linux__) #define MAIN_THREAD_POLLING 1 #endif namespace glfw { thread_local NATIVEwindow *currentWindow = nullptr; std::mutex windowHandleMutex; NATIVEwindow *sharedWindow = nullptr; InjectionHandler mainThreadInjectionHandler; std::mutex injectionHandlerMapMutex; int lastX = -1, lastY = -1; // XXX track this per-window uint64_t lastClickTime = 0; #ifdef MAIN_THREAD_POLLING std::thread::id mainThreadId; bool hasMainThreadId = false; #endif WindowState::WindowState() {} WindowState::~WindowState() {} void RunEventInWindowThread(uv_async_t *async) { Nan::HandleScope scope; EventHandler *eventHandler = (EventHandler *)async->data; std::deque<std::function<void(std::function<void(int argc, Local<Value> *argv)>)>> localFns; Local<Function> handlerFn; { std::lock_guard<std::mutex> lock(eventHandler->mutex); localFns = std::move(eventHandler->fns); eventHandler->fns.clear(); handlerFn = Nan::New(eventHandler->handlerFn); } for (auto iter = localFns.begin(); iter != localFns.end(); iter++) { Nan::HandleScope scope; (*iter)([&](int argc, Local<Value> *argv) -> void { Local<Object> asyncObject = Nan::New<Object>(); AsyncResource asyncResource(Isolate::GetCurrent(), asyncObject, "mlEvents"); asyncResource.MakeCallback(handlerFn, argc, argv); }); } } EventHandler::EventHandler(uv_loop_t *loop, Local<Function> handlerFn) : async(new uv_async_t()), handlerFn(handlerFn) { uv_async_init(loop, async.get(), RunEventInWindowThread); async->data = this; } EventHandler::~EventHandler() { uv_close((uv_handle_t *)async.release(), [](uv_handle_t *handle) { delete handle; }); } InjectionHandler::InjectionHandler() {} void QueueEvent(NATIVEwindow *window, std::function<void(std::function<void(int, Local<Value> *)>)> fn) { WindowState *windowState = (WindowState *)glfwGetWindowUserPointer(window); if (windowState->handler) { EventHandler *eventHandler = windowState->handler.get(); { std::lock_guard<std::mutex> lock(eventHandler->mutex); eventHandler->fns.push_back(fn); } uv_async_send(eventHandler->async.get()); } } bool glfwInitialized = false; void initializeGlfw() { glewExperimental = GL_TRUE; if (glfwInit() == GLFW_TRUE) { atexit([]() { glfwTerminate(); }); glfwDefaultWindowHints(); // we use OpenGL 2.1, GLSL 1.20. Comment this for now as this is for GLSL 1.50 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_RESIZABLE, 1); glfwWindowHint(GLFW_VISIBLE, 1); glfwWindowHint(GLFW_DECORATED, 1); glfwWindowHint(GLFW_RED_BITS, 8); glfwWindowHint(GLFW_GREEN_BITS, 8); glfwWindowHint(GLFW_BLUE_BITS, 8); glfwWindowHint(GLFW_DEPTH_BITS, 24); glfwWindowHint(GLFW_REFRESH_RATE, 0); glfwWindowHint(GLFW_CONTEXT_RELEASE_BEHAVIOR, GLFW_RELEASE_BEHAVIOR_NONE); glfwSetErrorCallback([](int err, const char *errString) { fprintf(stderr, "GLFW error: %d: %s", err, errString); }); } else { exerr << "Failed to initialize GLFW" << std::endl; abort(); } } void handleInjections() { std::lock_guard<std::mutex> lock(injectionHandlerMapMutex); for (auto iter = mainThreadInjectionHandler.fns.begin(); iter != mainThreadInjectionHandler.fns.end(); iter++) { std::function<void(InjectionHandler *)> &fn = *iter; fn(&mainThreadInjectionHandler); } mainThreadInjectionHandler.fns.clear(); } void QueueInjection(std::function<void(InjectionHandler *injectionHandler)> fn) { if (!glfwInitialized) { #ifndef MAIN_THREAD_POLLING std::thread([&]() -> void { initializeGlfw(); for (;;) { glfwWaitEvents(); handleInjections(); } }).detach(); #else { std::lock_guard<std::mutex> lock(injectionHandlerMapMutex); mainThreadInjectionHandler.fns.push_back([](InjectionHandler *injectionHandler) -> void { initializeGlfw(); }); } #endif glfwInitialized = true; } { std::lock_guard<std::mutex> lock(injectionHandlerMapMutex); mainThreadInjectionHandler.fns.push_back(fn); } #ifndef MAIN_THREAD_POLLING glfwPostEmptyEvent(); #else if (std::this_thread::get_id() == mainThreadId) { handleInjections(); } #endif } GLFWmonitor* _activeMonitor; GLFWmonitor* getMonitor() { if (_activeMonitor) { return _activeMonitor; } else { GLFWmonitor *monitor = glfwGetPrimaryMonitor(); return monitor; } } NAN_METHOD(GetMonitors) { int monitor_count, mode_count, xpos, ypos, width, height; int i, j; GLFWmonitor **monitors = glfwGetMonitors(&monitor_count); GLFWmonitor *primary = glfwGetPrimaryMonitor(); const GLFWvidmode *mode, *modes; Local<Array> js_monitors = Nan::New<Array>(monitor_count); Local<Object> js_monitor, js_mode; Local<Array> js_modes; for(i=0; i<monitor_count; i++){ js_monitor = Nan::New<Object>(); js_monitor->Set(JS_STR("is_primary"), JS_BOOL(monitors[i] == primary)); js_monitor->Set(JS_STR("index"), JS_INT(i)); js_monitor->Set(JS_STR("name"), JS_STR(glfwGetMonitorName(monitors[i]))); glfwGetMonitorPos(monitors[i], &xpos, &ypos); js_monitor->Set(JS_STR("pos_x"), JS_INT(xpos)); js_monitor->Set(JS_STR("pos_y"), JS_INT(ypos)); glfwGetMonitorPhysicalSize(monitors[i], &width, &height); js_monitor->Set(JS_STR("width_mm"), JS_INT(width)); js_monitor->Set(JS_STR("height_mm"), JS_INT(height)); mode = glfwGetVideoMode(monitors[i]); js_monitor->Set(JS_STR("width"), JS_INT(mode->width)); js_monitor->Set(JS_STR("height"), JS_INT(mode->height)); js_monitor->Set(JS_STR("rate"), JS_INT(mode->refreshRate)); modes = glfwGetVideoModes(monitors[i], &mode_count); js_modes = Nan::New<Array>(mode_count); for(j=0; j<mode_count; j++){ js_mode = Nan::New<Object>(); js_mode->Set(JS_STR("width"), JS_INT(modes[j].width)); js_mode->Set(JS_STR("height"), JS_INT(modes[j].height)); js_mode->Set(JS_STR("rate"), JS_INT(modes[j].refreshRate)); // NOTE: Are color bits necessary? js_modes->Set(JS_INT(j), js_mode); } js_monitor->Set(JS_STR("modes"), js_modes); js_monitors->Set(JS_INT(i), js_monitor); } info.GetReturnValue().Set(js_monitors); } NAN_METHOD(SetMonitor) { int index = TO_INT32(info[0]); int monitor_count; GLFWmonitor **monitors = glfwGetMonitors(&monitor_count); _activeMonitor = monitors[index]; } void GetScreenSize(int *width, int *height) { uv_sem_t sem; uv_sem_init(&sem, 0); QueueInjection([&](InjectionHandler *injectionHandler) -> void { GLFWmonitor *monitor = glfwGetPrimaryMonitor(); const GLFWvidmode *videoMode = glfwGetVideoMode(monitor); *width = videoMode->width; *height = videoMode->height; uv_sem_post(&sem); }); uv_sem_wait(&sem); uv_sem_destroy(&sem); } NAN_METHOD(GetScreenSize) { int width, height; GetScreenSize(&width, &height); Local<Array> result = Nan::New<Array>(2); result->Set(0, JS_INT(width)); result->Set(1, JS_INT(height)); info.GetReturnValue().Set(result); } // Window callbacks handling void APIENTRY windowPosCB(NATIVEwindow *window, int xpos, int ypos) { QueueEvent(window, [=](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("type"),JS_STR("move")); evt->Set(JS_STR("x"),JS_INT(xpos)); evt->Set(JS_STR("y"),JS_INT(ypos)); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR("move"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); }); } void APIENTRY windowSizeCB(NATIVEwindow *window, int w, int h) { QueueEvent(window, [=](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("type"),JS_STR("windowResize")); evt->Set(JS_STR("width"),JS_INT(w)); evt->Set(JS_STR("height"),JS_INT(h)); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR("windowResize"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); }); } void APIENTRY windowFramebufferSizeCB(NATIVEwindow *window, int w, int h) { QueueEvent(window, [=](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("type"),JS_STR("framebufferResize")); evt->Set(JS_STR("width"),JS_INT(w)); evt->Set(JS_STR("height"),JS_INT(h)); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR("framebufferResize"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); }); } void APIENTRY windowDropCB(NATIVEwindow *window, int count, const char **paths) { std::vector<char *> localPaths(count); for (int i = 0; i < count; i++) { const char *path = paths[i]; size_t size = strlen(path) + 1; char *localPath = new char[size]; memcpy(localPath, path, size); localPaths[i] = localPath; } QueueEvent(window, [localPaths{std::move(localPaths)}](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { Local<Array> pathsArray = Nan::New<Array>(localPaths.size()); for (int i = 0; i < localPaths.size(); i++) { pathsArray->Set(i, JS_STR(localPaths[i])); } Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("paths"), pathsArray); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR("drop"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); for (int i = 0; i < localPaths.size(); i++) { delete[] localPaths[i]; } }); } void APIENTRY windowCloseCB(NATIVEwindow *window) { QueueEvent(window, [=](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { Local<Object> evt = Nan::New<Object>(); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR("quit"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); }); } void APIENTRY windowRefreshCB(NATIVEwindow *window) { QueueEvent(window, [=](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("type"),JS_STR("refresh")); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR("refresh"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); }); } void APIENTRY windowFocusCB(NATIVEwindow *window, int focused) { QueueEvent(window, [=](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("type"),JS_STR("focus")); evt->Set(JS_STR("focused"),JS_BOOL((bool)focused)); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR("focus"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); }); } void APIENTRY windowMaximizeCB(NATIVEwindow *window, int maximized) { QueueEvent(window, [=](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("type"),JS_STR("maximize")); evt->Set(JS_STR("maximized"),JS_BOOL((bool)maximized)); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR("maximize"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); }); } void APIENTRY windowIconifyCB(NATIVEwindow *window, int iconified) { QueueEvent(window, [=](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("type"),JS_STR("minimize")); evt->Set(JS_STR("minimized"),JS_BOOL((bool)iconified)); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR("minimize"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); }); } static int jsKeyCode[]={ /*GLFW_KEY_ESCAPE*/ 27, /*GLFW_KEY_ENTER*/ 13, /*GLFW_KEY_TAB*/ 9, /*GLFW_KEY_BACKSPACE*/ 8, /*GLFW_KEY_INSERT*/ 45, /*GLFW_KEY_DELETE*/ 46, /*GLFW_KEY_RIGHT*/ 39, /*GLFW_KEY_LEFT*/ 37, /*GLFW_KEY_DOWN*/ 40, /*GLFW_KEY_UP*/ 38, /*GLFW_KEY_PAGE_UP*/ 33, /*GLFW_KEY_PAGE_DOWN*/ 34, /*GLFW_KEY_HOME*/ 36, /*GLFW_KEY_END*/ 35, /*GLFW_KEY_CAPS_LOCK*/ 20, /*GLFW_KEY_SCROLL_LOCK*/ 145, /*GLFW_KEY_NUM_LOCK*/ 144, /*GLFW_KEY_PRINT_SCREEN*/ 144, /* TODO */ /*GLFW_KEY_PAUSE*/ 19, /*GLFW_KEY_F1*/ 112, /*GLFW_KEY_F2*/ 113, /*GLFW_KEY_F3*/ 114, /*GLFW_KEY_F4*/ 115, /*GLFW_KEY_F5*/ 116, /*GLFW_KEY_F6*/ 117, /*GLFW_KEY_F7*/ 118, /*GLFW_KEY_F8*/ 119, /*GLFW_KEY_F9*/ 120, /*GLFW_KEY_F10*/ 121, /*GLFW_KEY_F11*/ 122, /*GLFW_KEY_F12*/ 123, /*GLFW_KEY_F13*/ 123, /* unknown */ /*GLFW_KEY_F14*/ 123, /* unknown */ /*GLFW_KEY_F15*/ 123, /* unknown */ /*GLFW_KEY_F16*/ 123, /* unknown */ /*GLFW_KEY_F17*/ 123, /* unknown */ /*GLFW_KEY_F18*/ 123, /* unknown */ /*GLFW_KEY_F19*/ 123, /* unknown */ /*GLFW_KEY_F20*/ 123, /* unknown */ /*GLFW_KEY_F21*/ 123, /* unknown */ /*GLFW_KEY_F22*/ 123, /* unknown */ /*GLFW_KEY_F23*/ 123, /* unknown */ /*GLFW_KEY_F24*/ 123, /* unknown */ /*GLFW_KEY_F25*/ 123, /* unknown */ /*GLFW_KEY_KP_0*/ 96, /*GLFW_KEY_KP_1*/ 97, /*GLFW_KEY_KP_2*/ 98, /*GLFW_KEY_KP_3*/ 99, /*GLFW_KEY_KP_4*/ 100, /*GLFW_KEY_KP_5*/ 101, /*GLFW_KEY_KP_6*/ 102, /*GLFW_KEY_KP_7*/ 103, /*GLFW_KEY_KP_8*/ 104, /*GLFW_KEY_KP_9*/ 105, /*GLFW_KEY_KP_DECIMAL*/ 110, /*GLFW_KEY_KP_DIVIDE*/ 111, /*GLFW_KEY_KP_MULTIPLY*/ 106, /*GLFW_KEY_KP_SUBTRACT*/ 109, /*GLFW_KEY_KP_ADD*/ 107, /*GLFW_KEY_KP_ENTER*/ 13, /*GLFW_KEY_KP_EQUAL*/ 187, /*GLFW_KEY_LEFT_SHIFT*/ 16, /*GLFW_KEY_LEFT_CONTROL*/ 17, /*GLFW_KEY_LEFT_ALT*/ 18, /*GLFW_KEY_LEFT_SUPER*/ 91, /*GLFW_KEY_RIGHT_SHIFT*/ 16, /*GLFW_KEY_RIGHT_CONTROL*/17, /*GLFW_KEY_RIGHT_ALT*/ 18, /*GLFW_KEY_RIGHT_SUPER*/ 93, /*GLFW_KEY_MENU*/ 18 }; const char *actionNames = "keyup\0 keydown\0keypress"; void APIENTRY keyCB(NATIVEwindow *window, int key, int scancode, int action, int mods) { if (key >= 0) { // media keys are -1 bool isPrintable = true; switch (key) { case GLFW_KEY_ESCAPE: case GLFW_KEY_ENTER: case GLFW_KEY_TAB: case GLFW_KEY_BACKSPACE: case GLFW_KEY_INSERT: case GLFW_KEY_DELETE: case GLFW_KEY_RIGHT: case GLFW_KEY_LEFT: case GLFW_KEY_DOWN: case GLFW_KEY_UP: case GLFW_KEY_PAGE_UP: case GLFW_KEY_PAGE_DOWN: case GLFW_KEY_HOME: case GLFW_KEY_END: case GLFW_KEY_CAPS_LOCK: case GLFW_KEY_SCROLL_LOCK: case GLFW_KEY_NUM_LOCK: case GLFW_KEY_PRINT_SCREEN: case GLFW_KEY_PAUSE: case GLFW_KEY_F1: case GLFW_KEY_F2: case GLFW_KEY_F3: case GLFW_KEY_F4: case GLFW_KEY_F5: case GLFW_KEY_F6: case GLFW_KEY_F7: case GLFW_KEY_F8: case GLFW_KEY_F9: case GLFW_KEY_F10: case GLFW_KEY_F11: case GLFW_KEY_F12: case GLFW_KEY_F13: case GLFW_KEY_F14: case GLFW_KEY_F15: case GLFW_KEY_F16: case GLFW_KEY_F17: case GLFW_KEY_F18: case GLFW_KEY_F19: case GLFW_KEY_F20: case GLFW_KEY_F21: case GLFW_KEY_F22: case GLFW_KEY_F23: case GLFW_KEY_F24: case GLFW_KEY_F25: case GLFW_KEY_LEFT_SHIFT: case GLFW_KEY_LEFT_CONTROL: case GLFW_KEY_LEFT_ALT: case GLFW_KEY_LEFT_SUPER: case GLFW_KEY_RIGHT_SHIFT: case GLFW_KEY_RIGHT_CONTROL: case GLFW_KEY_RIGHT_ALT: case GLFW_KEY_RIGHT_SUPER: case GLFW_KEY_MENU: isPrintable = false; } if (!isPrintable && action == GLFW_REPEAT) { action = GLFW_PRESS; } int charCode = key; if (action == GLFW_RELEASE || action == GLFW_PRESS) { switch (key) { case GLFW_KEY_SLASH: key = 191; break; // / case GLFW_KEY_GRAVE_ACCENT: key = 192; break; // ` case GLFW_KEY_LEFT_BRACKET: key = 219; break; // [ case GLFW_KEY_BACKSLASH: key = 220; break; /* \ */ case GLFW_KEY_RIGHT_BRACKET: key = 221; break; // ] case GLFW_KEY_APOSTROPHE: key = 222; break; // ' case GLFW_KEY_PERIOD: key = 190; break; // ' case GLFW_KEY_COMMA: key = 188; break; // ' case GLFW_KEY_SEMICOLON: key = 186; break; // ; case GLFW_KEY_EQUAL: key = 187; break; // = case GLFW_KEY_MINUS: key = 189; break; // - } } switch (key) { case GLFW_KEY_ESCAPE: key = 27; break; case GLFW_KEY_ENTER: key = 13; break; case GLFW_KEY_TAB: key = 9; break; case GLFW_KEY_BACKSPACE: key = 8; break; case GLFW_KEY_INSERT: key = 45; break; case GLFW_KEY_DELETE: key = 46; break; case GLFW_KEY_RIGHT: key = 39; break; case GLFW_KEY_LEFT: key = 37; break; case GLFW_KEY_DOWN: key = 40; break; case GLFW_KEY_UP: key = 38; break; case GLFW_KEY_PAGE_UP: key = 33; break; case GLFW_KEY_PAGE_DOWN: key = 34; break; case GLFW_KEY_HOME: key = 36; break; case GLFW_KEY_END: key = 35; break; case GLFW_KEY_CAPS_LOCK: key = 20; break; case GLFW_KEY_SCROLL_LOCK: key = 145; break; case GLFW_KEY_NUM_LOCK: key = 144; break; case GLFW_KEY_PRINT_SCREEN: key = 144; break; /* TODO */ case GLFW_KEY_PAUSE: key = 19; break; case GLFW_KEY_F1: key = 112; break; case GLFW_KEY_F2: key = 113; break; case GLFW_KEY_F3: key = 114; break; case GLFW_KEY_F4: key = 115; break; case GLFW_KEY_F5: key = 116; break; case GLFW_KEY_F6: key = 117; break; case GLFW_KEY_F7: key = 118; break; case GLFW_KEY_F8: key = 119; break; case GLFW_KEY_F9: key = 120; break; case GLFW_KEY_F10: key = 121; break; case GLFW_KEY_F11: key = 122; break; case GLFW_KEY_F12: key = 123; break; case GLFW_KEY_F13: key = 123; break; /* unknown */ case GLFW_KEY_F14: key = 123; break; /* unknown */ case GLFW_KEY_F15: key = 123; break; /* unknown */ case GLFW_KEY_F16: key = 123; break; /* unknown */ case GLFW_KEY_F17: key = 123; break; /* unknown */ case GLFW_KEY_F18: key = 123; break; /* unknown */ case GLFW_KEY_F19: key = 123; break; /* unknown */ case GLFW_KEY_F20: key = 123; break; /* unknown */ case GLFW_KEY_F21: key = 123; break; /* unknown */ case GLFW_KEY_F22: key = 123; break; /* unknown */ case GLFW_KEY_F23: key = 123; break; /* unknown */ case GLFW_KEY_F24: key = 123; break; /* unknown */ case GLFW_KEY_F25: key = 123; break; /* unknown */ case GLFW_KEY_KP_0: key = 96; break; case GLFW_KEY_KP_1: key = 97; break; case GLFW_KEY_KP_2: key = 98; break; case GLFW_KEY_KP_3: key = 99; break; case GLFW_KEY_KP_4: key = 100; break; case GLFW_KEY_KP_5: key = 101; break; case GLFW_KEY_KP_6: key = 102; break; case GLFW_KEY_KP_7: key = 103; break; case GLFW_KEY_KP_8: key = 104; break; case GLFW_KEY_KP_9: key = 105; break; case GLFW_KEY_KP_DECIMAL: key = 110; break; case GLFW_KEY_KP_DIVIDE: key = 111; break; case GLFW_KEY_KP_MULTIPLY: key = 106; break; case GLFW_KEY_KP_SUBTRACT: key = 109; break; case GLFW_KEY_KP_ADD: key = 107; break; case GLFW_KEY_KP_ENTER: key = 13; break; case GLFW_KEY_KP_EQUAL: key = 187; break; case GLFW_KEY_LEFT_SHIFT: key = 16; break; case GLFW_KEY_LEFT_CONTROL: key = 17; break; case GLFW_KEY_LEFT_ALT: key = 18; break; case GLFW_KEY_LEFT_SUPER: key = 91; break; case GLFW_KEY_RIGHT_SHIFT: key = 16; break; case GLFW_KEY_RIGHT_CONTROL: key = 17; break; case GLFW_KEY_RIGHT_ALT: key = 18; break; case GLFW_KEY_RIGHT_SUPER: key = 93; break; case GLFW_KEY_MENU: key = 18; break; } if ( action == 2 && // keypress key >= 65 && // A key <= 90 // Z ) { key += 32; } int which = key; QueueEvent(window, [=](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("type"), JS_STR(&actionNames[action << 3])); evt->Set(JS_STR("ctrlKey"), JS_BOOL(mods & GLFW_MOD_CONTROL)); evt->Set(JS_STR("shiftKey"), JS_BOOL(mods & GLFW_MOD_SHIFT)); evt->Set(JS_STR("altKey"), JS_BOOL(mods & GLFW_MOD_ALT)); evt->Set(JS_STR("metaKey"), JS_BOOL(mods & GLFW_MOD_SUPER)); evt->Set(JS_STR("which"), JS_INT(which)); evt->Set(JS_STR("keyCode"), JS_INT(key)); evt->Set(JS_STR("charCode"), JS_INT(charCode)); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR(&actionNames[action << 3]), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); }); if (action == GLFW_PRESS && isPrintable) { keyCB(window, charCode, scancode, GLFW_REPEAT, mods); } } } void APIENTRY cursorPosCB(NATIVEwindow* window, double x, double y) { int w, h; glfwGetWindowSize(window, &w, &h); if(x<0 || x>=w) return; if(y<0 || y>=h) return; int xi = static_cast<int>(x); int yi = static_cast<int>(y); int movementX, movementY; int mode = glfwGetInputMode(window, GLFW_CURSOR); if (mode == GLFW_CURSOR_DISABLED) { movementX = xi - (w / 2); movementY = yi - (h / 2); glfwSetCursorPos(window, w / 2, h / 2); } else { if (lastX != -1 && lastY != -1) { movementX = xi - lastX; movementY = yi - lastY; } else { movementX = 0; movementY = 0; } } lastX = xi; lastY = yi; QueueEvent(window, [=](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("type"),JS_STR("mousemove")); evt->Set(JS_STR("clientX"),JS_NUM(x)); evt->Set(JS_STR("clientY"),JS_NUM(y)); evt->Set(JS_STR("pageX"),JS_NUM(x)); evt->Set(JS_STR("pageY"),JS_NUM(y)); evt->Set(JS_STR("offsetX"),JS_NUM(x)); evt->Set(JS_STR("offsetY"),JS_NUM(y)); evt->Set(JS_STR("screenX"),JS_NUM(x)); evt->Set(JS_STR("screenY"),JS_NUM(y)); evt->Set(JS_STR("movementX"),JS_NUM(movementX)); evt->Set(JS_STR("movementY"),JS_NUM(movementY)); evt->Set(JS_STR("ctrlKey"),JS_BOOL(glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS)); evt->Set(JS_STR("shiftKey"),JS_BOOL(glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS)); evt->Set(JS_STR("altKey"),JS_BOOL(glfwGetKey(window, GLFW_KEY_LEFT_ALT) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_ALT) == GLFW_PRESS)); evt->Set(JS_STR("metaKey"),JS_BOOL(glfwGetKey(window, GLFW_KEY_LEFT_SUPER) == GLFW_PRESS || glfwGetKey(window, GLFW_KEY_RIGHT_SUPER) == GLFW_PRESS)); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR("mousemove"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); }); } void APIENTRY cursorEnterCB(NATIVEwindow* window, int entered) { QueueEvent(window, [=](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("type"),JS_STR("mouseenter")); evt->Set(JS_STR("entered"),JS_INT(entered)); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR("mouseenter"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); }); } void APIENTRY mouseButtonCB(NATIVEwindow *window, int button, int action, int mods) { QueueEvent(window, [=](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { double xpos, ypos; glfwGetCursorPos(window, &xpos, &ypos); int localButton = button; if (localButton == 2) { localButton = 1; } else if (localButton == 1) { localButton = 2; } { Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("type"),JS_STR(action ? "mousedown" : "mouseup")); evt->Set(JS_STR("button"),JS_INT(localButton)); evt->Set(JS_STR("which"),JS_INT(localButton + 1)); evt->Set(JS_STR("clientX"),JS_NUM(xpos)); evt->Set(JS_STR("clientY"),JS_NUM(ypos)); evt->Set(JS_STR("pageX"),JS_NUM(xpos)); evt->Set(JS_STR("pageY"),JS_NUM(ypos)); evt->Set(JS_STR("offsetX"),JS_NUM(xpos)); evt->Set(JS_STR("offsetY"),JS_NUM(ypos)); evt->Set(JS_STR("screenX"),JS_NUM(xpos)); evt->Set(JS_STR("screenY"),JS_NUM(ypos)); evt->Set(JS_STR("shiftKey"),JS_BOOL(mods & GLFW_MOD_SHIFT)); evt->Set(JS_STR("ctrlKey"),JS_BOOL(mods & GLFW_MOD_CONTROL)); evt->Set(JS_STR("altKey"),JS_BOOL(mods & GLFW_MOD_ALT)); evt->Set(JS_STR("metaKey"),JS_BOOL(mods & GLFW_MOD_SUPER)); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR(action ? "mousedown" : "mouseup"), // event name evt }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); } if (!action) { Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("type"),JS_STR("click")); evt->Set(JS_STR("button"),JS_INT(localButton)); evt->Set(JS_STR("which"),JS_INT(localButton + 1)); evt->Set(JS_STR("clientX"),JS_NUM(xpos)); evt->Set(JS_STR("clientY"),JS_NUM(ypos)); evt->Set(JS_STR("pageX"),JS_NUM(xpos)); evt->Set(JS_STR("pageY"),JS_NUM(ypos)); evt->Set(JS_STR("offsetX"),JS_NUM(xpos)); evt->Set(JS_STR("offsetY"),JS_NUM(ypos)); evt->Set(JS_STR("screenX"),JS_NUM(xpos)); evt->Set(JS_STR("screenY"),JS_NUM(ypos)); evt->Set(JS_STR("shiftKey"),JS_BOOL(mods & GLFW_MOD_SHIFT)); evt->Set(JS_STR("ctrlKey"),JS_BOOL(mods & GLFW_MOD_CONTROL)); evt->Set(JS_STR("altKey"),JS_BOOL(mods & GLFW_MOD_ALT)); evt->Set(JS_STR("metaKey"),JS_BOOL(mods & GLFW_MOD_SUPER)); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR("click"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); uint64_t now = glfwGetTimerValue(); uint64_t timeDiffTicks = now - lastClickTime; uint64_t frequency = glfwGetTimerFrequency(); double timeDiffSeconds = (double)timeDiffTicks / (double)frequency; if (timeDiffSeconds < 0.2) { evt->Set(JS_STR("type"),JS_STR("dblclick")); Local<Value> argv[] = { JS_STR("dblclick"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); } lastClickTime = now; } }); } void APIENTRY scrollCB(NATIVEwindow *window, double xoffset, double yoffset) { QueueEvent(window, [=](std::function<void(int, Local<Value> *)> eventHandlerFn) -> void { double xpos, ypos; glfwGetCursorPos(window, &xpos, &ypos); Local<Object> evt = Nan::New<Object>(); evt->Set(JS_STR("type"),JS_STR("wheel")); evt->Set(JS_STR("clientX"),JS_NUM(xpos)); evt->Set(JS_STR("clientY"),JS_NUM(ypos)); evt->Set(JS_STR("deltaX"),JS_NUM(-xoffset*120)); evt->Set(JS_STR("deltaY"),JS_NUM(-yoffset*120)); evt->Set(JS_STR("deltaZ"),JS_INT(0)); evt->Set(JS_STR("deltaMode"),JS_INT(0)); // evt->Set(JS_STR("windowHandle"), pointerToArray(window)); Local<Value> argv[] = { JS_STR("wheel"), // event name evt, }; eventHandlerFn(sizeof(argv)/sizeof(argv[0]), argv); }); } NAN_METHOD(BlitTopFrameBuffer) { GLuint fbo1 = TO_UINT32(info[0]); GLuint fbo2 = TO_UINT32(info[1]); int sw = TO_UINT32(info[2]); int sh = TO_UINT32(info[3]); int dw = TO_UINT32(info[4]); int dh = TO_UINT32(info[5]); bool color = TO_BOOL(info[6]); bool depth = TO_BOOL(info[7]); bool stencil = TO_BOOL(info[8]); glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo1); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo2); glBlitFramebuffer( 0, 0, sw, sh, 0, 0, dw, dh, (color ? GL_COLOR_BUFFER_BIT : 0) | (depth ? GL_DEPTH_BUFFER_BIT : 0) | (stencil ? GL_STENCIL_BUFFER_BIT : 0), (depth || stencil) ? GL_NEAREST : GL_LINEAR ); } NAN_METHOD(BlitChildFrameBuffer) { Local<Object> glObj = Local<Object>::Cast(info[0]); GLuint srcTex = TO_UINT32(info[1]); GLuint srcDepthTex = TO_UINT32(info[2]); bool isMultisampleSrc = Local<Boolean>::Cast(info[3])->Value(); GLuint tex = TO_UINT32(info[4]); GLuint depthTex = TO_UINT32(info[5]); bool isMultisampleDst = Local<Boolean>::Cast(info[6])->Value(); int sw = TO_UINT32(info[7]); int sh = TO_UINT32(info[8]); int dw = TO_UINT32(info[9]); int dh = TO_UINT32(info[10]); GLuint readFbo; glGenFramebuffers(1, &readFbo); glBindFramebuffer(GL_READ_FRAMEBUFFER, readFbo); glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, isMultisampleSrc ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D, srcTex, 0); if (srcDepthTex != 0) { glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, isMultisampleSrc ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D, srcDepthTex, 0); } GLuint drawFbo = 0; if (tex != 0) { glGenFramebuffers(1, &drawFbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFbo); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, isMultisampleDst ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D, tex, 0); if (depthTex != 0) { glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, isMultisampleDst ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D, depthTex, 0); } } else { glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); } glBlitFramebuffer( 0, 0, sw, sh, 0, 0, dw, dh, GL_COLOR_BUFFER_BIT | (srcDepthTex ? (GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT) : 0), srcDepthTex ? GL_NEAREST : GL_LINEAR ); glDeleteFramebuffers(1, &readFbo); if (drawFbo != 0) { glDeleteFramebuffers(1, &drawFbo); } WebGLRenderingContext *gl = ObjectWrap::Unwrap<WebGLRenderingContext>(glObj); if (gl->HasFramebufferBinding(GL_READ_FRAMEBUFFER)) { glBindFramebuffer(GL_READ_FRAMEBUFFER, gl->GetFramebufferBinding(GL_READ_FRAMEBUFFER)); } else { glBindFramebuffer(GL_READ_FRAMEBUFFER, gl->defaultFramebuffer); } if (gl->HasFramebufferBinding(GL_DRAW_FRAMEBUFFER)) { glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gl->GetFramebufferBinding(GL_DRAW_FRAMEBUFFER)); } else { glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gl->defaultFramebuffer); } } NATIVEwindow *GetCurrentWindowContext() { return currentWindow; } void SetCurrentWindowContext(NATIVEwindow *window) { if (currentWindow != window) { glfwMakeContextCurrent(window); currentWindow = window; } } void ReadPixels(WebGLRenderingContext *gl, unsigned int fbo, int x, int y, int width, int height, unsigned int format, unsigned int type, unsigned char *data) { glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); if (gl->HasFramebufferBinding(GL_READ_FRAMEBUFFER)) { glBindFramebuffer(GL_READ_FRAMEBUFFER, gl->GetFramebufferBinding(GL_READ_FRAMEBUFFER)); } else { glBindFramebuffer(GL_READ_FRAMEBUFFER, gl->defaultFramebuffer); } } NAN_METHOD(HasCurrentWindowContext) { info.GetReturnValue().Set(JS_BOOL(currentWindow != nullptr)); } NAN_METHOD(GetCurrentWindowContext) { if (currentWindow != nullptr) { info.GetReturnValue().Set(pointerToArray(currentWindow)); } else { info.GetReturnValue().Set(Nan::Null()); } } NAN_METHOD(SetCurrentWindowContext) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); SetCurrentWindowContext(window); } bool SetNativeWindowIcon(NATIVEwindow* window, const char* filename) { GLFWimage icon; int components; icon.pixels = stbi_load(filename, &icon.width, &icon.height, &components, STBI_rgb_alpha); if (icon.pixels != nullptr) { glfwSetWindowIcon(window, 1, &icon); stbi_image_free(icon.pixels); return true; } return false; } NATIVEwindow *CreateNativeWindow(unsigned int width, unsigned int height, bool visible) { glfwWindowHint(GLFW_VISIBLE, visible); { std::lock_guard<std::mutex> lock(windowHandleMutex); if (!sharedWindow) { sharedWindow = glfwCreateWindow(1, 1, "Exokit", nullptr, nullptr); if (sharedWindow) { glfwSetWindowUserPointer(sharedWindow, new WindowState()); } else { exerr << "Can't create GLFW window" << std::endl; abort(); return nullptr; } } } NATIVEwindow *window = glfwCreateWindow(width, height, "Exokit", nullptr, sharedWindow); if (window) { glfwSetWindowUserPointer(window, new WindowState()); SetNativeWindowIcon(window, "assets/icon.png"); return window; } else { exerr << "Can't create GLFW window" << std::endl; abort(); return nullptr; } } void DestroyNativeWindow(NATIVEwindow *window) { WindowState *windowState = (WindowState *)glfwGetWindowUserPointer(window); delete windowState; glfwDestroyWindow(window); } NAN_METHOD(SetWindowTitle) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); Nan::Utf8String str(Local<String>::Cast(info[1])); glfwSetWindowTitle(window, *str); } void GetWindowSize(NATIVEwindow *window, int *width, int *height) { glfwGetWindowSize(window, width, height); } NAN_METHOD(GetWindowSize) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); int w, h; GetWindowSize(window, &w, &h); Local<Object> result = Nan::New<Object>(); result->Set(JS_STR("width"),JS_INT(w)); result->Set(JS_STR("height"),JS_INT(h)); info.GetReturnValue().Set(result); } NAN_METHOD(SetWindowSize) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); glfwSetWindowSize(window, TO_UINT32(info[1]), TO_UINT32(info[2])); } NAN_METHOD(SetWindowPos) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); glfwSetWindowPos(window, TO_UINT32(info[1]), TO_UINT32(info[2])); } NAN_METHOD(GetWindowPos) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); int xpos, ypos; glfwGetWindowPos(window, &xpos, &ypos); Local<Object> result = Nan::New<Object>(); result->Set(JS_STR("xpos"),JS_INT(xpos)); result->Set(JS_STR("ypos"),JS_INT(ypos)); info.GetReturnValue().Set(result); } void GetFramebufferSize(NATIVEwindow *window, int *width, int *height) { glfwGetFramebufferSize(window, width, height); } NAN_METHOD(GetFramebufferSize) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); int width, height; GetFramebufferSize(window, &width, &height); Local<Object> result = Nan::New<Object>(); result->Set(JS_STR("width"),JS_INT(width)); result->Set(JS_STR("height"),JS_INT(height)); info.GetReturnValue().Set(result); } double GetDevicePixelRatio() { int width, height; uv_sem_t sem; uv_sem_init(&sem, 0); QueueInjection([&](InjectionHandler *injectionHandler) -> void { NATIVEwindow *window = CreateNativeWindow(100, 100, false); glfwGetFramebufferSize(window, &width, &height); DestroyNativeWindow(window); uv_sem_post(&sem); }); uv_sem_wait(&sem); uv_sem_destroy(&sem); return static_cast<double>(width)/100.0; } NAN_METHOD(GetDevicePixelRatio) { double devicePixelRatio = GetDevicePixelRatio(); info.GetReturnValue().Set(JS_NUM(devicePixelRatio)); } NATIVEwindow *GetGLContext(NATIVEwindow *window) { return window; } NAN_METHOD(IconifyWindow) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); glfwIconifyWindow(window); } NAN_METHOD(RestoreWindow) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); glfwRestoreWindow(window); } NAN_METHOD(SetVisibility) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); bool visible = TO_BOOL(info[1]); QueueInjection([window, visible](InjectionHandler *injectionHandler) -> void { if (visible) { glfwShowWindow(window); } else { glfwHideWindow(window); } }); } NAN_METHOD(SetWindowFocus) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); glfwFocusWindow(window); } NAN_METHOD(IsVisible) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); bool visible = glfwGetWindowAttrib(window, GLFW_VISIBLE); info.GetReturnValue().Set(JS_BOOL(visible)); } const GLFWvidmode *getBestVidMode(NATIVEwindow *window, GLFWmonitor *monitor) { int numVidModes; const GLFWvidmode *vidModes = glfwGetVideoModes(monitor, &numVidModes); const GLFWvidmode *bestVidMode = nullptr; for (int i = 0; i < numVidModes; i++) { const GLFWvidmode *vidMode = &vidModes[i]; if (bestVidMode == nullptr || vidMode->width > bestVidMode->width) { bestVidMode = vidMode; } } return bestVidMode; } NAN_METHOD(SetFullscreen) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); bool enabled = TO_BOOL(info[1]); QueueInjection([window, enabled](InjectionHandler *injectionHandler) -> void { GLFWmonitor *monitor = getMonitor(); if (enabled) { const GLFWvidmode *vidMode = getBestVidMode(window, monitor); if (vidMode != nullptr) { glfwSetWindowMonitor(window, monitor, 0, 0, vidMode->width, vidMode->height, 0); } } else { const GLFWvidmode *vidMode = getBestVidMode(window, monitor); glfwSetWindowMonitor(window, nullptr, vidMode->width/2 - 1280/2, vidMode->height/2 - 1024/2, 1280, 1024, 0); } }); } NAN_METHOD(InitWindow3D) { NATIVEwindow *windowHandle = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); WebGLRenderingContext *gl = ObjectWrap::Unwrap<WebGLRenderingContext>(Local<Object>::Cast(info[1])); SetCurrentWindowContext(windowHandle); GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao); #ifdef GL_VERTEX_PROGRAM_POINT_SIZE glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); #endif #ifdef GL_PROGRAM_POINT_SIZE glEnable(GL_PROGRAM_POINT_SIZE); #endif Local<Array> result = Nan::New<Array>(2); result->Set(0, pointerToArray(windowHandle)); result->Set(1, JS_INT(vao)); info.GetReturnValue().Set(result); } NATIVEwindow *CreateWindowHandle(unsigned int width, unsigned int height, bool initialVisible) { NATIVEwindow *windowHandle; uv_sem_t sem; uv_sem_init(&sem, 0); QueueInjection([&](InjectionHandler *injectionHandler) -> void { windowHandle = CreateNativeWindow(width, height, initialVisible); SetCurrentWindowContext(windowHandle); GLenum err = glewInit(); if (!err) { // swap interval glfwSwapInterval(0); // input mode // glfwSetInputMode(windowHandle, GLFW_CURSOR, GLFW_CURSOR_NORMAL); // window callbacks glfwSetWindowPosCallback(windowHandle, windowPosCB); glfwSetWindowSizeCallback(windowHandle, windowSizeCB); glfwSetWindowCloseCallback(windowHandle, windowCloseCB); glfwSetWindowRefreshCallback(windowHandle, windowRefreshCB); glfwSetWindowFocusCallback(windowHandle, windowFocusCB); glfwSetWindowMaximizeCallback(windowHandle, windowMaximizeCB); glfwSetWindowIconifyCallback(windowHandle, windowIconifyCB); glfwSetFramebufferSizeCallback(windowHandle, windowFramebufferSizeCB); glfwSetDropCallback(windowHandle, windowDropCB); // input callbacks glfwSetKeyCallback(windowHandle, keyCB); glfwSetMouseButtonCallback(windowHandle, mouseButtonCB); glfwSetCursorPosCallback(windowHandle, cursorPosCB); glfwSetCursorEnterCallback(windowHandle, cursorEnterCB); glfwSetScrollCallback(windowHandle, scrollCB); // size setting glfwSetWindowSizeLimits(windowHandle, 1, 1, GLFW_DONT_CARE, GLFW_DONT_CARE); } else { /* Problem: glewInit failed, something is seriously wrong. */ exerr << "Can't init GLEW (glew error " << (const char *)glewGetErrorString(err) << ")" << std::endl; DestroyNativeWindow(windowHandle); windowHandle = nullptr; } SetCurrentWindowContext(nullptr); uv_sem_post(&sem); }); uv_sem_wait(&sem); uv_sem_destroy(&sem); return windowHandle; } NAN_METHOD(CreateWindowHandle) { unsigned int width = info[0]->IsNumber() ? TO_UINT32(info[0]) : 1; unsigned int height = info[1]->IsNumber() ? TO_UINT32(info[1]) : 1; bool initialVisible = TO_BOOL(info[2]); NATIVEwindow *windowHandle = CreateWindowHandle(width, height, initialVisible); if (windowHandle) { info.GetReturnValue().Set(pointerToArray(windowHandle)); } else { info.GetReturnValue().Set(Nan::Null()); } } NAN_METHOD(DestroyWindowHandle) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); uv_sem_t sem; uv_sem_init(&sem, 0); QueueInjection([&](InjectionHandler *injectionHandler) -> void { DestroyNativeWindow(window); uv_sem_post(&sem); }); uv_sem_wait(&sem); uv_sem_destroy(&sem); } NAN_METHOD(SetEventHandler) { if (info[0]->IsArray() && info[1]->IsFunction()) { Local<Array> windowHandle = Local<Array>::Cast(info[0]); Local<Function> handlerFn = Local<Function>::Cast(info[1]); NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(windowHandle); WindowState *windowState = (WindowState *)glfwGetWindowUserPointer(window); uv_loop_t *loop = windowsystembase::GetEventLoop(); EventHandler *handler = new EventHandler(loop, handlerFn); windowState->handler.reset(handler); } else { Nan::ThrowError("SetEventHandler: invalid arguments"); } } NAN_METHOD(SwapBuffers) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); glfwSwapBuffers(window); } NAN_METHOD(GetRefreshRate) { int refreshRate; GLFWmonitor *monitor = getMonitor(); if (monitor) { const GLFWvidmode *mode = glfwGetVideoMode(monitor); refreshRate = mode->refreshRate; } else { refreshRate = 60; } info.GetReturnValue().Set(refreshRate); } NAN_METHOD(SetCursorMode) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); bool enabled = TO_BOOL(info[1]); QueueInjection([window, enabled](InjectionHandler *injectionHandler) -> void { if (enabled) { glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); } else { glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); int w, h; glfwGetWindowSize(window, &w, &h); int centerX = w/2; int centerY = h/2; glfwSetCursorPos(window, centerX, centerY); /* lastX = centerX; lastY = centerY; */ } }); } NAN_METHOD(SetCursorPosition) { NATIVEwindow *window = (NATIVEwindow *)arrayToPointer(Local<Array>::Cast(info[0])); int x = TO_INT32(info[1]); int y = TO_INT32(info[2]); glfwSetCursorPos(window, x, y); } NAN_METHOD(GetClipboard) { NATIVEwindow *window = GetCurrentWindowContext(); const char *clipboardContents = glfwGetClipboardString(window); if (clipboardContents != nullptr) { info.GetReturnValue().Set(JS_STR(clipboardContents)); } else { info.GetReturnValue().Set(Nan::Null()); } } NAN_METHOD(SetClipboard) { if (info[0]->IsString()) { NATIVEwindow *window = GetCurrentWindowContext(); Nan::Utf8String utf8_value(info[0]); glfwSetClipboardString(window, *utf8_value); } else { Nan::ThrowTypeError("Invalid arguments"); } } #ifdef MAIN_THREAD_POLLING NAN_METHOD(PollEvents) { glfwPollEvents(); handleInjections(); } #endif } /////////////////////////////////////////////////////////////////////////////// // // bindings // /////////////////////////////////////////////////////////////////////////////// #define JS_GLFW_CONSTANT(name) target->Set(JS_STR( #name ), JS_INT(GLFW_ ## name)) #define JS_GLFW_SET_METHOD(name) Nan::SetMethod(target, #name , glfw::name); /* Local<Object> makeGlfw() { glfwInit(); glewInit(); atexit([]() { glfwTerminate(); }); Isolate *isolate = Isolate::GetCurrent(); v8::EscapableHandleScope scope(isolate); Local<Object> target = Object::New(isolate); // GLFW initialization, termination and version querying JS_GLFW_SET_METHOD(GetVersion); JS_GLFW_SET_METHOD(GetVersionString); // Time JS_GLFW_SET_METHOD(GetTime); JS_GLFW_SET_METHOD(SetTime); // Monitor handling JS_GLFW_SET_METHOD(GetMonitors); // Window handling //JS_GLFW_SET_METHOD(CreateWindow); Nan::SetMethod(target, "CreateWindow", glfw::glfw_CreateWindow); Nan::SetMethod(target, "GetRenderTarget", glfw::GetRenderTarget); Nan::SetMethod(target, "BindFrameBuffer", glfw::BindFrameBuffer); Nan::SetMethod(target, "BlitFrameBuffer", glfw::BlitFrameBuffer); JS_GLFW_SET_METHOD(WindowHint); JS_GLFW_SET_METHOD(DefaultWindowHints); JS_GLFW_SET_METHOD(DestroyWindow); JS_GLFW_SET_METHOD(SetWindowShouldClose); JS_GLFW_SET_METHOD(WindowShouldClose); JS_GLFW_SET_METHOD(SetWindowTitle); JS_GLFW_SET_METHOD(GetWindowSize); JS_GLFW_SET_METHOD(SetWindowSize); JS_GLFW_SET_METHOD(SetWindowPos); JS_GLFW_SET_METHOD(GetWindowPos); JS_GLFW_SET_METHOD(GetFramebufferSize); JS_GLFW_SET_METHOD(IconifyWindow); JS_GLFW_SET_METHOD(RestoreWindow); JS_GLFW_SET_METHOD(ShowWindow); JS_GLFW_SET_METHOD(HideWindow); JS_GLFW_SET_METHOD(GetWindowAttrib); JS_GLFW_SET_METHOD(SetInputMode); JS_GLFW_SET_METHOD(PollEvents); JS_GLFW_SET_METHOD(WaitEvents); // Input handling JS_GLFW_SET_METHOD(GetKey); JS_GLFW_SET_METHOD(GetMouseButton); JS_GLFW_SET_METHOD(GetCursorPos); JS_GLFW_SET_METHOD(SetCursorPos); // Context handling JS_GLFW_SET_METHOD(MakeContextCurrent); JS_GLFW_SET_METHOD(GetCurrentContext); JS_GLFW_SET_METHOD(SwapBuffers); JS_GLFW_SET_METHOD(SwapInterval); JS_GLFW_SET_METHOD(ExtensionSupported); // Joystick JS_GLFW_SET_METHOD(JoystickPresent); JS_GLFW_SET_METHOD(GetJoystickAxes); JS_GLFW_SET_METHOD(GetJoystickButtons); JS_GLFW_SET_METHOD(GetJoystickName); // GLFW version JS_GLFW_CONSTANT(VERSION_MAJOR); JS_GLFW_CONSTANT(VERSION_MINOR); JS_GLFW_CONSTANT(VERSION_REVISION); // Input handling definitions // Key and button state/action definitions JS_GLFW_CONSTANT(RELEASE); JS_GLFW_CONSTANT(PRESS); JS_GLFW_CONSTANT(REPEAT); // These key codes are inspired by the *USB HID Usage Tables v1.12* (p. 53-60), // but re-arranged to map to 7-bit ASCII for printable keys (function keys are // put in the 256+ range). // // The naming of the key codes follow these rules: // - The US keyboard layout is used // - Names of printable alpha-numeric characters are used (e.g. "A", "R", // "3", etc.) // - For non-alphanumeric characters, Unicode:ish names are used (e.g. // "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not // correspond to the Unicode standard (usually for brevity) // - Keys that lack a clear US mapping are named "WORLD_x" // - For non-printable keys, custom names are used (e.g. "F4", // "BACKSPACE", etc.) // The unknown key JS_GLFW_CONSTANT(KEY_UNKNOWN); // Printable keys JS_GLFW_CONSTANT(KEY_SPACE); JS_GLFW_CONSTANT(KEY_APOSTROPHE); JS_GLFW_CONSTANT(KEY_COMMA); JS_GLFW_CONSTANT(KEY_MINUS); JS_GLFW_CONSTANT(KEY_PERIOD); JS_GLFW_CONSTANT(KEY_SLASH); JS_GLFW_CONSTANT(KEY_0); JS_GLFW_CONSTANT(KEY_1); JS_GLFW_CONSTANT(KEY_2); JS_GLFW_CONSTANT(KEY_3); JS_GLFW_CONSTANT(KEY_4); JS_GLFW_CONSTANT(KEY_5); JS_GLFW_CONSTANT(KEY_6); JS_GLFW_CONSTANT(KEY_7); JS_GLFW_CONSTANT(KEY_8); JS_GLFW_CONSTANT(KEY_9); JS_GLFW_CONSTANT(KEY_SEMICOLON); JS_GLFW_CONSTANT(KEY_EQUAL); JS_GLFW_CONSTANT(KEY_A); JS_GLFW_CONSTANT(KEY_B); JS_GLFW_CONSTANT(KEY_C); JS_GLFW_CONSTANT(KEY_D); JS_GLFW_CONSTANT(KEY_E); JS_GLFW_CONSTANT(KEY_F); JS_GLFW_CONSTANT(KEY_G); JS_GLFW_CONSTANT(KEY_H); JS_GLFW_CONSTANT(KEY_I); JS_GLFW_CONSTANT(KEY_J); JS_GLFW_CONSTANT(KEY_K); JS_GLFW_CONSTANT(KEY_L); JS_GLFW_CONSTANT(KEY_M); JS_GLFW_CONSTANT(KEY_N); JS_GLFW_CONSTANT(KEY_O); JS_GLFW_CONSTANT(KEY_P); JS_GLFW_CONSTANT(KEY_Q); JS_GLFW_CONSTANT(KEY_R); JS_GLFW_CONSTANT(KEY_S); JS_GLFW_CONSTANT(KEY_T); JS_GLFW_CONSTANT(KEY_U); JS_GLFW_CONSTANT(KEY_V); JS_GLFW_CONSTANT(KEY_W); JS_GLFW_CONSTANT(KEY_X); JS_GLFW_CONSTANT(KEY_Y); JS_GLFW_CONSTANT(KEY_Z); JS_GLFW_CONSTANT(KEY_LEFT_BRACKET); JS_GLFW_CONSTANT(KEY_BACKSLASH); JS_GLFW_CONSTANT(KEY_RIGHT_BRACKET); JS_GLFW_CONSTANT(KEY_GRAVE_ACCENT); JS_GLFW_CONSTANT(KEY_WORLD_1); JS_GLFW_CONSTANT(KEY_WORLD_2); // Function keys JS_GLFW_CONSTANT(KEY_ESCAPE); JS_GLFW_CONSTANT(KEY_ENTER); JS_GLFW_CONSTANT(KEY_TAB); JS_GLFW_CONSTANT(KEY_BACKSPACE); JS_GLFW_CONSTANT(KEY_INSERT); JS_GLFW_CONSTANT(KEY_DELETE); JS_GLFW_CONSTANT(KEY_RIGHT); JS_GLFW_CONSTANT(KEY_LEFT); JS_GLFW_CONSTANT(KEY_DOWN); JS_GLFW_CONSTANT(KEY_UP); JS_GLFW_CONSTANT(KEY_PAGE_UP); JS_GLFW_CONSTANT(KEY_PAGE_DOWN); JS_GLFW_CONSTANT(KEY_HOME); JS_GLFW_CONSTANT(KEY_END); JS_GLFW_CONSTANT(KEY_CAPS_LOCK); JS_GLFW_CONSTANT(KEY_SCROLL_LOCK); JS_GLFW_CONSTANT(KEY_NUM_LOCK); JS_GLFW_CONSTANT(KEY_PRINT_SCREEN); JS_GLFW_CONSTANT(KEY_PAUSE); JS_GLFW_CONSTANT(KEY_F1); JS_GLFW_CONSTANT(KEY_F2); JS_GLFW_CONSTANT(KEY_F3); JS_GLFW_CONSTANT(KEY_F4); JS_GLFW_CONSTANT(KEY_F5); JS_GLFW_CONSTANT(KEY_F6); JS_GLFW_CONSTANT(KEY_F7); JS_GLFW_CONSTANT(KEY_F8); JS_GLFW_CONSTANT(KEY_F9); JS_GLFW_CONSTANT(KEY_F10); JS_GLFW_CONSTANT(KEY_F11); JS_GLFW_CONSTANT(KEY_F12); JS_GLFW_CONSTANT(KEY_F13); JS_GLFW_CONSTANT(KEY_F14); JS_GLFW_CONSTANT(KEY_F15); JS_GLFW_CONSTANT(KEY_F16); JS_GLFW_CONSTANT(KEY_F17); JS_GLFW_CONSTANT(KEY_F18); JS_GLFW_CONSTANT(KEY_F19); JS_GLFW_CONSTANT(KEY_F20); JS_GLFW_CONSTANT(KEY_F21); JS_GLFW_CONSTANT(KEY_F22); JS_GLFW_CONSTANT(KEY_F23); JS_GLFW_CONSTANT(KEY_F24); JS_GLFW_CONSTANT(KEY_F25); JS_GLFW_CONSTANT(KEY_KP_0); JS_GLFW_CONSTANT(KEY_KP_1); JS_GLFW_CONSTANT(KEY_KP_2); JS_GLFW_CONSTANT(KEY_KP_3); JS_GLFW_CONSTANT(KEY_KP_4); JS_GLFW_CONSTANT(KEY_KP_5); JS_GLFW_CONSTANT(KEY_KP_6); JS_GLFW_CONSTANT(KEY_KP_7); JS_GLFW_CONSTANT(KEY_KP_8); JS_GLFW_CONSTANT(KEY_KP_9); JS_GLFW_CONSTANT(KEY_KP_DECIMAL); JS_GLFW_CONSTANT(KEY_KP_DIVIDE); JS_GLFW_CONSTANT(KEY_KP_MULTIPLY); JS_GLFW_CONSTANT(KEY_KP_SUBTRACT); JS_GLFW_CONSTANT(KEY_KP_ADD); JS_GLFW_CONSTANT(KEY_KP_ENTER); JS_GLFW_CONSTANT(KEY_KP_EQUAL); JS_GLFW_CONSTANT(KEY_LEFT_SHIFT); JS_GLFW_CONSTANT(KEY_LEFT_CONTROL); JS_GLFW_CONSTANT(KEY_LEFT_ALT); JS_GLFW_CONSTANT(KEY_LEFT_SUPER); JS_GLFW_CONSTANT(KEY_RIGHT_SHIFT); JS_GLFW_CONSTANT(KEY_RIGHT_CONTROL); JS_GLFW_CONSTANT(KEY_RIGHT_ALT); JS_GLFW_CONSTANT(KEY_RIGHT_SUPER); JS_GLFW_CONSTANT(KEY_MENU); JS_GLFW_CONSTANT(KEY_LAST); // Modifier key flags // If this bit is set one or more Shift keys were held down. JS_GLFW_CONSTANT(MOD_SHIFT); // If this bit is set one or more Control keys were held down. JS_GLFW_CONSTANT(MOD_CONTROL); // If this bit is set one or more Alt keys were held down. JS_GLFW_CONSTANT(MOD_ALT); // If this bit is set one or more Super keys were held down. JS_GLFW_CONSTANT(MOD_SUPER); // Mouse buttons JS_GLFW_CONSTANT(MOUSE_BUTTON_1); JS_GLFW_CONSTANT(MOUSE_BUTTON_2); JS_GLFW_CONSTANT(MOUSE_BUTTON_3); JS_GLFW_CONSTANT(MOUSE_BUTTON_4); JS_GLFW_CONSTANT(MOUSE_BUTTON_5); JS_GLFW_CONSTANT(MOUSE_BUTTON_6); JS_GLFW_CONSTANT(MOUSE_BUTTON_7); JS_GLFW_CONSTANT(MOUSE_BUTTON_8); JS_GLFW_CONSTANT(MOUSE_BUTTON_LAST); JS_GLFW_CONSTANT(MOUSE_BUTTON_LEFT); JS_GLFW_CONSTANT(MOUSE_BUTTON_RIGHT); JS_GLFW_CONSTANT(MOUSE_BUTTON_MIDDLE); // Joysticks JS_GLFW_CONSTANT(JOYSTICK_1); JS_GLFW_CONSTANT(JOYSTICK_2); JS_GLFW_CONSTANT(JOYSTICK_3); JS_GLFW_CONSTANT(JOYSTICK_4); JS_GLFW_CONSTANT(JOYSTICK_5); JS_GLFW_CONSTANT(JOYSTICK_6); JS_GLFW_CONSTANT(JOYSTICK_7); JS_GLFW_CONSTANT(JOYSTICK_8); JS_GLFW_CONSTANT(JOYSTICK_9); JS_GLFW_CONSTANT(JOYSTICK_10); JS_GLFW_CONSTANT(JOYSTICK_11); JS_GLFW_CONSTANT(JOYSTICK_12); JS_GLFW_CONSTANT(JOYSTICK_13); JS_GLFW_CONSTANT(JOYSTICK_14); JS_GLFW_CONSTANT(JOYSTICK_15); JS_GLFW_CONSTANT(JOYSTICK_16); JS_GLFW_CONSTANT(JOYSTICK_LAST); // errors Error codes // GLFW has not been initialized. JS_GLFW_CONSTANT(NOT_INITIALIZED); // No context is current for this thread. JS_GLFW_CONSTANT(NO_CURRENT_CONTEXT); // One of the enum parameters for the function was given an invalid enum. JS_GLFW_CONSTANT(INVALID_ENUM); // One of the parameters for the function was given an invalid value. JS_GLFW_CONSTANT(INVALID_VALUE); // A memory allocation failed. JS_GLFW_CONSTANT(OUT_OF_MEMORY); // GLFW could not find support for the requested client API on the system. JS_GLFW_CONSTANT(API_UNAVAILABLE); // The requested client API version is not available. JS_GLFW_CONSTANT(VERSION_UNAVAILABLE); // A platform-specific error occurred that does not match any of the more specific categories. JS_GLFW_CONSTANT(PLATFORM_ERROR); // The clipboard did not contain data in the requested format. JS_GLFW_CONSTANT(FORMAT_UNAVAILABLE); JS_GLFW_CONSTANT(FOCUSED); JS_GLFW_CONSTANT(ICONIFIED); JS_GLFW_CONSTANT(RESIZABLE); JS_GLFW_CONSTANT(VISIBLE); JS_GLFW_CONSTANT(DECORATED); JS_GLFW_CONSTANT(RED_BITS); JS_GLFW_CONSTANT(GREEN_BITS); JS_GLFW_CONSTANT(BLUE_BITS); JS_GLFW_CONSTANT(ALPHA_BITS); JS_GLFW_CONSTANT(DEPTH_BITS); JS_GLFW_CONSTANT(STENCIL_BITS); JS_GLFW_CONSTANT(ACCUM_RED_BITS); JS_GLFW_CONSTANT(ACCUM_GREEN_BITS); JS_GLFW_CONSTANT(ACCUM_BLUE_BITS); JS_GLFW_CONSTANT(ACCUM_ALPHA_BITS); JS_GLFW_CONSTANT(AUX_BUFFERS); JS_GLFW_CONSTANT(STEREO); JS_GLFW_CONSTANT(SAMPLES); JS_GLFW_CONSTANT(SRGB_CAPABLE); JS_GLFW_CONSTANT(REFRESH_RATE); JS_GLFW_CONSTANT(DOUBLEBUFFER); JS_GLFW_CONSTANT(TRUE); JS_GLFW_CONSTANT(FALSE); JS_GLFW_CONSTANT(CLIENT_API); JS_GLFW_CONSTANT(CONTEXT_VERSION_MAJOR); JS_GLFW_CONSTANT(CONTEXT_VERSION_MINOR); JS_GLFW_CONSTANT(CONTEXT_REVISION); JS_GLFW_CONSTANT(CONTEXT_ROBUSTNESS); JS_GLFW_CONSTANT(OPENGL_FORWARD_COMPAT); JS_GLFW_CONSTANT(OPENGL_DEBUG_CONTEXT); JS_GLFW_CONSTANT(OPENGL_PROFILE); JS_GLFW_CONSTANT(OPENGL_API); JS_GLFW_CONSTANT(OPENGL_ES_API); JS_GLFW_CONSTANT(NO_ROBUSTNESS); JS_GLFW_CONSTANT(NO_RESET_NOTIFICATION); JS_GLFW_CONSTANT(LOSE_CONTEXT_ON_RESET); JS_GLFW_CONSTANT(OPENGL_ANY_PROFILE); JS_GLFW_CONSTANT(OPENGL_CORE_PROFILE); JS_GLFW_CONSTANT(OPENGL_COMPAT_PROFILE); JS_GLFW_CONSTANT(CURSOR); JS_GLFW_CONSTANT(STICKY_KEYS); JS_GLFW_CONSTANT(STICKY_MOUSE_BUTTONS); JS_GLFW_CONSTANT(CURSOR_NORMAL); JS_GLFW_CONSTANT(CURSOR_HIDDEN); JS_GLFW_CONSTANT(CURSOR_DISABLED); JS_GLFW_CONSTANT(CONNECTED); JS_GLFW_CONSTANT(DISCONNECTED); // test scene JS_GLFW_SET_METHOD(testScene); JS_GLFW_SET_METHOD(testJoystick); return scope.Escape(target); } */ Local<Object> makeWindow() { #ifdef MAIN_THREAD_POLLING if (!glfw::hasMainThreadId) { glfw::mainThreadId = std::this_thread::get_id(); glfw::hasMainThreadId = true; } #endif Isolate *isolate = Isolate::GetCurrent(); v8::EscapableHandleScope scope(isolate); Local<Object> target = Object::New(isolate); windowsystembase::Decorate(target); Nan::SetMethod(target, "initWindow3D", glfw::InitWindow3D); Nan::SetMethod(target, "createWindowHandle", glfw::CreateWindowHandle); Nan::SetMethod(target, "destroyWindowHandle", glfw::DestroyWindowHandle); Nan::SetMethod(target, "setVisibility", glfw::SetVisibility); Nan::SetMethod(target, "isVisible", glfw::IsVisible); Nan::SetMethod(target, "setFullscreen", glfw::SetFullscreen); Nan::SetMethod(target, "getMonitors", glfw::GetMonitors); Nan::SetMethod(target, "setMonitor", glfw::SetMonitor); Nan::SetMethod(target, "getScreenSize", glfw::GetScreenSize); Nan::SetMethod(target, "setWindowTitle", glfw::SetWindowTitle); Nan::SetMethod(target, "getWindowSize", glfw::GetWindowSize); Nan::SetMethod(target, "setWindowSize", glfw::SetWindowSize); Nan::SetMethod(target, "setWindowPos", glfw::SetWindowPos); Nan::SetMethod(target, "getWindowPos", glfw::GetWindowPos); Nan::SetMethod(target, "setWindowFocus", glfw::SetWindowFocus); Nan::SetMethod(target, "getFramebufferSize", glfw::GetFramebufferSize); Nan::SetMethod(target, "getDevicePixelRatio", glfw::GetDevicePixelRatio); Nan::SetMethod(target, "iconifyWindow", glfw::IconifyWindow); Nan::SetMethod(target, "restoreWindow", glfw::RestoreWindow); Nan::SetMethod(target, "setEventHandler", glfw::SetEventHandler); Nan::SetMethod(target, "swapBuffers", glfw::SwapBuffers); Nan::SetMethod(target, "getRefreshRate", glfw::GetRefreshRate); Nan::SetMethod(target, "setCursorMode", glfw::SetCursorMode); Nan::SetMethod(target, "setCursorPosition", glfw::SetCursorPosition); Nan::SetMethod(target, "getClipboard", glfw::GetClipboard); Nan::SetMethod(target, "setClipboard", glfw::SetClipboard); Nan::SetMethod(target, "blitTopFrameBuffer", glfw::BlitTopFrameBuffer); Nan::SetMethod(target, "blitChildFrameBuffer", glfw::BlitChildFrameBuffer); Nan::SetMethod(target, "hasCurrentWindowContext", glfw::HasCurrentWindowContext); Nan::SetMethod(target, "getCurrentWindowContext", glfw::GetCurrentWindowContext); Nan::SetMethod(target, "setCurrentWindowContext", glfw::SetCurrentWindowContext); #ifdef MAIN_THREAD_POLLING Nan::SetMethod(target, "pollEvents", glfw::PollEvents); #endif return scope.Escape(target); }
33.074819
160
0.68258
Palmer-JC
43116fbcfeff073fa6844712bf33c37cbe5fb7b9
955
cpp
C++
codeforces/B - Equalize Prices/Accepted.cpp
kzvd4729/Problem-Solving
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
[ "MIT" ]
1
2022-02-11T16:55:36.000Z
2022-02-11T16:55:36.000Z
codeforces/B - Equalize Prices/Accepted.cpp
kzvd4729/Problem-Solving
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
[ "MIT" ]
null
null
null
codeforces/B - Equalize Prices/Accepted.cpp
kzvd4729/Problem-Solving
13b105e725a4c2f8db7fecc5d7a8f932b9fef4ab
[ "MIT" ]
null
null
null
/**************************************************************************************** * @author: kzvd4729 created: Jun/28/2019 19:22 * solution_verdict: Accepted language: GNU C++14 * run_time: 31 ms memory_used: 0 KB * problem: https://codeforces.com/contest/1183/problem/B ****************************************************************************************/ #include<bits/stdc++.h> #define long long long using namespace std; const int N=1e6; int main() { ios_base::sync_with_stdio(0);cin.tie(0); int q;cin>>q; while(q--) { int n,k;cin>>n>>k;int mn=1e9,mx=0; for(int i=1;i<=n;i++) { int x;cin>>x; mn=min(mn,x);mx=max(mx,x); } if(mx-mn>k+k)cout<<-1<<"\n"; else cout<<mn+k<<"\n"; } return 0; }
35.37037
111
0.362304
kzvd4729
4323ae1e55c975972ce0e40f3dd94e4413e2ae15
11,278
cpp
C++
FEM_2D_Plane_Stress.cpp
JoshuaSimon/2D-FEM-Solver
9f3c19b760350338a33445e9817e1c077f4718d5
[ "MIT" ]
3
2019-03-27T12:45:51.000Z
2019-08-25T09:41:56.000Z
FEM_2D_Plane_Stress.cpp
JoshuaSimon/2D-FEM-Solver
9f3c19b760350338a33445e9817e1c077f4718d5
[ "MIT" ]
null
null
null
FEM_2D_Plane_Stress.cpp
JoshuaSimon/2D-FEM-Solver
9f3c19b760350338a33445e9817e1c077f4718d5
[ "MIT" ]
null
null
null
// FEM_2D_Plane_Stress.cpp (Main) #include "pch.h" #include "FEM_Input.h" #include "FEM_GNUPlot.h" #include <Eigen/Dense> #include <Eigen/Sparse> #include <string> #include <vector> #include <iostream> #include <fstream> //Element data type struct Element { void CalculateStiffnessMatrix(const Eigen::Matrix3f& D, std::vector<Eigen::Triplet<float> >& triplets); Eigen::Matrix<float, 3, 6> B; int nodesIds[3]; }; //Boundary constraint data type struct Constraint { enum Type { UX = 1 << 0, UY = 1 << 1, UXY = UX | UY }; int node; Type type; }; //Globals int nodesCount; Eigen::VectorXf nodesX; Eigen::VectorXf nodesY; Eigen::VectorXf loads; std::vector< Element > elements; std::vector< Constraint > constraints; //Function for calculating the element stiffness matrix. void Element::CalculateStiffnessMatrix(const Eigen::Matrix3f& D, std::vector<Eigen::Triplet<float> >& triplets) { Eigen::Vector3f x, y; x << nodesX[nodesIds[0]], nodesX[nodesIds[1]], nodesX[nodesIds[2]]; y << nodesY[nodesIds[0]], nodesY[nodesIds[1]], nodesY[nodesIds[2]]; Eigen::Matrix3f C; C << Eigen::Vector3f(1.0f, 1.0f, 1.0f), x, y; //Calculating coefficients for shape functions (a1, a2, a3). //These are relevant for interpolation. Eigen::Matrix3f IC = C.inverse(); //Assemble B matrix for (int i = 0; i < 3; i++) { B(0, 2 * i + 0) = IC(1, i); B(0, 2 * i + 1) = 0.0f; B(1, 2 * i + 0) = 0.0f; B(1, 2 * i + 1) = IC(2, i); B(2, 2 * i + 0) = IC(2, i); B(2, 2 * i + 1) = IC(1, i); } //Calculate element stiffness (det(C)/2 = area of triangle). Eigen::Matrix<float, 6, 6> K = B.transpose() * D * B * C.determinant() / 2.0f; //Store values of element stiffness matrix with corresponding indices in global stiffness matrix in triplets. for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { Eigen::Triplet<float> trplt11(2 * nodesIds[i] + 0, 2 * nodesIds[j] + 0, K(2 * i + 0, 2 * j + 0)); Eigen::Triplet<float> trplt12(2 * nodesIds[i] + 0, 2 * nodesIds[j] + 1, K(2 * i + 0, 2 * j + 1)); Eigen::Triplet<float> trplt21(2 * nodesIds[i] + 1, 2 * nodesIds[j] + 0, K(2 * i + 1, 2 * j + 0)); Eigen::Triplet<float> trplt22(2 * nodesIds[i] + 1, 2 * nodesIds[j] + 1, K(2 * i + 1, 2 * j + 1)); triplets.push_back(trplt11); triplets.push_back(trplt12); triplets.push_back(trplt21); triplets.push_back(trplt22); } } } //Function for setting constraints. void SetConstraints(Eigen::SparseMatrix<float>::InnerIterator& it, int index) { if (it.row() == index || it.col() == index) { it.valueRef() = it.row() == it.col() ? 1.0f : 0.0f; } } //Function for applying constraints in stiffness matrix. void ApplyConstraints(Eigen::SparseMatrix<float>& K, const std::vector<Constraint>& constraints) { std::vector<int> indicesToConstraint; for (std::vector<Constraint>::const_iterator it = constraints.begin(); it != constraints.end(); ++it) { if (it->type & Constraint::UX) { indicesToConstraint.push_back(2 * it->node + 0); } if (it->type & Constraint::UY) { indicesToConstraint.push_back(2 * it->node + 1); } } for (int k = 0; k < K.outerSize(); ++k) { for (Eigen::SparseMatrix<float>::InnerIterator it(K, k); it; ++it) { for (std::vector<int>::iterator idit = indicesToConstraint.begin(); idit != indicesToConstraint.end(); ++idit) { SetConstraints(it, *idit); } } } } int main(void) { std::cout << "---------------------- 2D FEM SOLVER ---------------------" << std::endl; std::cout << "FEM software for solving elastic 2D plain stress problems." << std::endl; std::cout << "Created by Joshua Simon. Date: 25.02.2019." << std::endl; std::cout << std::endl; //1. Paths and filenames string mesh_data_file; //This filename is read from user input. string solver_input_file = "Solver_Input.txt"; string displacement_plot_data = "GNUPlot_Input_displacement.txt"; string stress_plot_data = "GNUPlot_Input_contour.txt"; //User input of mesh data file std::cout << "Enter the filename of the GiD mesh data file. If the data file is " << std::endl; std::cout << "not in same folder as this application, than enter the whole path " << std::endl; std::cout << "of the mesh data file with filename. Use \\\\ for \\ in address. " << std::endl; std::cout << std::endl << "Filename >> "; std::cin >> mesh_data_file; std::cout << std::endl << std::endl; //2. Pre Processing: //Read GiD mesh Data and write solver input. std::cout << "Pre Processor: Define boundary conditions and loads." << std::endl << std::endl; generateSolverInput(mesh_data_file, solver_input_file); std::cout << "Pre Processor: Solver input generated!" << std::endl << std::endl; std::ifstream infile(solver_input_file); std::ofstream outfile("Solution_Data.txt"); //This file contains solution data. std::ofstream outfile_gnuplot(displacement_plot_data); //This file contains plot data. std::ofstream outfile_gnuplot_contur(stress_plot_data); //This file contains plot data. //3. Solution: std::cout << "Solver: Creating mathematical model..." << std::endl; //Read material specifications float poissonRatio, youngModulus; infile >> poissonRatio >> youngModulus; //Assemble elasticity matrix D Eigen::Matrix3f D; D << 1.0f, poissonRatio, 0.0f, poissonRatio, 1.0, 0.0f, 0.0f, 0.0f, (1.0f - poissonRatio) / 2.0f; D *= youngModulus / (1.0f - pow(poissonRatio, 2.0f)); //Read number of nodes and their coordinates infile >> nodesCount; nodesX.resize(nodesCount); nodesY.resize(nodesCount); for (int i = 0; i < nodesCount; ++i) { infile >> nodesX[i] >> nodesY[i]; } //Read number of elements and their nodes int elementCount; infile >> elementCount; for (int i = 0; i < elementCount; ++i) { Element element; infile >> element.nodesIds[0] >> element.nodesIds[1] >> element.nodesIds[2]; elements.push_back(element); } //Read number of constraints and their node settings int constraintCount; infile >> constraintCount; for (int i = 0; i < constraintCount; ++i) { Constraint constraint; int type; infile >> constraint.node >> type; constraint.type = static_cast<Constraint::Type>(type); constraints.push_back(constraint); } loads.resize(2 * nodesCount); loads.setZero(); //Read number of nodal loads and nodal forces int loadsCount; infile >> loadsCount; for (int i = 0; i < loadsCount; ++i) { int node; float x, y; infile >> node >> x >> y; loads[2 * node + 0] = x; loads[2 * node + 1] = y; } //Calculate stiffness matrix for each element std::vector<Eigen::Triplet<float> > triplets; for (std::vector<Element>::iterator it = elements.begin(); it != elements.end(); ++it) { it->CalculateStiffnessMatrix(D, triplets); } //Assemble global stiffness matirx Eigen::SparseMatrix<float> globalK(2 * nodesCount, 2 * nodesCount); globalK.setFromTriplets(triplets.begin(), triplets.end()); //Apply Constraints ApplyConstraints(globalK, constraints); std::cout << "Solver: Mathematical model created!" << std::endl; //Solving std::cout << "Solver: Solving in progress..." << std::endl; Eigen::SimplicialLDLT<Eigen::SparseMatrix<float> > solver(globalK); Eigen::VectorXf displacements = solver.solve(loads); std::cout << "Solver: Solving done!" << std::endl << std::endl; //Writing output and display on console //std::cout << "Loads vector:" << std::endl << loads << std::endl << std::endl; //Loads //std::cout << "Displacements vector:" << std::endl << displacements << std::endl; //Displaysments outfile << displacements << std::endl; //std::cout << "Stresses:" << std::endl; //Von Mises Stress int m = 0; float sigma_max = 0.0; float *sigma_mises = new float[elementCount]; for (std::vector<Element>::iterator it = elements.begin(); it != elements.end(); ++it) { Eigen::Matrix<float, 6, 1> delta; delta << displacements.segment<2>(2 * it->nodesIds[0]), displacements.segment<2>(2 * it->nodesIds[1]), displacements.segment<2>(2 * it->nodesIds[2]); Eigen::Vector3f sigma = D * it->B * delta; sigma_mises[m] = sqrt(sigma[0] * sigma[0] - sigma[0] * sigma[1] + sigma[1] * sigma[1] + 3.0f * sigma[2] * sigma[2]); //Search for maximum stress if (sigma_mises[m] > sigma_max) { sigma_max = sigma_mises[m]; } //std::cout << sigma_mises[m] << std::endl; //Von Mises Stress outfile << sigma_mises[m] << std::endl; m++; } //4. Post Processing: //4.1 Writing GNUPlot output file for ploting mesh and mesh + displacements for (std::vector<Element>::iterator it = elements.begin(); it != elements.end(); ++it) { //Prints x,y,dis-x,dis-y for every node of element in one line for (int i = 0; i < 3; i++) { outfile_gnuplot << nodesX(it->nodesIds[i]) << " " << nodesY(it->nodesIds[i]) \ << " " << displacements(it->nodesIds[i] * 2) << " " << displacements(it->nodesIds[i] * 2 + 1) << std::endl; } //First node of element has to appear twice for plotting purpose outfile_gnuplot << nodesX(it->nodesIds[0]) << " " << nodesY(it->nodesIds[0]) \ << " " << displacements(it->nodesIds[0] * 2) << " " << displacements(it->nodesIds[0] * 2 + 1) << std::endl; //Empty line to sperate between elements outfile_gnuplot << std::endl; } //4.2 Writing GNUPlot output file for stress contour plot outfile_gnuplot_contur << "unset xtics" << std::endl; outfile_gnuplot_contur << "unset ytics" << std::endl; outfile_gnuplot_contur << "set cbrange [0:1]" << std::endl << std::endl; outfile_gnuplot_contur << "plot[-15:15][-15:15] \\" << std::endl; //Write color information for every element int mm = 0; for (std::vector<Element>::iterator it = elements.begin(); it != (elements.end()-1); ++it) { outfile_gnuplot_contur << "\"-\" title \"\" with filledcurve lt palette cb " \ << sigma_mises[mm] / sigma_max << " \\" << std::endl; outfile_gnuplot_contur << "fillstyle transparent solid 1.000000 ,\\" << std::endl; mm++; } //Write color information for last element outfile_gnuplot_contur << "\"-\" title \"\" with filledcurve lt palette cb " \ << sigma_mises[elementCount-1] / sigma_max << " \\" << std::endl; outfile_gnuplot_contur << "fillstyle transparent solid 1.000000 ;" << std::endl; for (std::vector<Element>::iterator it = elements.begin(); it != elements.end(); ++it) { //Elements and their nodes: //Prints x,y for every node of element in one line for (int i = 0; i < 3; i++) { outfile_gnuplot_contur << nodesX(it->nodesIds[i]) << " " << nodesY(it->nodesIds[i]) << std::endl; } //First node of element has to appear twice for plotting purpose outfile_gnuplot_contur << nodesX(it->nodesIds[0]) << " " << nodesY(it->nodesIds[0]) << std::endl; //'e' to sperate between elements outfile_gnuplot_contur << "e" << std::endl; } std::cout << "Post Processor: Plotting solution..." << std::endl << std::endl; //4.3 Plot results plot(displacement_plot_data); delete[] sigma_mises; return 0; }
32.976608
119
0.628835
JoshuaSimon
43284a7fd3c9e1f4ccdf2ccee67e81a16209caba
1,971
cpp
C++
Kernel/src/Arch/x86_64/Keyboard.cpp
adi-g15/LemonOS
47a15ecc0efe47eeebde0b63d668fb70c9e22b57
[ "BSD-2-Clause" ]
null
null
null
Kernel/src/Arch/x86_64/Keyboard.cpp
adi-g15/LemonOS
47a15ecc0efe47eeebde0b63d668fb70c9e22b57
[ "BSD-2-Clause" ]
null
null
null
Kernel/src/Arch/x86_64/Keyboard.cpp
adi-g15/LemonOS
47a15ecc0efe47eeebde0b63d668fb70c9e22b57
[ "BSD-2-Clause" ]
null
null
null
#include <Scheduler.h> #include <System.h> #include <IDT.h> #include <Logging.h> #include <APIC.h> #include <Fs/Filesystem.h> #include <Device.h> #define KEY_QUEUE_SIZE 256 namespace Keyboard{ uint8_t keyQueue[KEY_QUEUE_SIZE]; unsigned short keyQueueEnd = 0; unsigned short keyQueueStart = 0; unsigned short keyCount = 0; bool ReadKey(uint8_t* key){ if(keyCount <= 0) return false; *key = keyQueue[keyQueueStart]; keyQueueStart++; if(keyQueueStart >= KEY_QUEUE_SIZE) { keyQueueStart = 0; } keyCount--; return true; } class KeyboardDevice : public Device{ public: DirectoryEntry dirent; KeyboardDevice(char* name) : Device(name, DeviceTypeLegacyHID){ flags = FS_NODE_CHARDEVICE; strcpy(dirent.name, name); dirent.flags = flags; dirent.node = this; SetDeviceName("PS/2 Keyboard Device"); } ssize_t Read(size_t offset, size_t size, uint8_t *buffer){ if(size > keyCount) size = keyCount; if(!size) return 0; unsigned short i = 0; for(; i < size; i++){ if(!ReadKey(buffer++)) // Insert key and increment break; } return i; } }; KeyboardDevice kbDev("keyboard0"); // Interrupt handler void Handler(void*, RegisterContext* r) { // Read from the keyboard's data buffer uint8_t key = inportb(0x60); if(keyCount >= KEY_QUEUE_SIZE) return; // Drop key // Add key to queue keyQueue[keyQueueEnd] = key; keyQueueEnd++; if(keyQueueEnd >= KEY_QUEUE_SIZE) { keyQueueEnd = 0; } keyCount++; } // Register interrupt handler void Install() { IDT::RegisterInterruptHandler(IRQ0 + 1, Handler); APIC::IO::MapLegacyIRQ(1); outportb(0xF0, 1); // Set scan code 1 } }
21.423913
66
0.572806
adi-g15
4328e957fb7479b0a77f7dcadab32172d0f6d6e1
4,136
hpp
C++
include/boost/hana/detail/variadic/foldr1.hpp
rbock/hana
2b76377f91a5ebe037dea444e4eaabba6498d3a8
[ "BSL-1.0" ]
2
2015-05-07T14:29:13.000Z
2015-07-04T10:59:46.000Z
include/boost/hana/detail/variadic/foldr1.hpp
rbock/hana
2b76377f91a5ebe037dea444e4eaabba6498d3a8
[ "BSL-1.0" ]
null
null
null
include/boost/hana/detail/variadic/foldr1.hpp
rbock/hana
2b76377f91a5ebe037dea444e4eaabba6498d3a8
[ "BSL-1.0" ]
null
null
null
/*! @file Defines `boost::hana::detail::variadic::foldr1`. @copyright Louis Dionne 2014 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_DETAIL_VARIADIC_FOLDR1_HPP #define BOOST_HANA_DETAIL_VARIADIC_FOLDR1_HPP #include <boost/hana/core/datatype.hpp> #include <boost/hana/detail/type_fwd.hpp> namespace boost { namespace hana { namespace detail { namespace variadic { template <unsigned int narg> struct foldr1_impl; template <> struct foldr1_impl<1> { template <template <typename ...> class F, typename X1> using apply_t = X1; template <typename F, typename X1> static constexpr auto apply(F, X1 x1) { return x1; } }; template <> struct foldr1_impl<2> { template <template <typename ...> class F, typename X1, typename X2> using apply_t = typename F<X1, X2>::type; template <typename F, typename X1, typename X2> static constexpr auto apply(F f, X1 x1, X2 x2) { return f(x1, x2); } }; template <> struct foldr1_impl<3> { template <template <typename ...> class F, typename X1, typename X2, typename X3> using apply_t = typename F<X1, typename F<X2, X3>::type>::type; template <typename F, typename X1, typename X2, typename X3> static constexpr auto apply(F f, X1 x1, X2 x2, X3 x3) { return f(x1, f(x2, x3)); } }; // Given a number of arguments left to process, returns the number with // which the next call to `foldr1_impl` should be specialized. constexpr unsigned int foldr1_next(unsigned int n) { return n > 4 ? 4 : n; } template <> struct foldr1_impl<4> { template <template <typename ...> class F, typename X1, typename X2, typename X3, typename ...Xs> using apply_t = typename F<X1, typename F<X2, typename F<X3, typename foldr1_impl<foldr1_next(sizeof...(Xs))>:: template apply_t<F, Xs...> >::type>::type>::type; template <typename F, typename X1, typename X2, typename X3, typename ...Xs> static constexpr auto apply(F f, X1 x1, X2 x2, X3 x3, Xs ...xs) { return f(x1, f(x2, f(x3, foldr1_impl<foldr1_next(sizeof...(Xs))>::apply(f, xs...)))); } }; template <typename ...Xs, typename F> constexpr auto foldr1_helper(F f, ...) { return foldr1_impl<foldr1_next(sizeof...(Xs))>::apply(f, type<Xs>...); } template <typename ...Xs, typename F> constexpr auto foldr1_helper(F, Metafunction*) { return type< typename foldr1_impl<foldr1_next(sizeof...(Xs))>:: template apply_t<F::template apply, Xs...> >; } template <typename ...Xs, typename F> constexpr auto foldr1(F f) { return foldr1_helper<Xs...>(f, (datatype_t<F>*)0); } template <typename F, typename ...Xs> constexpr auto foldr1(F f, Xs ...xs) { return foldr1_impl<foldr1_next(sizeof...(Xs))>::apply(f, xs...); } #if 0 template <typename F, typename X0> constexpr auto foldr1_impl(F, X0 x0) { return x0; } template <typename F, typename X0, typename X1> constexpr auto foldr1_impl(F f, X0 x0, X1 x1) { return f(x0, x1); } template <typename F, typename X0, typename X1, typename X2> constexpr auto foldr1_impl(F f, X0 x0, X1 x1, X2 x2) { return f(x0, f(x1, x2)); } template <typename F, typename X0, typename X1, typename X2, typename X3> constexpr auto foldr1_impl(F f, X0 x0, X1 x1, X2 x2, X3 x3) { return f(x0, f(x1, f(x2, x3))); } template <typename F, typename X0, typename X1, typename X2, typename X3, typename ...Xs> constexpr auto foldr1_impl(F f, X0 x0, X1 x1, X2 x2, X3 x3, Xs ...xs) { return f(x0, f(x1, f(x2, f(x3, foldr1_impl(f, xs...))))); } BOOST_HANA_CONSTEXPR_LAMBDA auto foldr1 = [](auto f, auto x, auto ...xs) { return foldr1_impl(f, x, xs...); }; #endif }}}} // end namespace boost::hana::detail::variadic #endif // !BOOST_HANA_DETAIL_VARIADIC_FOLDR1_HPP
34.181818
105
0.626692
rbock
43292ae2fa0c40ac72238dbd4ef74774a4d4a9e1
2,945
cc
C++
src/atlas/mesh/actions/ExtendNodesGlobal.cc
twsearle/atlas
a1916fd521f9935f846004e6194f80275de4de83
[ "Apache-2.0" ]
67
2018-03-01T06:56:49.000Z
2022-03-08T18:44:47.000Z
src/atlas/mesh/actions/ExtendNodesGlobal.cc
twsearle/atlas
a1916fd521f9935f846004e6194f80275de4de83
[ "Apache-2.0" ]
93
2018-12-07T17:38:04.000Z
2022-03-31T10:04:51.000Z
src/atlas/mesh/actions/ExtendNodesGlobal.cc
twsearle/atlas
a1916fd521f9935f846004e6194f80275de4de83
[ "Apache-2.0" ]
33
2018-02-28T17:06:19.000Z
2022-01-20T12:12:27.000Z
/* * (C) Copyright 2013 ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation * nor does it submit to any jurisdiction. */ #include "atlas/mesh/actions/ExtendNodesGlobal.h" #include "atlas/array.h" #include "atlas/field/Field.h" #include "atlas/grid/Grid.h" #include "atlas/grid/Iterator.h" #include "atlas/mesh/Mesh.h" #include "atlas/mesh/Nodes.h" #include "atlas/runtime/Exception.h" #include "atlas/util/CoordinateEnums.h" #include "atlas/util/Earth.h" namespace atlas { namespace mesh { namespace actions { ExtendNodesGlobal::ExtendNodesGlobal(const std::string& gridname): gridname_(gridname) {} void ExtendNodesGlobal::operator()(const Grid& grid, Mesh& mesh) const { if (grid.domain().global()) { return; // don't add virtual points to global domains } Grid O16("O16"); // virtual points std::vector<PointXY> extended_pts; extended_pts.reserve(grid.size()); // loop over the point and keep the ones that *don't* fall in the domain for (const PointLonLat& lonlat : O16.lonlat()) { PointXY xy = grid.projection().xy(lonlat); if (not grid.domain().contains(xy)) { extended_pts.push_back(xy); } } mesh::Nodes& nodes = mesh.nodes(); const idx_t nb_real_pts = nodes.size(); const idx_t nb_extension_pts = extended_pts.size(); idx_t new_size = nodes.size() + extended_pts.size(); nodes.resize(new_size); // resizes the fields const idx_t nb_total_pts = nodes.size(); ATLAS_ASSERT(nb_total_pts == nb_real_pts + nb_extension_pts); nodes.metadata().set<idx_t>("NbRealPts", nb_real_pts); nodes.metadata().set<idx_t>("NbVirtualPts", nb_extension_pts); array::ArrayView<double, 2> xyz = array::make_view<double, 2>(nodes.field("xyz")); array::ArrayView<double, 2> xy = array::make_view<double, 2>(nodes.xy()); array::ArrayView<double, 2> lonlat = array::make_view<double, 2>(nodes.lonlat()); array::ArrayView<gidx_t, 1> gidx = array::make_view<gidx_t, 1>(nodes.global_index()); for (idx_t i = 0; i < nb_extension_pts; ++i) { const idx_t n = nb_real_pts + i; const PointLonLat pLL = grid.projection().lonlat(extended_pts[i]); PointXYZ pXYZ; util::Earth::convertSphericalToCartesian(pLL, pXYZ); xyz(n, XX) = pXYZ.x(); xyz(n, YY) = pXYZ.y(); xyz(n, ZZ) = pXYZ.z(); xy(n, XX) = extended_pts[i].x(); xy(n, YY) = extended_pts[i].y(); lonlat(n, LON) = pLL.lon(); lonlat(n, LAT) = pLL.lat(); gidx(n) = n + 1; } } } // namespace actions } // namespace mesh } // namespace atlas
32.362637
91
0.64618
twsearle
432e5c2df7b0ea0380037b8c7691972f3e4e8c52
2,611
cpp
C++
higan/target-bsnes/settings/hotkeys.cpp
13824125580/higan
fbdd3f980b65412c362096579869ae76730e4118
[ "Intel", "ISC" ]
10
2019-12-19T01:19:41.000Z
2021-02-18T16:30:29.000Z
higan/target-bsnes/settings/hotkeys.cpp
13824125580/higan
fbdd3f980b65412c362096579869ae76730e4118
[ "Intel", "ISC" ]
null
null
null
higan/target-bsnes/settings/hotkeys.cpp
13824125580/higan
fbdd3f980b65412c362096579869ae76730e4118
[ "Intel", "ISC" ]
null
null
null
auto HotkeySettings::create() -> void { setIcon(Icon::Device::Keyboard); setText("Hotkeys"); layout.setPadding(5); mappingList.setBatchable(); mappingList.setHeadered(); mappingList.onActivate([&] { if(assignButton.enabled()) assignButton.doActivate(); }); mappingList.onChange([&] { auto batched = mappingList.batched(); assignButton.setEnabled(batched.size() == 1); clearButton.setEnabled(batched.size() >= 1); }); mappingList.onSize([&] { mappingList.resizeColumns(); }); assignButton.setText("Assign").onActivate([&] { assignMapping(); }); clearButton.setText("Clear").onActivate([&] { for(auto item : mappingList.batched()) { inputManager.hotkeys[item.offset()].unbind(); } refreshMappings(); }); } auto HotkeySettings::reloadMappings() -> void { mappingList.reset(); mappingList.append(TableViewColumn().setText("Name")); mappingList.append(TableViewColumn().setText("Mapping").setExpandable()); for(auto& hotkey : inputManager.hotkeys) { mappingList.append(TableViewItem() .append(TableViewCell().setText(hotkey.name).setFont(Font().setBold()).setBackgroundColor({240, 240, 255})) .append(TableViewCell()) ); } refreshMappings(); mappingList.doChange(); } auto HotkeySettings::refreshMappings() -> void { uint index = 0; for(auto& hotkey : inputManager.hotkeys) { mappingList.item(index++).cell(1).setText(hotkey.displayName()); } mappingList.resizeColumns(); } auto HotkeySettings::assignMapping() -> void { inputManager.poll(); //clear any pending events first if(auto item = mappingList.selected()) { activeMapping = inputManager.hotkeys[item.offset()]; settingsWindow.layout.setEnabled(false); settingsWindow.statusBar.setText({"Press a key or button to map [", activeMapping->name, "] ..."}); settingsWindow.setDismissable(false); } } auto HotkeySettings::cancelMapping() -> void { activeMapping.reset(); settingsWindow.statusBar.setText(); settingsWindow.layout.setEnabled(); settingsWindow.doSize(); settingsWindow.setDismissable(true); } auto HotkeySettings::inputEvent(shared_pointer<HID::Device> device, uint group, uint input, int16 oldValue, int16 newValue) -> void { if(!activeMapping) return; if(device->isMouse()) return; if(activeMapping->bind(device, group, input, oldValue, newValue)) { activeMapping.reset(); settingsWindow.statusBar.setText("Mapping assigned."); refreshMappings(); timer.onActivate([&] { timer.setEnabled(false); cancelMapping(); }).setInterval(200).setEnabled(); } }
30.717647
133
0.692838
13824125580
432ebabcf62086404963b5b3d0bcd883448fcd26
5,214
hpp
C++
PathTracer/src/GDIWindow.hpp
Guarneri1743/PathTracer
2eb4297ddbc425771dde5575fc67c054395b240d
[ "MIT" ]
null
null
null
PathTracer/src/GDIWindow.hpp
Guarneri1743/PathTracer
2eb4297ddbc425771dde5575fc67c054395b240d
[ "MIT" ]
null
null
null
PathTracer/src/GDIWindow.hpp
Guarneri1743/PathTracer
2eb4297ddbc425771dde5575fc67c054395b240d
[ "MIT" ]
null
null
null
#ifndef _GDI_WINDOW_ #define _GDI_WINDOW_ namespace Guarneri { static LRESULT event_callback(HWND, UINT, WPARAM, LPARAM); static bool closed; class GDIWindow { public: void* framebuffer; int width; int height; float aspect; LPCSTR title; LPCSTR name; bool initialized; int buffer_size; HWND window_handle; HDC window_device_context; HBITMAP bitmap_handle; HBITMAP original_handle; int text_start = 16; public: void initialize(int w, int h, LPCSTR title_str, LRESULT(*event_callback)(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)); void set_title(LPCSTR _title); void draw_text(const int& w, const int& h, LPCSTR text); bool is_valid(); void flush(); void get_mouse_position(float& x, float& y, int& xi, int& yi); RECT get_rect(); void dispose(); void send_message(); }; void GDIWindow::initialize(int w, int h, LPCSTR title_str, LRESULT(*event_callback)(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)) { if (initialized) { return; } this->width = w; this->height = h; this->aspect = (float)w / (float)h; this->title = title_str; this->name = title_str; buffer_size = width * height * 4; window_handle = nullptr; window_device_context = nullptr; framebuffer = nullptr; bitmap_handle = nullptr; closed = false; WNDCLASS win_class; win_class.style = CS_BYTEALIGNCLIENT; win_class.lpfnWndProc = (WNDPROC)event_callback; win_class.cbClsExtra = 0; win_class.cbWndExtra = 0; win_class.hInstance = GetModuleHandle(nullptr); win_class.hIcon = nullptr; win_class.hCursor = LoadCursor(nullptr, IDC_ARROW); win_class.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); win_class.lpszMenuName = title; win_class.lpszClassName = name; BITMAPINFO bitmap_info; BITMAPINFOHEADER bitmap_header; bitmap_header.biSize = sizeof(BITMAPINFOHEADER); bitmap_header.biWidth = width; bitmap_header.biHeight = height; bitmap_header.biPlanes = 1; bitmap_header.biBitCount = 32; bitmap_header.biCompression = BI_RGB; bitmap_header.biSizeImage = buffer_size; bitmap_header.biXPelsPerMeter = 0; bitmap_header.biYPelsPerMeter = 0; bitmap_header.biClrUsed = 0; bitmap_header.biClrImportant = 0; bitmap_info.bmiHeader = bitmap_header; RegisterClass(&win_class); window_handle = CreateWindow(name, title, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, 0, 0, 0, 0, nullptr, nullptr, win_class.hInstance, nullptr); HDC hDC = GetDC(window_handle); window_device_context = CreateCompatibleDC(hDC); ReleaseDC(window_handle, hDC); LPVOID buffer; bitmap_handle = CreateDIBSection(window_device_context, &bitmap_info, DIB_RGB_COLORS, &buffer, 0, 0); if (bitmap_handle != nullptr) { original_handle = (HBITMAP)SelectObject(window_device_context, bitmap_handle); } framebuffer = (void*)buffer; memset(framebuffer, 0, buffer_size); RECT rect = { 0, 0, width, height }; AdjustWindowRect(&rect, GetWindowLong(window_handle, GWL_STYLE), 0); int real_width = rect.right - rect.left; int real_height = rect.bottom - rect.top; int window_x = (GetSystemMetrics(SM_CXSCREEN) - real_width) / 2; int window_y = (GetSystemMetrics(SM_CYSCREEN) - real_height) / 2; SetWindowPos(window_handle, nullptr, window_x, window_y, real_width, real_height, (SWP_NOCOPYBITS | SWP_NOZORDER | SWP_SHOWWINDOW)); SetForegroundWindow(window_handle); ShowWindow(window_handle, SW_NORMAL); // window initialized initialized = true; } void GDIWindow::set_title(LPCSTR _title) { SetWindowText(window_handle, _title); } void GDIWindow::draw_text(const int& w, const int& h, LPCSTR text) { RECT rect; rect.left = 1; rect.right = 1 + w; rect.bottom = text_start - h; rect.top = text_start; DrawText(window_device_context, text, -1, &rect, DT_SINGLELINE | DT_LEFT | DT_VCENTER); text_start += h - 4; } bool GDIWindow::is_valid() { return !closed; } void GDIWindow::flush() { text_start = 16; HDC hDC = GetDC(window_handle); BitBlt(hDC, 0, 0, width, height, window_device_context, 0, 0, SRCCOPY); ReleaseDC(window_handle, hDC); send_message(); } void GDIWindow::get_mouse_position(float& x, float& y, int& xi, int& yi) { POINT pt; if (GetCursorPos(&pt)) { ScreenToClient(window_handle, &pt); xi = (int)pt.x; yi = (int)pt.y; x = (float)pt.x / (float)this->width; y = (float)pt.y / (float)this->height; } } RECT GDIWindow::get_rect() { RECT rect; if (GetWindowRect(window_handle, &rect)) { return rect; } return rect; } void GDIWindow::dispose() { if (original_handle) { SelectObject(window_device_context, original_handle); original_handle = nullptr; } if (window_device_context) { DeleteDC(window_device_context); window_device_context = nullptr; } if (bitmap_handle) { DeleteObject(bitmap_handle); bitmap_handle = nullptr; } if (window_handle) { CloseWindow(window_handle); window_handle = nullptr; } closed = true; } void GDIWindow::send_message() { MSG msg; while (1) { if (!PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) break; if (!GetMessage(&msg, nullptr, 0, 0)) break; DispatchMessage(&msg); } } } #endif
25.684729
162
0.71097
Guarneri1743
432f3d25a1dc81fab25c7e663e92e05d21de5d10
1,006
cpp
C++
mIon/Engine.cpp
Svensational/mIon
e72aec811a60592b9e7f5bf456bede83fc8ef509
[ "MIT" ]
null
null
null
mIon/Engine.cpp
Svensational/mIon
e72aec811a60592b9e7f5bf456bede83fc8ef509
[ "MIT" ]
null
null
null
mIon/Engine.cpp
Svensational/mIon
e72aec811a60592b9e7f5bf456bede83fc8ef509
[ "MIT" ]
null
null
null
#include "Engine.h" #include <thread> namespace mion { Engine * Engine::s_pInstance = nullptr; Engine::Engine() : m_bRunning( false ), m_pWindow( nullptr ) { } Engine::~Engine() { } Engine * const Engine::getInstance() { return s_pInstance; } void Engine::renderLoop() { const std::chrono::high_resolution_clock::duration dur = std::chrono::nanoseconds( 1000000000 / 60 ); std::chrono::high_resolution_clock::time_point tp; while ( m_bRunning ) { tp = std::chrono::high_resolution_clock::now() + dur; // do stuff! std::this_thread::sleep_until( tp ); } } void Engine::logicLoop() { const std::chrono::high_resolution_clock::duration dur = std::chrono::nanoseconds( 1000000000 / ( 60 * 4 ) ); std::chrono::high_resolution_clock::time_point tp; while ( m_bRunning ) { tp = std::chrono::high_resolution_clock::now() + dur; // do stuff! std::this_thread::sleep_until( tp ); } } } // namespace mion
18.981132
113
0.633201
Svensational
43312442df6f0bbff4cb5241d5bf75a40851a09a
5,420
cpp
C++
Examples/Graph.cpp
haskellstudio/belle_old
a5ce86954b61dbacde1d1bf24472d95246be45e5
[ "BSD-2-Clause" ]
null
null
null
Examples/Graph.cpp
haskellstudio/belle_old
a5ce86954b61dbacde1d1bf24472d95246be45e5
[ "BSD-2-Clause" ]
null
null
null
Examples/Graph.cpp
haskellstudio/belle_old
a5ce86954b61dbacde1d1bf24472d95246be45e5
[ "BSD-2-Clause" ]
null
null
null
/* ============================================================================== Copyright 2007-2013 William Andrew Burnson. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY WILLIAM ANDREW BURNSON ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WILLIAM ANDREW BURNSON OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------ This file is part of Belle, Bonne, Sage -- The 'Beautiful, Good, Wise' C++ Vector-Graphics Library for Music Notation ============================================================================== */ /*Include Belle, Bonne, Sage and compile it in this .cpp file. See the previous tutorials for an explanation.*/ #define BELLE_COMPILE_INLINE #include "Belle.h" int main() { //Helper namespaces using namespace prim; using namespace belle; using namespace belle::graph; //Create an empty music graph. Music g; //----------------// //Treble Clef Part// //----------------// /*Create barline, clef, key signature, and time signature tokens. Each token is created and added to its own island (which is a container for tokens).*/ MusicNode b = g.CreateAndAddBarline(); MusicNode c = g.CreateAndAddClef(mica::TrebleClef); MusicNode k = g.CreateAndAddKeySignature(mica::TwoSharps, mica::Major); MusicNode t = g.CreateAndAddTimeSignature(3, prim::Ratio(1, 4)); //Link the clef island from the barline island g.Connect(b, c)->Set(mica::Type) = mica::Partwise; //Link the key signature island from the clef island. g.Connect(c, k)->Set(mica::Type) = mica::Partwise; //Link the time signature island from the key signature island. g.Connect(k, t)->Set(mica::Type) = mica::Partwise; /*Create a quarter-note chord and link its island partwise from the time signature island.*/ MusicNode chord = g.CreateChord(prim::Ratio(3, 4)); g.CreateAndAddNote(chord, mica::D4); g.CreateAndAddNote(chord, mica::FSharp4); MusicNode chordIsland = g.AddChordToNewIsland(chord); g.Connect(t, chordIsland)->Set(mica::Type) = mica::Partwise; //Create a final barline. MusicNode f = g.CreateAndAddBarline(mica::EndBarline); g.Connect(chordIsland, f)->Set(mica::Type) = mica::Partwise; //--------------// //Bass Clef Part// //--------------// /*Create barline, clef, key signature, and time signature tokens. Each token is created and added to its own island (which is a container for tokens).*/ MusicNode b2 = g.CreateAndAddBarline(); MusicNode c2 = g.CreateAndAddClef(mica::BassClef); MusicNode k2 = g.CreateAndAddKeySignature(mica::TwoSharps, mica::Major); MusicNode t2 = g.CreateAndAddTimeSignature(3, prim::Ratio(1, 4)); //Link the clef island from the barline island g.Connect(b2, c2)->Set(mica::Type) = mica::Partwise; //Link the key signature island from the clef island. g.Connect(c2, k2)->Set(mica::Type) = mica::Partwise; //Link the time signature island from the key signature island. g.Connect(k2, t2)->Set(mica::Type) = mica::Partwise; /*Create a quarter-note chord and link its island partwise from the time signature island.*/ MusicNode chord2 = g.CreateChord(prim::Ratio(3, 4)); g.CreateAndAddNote(chord2, mica::D3); g.CreateAndAddNote(chord2, mica::A3); MusicNode chordIsland2= g.AddChordToNewIsland(chord2); g.Connect(t2, chordIsland2)->Set(mica::Type) = mica::Partwise; //Create a final barline. MusicNode f2 = g.CreateAndAddBarline(mica::EndBarline); g.Connect(chordIsland2, f2)->Set(mica::Type) = mica::Partwise; //-------------------------------// //Link Parts Together Instantwise// //-------------------------------// g.Connect(b, b2)->Set(mica::Type) = mica::Instantwise; g.Connect(c, c2)->Set(mica::Type) = mica::Instantwise; g.Connect(k, k2)->Set(mica::Type) = mica::Instantwise; g.Connect(t, t2)->Set(mica::Type) = mica::Instantwise; g.Connect(chordIsland, chordIsland2)->Set(mica::Type) = mica::Instantwise; g.Connect(f, f2)->Set(mica::Type) = mica::Instantwise; /*Export the graph, reimport the graph (as a test of serialization), and show a visualization of it.*/ Music h; h.ImportXML(g.ExportXML()); Utility::OpenGraphVisualization(h); prim::c >> h.ExportXML(); prim::c >> h; return prim::c.Finish(); }
40.75188
80
0.670295
haskellstudio
43354a170b1c217ee5bb68cebe6fab6e2b7b871c
584
cpp
C++
CC/CF/UniqueNumber.cpp
MrRobo24/Codes
9513f42b61e898577123d5b996e43ba7a067a019
[ "MIT" ]
1
2020-10-12T08:03:20.000Z
2020-10-12T08:03:20.000Z
CC/CF/UniqueNumber.cpp
MrRobo24/Codes
9513f42b61e898577123d5b996e43ba7a067a019
[ "MIT" ]
null
null
null
CC/CF/UniqueNumber.cpp
MrRobo24/Codes
9513f42b61e898577123d5b996e43ba7a067a019
[ "MIT" ]
null
null
null
//AC #include <bits/stdc++.h> #define LLI long long using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); LLI t; cin >> t; while (t--) { LLI x; cin >> x; if (x > 45) { cout << -1 << "\n"; continue; } string ans = ""; LLI s = 9; while (x > 0) { if (x < s) { s = x; } x -= s; ans = (char)('0' + s) + ans; s--; } cout << ans << "\n"; } return 0; }
14.6
40
0.333904
MrRobo24
433616b4fd14a9773fcbc76963fa29ec69c08b56
836
cpp
C++
storm/dp_knapsack_bottom-up.cpp
italo-batista/problems-solving
f83ad34f0abebd52925c4020635556f20743ba06
[ "MIT" ]
null
null
null
storm/dp_knapsack_bottom-up.cpp
italo-batista/problems-solving
f83ad34f0abebd52925c4020635556f20743ba06
[ "MIT" ]
null
null
null
storm/dp_knapsack_bottom-up.cpp
italo-batista/problems-solving
f83ad34f0abebd52925c4020635556f20743ba06
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <iostream> #include <cstdlib> #include <algorithm> #define MAX 4000 using namespace std; int n, s, peso[MAX], valor[MAX], dp[MAX][MAX]; int main() { memset(dp, -1, sizeof(dp)); // dp[all i] = -1 cin >> s >> n; for (int i=1; i<=n; i++) { cin >> peso[i] >> valor[i]; } // knapsack algo for (int i=0; i<=n; i++) { int obj = i; for (int j=0; j<=s; j++) { if (i == 0 || j == 0) dp[obj][j] = 0; else { int aguenta = j; int n_coloca = dp[obj-1][aguenta]; if (peso[obj] <= aguenta) { int coloca = valor[obj] + dp[obj-1][aguenta-peso[obj]]; dp[obj][aguenta] = max(coloca, n_coloca); } else { dp[obj][aguenta] = n_coloca; } } } } cout << dp[n][s]; return 0; }
15.481481
60
0.503589
italo-batista
433665e9296f999511098d4171f36eb6d3552a6e
38,083
cpp
C++
src/asdxShader.cpp
ProjectAsura/asdx11
67c3d4129f3e6d32e66c64ee9354d873f99d0eaf
[ "MIT" ]
null
null
null
src/asdxShader.cpp
ProjectAsura/asdx11
67c3d4129f3e6d32e66c64ee9354d873f99d0eaf
[ "MIT" ]
null
null
null
src/asdxShader.cpp
ProjectAsura/asdx11
67c3d4129f3e6d32e66c64ee9354d873f99d0eaf
[ "MIT" ]
null
null
null
//----------------------------------------------------------------------------- // File : asdxShader.h // Desc : Shader Set Module. // Copyright(c) Project Asura. ALl right reserved. //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- #include <asdxShader.h> #include <asdxLogger.h> namespace asdx { /////////////////////////////////////////////////////////////////////////////// // ShaderCBV class /////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- // コンストラクタです. //----------------------------------------------------------------------------- ShaderCBV::ShaderCBV() { /* DO_NOTHING */ } //----------------------------------------------------------------------------- // デストラクタです. //----------------------------------------------------------------------------- ShaderCBV::~ShaderCBV() { Term(); } //----------------------------------------------------------------------------- // 初期化処理を行います. //----------------------------------------------------------------------------- bool ShaderCBV::Init ( ID3D11Device* pDevice, ID3D11ShaderReflectionConstantBuffer* pReflection ) { if (pDevice == nullptr || pReflection == nullptr) { ELOG("Error : Invalid Argument."); return false; } D3D11_SHADER_BUFFER_DESC buf_desc; auto hr = pReflection->GetDesc(&buf_desc); if (FAILED(hr)) { ELOG("Error : ID3D11ShaderReflectionConstantBuffer::GetDesc() Failed. recode = 0x%x", hr); return false; } auto size = buf_desc.Size; m_Memory.resize(size); D3D11_BUFFER_DESC cb_desc = {}; cb_desc.Usage = D3D11_USAGE_DEFAULT; cb_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; cb_desc.ByteWidth = size; cb_desc.CPUAccessFlags = 0; hr = pDevice->CreateBuffer(&cb_desc, nullptr, m_CB.GetAddress()); if (FAILED(hr)) { ELOG("Error : ID3D11Device::CreateBuffer() Failed"); return false; } for(auto i=0u; i<buf_desc.Variables; ++i) { auto pVar = pReflection->GetVariableByIndex(i); if (pVar == nullptr) { continue; } D3D11_SHADER_VARIABLE_DESC var_desc; hr = pVar->GetDesc(&var_desc); if (FAILED(hr)) { continue; } BufferParam param; param.Offset = var_desc.StartOffset; param.Size = var_desc.Size; if (!Contain(var_desc.Name)) { m_ParamMap[var_desc.Name] = param; } auto head = m_Memory.data(); memcpy(head + var_desc.StartOffset, var_desc.DefaultValue, var_desc.Size); } return true; } //----------------------------------------------------------------------------- // 終了処理を行います. //----------------------------------------------------------------------------- void ShaderCBV::Term() { m_CB.Reset(); m_ParamMap.clear(); m_Memory .clear(); } //----------------------------------------------------------------------------- // パラメータを設定します. //----------------------------------------------------------------------------- bool ShaderCBV::SetParam(const char* name, const void* ptr, size_t size) { if (!Contain(name)) { return false; } auto param = m_ParamMap[name]; if (param.Size != size) { return false; } auto head = m_Memory.data(); memcpy(head + param.Offset, ptr, param.Size); return true; } //----------------------------------------------------------------------------- // パラメータを取得します. //----------------------------------------------------------------------------- bool ShaderCBV::GetParam(const char* name, void* ptr, size_t size) const { if (!Contain(name)) { return false; } auto param = m_ParamMap.at(name); if (param.Size != size) { return false; } auto head = m_Memory.data(); memcpy(ptr, head + param.Offset, param.Size); return true; } //----------------------------------------------------------------------------- // 指定されたパラメータ名が含まれるかチェックします. //----------------------------------------------------------------------------- bool ShaderCBV::Contain(const char* name) const { return m_ParamMap.find(name) != m_ParamMap.end(); } //----------------------------------------------------------------------------- // サブリソースを更新します. //----------------------------------------------------------------------------- void ShaderCBV::UpdateSubresource(ID3D11DeviceContext* pContext) { pContext->UpdateSubresource(m_CB.GetPtr(), 0, nullptr, m_Memory.data(), 0, 0); } //----------------------------------------------------------------------------- // バッファを返却します //----------------------------------------------------------------------------- ID3D11Buffer* ShaderCBV::GetPtr() const { return m_CB.GetPtr(); } /////////////////////////////////////////////////////////////////////////////// // VertexShader class /////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- // コンストラクタです. //----------------------------------------------------------------------------- VertexShader::VertexShader() { /* DO_NOTHING */ } //----------------------------------------------------------------------------- // デストラクタです. //----------------------------------------------------------------------------- VertexShader::~VertexShader() { Term(); } //----------------------------------------------------------------------------- // 初期化処理を行います. //----------------------------------------------------------------------------- bool VertexShader::Init ( ID3D11Device* pDevice, const uint8_t* pBinary, size_t binarySize, uint32_t elementCount, const D3D11_INPUT_ELEMENT_DESC* pElements ) { auto hr = pDevice->CreateVertexShader(pBinary, binarySize, nullptr, m_VS.GetAddress()); if (FAILED(hr)) { ELOG("Error : ID3D11Device::CreateVertexShader() Failed."); Term(); return false; } hr = pDevice->CreateInputLayout(pElements, elementCount, pBinary, binarySize, m_IL.GetAddress()); if (FAILED(hr)) { ELOG("Error : ID3D11Device::CreateInputLayout() Failed."); Term(); return false; } hr = D3DReflect(pBinary, binarySize, IID_PPV_ARGS(m_Reflection.GetAddress())); if (FAILED(hr)) { ELOG("Error : D3DReflect() Failed."); Term(); return false; } return true; } //----------------------------------------------------------------------------- // ソースコードから初期化処理を行います. //----------------------------------------------------------------------------- bool VertexShader::Init ( ID3D11Device* pDevice, const wchar_t* path, const char* entryPoint, const char* shaderModel, uint32_t elementCount, const D3D11_INPUT_ELEMENT_DESC* pElements ) { DWORD flag = D3DCOMPILE_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG) flag |= D3DCOMPILE_DEBUG; #else flag |= D3DCOMPILE_OPTIMIZATION_LEVEL3; #endif RefPtr<ID3DBlob> pBlob; RefPtr<ID3DBlob> pErrorBlob; auto hr = D3DCompileFromFile( path, nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, entryPoint, shaderModel, flag, 0, pBlob.GetAddress(), pErrorBlob.GetAddress()); if (FAILED(hr)) { if (pErrorBlob.GetPtr() != nullptr) { ELOGA("Error : D3DCompileFromFile() Failed. msg = %s", pErrorBlob->GetBufferPointer()); } ELOGA("Error : D3DCompileFromFile() errcode = 0x%x", hr); Term(); return false; } return Init( pDevice, reinterpret_cast<uint8_t*>(pBlob->GetBufferPointer()), pBlob->GetBufferSize(), elementCount, pElements); } //----------------------------------------------------------------------------- // ソースコードから初期化処理を行います. //----------------------------------------------------------------------------- bool VertexShader::Init ( ID3D11Device* pDevice, const char* sourceCode, size_t sourceCodeSize, const char* entryPoint, const char* shaderModel, uint32_t elementCount, const D3D11_INPUT_ELEMENT_DESC* pElements ) { DWORD flag = D3DCOMPILE_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG) flag |= D3DCOMPILE_DEBUG; #else flag |= D3DCOMPILE_OPTIMIZATION_LEVEL3; #endif RefPtr<ID3DBlob> pBlob; RefPtr<ID3DBlob> pErrorBlob; auto hr = D3DCompile( sourceCode, sourceCodeSize, "vertex_shader", nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, entryPoint, shaderModel, flag, 0, pBlob.GetAddress(), pErrorBlob.GetAddress()); if (FAILED(hr)) { if (pErrorBlob.GetPtr() != nullptr) { ELOGA("Error : D3DCompileFromFile() Failed. msg = %s", pErrorBlob->GetBufferPointer()); } ELOGA("Error : D3DCompileFromFile() errcode = 0x%x", hr); Term(); return false; } return Init( pDevice, reinterpret_cast<uint8_t*>(pBlob->GetBufferPointer()), pBlob->GetBufferSize(), elementCount, pElements); } //----------------------------------------------------------------------------- // 終了処理を行います. //----------------------------------------------------------------------------- void VertexShader::Term() { m_VS.Reset(); m_IL.Reset(); m_Reflection.Reset(); } //----------------------------------------------------------------------------- // シェーダを設定します. //----------------------------------------------------------------------------- void VertexShader::Bind(ID3D11DeviceContext* pContext) { pContext->IASetInputLayout(m_IL.GetPtr()); pContext->VSSetShader(m_VS.GetPtr(), nullptr, 0); } //----------------------------------------------------------------------------- // シェーダの設定を解除します. //----------------------------------------------------------------------------- void VertexShader::UnBind(ID3D11DeviceContext* pContext) { pContext->IASetInputLayout(nullptr); pContext->VSSetShader(nullptr, nullptr, 0); } //----------------------------------------------------------------------------- // シェーダリフレクションを取得します. //----------------------------------------------------------------------------- ID3D11ShaderReflection* VertexShader::GetReflection() const { return m_Reflection.GetPtr(); } /////////////////////////////////////////////////////////////////////////////// // PixelShader class /////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- // コンストラクタです. //----------------------------------------------------------------------------- PixelShader::PixelShader() { /* DO_NOTHING */ } //----------------------------------------------------------------------------- // デストラクタです. //----------------------------------------------------------------------------- PixelShader::~PixelShader() { Term(); } //----------------------------------------------------------------------------- // 初期化処理を行います. //----------------------------------------------------------------------------- bool PixelShader::Init(ID3D11Device* pDevice, const uint8_t* pBinary, size_t binarySize) { auto hr = pDevice->CreatePixelShader(pBinary, binarySize, nullptr, m_PS.GetAddress()); if (FAILED(hr)) { ELOG("Error : ID3D11Device::CreatePixelShader() Failed."); Term(); return false; } hr = D3DReflect(pBinary, binarySize, IID_PPV_ARGS(m_Reflection.GetAddress())); if (FAILED(hr)) { ELOG("Error : D3DReflect() Failed."); Term(); return false; } return true; } //----------------------------------------------------------------------------- // ソースコードから初期化処理を行います. //----------------------------------------------------------------------------- bool PixelShader::Init ( ID3D11Device* pDevice, const wchar_t* path, const char* entryPoint, const char* shaderModel ) { DWORD flag = D3DCOMPILE_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG) flag |= D3DCOMPILE_DEBUG; #else flag |= D3DCOMPILE_OPTIMIZATION_LEVEL3; #endif RefPtr<ID3DBlob> pBlob; RefPtr<ID3DBlob> pErrorBlob; auto hr = D3DCompileFromFile( path, nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, entryPoint, shaderModel, flag, 0, pBlob.GetAddress(), pErrorBlob.GetAddress()); if (FAILED(hr)) { if (pErrorBlob.GetPtr() != nullptr) { ELOGA("Error : D3DCompileFromFile() Failed. msg = %s", pErrorBlob->GetBufferPointer()); } ELOGA("Error : D3DCompileFromFile() errcode = 0x%x", hr); Term(); return false; } return Init( pDevice, reinterpret_cast<uint8_t*>(pBlob->GetBufferPointer()), pBlob->GetBufferSize()); } //----------------------------------------------------------------------------- // ソースコードから初期化処理を行います. //----------------------------------------------------------------------------- bool PixelShader::Init ( ID3D11Device* pDevice, const char* sourceCode, size_t sourceCodeSize, const char* entryPoint, const char* shaderModel ) { DWORD flag = D3DCOMPILE_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG) flag |= D3DCOMPILE_DEBUG; #else flag |= D3DCOMPILE_OPTIMIZATION_LEVEL3; #endif RefPtr<ID3DBlob> pBlob; RefPtr<ID3DBlob> pErrorBlob; auto hr = D3DCompile( sourceCode, sourceCodeSize, "pixel_shader", nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, entryPoint, shaderModel, flag, 0, pBlob.GetAddress(), pErrorBlob.GetAddress()); if (FAILED(hr)) { if (pErrorBlob.GetPtr() != nullptr) { ELOGA("Error : D3DCompileFromFile() Failed. msg = %s", pErrorBlob->GetBufferPointer()); } ELOGA("Error : D3DCompileFromFile() errcode = 0x%x", hr); Term(); return false; } return Init( pDevice, reinterpret_cast<uint8_t*>(pBlob->GetBufferPointer()), pBlob->GetBufferSize()); } //----------------------------------------------------------------------------- // 終了処理を行います. //----------------------------------------------------------------------------- void PixelShader::Term() { m_PS.Reset(); m_Reflection.Reset(); } //----------------------------------------------------------------------------- // シェーダを設定します. //----------------------------------------------------------------------------- void PixelShader::Bind(ID3D11DeviceContext* pContext) { pContext->PSSetShader(m_PS.GetPtr(), nullptr, 0); } //----------------------------------------------------------------------------- // シェーダの設定を解除します. //----------------------------------------------------------------------------- void PixelShader::UnBind(ID3D11DeviceContext* pContext) { pContext->PSSetShader(nullptr, nullptr, 0); } //----------------------------------------------------------------------------- // シェーダリフレクションを取得します. //----------------------------------------------------------------------------- ID3D11ShaderReflection* PixelShader::GetReflection() const { return m_Reflection.GetPtr(); } /////////////////////////////////////////////////////////////////////////////// // GeometryShader class /////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- // コンストラクタです. //----------------------------------------------------------------------------- GeometryShader::GeometryShader() { /* DO_NOTHING */ } //----------------------------------------------------------------------------- // デストラクタです. //----------------------------------------------------------------------------- GeometryShader::~GeometryShader() { Term(); } //----------------------------------------------------------------------------- // 初期化処理を行います. //----------------------------------------------------------------------------- bool GeometryShader::Init(ID3D11Device* pDevice, const uint8_t* pBinary, size_t binarySize) { auto hr = pDevice->CreateGeometryShader(pBinary, binarySize, nullptr, m_GS.GetAddress()); if (FAILED(hr)) { ELOG("Error : ID3D11Device::CreateGeometryShader() Failed."); Term(); return false; } hr = D3DReflect(pBinary, binarySize, IID_PPV_ARGS(m_Reflection.GetAddress())); if (FAILED(hr)) { ELOG("Error : D3DReflect() Failed."); Term(); return false; } return true; } //----------------------------------------------------------------------------- // ソースコードから初期化処理を行います. //----------------------------------------------------------------------------- bool GeometryShader::Init ( ID3D11Device* pDevice, const wchar_t* path, const char* entryPoint, const char* shaderModel ) { DWORD flag = D3DCOMPILE_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG) flag |= D3DCOMPILE_DEBUG; #else flag |= D3DCOMPILE_OPTIMIZATION_LEVEL3; #endif RefPtr<ID3DBlob> pBlob; RefPtr<ID3DBlob> pErrorBlob; auto hr = D3DCompileFromFile( path, nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, entryPoint, shaderModel, flag, 0, pBlob.GetAddress(), pErrorBlob.GetAddress()); if (FAILED(hr)) { if (pErrorBlob.GetPtr() != nullptr) { ELOGA("Error : D3DCompileFromFile() Failed. msg = %s", pErrorBlob->GetBufferPointer()); } ELOGA("Error : D3DCompileFromFile() errcode = 0x%x", hr); Term(); return false; } return Init( pDevice, reinterpret_cast<uint8_t*>(pBlob->GetBufferPointer()), pBlob->GetBufferSize()); } //----------------------------------------------------------------------------- // ソースコードから初期化処理を行います. //----------------------------------------------------------------------------- bool GeometryShader::Init ( ID3D11Device* pDevice, const char* sourceCode, size_t sourceCodeSize, const char* entryPoint, const char* shaderModel ) { DWORD flag = D3DCOMPILE_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG) flag |= D3DCOMPILE_DEBUG; #else flag |= D3DCOMPILE_OPTIMIZATION_LEVEL3; #endif RefPtr<ID3DBlob> pBlob; RefPtr<ID3DBlob> pErrorBlob; auto hr = D3DCompile( sourceCode, sourceCodeSize, "geometry_shader", nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, entryPoint, shaderModel, flag, 0, pBlob.GetAddress(), pErrorBlob.GetAddress()); if (FAILED(hr)) { if (pErrorBlob.GetPtr() != nullptr) { ELOGA("Error : D3DCompileFromFile() Failed. msg = %s", pErrorBlob->GetBufferPointer()); } ELOGA("Error : D3DCompileFromFile() errcode = 0x%x", hr); Term(); return false; } return Init( pDevice, reinterpret_cast<uint8_t*>(pBlob->GetBufferPointer()), pBlob->GetBufferSize()); } //----------------------------------------------------------------------------- // 終了処理を行います. //----------------------------------------------------------------------------- void GeometryShader::Term() { m_GS.Reset(); m_Reflection.Reset(); } //----------------------------------------------------------------------------- // シェーダを設定します. //----------------------------------------------------------------------------- void GeometryShader::Bind(ID3D11DeviceContext* pContext) { pContext->GSSetShader(m_GS.GetPtr(), nullptr, 0); } //----------------------------------------------------------------------------- // シェーダの設定を解除します. //----------------------------------------------------------------------------- void GeometryShader::UnBind(ID3D11DeviceContext* pContext) { pContext->GSSetShader(nullptr, nullptr, 0); } //----------------------------------------------------------------------------- // シェーダリフレクションを取得します. //----------------------------------------------------------------------------- ID3D11ShaderReflection* GeometryShader::GetReflection() const { return m_Reflection.GetPtr(); } /////////////////////////////////////////////////////////////////////////////// // HullShader class /////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- // コンストラクタです. //----------------------------------------------------------------------------- HullShader::HullShader() { /* DO_NOTHING */ } //----------------------------------------------------------------------------- // デストラクタです. //----------------------------------------------------------------------------- HullShader::~HullShader() { Term(); } //----------------------------------------------------------------------------- // 初期化処理を行います. //----------------------------------------------------------------------------- bool HullShader::Init(ID3D11Device* pDevice, const uint8_t* pBinary, size_t binarySize) { auto hr = pDevice->CreateHullShader(pBinary, binarySize, nullptr, m_HS.GetAddress()); if (FAILED(hr)) { ELOG("Error : ID3D11Device::CreatePixelShader() Failed."); Term(); return false; } hr = D3DReflect(pBinary, binarySize, IID_PPV_ARGS(m_Reflection.GetAddress())); if (FAILED(hr)) { ELOG("Error : D3DReflect() Failed."); Term(); return false; } return true; } //----------------------------------------------------------------------------- // ソースコードから初期化処理を行います. //----------------------------------------------------------------------------- bool HullShader::Init ( ID3D11Device* pDevice, const wchar_t* path, const char* entryPoint, const char* shaderModel ) { DWORD flag = D3DCOMPILE_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG) flag |= D3DCOMPILE_DEBUG; #else flag |= D3DCOMPILE_OPTIMIZATION_LEVEL3; #endif RefPtr<ID3DBlob> pBlob; RefPtr<ID3DBlob> pErrorBlob; auto hr = D3DCompileFromFile( path, nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, entryPoint, shaderModel, flag, 0, pBlob.GetAddress(), pErrorBlob.GetAddress()); if (FAILED(hr)) { if (pErrorBlob.GetPtr() != nullptr) { ELOGA("Error : D3DCompileFromFile() Failed. msg = %s", pErrorBlob->GetBufferPointer()); } ELOGA("Error : D3DCompileFromFile() errcode = 0x%x", hr); Term(); return false; } return Init( pDevice, reinterpret_cast<uint8_t*>(pBlob->GetBufferPointer()), pBlob->GetBufferSize()); } //----------------------------------------------------------------------------- // ソースコードから初期化処理を行います. //----------------------------------------------------------------------------- bool HullShader::Init ( ID3D11Device* pDevice, const char* sourceCode, size_t sourceCodeSize, const char* entryPoint, const char* shaderModel ) { DWORD flag = D3DCOMPILE_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG) flag |= D3DCOMPILE_DEBUG; #else flag |= D3DCOMPILE_OPTIMIZATION_LEVEL3; #endif RefPtr<ID3DBlob> pBlob; RefPtr<ID3DBlob> pErrorBlob; auto hr = D3DCompile( sourceCode, sourceCodeSize, "hull_shader", nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, entryPoint, shaderModel, flag, 0, pBlob.GetAddress(), pErrorBlob.GetAddress()); if (FAILED(hr)) { if (pErrorBlob.GetPtr() != nullptr) { ELOGA("Error : D3DCompileFromFile() Failed. msg = %s", pErrorBlob->GetBufferPointer()); } ELOGA("Error : D3DCompileFromFile() errcode = 0x%x", hr); Term(); return false; } return Init( pDevice, reinterpret_cast<uint8_t*>(pBlob->GetBufferPointer()), pBlob->GetBufferSize()); } //----------------------------------------------------------------------------- // 終了処理を行います. //----------------------------------------------------------------------------- void HullShader::Term() { m_HS.Reset(); m_Reflection.Reset(); } //----------------------------------------------------------------------------- // シェーダを設定します. //----------------------------------------------------------------------------- void HullShader::Bind(ID3D11DeviceContext* pContext) { pContext->HSSetShader(m_HS.GetPtr(), nullptr, 0); } //----------------------------------------------------------------------------- // シェーダの設定を解除します. //----------------------------------------------------------------------------- void HullShader::UnBind(ID3D11DeviceContext* pContext) { pContext->HSSetShader(nullptr, nullptr, 0); } //----------------------------------------------------------------------------- // シェーダリフレクションを取得します. //----------------------------------------------------------------------------- ID3D11ShaderReflection* HullShader::GetReflection() const { return m_Reflection.GetPtr(); } /////////////////////////////////////////////////////////////////////////////// // DomainShader class /////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- // コンストラクタです. //----------------------------------------------------------------------------- DomainShader::DomainShader() { /* DO_NOTHING */ } //----------------------------------------------------------------------------- // デストラクタです. //----------------------------------------------------------------------------- DomainShader::~DomainShader() { Term(); } //----------------------------------------------------------------------------- // 初期化処理を行います. //----------------------------------------------------------------------------- bool DomainShader::Init(ID3D11Device* pDevice, const uint8_t* pBinary, size_t binarySize) { auto hr = pDevice->CreateDomainShader(pBinary, binarySize, nullptr, m_DS.GetAddress()); if (FAILED(hr)) { ELOG("Error : ID3D11Device::CreateDomainShader() Failed."); Term(); return false; } hr = D3DReflect(pBinary, binarySize, IID_PPV_ARGS(m_Reflection.GetAddress())); if (FAILED(hr)) { ELOG("Error : D3DReflect() Failed."); Term(); return false; } return true; } //----------------------------------------------------------------------------- // ソースコードから初期化処理を行います. //----------------------------------------------------------------------------- bool DomainShader::Init ( ID3D11Device* pDevice, const wchar_t* path, const char* entryPoint, const char* shaderModel ) { DWORD flag = D3DCOMPILE_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG) flag |= D3DCOMPILE_DEBUG; #else flag |= D3DCOMPILE_OPTIMIZATION_LEVEL3; #endif RefPtr<ID3DBlob> pBlob; RefPtr<ID3DBlob> pErrorBlob; auto hr = D3DCompileFromFile( path, nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, entryPoint, shaderModel, flag, 0, pBlob.GetAddress(), pErrorBlob.GetAddress()); if (FAILED(hr)) { if (pErrorBlob.GetPtr() != nullptr) { ELOGA("Error : D3DCompileFromFile() Failed. msg = %s", pErrorBlob->GetBufferPointer()); } ELOGA("Error : D3DCompileFromFile() errcode = 0x%x", hr); Term(); return false; } return Init( pDevice, reinterpret_cast<uint8_t*>(pBlob->GetBufferPointer()), pBlob->GetBufferSize()); } //----------------------------------------------------------------------------- // ソースコードから初期化処理を行います. //----------------------------------------------------------------------------- bool DomainShader::Init ( ID3D11Device* pDevice, const char* sourceCode, size_t sourceCodeSize, const char* entryPoint, const char* shaderModel ) { DWORD flag = D3DCOMPILE_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG) flag |= D3DCOMPILE_DEBUG; #else flag |= D3DCOMPILE_OPTIMIZATION_LEVEL3; #endif RefPtr<ID3DBlob> pBlob; RefPtr<ID3DBlob> pErrorBlob; auto hr = D3DCompile( sourceCode, sourceCodeSize, "domain_shader", nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, entryPoint, shaderModel, flag, 0, pBlob.GetAddress(), pErrorBlob.GetAddress()); if (FAILED(hr)) { if (pErrorBlob.GetPtr() != nullptr) { ELOGA("Error : D3DCompileFromFile() Failed. msg = %s", pErrorBlob->GetBufferPointer()); } ELOGA("Error : D3DCompileFromFile() errcode = 0x%x", hr); Term(); return false; } return Init( pDevice, reinterpret_cast<uint8_t*>(pBlob->GetBufferPointer()), pBlob->GetBufferSize()); } //----------------------------------------------------------------------------- // 終了処理を行います. //----------------------------------------------------------------------------- void DomainShader::Term() { m_DS.Reset(); m_Reflection.Reset(); } //----------------------------------------------------------------------------- // シェーダを設定します. //----------------------------------------------------------------------------- void DomainShader::Bind(ID3D11DeviceContext* pContext) { pContext->DSSetShader(m_DS.GetPtr(), nullptr, 0); } //----------------------------------------------------------------------------- // シェーダの設定を解除します. //----------------------------------------------------------------------------- void DomainShader::UnBind(ID3D11DeviceContext* pContext) { pContext->DSSetShader(nullptr, nullptr, 0); } //----------------------------------------------------------------------------- // シェーダリフレクションを取得します. //----------------------------------------------------------------------------- ID3D11ShaderReflection* DomainShader::GetReflection() const { return m_Reflection.GetPtr(); } /////////////////////////////////////////////////////////////////////////////// // ComputeShader class /////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- // コンストラクタです. //----------------------------------------------------------------------------- ComputeShader::ComputeShader() : m_ThreadX(0) , m_ThreadY(0) , m_ThreadZ(0) { /* DO_NOTHING */ } //----------------------------------------------------------------------------- // デストラクタです. //----------------------------------------------------------------------------- ComputeShader::~ComputeShader() { Term(); } //----------------------------------------------------------------------------- // 初期化処理を行います. //----------------------------------------------------------------------------- bool ComputeShader::Init(ID3D11Device* pDevice, const uint8_t* pBinary, size_t binarySize) { auto hr = pDevice->CreateComputeShader(pBinary, binarySize, nullptr, m_CS.GetAddress()); if (FAILED(hr)) { ELOG("Error : ID3D11Device::CreatePixelShader() Failed."); Term(); return false; } hr = D3DReflect(pBinary, binarySize, IID_PPV_ARGS(m_Reflection.GetAddress())); if (FAILED(hr)) { ELOG("Error : D3DReflect() Failed."); Term(); return false; } m_Reflection->GetThreadGroupSize(&m_ThreadX, &m_ThreadY, &m_ThreadZ); return true; } //----------------------------------------------------------------------------- // ソースコードから初期化処理を行います. //----------------------------------------------------------------------------- bool ComputeShader::Init ( ID3D11Device* pDevice, const wchar_t* path, const char* entryPoint, const char* shaderModel ) { DWORD flag = D3DCOMPILE_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG) flag |= D3DCOMPILE_DEBUG; #else flag |= D3DCOMPILE_OPTIMIZATION_LEVEL3; #endif RefPtr<ID3DBlob> pBlob; RefPtr<ID3DBlob> pErrorBlob; auto hr = D3DCompileFromFile( path, nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, entryPoint, shaderModel, flag, 0, pBlob.GetAddress(), pErrorBlob.GetAddress()); if (FAILED(hr)) { if (pErrorBlob.GetPtr() != nullptr) { ELOGA("Error : D3DCompileFromFile() Failed. msg = %s", pErrorBlob->GetBufferPointer()); } ELOGA("Error : D3DCompileFromFile() errcode = 0x%x", hr); Term(); return false; } return Init( pDevice, reinterpret_cast<uint8_t*>(pBlob->GetBufferPointer()), pBlob->GetBufferSize()); } //----------------------------------------------------------------------------- // ソースコードから初期化処理を行います. //----------------------------------------------------------------------------- bool ComputeShader::Init ( ID3D11Device* pDevice, const char* sourceCode, size_t sourceCodeSize, const char* entryPoint, const char* shaderModel ) { DWORD flag = D3DCOMPILE_ENABLE_STRICTNESS; #if defined(DEBUG) || defined(_DEBUG) flag |= D3DCOMPILE_DEBUG; #else flag |= D3DCOMPILE_OPTIMIZATION_LEVEL3; #endif RefPtr<ID3DBlob> pBlob; RefPtr<ID3DBlob> pErrorBlob; auto hr = D3DCompile( sourceCode, sourceCodeSize, "compute_shader", nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, entryPoint, shaderModel, flag, 0, pBlob.GetAddress(), pErrorBlob.GetAddress()); if (FAILED(hr)) { if (pErrorBlob.GetPtr() != nullptr) { ELOGA("Error : D3DCompileFromFile() Failed. msg = %s", pErrorBlob->GetBufferPointer()); } ELOGA("Error : D3DCompileFromFile() errcode = 0x%x", hr); Term(); return false; } return Init( pDevice, reinterpret_cast<uint8_t*>(pBlob->GetBufferPointer()), pBlob->GetBufferSize()); } //----------------------------------------------------------------------------- // 終了処理を行います. //----------------------------------------------------------------------------- void ComputeShader::Term() { m_CS.Reset(); m_Reflection.Reset(); m_ThreadX = m_ThreadY = m_ThreadZ = 0; } //----------------------------------------------------------------------------- // シェーダを設定します. //----------------------------------------------------------------------------- void ComputeShader::Bind(ID3D11DeviceContext* pContext) { pContext->CSSetShader(m_CS.GetPtr(), nullptr, 0); } //----------------------------------------------------------------------------- // シェーダの設定を解除します. //----------------------------------------------------------------------------- void ComputeShader::UnBind(ID3D11DeviceContext* pContext) { pContext->CSSetShader(nullptr, nullptr, 0); } //----------------------------------------------------------------------------- // ディスパッチします. //----------------------------------------------------------------------------- void ComputeShader::Dispatch(ID3D11DeviceContext* pContext) { pContext->Dispatch(m_ThreadX, m_ThreadY, m_ThreadZ); } //----------------------------------------------------------------------------- // シェーダリフレクションを取得します. //----------------------------------------------------------------------------- ID3D11ShaderReflection* ComputeShader::GetReflection() const { return m_Reflection.GetPtr(); } } // namespace asdx
30.712097
102
0.401675
ProjectAsura
4337b08acc7c11d11f0080fecfdd8a9033effeee
50,009
cxx
C++
src/decomposition/path/path.cxx
huttered40/critter
50609be057ff62b8f9f8018355736749bc83cfc9
[ "BSD-2-Clause" ]
1
2021-09-12T01:44:43.000Z
2021-09-12T01:44:43.000Z
src/decomposition/path/path.cxx
huttered40/critter
50609be057ff62b8f9f8018355736749bc83cfc9
[ "BSD-2-Clause" ]
20
2020-02-29T03:12:33.000Z
2020-12-21T17:43:34.000Z
src/decomposition/path/path.cxx
huttered40/critter
50609be057ff62b8f9f8018355736749bc83cfc9
[ "BSD-2-Clause" ]
1
2020-07-21T11:52:54.000Z
2020-07-21T11:52:54.000Z
#include "path.h" #include "../container/symbol_tracker.h" #include "../../discretization/util/util.h" #include "../util/util.h" #include "../../util/util.h" namespace critter{ namespace internal{ namespace decomposition{ void path::exchange_communicators(MPI_Comm oldcomm, MPI_Comm newcomm){ // Accumulate the computation time between last communication routine // as both execution-time and computation time into both // the execution-time critical path data structures and the // per-process data structures. volatile auto curtime = MPI_Wtime(); auto save_comp_time = curtime - computation_timer; if (mode==1){ cp_costs[num_cp_measures-1] += save_comp_time; cp_costs[num_cp_measures-3] += save_comp_time; vol_costs[num_vol_measures-1] += save_comp_time; vol_costs[num_vol_measures-3] += save_comp_time; if (path_decomposition == 1){ for (size_t i=0; i<path_count; i++){ cp_costs[cp_costs_size-path_count-1-i] += save_comp_time; } } if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ // Get the current symbol's execution-time since last // communication routine or its inception. // Accumulate as both execution-time and computation time // into both the execution-time critical path data structures // and the per-process data structures. auto last_symbol_time = curtime - symbol_timers[symbol_stack.top()].start_timer.top(); for (auto i=0; i<path_count; i++){ for (auto j=0; j<path_measure_index.size(); j++){ if (path_measure_index[j] == path_measure_select.size()-1){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += last_symbol_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += last_symbol_time; } else if (path_measure_index[j] == path_measure_select.size()-2){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += last_symbol_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += last_symbol_time; } } } symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-1] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-2] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-1] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-2] += last_symbol_time; } } if (mode==1){ computation_timer = MPI_Wtime(); if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ symbol_timers[symbol_stack.top()].start_timer.top() = computation_timer; } } } bool path::initiate_comp(size_t id, volatile double curtime, float flop_count, int param1, int param2, int param3, int param4, int param5){ // accumulate computation time auto save_comp_time = curtime - computation_timer; cp_costs[num_cp_measures-3] += save_comp_time; cp_costs[num_cp_measures-1] += save_comp_time; vol_costs[num_vol_measures-3] += save_comp_time; vol_costs[num_vol_measures-1] += save_comp_time; if (path_decomposition == 1){ for (size_t i=0; i<path_count; i++){ cp_costs[cp_costs_size-path_count-1-i] += save_comp_time; } } if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ // Get the current symbol's execution-time since last // communication routine or its inception. // Accumulate as both execution-time and computation time // into both the execution-time critical path data structures // and the per-process data structures. auto last_symbol_time = curtime - symbol_timers[symbol_stack.top()].start_timer.top(); for (auto i=0; i<path_count; i++){ for (auto j=0; j<path_measure_index.size(); j++){ if (path_measure_index[j] == path_measure_select.size()-1){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += last_symbol_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += last_symbol_time; } else if (path_measure_index[j] == path_measure_select.size()-2){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += last_symbol_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += last_symbol_time; } } } symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-1] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-2] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-1] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-2] += last_symbol_time; } // start compunication timer for compunication routine comp_start_time = MPI_Wtime(); return true; } void path::complete_comp(double errtime, size_t id, float flop_count, int param1, int param2, int param3, int param4, int param5){ volatile auto comp_time = MPI_Wtime() - comp_start_time - errtime; // complete computation time // Save kernel information if (autotuning_debug == 1){ comp_kernel_key key(-1,id,flop_count,param1,param2,param3,param4,param5); if (comp_kernel_info.find(key) == comp_kernel_info.end()){ comp_kernel_info[key] = std::make_pair(1,comp_time); } else{ comp_kernel_info[key].first++; comp_kernel_info[key].second += comp_time; } } // Decompose measurements along multiple paths by symbol if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ for (auto i=0; i<path_count; i++){ for (auto j=0; j<path_measure_index.size(); j++){ if (path_measure_index[j] == path_measure_select.size()-5){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += flop_count; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += flop_count; } else if (path_measure_index[j] == path_measure_select.size()-2){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += comp_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += comp_time; } else if (path_measure_index[j] == path_measure_select.size()-1){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += comp_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += comp_time; } } } symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-5] += flop_count; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-5] += flop_count; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-2] += comp_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-2] += comp_time; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-1] += comp_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-1] += comp_time; } cp_costs[num_cp_measures-6] += flop_count; cp_costs[num_cp_measures-3] += comp_time; cp_costs[num_cp_measures-2] += comp_time; cp_costs[num_cp_measures-1] += comp_time; if (path_decomposition == 1){ for (size_t i=0; i<path_count; i++){ cp_costs[cp_costs_size-1-i] += comp_time; } for (size_t i=0; i<path_count; i++){ cp_costs[cp_costs_size-path_count-1-i] += comp_time; } for (size_t i=0; i<path_count; i++){ cp_costs[cp_costs_size-3*path_count-1-i] += flop_count; } } vol_costs[num_vol_measures-7] += flop_count; vol_costs[num_vol_measures-3] += comp_time; vol_costs[num_vol_measures-2] += comp_time; vol_costs[num_vol_measures-1] += comp_time; computation_timer = MPI_Wtime(); if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ symbol_timers[symbol_stack.top()].start_timer.top() = computation_timer; } } static void update_cp_decomp1(float* in, float* inout, size_t len){ assert(len == cp_costs_size); // this assert prevents user from obtaining wrong output if MPI implementation cuts up the message. if (path_count > 0){ // We do not track paths for synchronization time nor comp-kernel time, so check for those for (int i=0; i<path_index.size(); i++){ // 0->0, 1->1, 2->2, 3->3, 4->5, 5->7 int j= path_index[i]<4 ? path_index[i] : path_index[i]+1; if (j==6) j++; path_decisions[i] = inout[j] > in[j]; } for (int i=0; i<num_cp_measures; i++){ inout[i] = std::max(inout[i],in[i]); } for (int i=num_cp_measures; i<cp_costs_size; i++){ int idx = (i-num_cp_measures)%path_count; inout[i] = (path_decisions[idx] ? inout[i] : in[i]); } } else{ for (int i=0; i<num_cp_measures; i++){ inout[i] = std::max(inout[i],in[i]); } } } static void update_cp_decomp2(float* in, float* inout, size_t len){ assert(len == cp_costs_size); // this assert prevents user from obtaining wrong output if MPI implementation cuts up the message. if (path_count > 0){ // We do not track paths for synchronization time nor comp-kernel time, so check for those for (int i=0; i<path_index.size(); i++){ // 0->0, 1->1, 2->2, 3->3, 4->5, 5->7 int j= path_index[i]<4 ? path_index[i] : path_index[i]+1; if (j==6) j++; assert(path_index[i] == 5); path_decisions[i] = inout[j] > in[j]; } for (int i=0; i<num_cp_measures; i++){ inout[i] = std::max(inout[i],in[i]); } size_t path_select_offset = 4*num_decomp_cp_measures+1; for (int i=num_cp_measures; i<cp_costs_size; i++){ int idx = (i-num_cp_measures)%(path_count*path_select_offset);// restarts for each symbol idx /= path_select_offset; inout[i] = (path_decisions[idx] ? inout[i] : in[i]); } } else{ for (int i=0; i<num_cp_measures; i++){ inout[i] = std::max(inout[i],in[i]); } } } static void propagate_cp_decomp1_op(float* in, float* inout, int* len, MPI_Datatype* dtype){ update_cp_decomp1(in,inout,static_cast<size_t>(*len)); } static void propagate_cp_decomp2_op(float* in, float* inout, int* len, MPI_Datatype* dtype){ update_cp_decomp2(in,inout,static_cast<size_t>(*len)); } bool path::initiate_comm(blocking& tracker, volatile double curtime, int64_t nelem, MPI_Datatype t, MPI_Comm comm, bool is_sender, int partner1, int user_tag1, int partner2, int user_tag2){ // Check for conflicting communication tag(s) if (partner1 != -1) assert(!(user_tag1 >= internal_tag && user_tag1 <= internal_tag5)); if (partner2 != -1) assert(!(user_tag2 >= internal_tag && user_tag2 <= internal_tag5)); // Save and accumulate the computation time between last communication routine as both execution-time and computation time // into both the execution-time critical path data structures and the per-process data structures. tracker.comp_time = curtime - computation_timer; int rank; MPI_Comm_rank(comm, &rank); MPI_Buffer_attach(&eager_pad[0],eager_pad.size()); // Save caller communication attributes into reference object for use in corresponding static method 'complete' int word_size,np; MPI_Type_size(t, &word_size); int64_t nbytes = word_size * nelem; MPI_Comm_size(comm, &np); tracker.nbytes = nbytes; tracker.comm = comm; tracker.comm_size = np; tracker.is_sender = is_sender; tracker.partner1 = partner1; tracker.partner2 = partner2 != -1 ? partner2 : partner1;// Useful in propagation tracker.synch_time = 0.;// might get updated below tracker.barrier_time = 0.;// might get updated below if (partner1 == MPI_ANY_SOURCE){// only possible for 'MPI_Recv' MPI_Status st; PMPI_Probe(partner1,user_tag1,comm,&st); save_wildcard_id = st.MPI_SOURCE; tracker.partner1 = save_wildcard_id; } else if (partner2 == MPI_ANY_SOURCE){// only possible for 'MPI_Sendrecv' / 'MPI_Sendrecv_replace' assert((tracker.tag == 13) || (tracker.tag == 14)); MPI_Status st; PMPI_Probe(partner2,user_tag2,comm,&st); save_wildcard_id = st.MPI_SOURCE; tracker.partner2 = save_wildcard_id; } volatile auto init_time = MPI_Wtime(); if (tracker.partner1 == -1){ PMPI_Barrier(tracker.comm); tracker.barrier_time = MPI_Wtime() - init_time; } else { MPI_Request barrier_reqs[3]; int barrier_count=0; char sbuf='H'; char rbuf='H'; if ((is_sender) && (rank != tracker.partner1)){ PMPI_Bsend(&sbuf, 1, MPI_CHAR, tracker.partner1, internal_tag3, tracker.comm); } if ((!is_sender) && (rank != tracker.partner1)){ PMPI_Irecv(&rbuf, 1, MPI_CHAR, tracker.partner1, internal_tag3, tracker.comm, &barrier_reqs[barrier_count]); barrier_count++; } if ((partner2 != -1) && (rank != partner2)){ PMPI_Irecv(&rbuf, 1, MPI_CHAR, tracker.partner2, internal_tag3, tracker.comm, &barrier_reqs[barrier_count]); barrier_count++; } PMPI_Waitall(barrier_count,&barrier_reqs[0],MPI_STATUSES_IGNORE); if (barrier_count>0) tracker.barrier_time = MPI_Wtime() - init_time; } cp_costs[num_cp_measures-3] += tracker.comp_time; cp_costs[num_cp_measures-1] += tracker.comp_time; vol_costs[num_vol_measures-3] += tracker.comp_time; vol_costs[num_vol_measures-1] += tracker.comp_time; if (path_decomposition == 1){ for (size_t i=0; i<path_count; i++){ cp_costs[cp_costs_size-1-i-path_count] += tracker.comp_time; cp_costs[cp_costs_size-1-i-2*path_count] += tracker.barrier_time; } } if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ auto last_symbol_time = curtime - symbol_timers[symbol_stack.top()].start_timer.top(); for (auto i=0; i<path_count; i++){ for (auto j=0; j<path_measure_index.size(); j++){ if (path_measure_index[j] == path_measure_select.size()-1){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += last_symbol_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += last_symbol_time; } else if (path_measure_index[j] == path_measure_select.size()-2){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += last_symbol_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += last_symbol_time; } } } symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-1] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-2] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-1] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-2] += last_symbol_time; } if (track_synchronization && tracker.partner1==-1){ // Use the user communication routine to measre synchronization time. // Note the following consequences of using a tiny 1-byte message (note that 0-byte is trivially handled by most MPI implementations) on measuring synchronization time: // 1) The collective communication algorithm is likely different for small messages than large messages. // 2) The eager sending protocol will be utilized, which would incur a potentially significant difference in synchronization time than if rendezvous protocol was invoked. // Special arrays for use in the collective -v routines as well as Reduce_scatter. std::vector<int> counts(np,1); std::vector<int> disp(np,0); if (tracker.tag>=9 && tracker.tag<=12) for (int i=1; i<np; i++) disp[i]=disp[i-1]+1; // start synchronization timer for communication routine tracker.start_time = MPI_Wtime(); switch (tracker.tag){ case 0: PMPI_Barrier(tracker.comm); break; case 1: PMPI_Bcast(&synch_pad_send[0], 1, MPI_CHAR, 0, tracker.comm);// arbitrary root 0 break; case 2: PMPI_Reduce(&synch_pad_send[0], &synch_pad_recv[0], 1, MPI_CHAR, MPI_MAX, 0, tracker.comm);// arbitrary root 0 break; case 3: PMPI_Allreduce(MPI_IN_PLACE, &synch_pad_send[0], 1, MPI_CHAR, MPI_MAX, tracker.comm); break; case 4: PMPI_Gather(&synch_pad_send[0], 1, MPI_CHAR, &synch_pad_recv[0], 1, MPI_CHAR, 0, tracker.comm);// arbitrary root 0 break; case 5: PMPI_Allgather(&synch_pad_send[0], 1, MPI_CHAR, &synch_pad_recv[0], 1, MPI_CHAR, tracker.comm); break; case 6: PMPI_Scatter(&synch_pad_send[0], 1, MPI_CHAR, &synch_pad_recv[0], 1, MPI_CHAR, 0, tracker.comm);// arbitrary root 0 break; case 7: PMPI_Reduce_scatter(&synch_pad_send[0], &synch_pad_recv[0], &counts[0], MPI_CHAR, MPI_MAX, tracker.comm); break; case 8: PMPI_Alltoall(&synch_pad_send[0], 1, MPI_CHAR, &synch_pad_recv[0], 1, MPI_CHAR, tracker.comm); break; case 9: PMPI_Gatherv(&synch_pad_send[0], 1, MPI_CHAR, &synch_pad_recv[0], &counts[0], &disp[0], MPI_CHAR, 0, tracker.comm);// arbitrary root 0 break; case 10: PMPI_Allgatherv(&synch_pad_send[0], 1, MPI_CHAR, &synch_pad_recv[0], &counts[0], &disp[0], MPI_CHAR, tracker.comm); break; case 11: PMPI_Scatterv(&synch_pad_send[0], &counts[0], &disp[0], MPI_CHAR, &synch_pad_recv[0], 1, MPI_CHAR, 0, tracker.comm);// arbitrary root 0 break; case 12: PMPI_Alltoallv(&synch_pad_send[0], &counts[0], &disp[0], MPI_CHAR, &synch_pad_recv[0], &counts[0], &disp[0], MPI_CHAR, tracker.comm); break; } tracker.synch_time = MPI_Wtime()-tracker.start_time; } void* temp_buf; int temp_size; MPI_Buffer_detach(&temp_buf,&temp_size); // start communication timer for communication routine tracker.start_time = MPI_Wtime(); return true; } void path::complete_comm(blocking& tracker){ volatile auto comm_time = MPI_Wtime() - tracker.start_time; // complete communication time int rank; MPI_Comm_rank(tracker.comm, &rank); MPI_Buffer_attach(&eager_pad[0],eager_pad.size()); // Save kernel information if (autotuning_debug == 1){ assert(comm_channel_map.find(tracker.comm) != comm_channel_map.end()); int comm_sizes[2]={0,0}; int comm_strides[2]={0,0}; for (auto i=0; i<comm_channel_map[tracker.comm]->id.size(); i++){ comm_sizes[i]=comm_channel_map[tracker.comm]->id[i].first; comm_strides[i]=comm_channel_map[tracker.comm]->id[i].second; } comm_kernel_key key(rank,-1,tracker.tag,comm_sizes,comm_strides,tracker.nbytes,tracker.partner1); if (comm_kernel_info.find(key) == comm_kernel_info.end()){ comm_kernel_info[key] = std::make_pair(1,comm_time); } else{ comm_kernel_info[key].first++; comm_kernel_info[key].second += comm_time; } } std::pair<float,float> cost = cost_model == 0 ? tracker.cost_func_bsp(tracker.nbytes, tracker.comm_size) : tracker.cost_func_alphabeta(tracker.nbytes, tracker.comm_size); // Decompose measurements along multiple paths by MPI routine. *tracker.my_synch_time += tracker.synch_time; *tracker.my_comm_time += comm_time; *tracker.my_msg_count += cost.first; *tracker.my_wrd_count += cost.second; for (size_t i=0; i<path_count; i++){ *(tracker.cp_synch_time+i) += tracker.synch_time; *(tracker.cp_comm_time+i) += comm_time; *(tracker.cp_msg_count+i) += cost.first; *(tracker.cp_wrd_count+i) += cost.second; } // Decompose measurements along multiple paths by symbol if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ for (auto i=0; i<path_count; i++){ // update all communication-related measures for the top symbol in stack for (auto j=0; j<path_measure_index.size(); j++){ if (path_measure_index[j] == 0){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += cost.second; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += cost.second; } else if (path_measure_index[j] == 1){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += cost.second; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += cost.second; } else if (path_measure_index[j] == path_measure_select.size()-4){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += comm_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += comm_time; } else if (path_measure_index[j] == path_measure_select.size()-3){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += tracker.synch_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += tracker.synch_time; } else if (path_measure_index[j] == path_measure_select.size()-1){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += comm_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += comm_time; } } } symbol_timers[symbol_stack.top()].pp_exclusive_measure[0] += cost.second; symbol_timers[symbol_stack.top()].pp_excl_measure[0] += cost.second; symbol_timers[symbol_stack.top()].pp_exclusive_measure[1] += cost.first; symbol_timers[symbol_stack.top()].pp_excl_measure[1] += cost.first; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-4] += comm_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-4] += comm_time; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-3] += tracker.synch_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-3] += tracker.synch_time; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-1] += comm_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-1] += comm_time; if (include_barrier_time){ symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-1] += tracker.barrier_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-1] += tracker.barrier_time; } } // Update measurements that define the critical path for each metric. cp_costs[num_cp_measures-8] += cost.second; cp_costs[num_cp_measures-7] += cost.first; cp_costs[num_cp_measures-5] += comm_time; cp_costs[num_cp_measures-4] += tracker.synch_time; cp_costs[num_cp_measures-1] += comm_time; vol_costs[num_vol_measures-9] += cost.second; vol_costs[num_vol_measures-8] += cost.first; vol_costs[num_vol_measures-6] += tracker.barrier_time;// Note this will be a bit high, as it includes time for last process to enter vol_costs[num_vol_measures-5] += comm_time; vol_costs[num_vol_measures-4] += tracker.synch_time; vol_costs[num_vol_measures-1] += comm_time; if (include_barrier_time){ vol_costs[num_vol_measures-1] += tracker.barrier_time; } // Note that this block of code below is left in solely for blocking communication to avoid over-counting the idle time // If per-process execution-time gets larger than execution-time along the execution-time critical path, // subtract out the difference from idle time. auto path_diff = vol_costs[num_vol_measures-1]-cp_costs[num_cp_measures-1]; if (include_barrier_time==0) path_diff += vol_costs[num_vol_measures-6]; vol_costs[num_vol_measures-6] -= std::max((float)0.,path_diff); if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ // Special handling of excessively large idle time caused by suspected tool interference // Specifically, this interference is caused by not subtracting out the barrier time of the last process to enter the barrier (which ideally is 0). if (include_barrier_time){ symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-1] -= std::max((float)0.,path_diff); symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-1] -= std::max((float)0.,path_diff); symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-6] -= std::max((float)0.,path_diff); symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-6] -= std::max((float)0.,path_diff); } } // Due to granularity of timing, if a per-process measure ever gets more expensive than a critical path measure, we set the per-process measure to the cp measure for (int i=1; i<=5; i++){ vol_costs[num_vol_measures-i] = std::min(vol_costs[num_vol_measures-i],cp_costs[num_cp_measures-i]); } propagate(tracker); void* temp_buf; int temp_size; MPI_Buffer_detach(&temp_buf,&temp_size); // Prepare to leave interception and re-enter user code by restarting computation timers. bsp_counter++; computation_timer = MPI_Wtime(); if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ symbol_timers[symbol_stack.top()].start_timer.top() = computation_timer; } } // Called by both nonblocking p2p and nonblocking collectives bool path::initiate_comm(nonblocking& tracker, volatile double curtime, int64_t nelem, MPI_Datatype t, MPI_Comm comm, bool is_sender, int partner, int user_tag){ // Check for conflicting communication tag(s) if (partner != -1) assert(!(user_tag >= internal_tag && user_tag <= internal_tag5)); tracker.comp_time = curtime - computation_timer; cp_costs[num_cp_measures-3] += tracker.comp_time; cp_costs[num_cp_measures-1] += tracker.comp_time; vol_costs[num_vol_measures-3] += tracker.comp_time; vol_costs[num_vol_measures-1] += tracker.comp_time; if (path_decomposition == 1){ for (size_t i=0; i<path_count; i++){ cp_costs[cp_costs_size-1-i-path_count] += tracker.comp_time; } } if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ auto last_symbol_time = curtime - symbol_timers[symbol_stack.top()].start_timer.top(); for (auto i=0; i<path_count; i++){ for (auto j=0; j<path_measure_index.size(); j++){ if (path_measure_index[j] == path_measure_select.size()-1){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += last_symbol_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += last_symbol_time; } else if (path_measure_index[j] == path_measure_select.size()-2){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += last_symbol_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += last_symbol_time; } } } symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-1] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-2] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-1] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-2] += last_symbol_time; } // Note: routine below will be called immediately afterward. return true; } // Called by both nonblocking p2p and nonblocking collectives void path::initiate_comm(nonblocking& tracker, volatile double itime, int64_t nelem, MPI_Datatype t, MPI_Comm comm, MPI_Request* request, bool is_sender, int partner, int user_tag){ // Check for conflicting communication tag(s) if (partner != -1) assert(!(user_tag >= internal_tag && user_tag <= internal_tag5)); // Deal with computational cost at the beginning, but don't synchronize to find computation-critical path-path yet or that will screw up calculation of overlap! tracker.comp_time = itime; cp_costs[num_cp_measures-3] += tracker.comp_time; cp_costs[num_cp_measures-1] += tracker.comp_time; vol_costs[num_vol_measures-3] += tracker.comp_time; vol_costs[num_vol_measures-1] += tracker.comp_time; if (path_decomposition == 1){ for (size_t i=0; i<path_count; i++){ cp_costs[cp_costs_size-1-i-path_count] += tracker.comp_time; } } if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ auto last_symbol_time = itime; for (auto i=0; i<path_count; i++){ for (auto j=0; j<path_measure_index.size(); j++){ if (path_measure_index[j] == path_measure_select.size()-1){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += last_symbol_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += last_symbol_time; } else if (path_measure_index[j] == path_measure_select.size()-2){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += last_symbol_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += last_symbol_time; } } } symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-1] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-2] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-1] += last_symbol_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-2] += last_symbol_time; } int rank; MPI_Comm_rank(comm,&rank); int el_size,p; MPI_Type_size(t, &el_size); int64_t nbytes = el_size * nelem; MPI_Comm_size(comm, &p); MPI_Buffer_attach(&eager_pad[0],eager_pad.size()); MPI_Request barrier_req = MPI_REQUEST_NULL;// Only necessary for nonblocking receives // Issue the barrier call, regardless of msg size // Note that this is only necessary due to blocking+nonblocking p2p communication // Therefore, nonblocking collectives need not participate in the barrier call if (partner!=-1){// Branch protects against nonblocking collectives if (is_sender && rank != partner){ PMPI_Bsend(&barrier_pad_send, 1, MPI_CHAR, partner, internal_tag3, comm); } else if (!is_sender && rank != partner){ PMPI_Irecv(&barrier_pad_recv, 1, MPI_CHAR, partner, internal_tag3, comm, &barrier_req); } } tracker.comm = comm; tracker.is_sender = is_sender; tracker.partner1 = partner; tracker.partner2 = -1; tracker.comm_size = p; tracker.nbytes = nbytes; MPI_Request prop_req = MPI_REQUEST_NULL; float* path_data = nullptr; propagate(tracker,path_data,&prop_req); nonblocking_info msg_info(path_data,barrier_req,prop_req,is_sender,partner,comm,(float)nbytes,(float)p,&tracker); nonblocking_internal_info[*request] = msg_info; void* temp_buf; int temp_size; MPI_Buffer_detach(&temp_buf,&temp_size); computation_timer = MPI_Wtime(); if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ symbol_timers[symbol_stack.top()].start_timer.top() = computation_timer; } } void path::complete_comm(double comp_time){ cp_costs[num_cp_measures-3] += comp_time; cp_costs[num_cp_measures-1] += comp_time; if (path_decomposition == 1){ for (size_t i=0; i<path_count; i++){ cp_costs[cp_costs_size-1-i-path_count] += comp_time; } } vol_costs[num_vol_measures-3] += comp_time; vol_costs[num_vol_measures-1] += comp_time; // Decompose measurements along multiple paths by symbol if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ for (auto i=0; i<path_count; i++){ for (auto j=0; j<path_measure_index.size(); j++){ if (path_measure_index[j] == path_measure_select.size()-2){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += comp_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += comp_time; } else if (path_measure_index[j] == path_measure_select.size()-1){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += comp_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += comp_time; } } } symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-2] += comp_time; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-1] += comp_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-2] += comp_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-1] += comp_time; } } void path::complete_comm(nonblocking& tracker, MPI_Request* request, double comp_time, double comm_time){ auto info_it = nonblocking_internal_info.find(*request); assert(info_it != nonblocking_internal_info.end()); tracker.is_sender = info_it->second.is_sender; tracker.comm = info_it->second.comm; tracker.partner1 = info_it->second.partner; tracker.partner2 = -1; tracker.nbytes = info_it->second.nbytes; tracker.comm_size = info_it->second.comm_size; tracker.synch_time=0; int rank; MPI_Comm_rank(tracker.comm, &rank); if (autotuning_debug == 1){ assert(comm_channel_map.find(tracker.comm) != comm_channel_map.end()); int comm_sizes[2]={0,0}; int comm_strides[2]={0,0}; for (auto i=0; i<comm_channel_map[tracker.comm]->id.size(); i++){ comm_sizes[i]=comm_channel_map[tracker.comm]->id[i].first; comm_strides[i]=comm_channel_map[tracker.comm]->id[i].second; } comm_kernel_key key(rank,-1,tracker.tag,comm_sizes,comm_strides,tracker.nbytes,tracker.partner1); if (comm_kernel_info.find(key) == comm_kernel_info.end()){ comm_kernel_info[key] = std::make_pair(1,comm_time); } else{ comm_kernel_info[key].first++; comm_kernel_info[key].second += comm_time; } } std::pair<float,float> cost = cost_model == 0 ? tracker.cost_func_bsp(tracker.nbytes, tracker.comm_size) : tracker.cost_func_alphabeta(tracker.nbytes, tracker.comm_size); if (!is_first_request && cost_model==0) cost.first = 0; // Update measurements that define the critical path for each metric. cp_costs[0] += cost.second; cp_costs[1] += cost.first; cp_costs[num_cp_measures-5] += comm_time; cp_costs[num_cp_measures-4] += 0.; cp_costs[num_cp_measures-3] += comp_time; cp_costs[num_cp_measures-1] += comp_time+comm_time; if (path_decomposition == 1){ for (size_t i=0; i<path_count; i++){ cp_costs[cp_costs_size-1-i-path_count] += comp_time; } } vol_costs[0] += cost.second; vol_costs[1] += cost.first; vol_costs[num_vol_measures-5] += comm_time; vol_costs[num_vol_measures-3] += comp_time; vol_costs[num_vol_measures-1] += comp_time+comm_time; // Due to granularity of timing, if a per-process measure ever gets more expensive than a critical path measure, we set the per-process measure to the cp measure for (int i=1; i<=5; i++){ vol_costs[num_vol_measures-i] = std::min(vol_costs[num_vol_measures-i],cp_costs[num_cp_measures-i]); } // Decompose measurements along multiple paths by MPI routine. // Accumuate MPI routine-local measurements. The "my_..." members will never modify the accumulations, while the "cp_..." will first accumulate before path propagation. *tracker.my_synch_time += 0; *tracker.my_comm_time += comm_time; *tracker.my_msg_count += cost.first; *tracker.my_wrd_count += cost.second; for (size_t i=0; i<path_count; i++){ *(tracker.cp_synch_time+i) += tracker.synch_time; *(tracker.cp_comm_time+i) += comm_time; *(tracker.cp_msg_count+i) += cost.first; *(tracker.cp_wrd_count+i) += cost.second; } // Decompose measurements along multiple paths by symbol if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ for (auto i=0; i<path_count; i++){ for (auto j=0; j<path_measure_index.size(); j++){ if (path_measure_index[j] == 0){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += cost.second; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += cost.second; } else if (path_measure_index[j] == 1){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += cost.first; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += cost.first; } else if (path_measure_index[j] == path_measure_select.size()-4){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += comm_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += comm_time; } else if (path_measure_index[j] == path_measure_select.size()-2){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += comp_time; symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += comp_time; } else if (path_measure_index[j] == path_measure_select.size()-1){ symbol_timers[symbol_stack.top()].cp_exclusive_measure[i][j] += (comp_time+comm_time); symbol_timers[symbol_stack.top()].cp_excl_measure[i][j] += (comp_time+comm_time); } } } symbol_timers[symbol_stack.top()].pp_exclusive_measure[0] += cost.second; symbol_timers[symbol_stack.top()].pp_exclusive_measure[1] += cost.first; symbol_timers[symbol_stack.top()].pp_excl_measure[0] += cost.second; symbol_timers[symbol_stack.top()].pp_excl_measure[1] += cost.first; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-4] += comm_time; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-2] += comp_time; symbol_timers[symbol_stack.top()].pp_exclusive_measure[num_decomp_pp_measures-1] += (comp_time+comm_time); symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-4] += comm_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-2] += comp_time; symbol_timers[symbol_stack.top()].pp_excl_measure[num_decomp_pp_measures-1] += (comp_time+comm_time); } nonblocking_internal_info.erase(*request); } int path::complete_comm(double curtime, MPI_Request* request, MPI_Status* status, int is_test, int* flag){ auto comp_time = curtime - computation_timer; int ret = MPI_SUCCESS; auto info_it = nonblocking_internal_info.find(*request); assert(info_it != nonblocking_internal_info.end()); MPI_Request save_request = info_it->first; volatile auto last_start_time = MPI_Wtime(); if (is_test == 0) ret = PMPI_Wait(request, status); else{ ret = PMPI_Test(request,flag,status); if (*flag == 0){ auto save_comm_time = MPI_Wtime() - last_start_time; complete_comm(save_comm_time+comp_time); computation_timer = MPI_Wtime(); if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ symbol_timers[symbol_stack.top()].start_timer.top() = computation_timer; } return ret; } } auto save_comm_time = MPI_Wtime() - last_start_time; int rank; MPI_Comm_rank(info_it->second.track->comm,&rank); if (rank != info_it->second.partner){ // If receiver or collective, complete the barrier and the path data propagation if (!info_it->second.is_sender || info_it->second.partner==-1){ assert(info_it->second.path_data != nullptr); MPI_Request req_array[] = {info_it->second.barrier_req, info_it->second.prop_req}; PMPI_Waitall(2, &req_array[0], MPI_STATUSES_IGNORE); if (path_decomposition <= 1) update_cp_decomp1(info_it->second.path_data,&cp_costs[0],cp_costs_size); else if (path_decomposition == 2) update_cp_decomp2(info_it->second.path_data,&cp_costs[0],cp_costs_size); if (info_it->second.path_data != nullptr) free(info_it->second.path_data); if (info_it->second.partner == MPI_ANY_SOURCE) { info_it->second.track->partner1 = status->MPI_SOURCE; } } } complete_comm(*info_it->second.track, &save_request, comp_time, save_comm_time); computation_timer = MPI_Wtime(); if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ symbol_timers[symbol_stack.top()].start_timer.top() = computation_timer; } return ret; } int path::complete_comm(double curtime, int count, MPI_Request array_of_requests[], int* indx, MPI_Status* status, int is_test, int* flag){ auto comp_time = curtime - computation_timer; int ret = MPI_SUCCESS; // We must save the requests before the completition of a request by the MPI implementation // because its tag is set to MPI_REQUEST_NULL and lost forever std::vector<MPI_Request> pt(count); for (int i=0;i<count;i++){pt[i]=(array_of_requests)[i];} volatile auto last_start_time = MPI_Wtime(); if (is_test == 0) ret = PMPI_Waitany(count,array_of_requests,indx,status); else{ ret = PMPI_Testany(count,array_of_requests,indx,flag,status); if (*flag == 0){ auto save_comm_time = MPI_Wtime() - last_start_time; complete_comm(save_comm_time+comp_time); computation_timer = MPI_Wtime(); if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ symbol_timers[symbol_stack.top()].start_timer.top() = computation_timer; } return ret; } } auto waitany_comm_time = MPI_Wtime() - last_start_time; MPI_Request request = pt[*indx]; auto info_it = nonblocking_internal_info.find(request); assert(info_it != nonblocking_internal_info.end()); int rank; MPI_Comm_rank(info_it->second.track->comm,&rank); if (rank != info_it->second.partner){ // If receiver, complete the barrier and the path data propagation if (!info_it->second.is_sender || info_it->second.partner==-1){ assert(info_it->second.path_data != nullptr); MPI_Request req_array[] = {info_it->second.barrier_req, info_it->second.prop_req}; PMPI_Waitall(2, &req_array[0], MPI_STATUSES_IGNORE); if (path_decomposition <= 1) update_cp_decomp1(info_it->second.path_data,&cp_costs[0],cp_costs_size); else if (path_decomposition == 2) update_cp_decomp2(info_it->second.path_data,&cp_costs[0],cp_costs_size); if (info_it->second.path_data != nullptr) free(info_it->second.path_data); if (info_it->second.partner == MPI_ANY_SOURCE) { info_it->second.track->partner1 = status->MPI_SOURCE; } } } complete_comm(*info_it->second.track, &request, comp_time, waitany_comm_time); computation_timer = MPI_Wtime(); if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ symbol_timers[symbol_stack.top()].start_timer.top() = computation_timer; } return ret; } int path::complete_comm(double curtime, int incount, MPI_Request array_of_requests[], int* outcount, int array_of_indices[], MPI_Status array_of_statuses[], int is_test){ auto waitsome_comp_time = curtime - computation_timer; int ret = MPI_SUCCESS; is_first_request=true; // We must save the requests before the completition of a request by the MPI implementation // because its tag is set to MPI_REQUEST_NULL and lost forever std::vector<MPI_Request> pt(incount); for (int i=0;i<incount;i++){pt[i]=(array_of_requests)[i];} volatile auto last_start_time = MPI_Wtime(); if (is_test == 0) ret = PMPI_Waitsome(incount,array_of_requests,outcount,array_of_indices,array_of_statuses); else{ ret = PMPI_Testsome(incount,array_of_requests,outcount,array_of_indices,array_of_statuses); if (*outcount == 0){ auto save_comm_time = MPI_Wtime() - last_start_time; complete_comm(save_comm_time+waitsome_comp_time); computation_timer = MPI_Wtime(); if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ symbol_timers[symbol_stack.top()].start_timer.top() = computation_timer; } return ret; } } auto waitsome_comm_time = MPI_Wtime() - last_start_time; for (int i=0; i<*outcount; i++){ MPI_Request request = pt[(array_of_indices)[i]]; auto info_it = nonblocking_internal_info.find(request); assert(info_it != nonblocking_internal_info.end()); int rank; MPI_Comm_rank(info_it->second.track->comm,&rank); if (rank != info_it->second.partner){ // If receiver, complete the barrier and the path data propagation if (!info_it->second.is_sender || info_it->second.partner==-1){ assert(info_it->second.path_data != nullptr); MPI_Request req_array[] = {info_it->second.barrier_req, info_it->second.prop_req}; PMPI_Waitall(2, &req_array[0], MPI_STATUSES_IGNORE); if (path_decomposition <= 1) update_cp_decomp1(info_it->second.path_data,&cp_costs[0],cp_costs_size); else if (path_decomposition == 2) update_cp_decomp2(info_it->second.path_data,&cp_costs[0],cp_costs_size); if (info_it->second.path_data != nullptr) free(info_it->second.path_data); if (info_it->second.partner == MPI_ANY_SOURCE) { info_it->second.track->partner1 = (array_of_statuses)[i].MPI_SOURCE; } } } complete_comm(*info_it->second.track, &request, waitsome_comp_time, waitsome_comm_time); waitsome_comp_time=0; waitsome_comm_time=0; is_first_request=false; } computation_timer = MPI_Wtime(); if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ symbol_timers[symbol_stack.top()].start_timer.top() = computation_timer; } return ret; } int path::complete_comm(double curtime, int count, MPI_Request array_of_requests[], MPI_Status array_of_statuses[], int is_test, int* flag){ auto waitall_comp_time = curtime - computation_timer; int ret = MPI_SUCCESS; is_first_request=true; // We must save the requests before the completition of a request by the MPI implementation // because its tag is set to MPI_REQUEST_NULL and lost forever std::vector<MPI_Request> pt(count); for (int i=0;i<count;i++){pt[i]=(array_of_requests)[i];} volatile auto last_start_time = MPI_Wtime(); if (is_test == 0) ret = PMPI_Waitall(count,array_of_requests,array_of_statuses); else{ ret = PMPI_Testall(count,array_of_requests,flag,array_of_statuses); if (*flag == 0){ auto save_comm_time = MPI_Wtime() - last_start_time; complete_comm(save_comm_time+waitall_comp_time); computation_timer = MPI_Wtime(); if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ symbol_timers[symbol_stack.top()].start_timer.top() = computation_timer; } return ret; } } auto waitall_comm_time = MPI_Wtime() - last_start_time; for (int i=0; i<count; i++){ MPI_Request request = pt[i]; auto info_it = nonblocking_internal_info.find(request); assert(info_it != nonblocking_internal_info.end()); int rank; MPI_Comm_rank(info_it->second.track->comm,&rank); if (rank != info_it->second.partner){ // If receiver, complete the barrier and the path data propagation if (!info_it->second.is_sender || info_it->second.partner==-1){ assert(info_it->second.path_data != nullptr); MPI_Request req_array[] = {info_it->second.barrier_req, info_it->second.prop_req}; PMPI_Waitall(2, &req_array[0], MPI_STATUSES_IGNORE); if (path_decomposition <= 1) update_cp_decomp1(info_it->second.path_data,&cp_costs[0],cp_costs_size); else if (path_decomposition == 2) update_cp_decomp2(info_it->second.path_data,&cp_costs[0],cp_costs_size); if (info_it->second.path_data != nullptr) free(info_it->second.path_data); if (info_it->second.partner == MPI_ANY_SOURCE) { info_it->second.track->partner1 = (array_of_statuses)[i].MPI_SOURCE; } } } complete_comm(*info_it->second.track, &request, waitall_comp_time, waitall_comm_time); // Although we have to exchange the path data for each request, we do not want to float-count the computation time nor the communicaion time waitall_comp_time=0; waitall_comm_time=0; is_first_request=false; } computation_timer = MPI_Wtime(); if (path_decomposition == 2 && path_count>0 && symbol_stack.size()>0){ symbol_timers[symbol_stack.top()].start_timer.top() = computation_timer; } return ret; } void path::propagate(blocking& tracker){ int rank; MPI_Comm_rank(tracker.comm,&rank); if ((rank == tracker.partner1) && (rank == tracker.partner2)) { return; } // Exchange the tracked routine critical path data if (tracker.partner1 == -1){ MPI_Op op; if (path_decomposition <= 1) MPI_Op_create((MPI_User_function*) propagate_cp_decomp1_op,0,&op); else if (path_decomposition == 2) MPI_Op_create((MPI_User_function*) propagate_cp_decomp2_op,0,&op); PMPI_Allreduce(MPI_IN_PLACE, &cp_costs[0], cp_costs.size(), MPI_FLOAT, op, tracker.comm); MPI_Op_free(&op); } else{ if (tracker.is_sender){ PMPI_Bsend(&cp_costs[0], cp_costs.size(), MPI_FLOAT, tracker.partner1, internal_tag2, tracker.comm); } else{ PMPI_Recv(&cp_costs_foreign[0], cp_costs.size(), MPI_FLOAT, tracker.partner1, internal_tag2, tracker.comm, MPI_STATUS_IGNORE); if (path_decomposition <= 1) update_cp_decomp1(&cp_costs_foreign[0],&cp_costs[0],cp_costs_size); else if (path_decomposition == 2) update_cp_decomp2(&cp_costs_foreign[0],&cp_costs[0],cp_costs_size); } if (tracker.partner2 != tracker.partner1){ PMPI_Recv(&cp_costs_foreign[0], cp_costs.size(), MPI_FLOAT, tracker.partner2, internal_tag2, tracker.comm, MPI_STATUS_IGNORE); if (path_decomposition <= 1) update_cp_decomp1(&cp_costs_foreign[0],&cp_costs[0],cp_costs_size); else if (path_decomposition == 2) update_cp_decomp2(&cp_costs_foreign[0],&cp_costs[0],cp_costs_size); } } } void path::propagate(nonblocking& tracker, float*& path_data, MPI_Request* prop_req){ int rank; MPI_Comm_rank(tracker.comm,&rank); if (rank == tracker.partner1) { return; } // Exchange the tracked routine critical path data if (tracker.partner1 == -1){ MPI_Op op; if (path_decomposition <= 1) MPI_Op_create((MPI_User_function*) propagate_cp_decomp1_op,0,&op); else if (path_decomposition == 2) MPI_Op_create((MPI_User_function*) propagate_cp_decomp2_op,0,&op); path_data = (float*)malloc(cp_costs.size()*sizeof(float)); std::memcpy(path_data, &cp_costs[0], cp_costs.size()*sizeof(float)); PMPI_Iallreduce(MPI_IN_PLACE,path_data,cp_costs.size(),MPI_FLOAT,op,tracker.comm,prop_req); //MPI_Op_free(&op); } else{ if (tracker.is_sender){ PMPI_Bsend(&cp_costs[0], cp_costs.size(), MPI_FLOAT, tracker.partner1, internal_tag2, tracker.comm); } else{ path_data = (float*)malloc(cp_costs.size()*sizeof(float)); PMPI_Irecv(path_data, cp_costs.size(), MPI_FLOAT, tracker.partner1, internal_tag2, tracker.comm, prop_req); } } } } } }
51.55567
175
0.707793
huttered40
4337c0bd814d439575b21c2b54f38d573e1d0714
4,649
cpp
C++
Source/Gui/OptionBox.cpp
alvinahmadov/Dixter
6f98f1e84192e1e43eee409bdee6b3dac75d6443
[ "MIT" ]
4
2018-12-06T01:20:50.000Z
2019-08-04T10:19:23.000Z
Source/Gui/OptionBox.cpp
alvinahmadov/Dixter
6f98f1e84192e1e43eee409bdee6b3dac75d6443
[ "MIT" ]
null
null
null
Source/Gui/OptionBox.cpp
alvinahmadov/Dixter
6f98f1e84192e1e43eee409bdee6b3dac75d6443
[ "MIT" ]
null
null
null
/** * Copyright (C) 2015-2019 * Author Alvin Ahmadov <[email protected]> * * This file is part of Dixter Project * License-Identifier: MIT License * See README.md for more information. */ #include <QDebug> #include "Utilities.hpp" #include "Configuration.hpp" #include "Constants.hpp" #include "Gui/OptionBox.hpp" namespace AlgoUtils = Dixter::Utilities::Algorithms; using std::vector; namespace Dixter { namespace Gui { void arrayStringToVector(const QStringList& src, vector<QString>& dest) { AlgoUtils::foreachCompound(src, dest, [](const QString& srcValue, QString& destValue) { destValue = srcValue; }); } void vectorToArrayString(const vector<QString>& src, QStringList& dest) { Utilities::Algorithms::foreachCompound(src, dest, [ ](const QString& srcValue, QString& destValue) { destValue = srcValue; }); } QStringList vectorToArrayString(const vector<QString>& src) { QStringList __ret {}; Utilities::Algorithms::foreachCompound(src, __ret, [ ](const QString& srcValue, QString& destValue) { destValue = srcValue; }); return __ret; } Int32 compare(const QVariant& v1, const QVariant& v2) { return v1.toString().compare(v2.toString()); } TOptionBox::TOptionBox(QWidget* parent, const QString& placeholder, const QSize& size, bool sort) : QComboBox(parent), m_isPlaceholderSet(), m_sort(sort), m_placeHolder(placeholder) { setPlaceholder(placeholder); if (size.height() > 0 and size.width() > 0) setMinimumSize(size); init(); connectEvents(); } TOptionBox::TOptionBox(const QString& placeholder, const QSize& size, bool sort) : TOptionBox(nullptr, placeholder, size, sort) { } inline void TOptionBox::setPlaceholder(const QString& placeholder) { if (not placeholder.isEmpty()) { m_placeHolder = placeholder; m_isPlaceholderSet = true; if (count() > 0) { int srchNum { }; srchNum = findText(m_placeHolder); if (srchNum != -1) { setCurrentIndex(srchNum); } else { insertItem(0, m_placeHolder); } } else { addItem(m_placeHolder); } setCurrentText(m_placeHolder); } } void TOptionBox::resetPlaceholder() { if (m_isPlaceholderSet) { auto idx = findText(m_placeHolder); if (idx > -1) removeItem(idx); m_isPlaceholderSet = false; } } void TOptionBox::setValues(vector<TUString>& options, bool sort) { Q_UNUSED(sort) if (options.size() > 0) { for (const auto& option : options) { auto __option = option.asCustom(); addItem(__option); } } } void TOptionBox::setValues(const QStringList& options) { if (options.size() > 0) { for (const auto& option : options) { addItem(option); } } } void TOptionBox::swapCurrent(TOptionBox* src) { if(isPlaceholderSet() or src->isPlaceholderSet()) return; auto __srcCount = src->getItemCount(); auto __currentIndex = currentIndex(); if (__srcCount > 0) { setCurrentIndex(src->currentIndex()); src->setCurrentIndex(__currentIndex); } } void TOptionBox::sort(bool ascending) { //TODO(Alvin): Reimplement (void)ascending; // auto __currentValues = currentData(); // clear(); // if (ascending) // { // std::sort(__currentValues.begin(), __currentValues.end(), std::greater<QString>()); // } else // { // std::sort(__currentValues.begin(), __currentValues.end(), std::less<QString>()); // } // // setValues(__currentValues); } Int32 TOptionBox::getItemCount() const { return (isPlaceholderSet() ? count() - 1 : count()); } Int32 TOptionBox::getPosition(const QString& value) { Int32 __pos { -1 }; __pos = findText(value); return __pos; } bool TOptionBox::isPlaceholderSet() const { return m_isPlaceholderSet; } void TOptionBox::onChanged(int) { resetPlaceholder(); } void TOptionBox::init() { auto __confMan = getIniManager({ g_guiConfigPath}); auto __bgColour = __confMan->accessor()->getValue(NodeKey::kWinBgColourNode).asCustom(); auto __fontName = __confMan->accessor()->getValue(NodeKey::kWinFontNameNode).asCustom(); int __fontSize = __confMan->accessor()->getValue(NodeKey::kWinFontSizeNode); __bgColour.prepend('#'); setPalette(QPalette(__bgColour)); setFont(QFont(__fontName, __fontSize)); } void TOptionBox::connectEvents() { connect(this, SIGNAL(activated(int)), SLOT(onChanged(int))); } } }
22.244019
102
0.640783
alvinahmadov
4338947a412da18f04207d6cd91e24b985b681b3
914
cpp
C++
RayTracing/Grid/UI/Float3Slider.cpp
DarriusWrightGD/realtimeraytracing
1b1117858dcd8880ed88b59ce0388cfb39fc1d96
[ "MIT" ]
1
2020-03-27T18:59:57.000Z
2020-03-27T18:59:57.000Z
RayTracing/Grid/UI/Float3Slider.cpp
DarriusWrightGD/RealtimeRaytracing
1b1117858dcd8880ed88b59ce0388cfb39fc1d96
[ "MIT" ]
null
null
null
RayTracing/Grid/UI/Float3Slider.cpp
DarriusWrightGD/RealtimeRaytracing
1b1117858dcd8880ed88b59ce0388cfb39fc1d96
[ "MIT" ]
null
null
null
#include "Float3Slider.h" Float3Slider::Float3Slider(char * name, glm::vec3 min, glm::vec3 max, float * value , glm::vec3 gran) : min(min), max(max), value(value), gran(gran) { sliderLayout = new QHBoxLayout(); vectorLabel = new QLabel(name); sliderVector[0] = new FloatSlider("X", min[0],max[0],&value[0], gran[0]); sliderVector[1] = new FloatSlider("Y", min[1],max[1],&value[1], gran[1]); sliderVector[2] = new FloatSlider("Z", min[2],max[2],&value[2], gran[2]); sliderLayout->addWidget(vectorLabel); sliderLayout->addWidget(sliderVector[0]); sliderLayout->addWidget(sliderVector[1]); sliderLayout->addWidget(sliderVector[2]); sliderLayout->setContentsMargins(0,0,0,0); sliderLayout->setSpacing(0); sliderLayout->setMargin(0); setLayout(sliderLayout); } Float3Slider::~Float3Slider(void) { } void Float3Slider::update() { for (int i = 0; i < 3; i++) { sliderVector[i]->update(); } }
23.435897
103
0.68709
DarriusWrightGD
433d04b598e823da49c5fb6e196785cd3745b131
3,505
hpp
C++
src/xalanc/PlatformSupport/Writer.hpp
ulisesten/xalanc
a722de08e61ce66965c4a828242f7d1250950621
[ "Apache-2.0" ]
24
2015-07-29T22:49:17.000Z
2022-03-25T10:14:17.000Z
src/xalanc/PlatformSupport/Writer.hpp
ulisesten/xalanc
a722de08e61ce66965c4a828242f7d1250950621
[ "Apache-2.0" ]
14
2019-05-10T16:25:50.000Z
2021-11-24T18:04:47.000Z
src/xalanc/PlatformSupport/Writer.hpp
ulisesten/xalanc
a722de08e61ce66965c4a828242f7d1250950621
[ "Apache-2.0" ]
28
2015-04-20T15:50:51.000Z
2022-01-26T14:56:55.000Z
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if !defined(WRITER_HEADER_GUARD_1357924680) #define WRITER_HEADER_GUARD_1357924680 // Base include file. Must be first. #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp> #include <cstddef> #include <xalanc/XalanDOM/XalanDOMString.hpp> namespace XALAN_CPP_NAMESPACE { class XalanOutputStream; class XALAN_PLATFORMSUPPORT_EXPORT Writer { public: Writer(); virtual ~Writer(); /** * Close the stream */ virtual void close() = 0; /** * Flush the stream */ virtual void flush() = 0; /** * Get the stream associated with the writer... */ virtual XalanOutputStream* getStream(); /** * Get the stream associated with the writer... */ virtual const XalanOutputStream* getStream() const; // Output functions static const size_t npos; /** * Writes a string * * @param s string to write * @param theOffset starting offset in string to begin writing, default 0 * @param theLength number of characters to write. If the length is npos, then the array is assumed to be null-terminated. */ virtual void write( const char* s, size_t theOffset = 0, size_t theLength = npos) = 0; /** * Writes a string * * @param s string to write * @param theOffset starting offset in string to begin writing, default 0 * @param theLength number of characters to write. If the length is XalanDOMString::npos, then the array is assumed to be null-terminated. */ virtual void write( const XalanDOMChar* s, XalanDOMString::size_type theOffset = 0, XalanDOMString::size_type theLength = XalanDOMString::npos) = 0; /** * Writes a character * * @param c character to write */ virtual void write(XalanDOMChar c) = 0; /** * Writes a string * * @param s string to write * @param theOffset starting offset in string to begin writing, default 0 * @param theLength number of characters to write. If the length is XalanDOMString::npos, then the entire string is printed. */ virtual void write( const XalanDOMString& s, XalanDOMString::size_type theOffset = 0, XalanDOMString::size_type theLength = XalanDOMString::npos) = 0; private: // Not implemented Writer(const Writer&); Writer& operator=(const Writer&); bool operator==(const Writer&); }; } #endif // WRITER_HEADER_GUARD_1357924680
23.682432
144
0.637946
ulisesten
433d1527559c11feb2d9e258eecd883f91e66a7b
2,174
hh
C++
src/rng/LC_Subrandom_Generator.hh
rspavel/Draco
b279b1afbfbb39f2d521579697172394c5efd81d
[ "BSD-3-Clause-Open-MPI" ]
null
null
null
src/rng/LC_Subrandom_Generator.hh
rspavel/Draco
b279b1afbfbb39f2d521579697172394c5efd81d
[ "BSD-3-Clause-Open-MPI" ]
null
null
null
src/rng/LC_Subrandom_Generator.hh
rspavel/Draco
b279b1afbfbb39f2d521579697172394c5efd81d
[ "BSD-3-Clause-Open-MPI" ]
null
null
null
//----------------------------------*-C++-*----------------------------------// /*! * \file rng/LC_Subrandom_Generator.hh * \author Kent Budge * \brief Definition of class LC_Subrandom_Generator * \note Copyright (C) 2016-2019 Triad National Security, LLC. * All rights reserved. */ //---------------------------------------------------------------------------// #ifndef rng_LC_Subrandom_Generator_hh #define rng_LC_Subrandom_Generator_hh #include "Subrandom_Generator.hh" #include "gsl/gsl_rng.h" namespace rtt_rng { //===========================================================================// /*! * \class LC_Subrandom_Generator * \brief Generator for a sequence of subrandom (pseudorandom) vectors. * * This is an implementation of the old, hoary linear congruential * generator. The name is somewhat of a misnomer since this is a true * pseudorandom generator (is that an oxymoron?) rather than a subrandom * generator. In other words, the approximation to an integral computed using * this sequence as quadrature points converges smoothly, but only as * 1/sqrt(N) rather than 1/N. */ //===========================================================================// class LC_Subrandom_Generator : public Subrandom_Generator { public: // NESTED CLASSES AND TYPEDEFS // CREATORS //! Normal constructor. explicit LC_Subrandom_Generator(unsigned const count = 1); ~LC_Subrandom_Generator(); // MANIPULATORS //! Advance sequence. void shift_vector(); //! Get the next element in the current vector. double shift(); // ACCESSORS bool check_class_invariants() const; private: // NESTED CLASSES AND TYPEDEFS // IMPLEMENTATION //! not implemented LC_Subrandom_Generator(LC_Subrandom_Generator const &); // not implemented LC_Subrandom_Generator &operator=(LC_Subrandom_Generator const &); // DATA gsl_rng *generator_; }; } // end namespace rtt_rng #endif // rng_LC_Subrandom_Generator_hh //---------------------------------------------------------------------------// // end of rng/LC_Subrandom_Generator.hh //---------------------------------------------------------------------------//
28.233766
79
0.579577
rspavel
433e267645d7db0ec43692267f8e771a01a48d07
511
hpp
C++
plugins/libpng/include/sge/libpng/error_context_ref.hpp
cpreh/spacegameengine
313a1c34160b42a5135f8223ffaa3a31bc075a01
[ "BSL-1.0" ]
2
2016-01-27T13:18:14.000Z
2018-05-11T01:11:32.000Z
plugins/libpng/include/sge/libpng/error_context_ref.hpp
cpreh/spacegameengine
313a1c34160b42a5135f8223ffaa3a31bc075a01
[ "BSL-1.0" ]
null
null
null
plugins/libpng/include/sge/libpng/error_context_ref.hpp
cpreh/spacegameengine
313a1c34160b42a5135f8223ffaa3a31bc075a01
[ "BSL-1.0" ]
3
2018-05-11T01:11:34.000Z
2021-04-24T19:47:45.000Z
// Copyright Carl Philipp Reh 2006 - 2019. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef SGE_LIBPNG_ERROR_CONTEXT_REF_HPP_INCLUDED #define SGE_LIBPNG_ERROR_CONTEXT_REF_HPP_INCLUDED #include <sge/libpng/error_context_fwd.hpp> #include <fcppt/reference_impl.hpp> namespace sge::libpng { using error_context_ref = fcppt::reference<sge::libpng::error_context>; } #endif
25.55
71
0.761252
cpreh
433f775a1a2d66621435d3f82f7810ba28529c92
581
cpp
C++
272 TEX Quotes.cpp
zihadboss/UVA-Solutions
020fdcb09da79dc0a0411b04026ce3617c09cd27
[ "Apache-2.0" ]
86
2016-01-20T11:36:50.000Z
2022-03-06T19:43:14.000Z
272 TEX Quotes.cpp
Mehedishihab/UVA-Solutions
474fe3d9d9ba574b97fd40ca5abb22ada95654a1
[ "Apache-2.0" ]
null
null
null
272 TEX Quotes.cpp
Mehedishihab/UVA-Solutions
474fe3d9d9ba574b97fd40ca5abb22ada95654a1
[ "Apache-2.0" ]
113
2015-12-04T06:40:57.000Z
2022-02-11T02:14:28.000Z
#include <iostream> #include <string> using namespace std; int main() { string temp; bool isFirst(true); while (getline(cin, temp)) { for (string::iterator iter = temp.begin(); iter != temp.end(); ++iter) { if (*iter == '"') { if (isFirst) cout << "``"; else cout << "''"; isFirst = !isFirst; } else cout << *iter; } cout << '\n'; } }
18.15625
78
0.342513
zihadboss
434088dc41dd9cf7b51e868677a756cd0fce5f2d
1,186
cpp
C++
Game_Engine/GameOver.cpp
IndiaWomble/Game-Engine
8b2a47db6e976d272e62c6f9f4f2bc8d6b07b957
[ "Apache-2.0" ]
null
null
null
Game_Engine/GameOver.cpp
IndiaWomble/Game-Engine
8b2a47db6e976d272e62c6f9f4f2bc8d6b07b957
[ "Apache-2.0" ]
null
null
null
Game_Engine/GameOver.cpp
IndiaWomble/Game-Engine
8b2a47db6e976d272e62c6f9f4f2bc8d6b07b957
[ "Apache-2.0" ]
null
null
null
//Game Over State source file #include "GameOver.h" //Instantiating static variable gameOverID const std::string GameOverState::gameOverID = "GAMEOVER"; //GameOver State constructor GameOverState::GameOverState(std::vector<GameObject*> parameter, void (*callbackFunction)()) { for (int i = 0; i < parameter.size(); i++) gameObjects.push_back(parameter[i]); callback = callbackFunction; sleepTime = 0.0f; } //Return state ID std::string GameOverState::GetStateID() const { return gameOverID; } //Update function of GameOver State void GameOverState::Update(float dtAsSeconds) { //Find a way to change state to play state and revert back all the updates to the initial values /*sleepTime += dtAsSeconds; if (sleepTime > 2) callback();*/ } //Render function of GameOver State void GameOverState::Render(RenderWindow* window) { gameObjects[1]->DrawStill(window); } //First function to be called when we enter GameOver State bool GameOverState::OnEnter() { return true; } //Last function to be called when we exit GameOver State bool GameOverState::OnExit() { for (int i = 0; i < gameObjects.size(); i++) gameObjects[i]->Clean(); gameObjects.clear(); return true; }
23.254902
97
0.735245
IndiaWomble
43416145b8f4cbbf25133e338b72525b6d825609
4,188
cpp
C++
src/ledger/FeeFrame.cpp
RomanTkachenkoDistr/SwarmCore
db0544758e7bb3c879778cfdd6946b9a72ba23ab
[ "Apache-2.0", "BSD-2-Clause", "MIT", "ECL-2.0", "BSL-1.0", "BSD-3-Clause" ]
null
null
null
src/ledger/FeeFrame.cpp
RomanTkachenkoDistr/SwarmCore
db0544758e7bb3c879778cfdd6946b9a72ba23ab
[ "Apache-2.0", "BSD-2-Clause", "MIT", "ECL-2.0", "BSL-1.0", "BSD-3-Clause" ]
null
null
null
src/ledger/FeeFrame.cpp
RomanTkachenkoDistr/SwarmCore
db0544758e7bb3c879778cfdd6946b9a72ba23ab
[ "Apache-2.0", "BSD-2-Clause", "MIT", "ECL-2.0", "BSL-1.0", "BSD-3-Clause" ]
null
null
null
#include "ledger/FeeFrame.h" #include "database/Database.h" #include "crypto/SecretKey.h" #include "crypto/SHA.h" #include "LedgerDelta.h" #include "util/types.h" using namespace std; using namespace soci; namespace stellar { FeeFrame::FeeFrame() : EntryFrame(LedgerEntryType::FEE), mFee(mEntry.data.feeState()) { } FeeFrame::FeeFrame(LedgerEntry const& from) : EntryFrame(from), mFee(mEntry.data.feeState()) { } FeeFrame::FeeFrame(FeeFrame const& from) : FeeFrame(from.mEntry) { } FeeFrame& FeeFrame::operator=(FeeFrame const& other) { if (&other != this) { mFee = other.mFee; mKey = other.mKey; mKeyCalculated = other.mKeyCalculated; } return *this; } FeeFrame::pointer FeeFrame::create(FeeType feeType, int64_t fixedFee, int64_t percentFee, AssetCode asset, AccountID* accountID, AccountType* accountType, int64_t subtype, int64_t lowerBound, int64_t upperBound) { LedgerEntry le; le.data.type(LedgerEntryType::FEE); FeeEntry& entry = le.data.feeState(); entry.fixedFee = fixedFee; entry.percentFee = percentFee; entry.feeType = feeType; entry.asset = asset; entry.subtype = subtype; if (accountID) entry.accountID.activate() = *accountID; if (accountType) entry.accountType.activate() = *accountType; entry.lowerBound = lowerBound; entry.upperBound = upperBound; entry.hash = calcHash(feeType, asset, accountID, accountType, subtype); return std::make_shared<FeeFrame>(le); } bool FeeFrame::isInRange(int64_t a, int64_t b, int64_t point) { return a <= point && point <= b; } int64_t FeeFrame::calculatePercentFee(int64_t amount, bool roundUp) { if (mFee.percentFee == 0) return 0; auto rounding = roundUp ? ROUND_UP : ROUND_DOWN; return bigDivide(amount, mFee.percentFee, 100 * ONE, rounding); } bool FeeFrame::calculatePercentFee(const uint64_t amount, uint64_t& result, const Rounding rounding) const { result = 0; if (mFee.percentFee == 0) { return true; } return bigDivide(result, amount, mFee.percentFee, 100 * ONE, rounding); } int64_t FeeFrame::calculatePercentFeeForPeriod(int64_t amount, int64_t periodPassed, int64_t basePeriod) { if (mFee.percentFee == 0 || periodPassed == 0 || basePeriod == 0 || amount == 0) { return 0; } int64_t percentFeeForFullPeriod = calculatePercentFee(amount); return bigDivide(percentFeeForFullPeriod, periodPassed, basePeriod, ROUND_UP); } bool FeeFrame::isValid(FeeEntry const& oe) { auto res = oe.fixedFee >= 0 && oe.percentFee >= 0 && oe.percentFee <= 100 * ONE && isFeeTypeValid(oe.feeType) && oe.lowerBound <= oe.upperBound; return res; } Hash FeeFrame::calcHash(FeeType feeType, AssetCode asset, AccountID* accountID, AccountType* accountType, int64_t subtype) { std::string data = ""; char buff[100]; snprintf(buff, sizeof(buff), "type:%i", feeType); std::string buffAsStdStr = buff; data += buffAsStdStr; std::string rawAsset = asset; snprintf(buff, sizeof(buff), "asset:%s", rawAsset.c_str()); buffAsStdStr = buff; data += buffAsStdStr; snprintf(buff, sizeof(buff), "subtype:%s", std::to_string(subtype).c_str()); buffAsStdStr = buff; data += buffAsStdStr; if (accountID) { std::string actIDStrKey = PubKeyUtils::toStrKey(*accountID); snprintf(buff, sizeof(buff), "accountID:%s", actIDStrKey.c_str()); buffAsStdStr = buff; data += buffAsStdStr; } if (accountType) { snprintf(buff, sizeof(buff), "accountType:%i", *accountType); buffAsStdStr = buff; data += buffAsStdStr; } return Hash(sha256(data)); } bool FeeFrame::isValid() const { return isValid(mFee); } }
27.019355
121
0.608644
RomanTkachenkoDistr
43469e8d2db6b4e321b9f51e6b035ac8d2e50f45
13,751
cxx
C++
code/plugins/xray_re/xr_scene.cxx
Rikoshet-234/xray-oxygen
eaac3fa4780639152684f3251b8b4452abb8e439
[ "Apache-2.0" ]
7
2018-03-27T12:36:07.000Z
2020-06-26T11:31:52.000Z
code/plugins/xray_re/xr_scene.cxx
Rikoshet-234/xray-oxygen
eaac3fa4780639152684f3251b8b4452abb8e439
[ "Apache-2.0" ]
2
2018-05-26T23:17:14.000Z
2019-04-14T18:33:27.000Z
code/plugins/xray_re/xr_scene.cxx
Rikoshet-234/xray-oxygen
eaac3fa4780639152684f3251b8b4452abb8e439
[ "Apache-2.0" ]
5
2020-10-18T11:55:26.000Z
2022-03-28T07:21:35.000Z
#include "xr_scene.h" #include "xr_scene_ai_map.h" #include "xr_scene_details.h" #include "xr_scene_glows.h" #include "xr_scene_groups.h" #include "xr_scene_lights.h" #include "xr_scene_particles.h" #include "xr_scene_portals.h" #include "xr_scene_sectors.h" #include "xr_scene_shapes.h" #include "xr_scene_sound_envs.h" #include "xr_scene_sound_srcs.h" #include "xr_scene_spawns.h" #include "xr_scene_visuals.h" #include "xr_scene_wallmarks.h" #include "xr_scene_ways.h" #include "xr_file_system.h" #include "xr_motion.h" #include "xr_utils.h" using namespace xray_re; void b_params::init() { sm_angle = 75.f; weld_distance = 0.005f; lm_rms_zero = 4; lm_rms = 4; lm_jitter_samples = 9; lm_pixels_per_meter = 10.0; convert_progressive = 0; pm_uv = 0; pm_pos = 0; pm_curv = 0; pm_border_h_angle = 0; pm_border_h_distance = 0; pm_heuristic = 0; } void b_params::set_debug() { lm_pixels_per_meter = 0.1f; lm_jitter_samples = 1; convert_progressive = XRLC_QUALITY_DRAFT; } void b_params::set_release() { lm_pixels_per_meter = 10.f; lm_jitter_samples = 9; convert_progressive = XRLC_QUALITY_HIGH; } void b_params::save_v12(xr_ini_writer *w) { w->open_section("build_params"); w->write("light_jitter_samples", lm_jitter_samples); w->write("light_pixel_per_meter", lm_pixels_per_meter); w->write("light_quality", 2); // TEMP w->write("light_quality_reserved", 0); // TEMP w->write("light_rms", lm_rms); w->write("light_rms_zero", lm_rms_zero); w->write("reserved_0", pm_uv); w->write("reserved_1", pm_pos); w->write("reserved_2", pm_curv); w->write("reserved_3", pm_border_h_angle); w->write("reserved_4", pm_border_h_distance); w->write("reserved_5", pm_heuristic); w->write("smooth_angle", sm_angle); w->write("weld_distance", weld_distance); w->close_section(); } //////////////////////////////////////////////////////////////////////////////// xr_scene::xr_scene(): m_name("level"), m_name_prefix("level_prefix") { m_parts.push_back(new xr_scene_ai_map(*this)); m_parts.push_back(new xr_scene_details(*this)); m_parts.push_back(new xr_scene_glows(*this)); m_parts.push_back(new xr_scene_groups(*this)); m_parts.push_back(new xr_scene_lights(*this)); m_parts.push_back(new xr_scene_visuals(*this)); m_parts.push_back(new xr_scene_particles(*this)); m_parts.push_back(new xr_scene_portals(*this)); m_parts.push_back(new xr_scene_sectors(*this)); m_parts.push_back(new xr_scene_shapes(*this)); m_parts.push_back(new xr_scene_sound_envs(*this)); m_parts.push_back(new xr_scene_sound_srcs(*this)); m_parts.push_back(new xr_scene_spawns(*this)); m_parts.push_back(new xr_scene_wallmarks(*this)); m_parts.push_back(new xr_scene_ways(*this)); m_camera_pos.set(); m_camera_orient.set(); m_bparams.init(); set_quality(XRLC_QUALITY_HIGH); m_guid.reset(); } xr_scene::~xr_scene() { delete_elements(m_parts); delete_elements(m_objects); } void xr_scene::set_quality(unsigned xrlc_quality) { switch (xrlc_quality) { case XRLC_QUALITY_DRAFT: m_hemi_quality = 0; m_sun_quality = 0; m_bparams.set_debug(); break; case XRLC_QUALITY_HIGH: case XRLC_QUALITY_CUSTOM: default: m_hemi_quality = 3; m_sun_quality = 3; m_bparams.set_release(); break; } } xr_scene_part* xr_scene::part(scene_chunk_id chunk_id) { for (xr_scene_part_vec_it it = m_parts.begin(), end = m_parts.end(); it != end; ++it) { if ((*it)->chunk_id() == chunk_id) return *it; } return 0; } xr_scene_ai_map* xr_scene::ai_map() { return dynamic_cast<xr_scene_ai_map*>(part(SCENE_CHUNK_AI_MAP)); } xr_scene_details* xr_scene::details() { return dynamic_cast<xr_scene_details*>(part(SCENE_CHUNK_DETAIL_OBJECTS)); } xr_scene_glows* xr_scene::glows() { return dynamic_cast<xr_scene_glows*>(part(SCENE_CHUNK_GLOWS)); } xr_scene_groups* xr_scene::groups() { return dynamic_cast<xr_scene_groups*>(part(SCENE_CHUNK_GROUPS)); } xr_scene_lights* xr_scene::lights() { return dynamic_cast<xr_scene_lights*>(part(SCENE_CHUNK_LIGHTS)); } xr_scene_particles* xr_scene::particles() { return dynamic_cast<xr_scene_particles*>(part(SCENE_CHUNK_PARTICLES)); } xr_scene_portals* xr_scene::portals() { return dynamic_cast<xr_scene_portals*>(part(SCENE_CHUNK_PORTALS)); } xr_scene_sectors* xr_scene::sectors() { return dynamic_cast<xr_scene_sectors*>(part(SCENE_CHUNK_SECTORS)); } xr_scene_shapes* xr_scene::shapes() { return dynamic_cast<xr_scene_shapes*>(part(SCENE_CHUNK_SHAPES)); } xr_scene_sound_envs* xr_scene::sound_envs() { return dynamic_cast<xr_scene_sound_envs*>(part(SCENE_CHUNK_SOUND_ENVS)); } xr_scene_sound_srcs* xr_scene::sound_srcs() { return dynamic_cast<xr_scene_sound_srcs*>(part(SCENE_CHUNK_SOUND_SRCS)); } xr_scene_spawns* xr_scene::spawns() { return dynamic_cast<xr_scene_spawns*>(part(SCENE_CHUNK_SPAWNS)); } xr_scene_visuals* xr_scene::visuals() { return dynamic_cast<xr_scene_visuals*>(part(SCENE_CHUNK_SCENE_OBJECTS)); } xr_scene_wallmarks* xr_scene::wallmarks() { return dynamic_cast<xr_scene_wallmarks*>(part(SCENE_CHUNK_WALLMARKS)); } xr_scene_ways* xr_scene::ways() { return dynamic_cast<xr_scene_ways*>(part(SCENE_CHUNK_WAYS)); } xr_custom_object* xr_scene::create_object(tools_class_id class_id) { switch (class_id) { case TOOLS_CLASS_GROUP: return new xr_group_object(*this); case TOOLS_CLASS_GLOW: return new xr_glow_object(*this); case TOOLS_CLASS_SCENE_OBJECT: return new xr_visual_object(*this); case TOOLS_CLASS_LIGHT: return new xr_light_object(*this); case TOOLS_CLASS_SHAPE: return new xr_shape_object(*this); case TOOLS_CLASS_SOUND_ENV: return new xr_sound_env_object(*this); case TOOLS_CLASS_SOUND_SRC: return new xr_sound_src_object(*this); case TOOLS_CLASS_SPAWN: return new xr_spawn_object(*this); case TOOLS_CLASS_WAY: return new xr_way_object(*this); case TOOLS_CLASS_SECTOR: return new xr_sector_object(*this); case TOOLS_CLASS_PORTAL: return new xr_portal_object(*this); case TOOLS_CLASS_PARTICLE: return new xr_particle_object(*this); default: return 0; } } struct read_object { explicit read_object(xr_scene& _scene): scene(_scene) {} void operator()(xr_custom_object*& object, xr_reader& r) { xr_assert(sizeof(tools_class_id) == 4); tools_class_id class_id; if (!r.r_chunk(TOOLS_CHUNK_OBJECT_CLASS, class_id)) xr_not_expected(); object = scene.create_object(class_id); xr_assert(object); xr_reader* s = r.open_chunk(TOOLS_CHUNK_OBJECT_DATA); xr_assert(s); object->load(*s); r.close_chunk(s); } xr_scene& scene; }; void xr_scene::load_objects(xr_reader& r, uint32_t chunk_id, xr_custom_object_vec& objects) { xr_reader* s = r.open_chunk(chunk_id); if (s) { s->r_chunks(objects, read_object(*this)); r.close_chunk(s); } } struct write_object { void operator()(xr_custom_object* const& object, xr_writer& w) const { tools_class_id class_id = object->class_id(); w.w_chunk(TOOLS_CHUNK_OBJECT_CLASS, class_id); w.open_chunk(TOOLS_CHUNK_OBJECT_DATA); object->save(w); w.close_chunk(); }}; void xr_scene::save_objects(xr_writer& w, uint32_t chunk_id, const xr_custom_object_vec& objects) const { w.open_chunk(chunk_id); w.w_chunks(objects, write_object()); w.close_chunk(); } struct ini_write_object { void operator()(xr_custom_object* const& object, xr_ini_writer* w) const { object->save_v12(w); }}; void xr_scene::save_objects(xr_ini_writer* w, const std::vector<xr_custom_object*>& objects, const char* prefix) const { w->w_sections(objects, ini_write_object(), prefix); } void xr_scene::load_options(xr_reader& r) { uint32_t version; if (!r.r_chunk<uint32_t>(SCENE_CHUNK_LO_VERSION, version)) xr_not_expected(); xr_assert(version == SCENE_LO_VERSION); if (!r.r_chunk(SCENE_CHUNK_LO_NAMES, m_name)) xr_not_expected(); r.r_chunk(SCENE_CHUNK_LO_NAME_PREFIX, m_name_prefix); r.r_chunk(SCENE_CHUNK_LO_BOP, m_custom_data); if (r.r_chunk(SCENE_CHUNK_LO_BPARAMS_VERSION, version) && version == SCENE_LO_BPARAMS_VERSION) { r.r_chunk<b_params>(SCENE_CHUNK_LO_BPARAMS, m_bparams); } if (r.find_chunk(SCENE_CHUNK_LO_QUALITY)) { m_hemi_quality = r.r_u8(); m_sun_quality = r.r_u8(); r.debug_find_chunk(); } } void xr_scene::save_options(xr_writer& w) { w.w_chunk<uint32_t>(SCENE_CHUNK_LO_VERSION, SCENE_LO_VERSION); w.w_chunk(SCENE_CHUNK_LO_NAMES, m_name); w.w_chunk(SCENE_CHUNK_LO_NAME_PREFIX, m_name_prefix); w.w_chunk(SCENE_CHUNK_LO_BOP, m_custom_data); w.w_chunk<uint32_t>(SCENE_CHUNK_LO_BPARAMS_VERSION, SCENE_LO_BPARAMS_VERSION); w.w_chunk(SCENE_CHUNK_LO_BPARAMS, m_bparams); w.open_chunk(SCENE_CHUNK_LO_QUALITY); w.w_u8(m_hemi_quality); w.w_u8(m_sun_quality); w.close_chunk(); } bool xr_scene::load(const char* name) { xr_file_system& fs = xr_file_system::instance(); xr_reader* r = fs.r_open(PA_MAPS, std::string(name) + ".level"); if (r == 0) return false; uint32_t version; if (!r->r_chunk<uint32_t>(SCENE_CHUNK_VERSION, version)) { msg("no scene version chunk"); xr_not_expected(); } xr_assert(version == SCENE_VERSION); if (version != SCENE_VERSION) { msg("unexpected scene version %" PRIu32, version); xr_not_expected(); } xr_reader* s = r->open_chunk(SCENE_CHUNK_OPTIONS); if (s) { load_options(*s); r->close_chunk(s); } else { msg("no level options chunk"); xr_not_expected(); } if (r->find_chunk(SCENE_CHUNK_CAMERA)) { r->r_fvector3(m_camera_pos); r->r_fvector3(m_camera_orient); r->debug_find_chunk(); } else { msg("no scene camera chunk"); xr_not_expected(); } if (!r->r_chunk<xr_guid>(TOOLS_CHUNK_GUID, m_guid)) { msg("no tools GUID chunk"); xr_not_expected(); } m_revision.load(*r); size_t num_objects = 0; if (r->find_chunk(SCENE_CHUNK_COUNT)) { num_objects = r->r_u32(); r->debug_find_chunk(); } load_objects(*r, SCENE_CHUNK_OBJECTS, m_objects); if (r->find_chunk(SCENE_CHUNK_SNAP_OBJECTS)) r->r_seq(r->r_u32(), m_snap_objects, xr_reader::f_r_sz()); fs.r_close(r); std::string parts_path(name); parts_path += '\\'; for (xr_scene_part_vec_it it = m_parts.begin(), end = m_parts.end(); it != end; ++it) { xr_scene_part* part = *it; r = fs.r_open(PA_MAPS, parts_path + part->file_name()); if (r == 0) msg("can't load scene part %s", part->file_name()); xr_assert(r); xr_guid guid; if (!r->r_chunk<xr_guid>(TOOLS_CHUNK_GUID, guid) || guid != m_guid) xr_not_expected(); xr_reader* s = r->open_chunk(part->chunk_id()); xr_assert(s); if (s) { part->load(*s); r->close_chunk(s); } fs.r_close(r); } return true; } bool xr_scene::save(const char* name) { xr_memory_writer* w = new xr_memory_writer(); w->w_chunk<uint32_t>(SCENE_CHUNK_VERSION, SCENE_VERSION); w->open_chunk(SCENE_CHUNK_OPTIONS); save_options(*w); w->close_chunk(); w->w_chunk(TOOLS_CHUNK_GUID, m_guid); m_revision.save(*w); w->open_chunk(SCENE_CHUNK_CAMERA); w->w_fvector3(m_camera_pos); w->w_fvector3(m_camera_orient); w->close_chunk(); w->open_chunk(SCENE_CHUNK_SNAP_OBJECTS); w->w_size_u32(m_snap_objects.size()); w->w_seq(m_snap_objects, xr_writer::f_w_sz()); w->close_chunk(); if (!m_objects.empty()) save_objects(*w, SCENE_CHUNK_OBJECTS, m_objects); bool status = w->save_to(PA_MAPS, std::string(name) + ".level"); delete w; xr_file_system& fs = xr_file_system::instance(); fs.create_folder(PA_MAPS, name); std::string parts_path(name); parts_path += '\\'; for (xr_scene_part_vec_it it = m_parts.begin(), end = m_parts.end(); it != end; ++it) { xr_scene_part* part = *it; w = new xr_memory_writer(); w->w_chunk(TOOLS_CHUNK_GUID, m_guid); w->open_chunk(part->chunk_id()); part->save(*w); w->close_chunk(); if (!w->save_to(PA_MAPS, parts_path + part->file_name())) msg("can't save scene part %s", part->file_name()); delete w; } return status; } bool xr_scene::save_v12(const char* name) { xr_ini_writer *w = new xr_ini_writer(); m_bparams.save_v12(w); w->open_section("camera"); w->write("hpb", m_camera_orient); w->write("pos", m_camera_pos); w->close_section(); write_guid(w); w->open_section("level_options"); w->write("bop", ""); w->write("game_type", 1); w->write("level_path", m_name, false); w->write("level_prefix", m_name_prefix, false); w->write("light_hemi_quality", m_hemi_quality); w->write("light_sun_quality", m_sun_quality); w->write("map_version", 1.0f); w->write("version", 12); w->write("version_bp", SCENE_LO_BPARAMS_VERSION); w->close_section(); m_revision.save_v12(w); w->open_section("version"); w->write("value", SCENE_VERSION); w->close_section(); w->save_to(PA_MAPS, std::string(name) + ".level"); delete w; xr_file_system& fs = xr_file_system::instance(); fs.create_folder(PA_MAPS, name); std::string parts_path(name); parts_path += '\\'; for (xr_scene_part_vec_it it = m_parts.begin(), end = m_parts.end(); it != end; ++it) { xr_scene_part* part = *it; const type_info& type = typeid(*part); w = new xr_ini_writer(); if (type == typeid(xr_scene_ai_map) || type == typeid(xr_scene_details) || type == typeid(xr_scene_wallmarks)) { w->w_chunk(TOOLS_CHUNK_GUID, m_guid); w->open_chunk(part->chunk_id()); part->save(*w); w->close_chunk(); } else { write_guid(w); part->save_v12(w); } if (!w->save_to(PA_MAPS, parts_path + part->file_name())) msg("can't save scene part %s", part->file_name()); delete w; } return true; } void xr_scene::write_guid(xr_ini_writer* w) { //msg("%s", "guid save_v12"); w->open_section("guid"); uint32_t tmp[4]; memcpy(tmp, ((char *)m_guid.g) + 1, sizeof(uint32_t) * 4); xr_guid *guid2 = new xr_guid; memcpy(&guid2->g, tmp, sizeof(uint32_t) * 4); w->write("guid_g0", &m_guid); w->write("guid_g1", guid2); w->close_section(); } void xr_scene::write_revision(xr_ini_writer* w, bool scene_part) { m_revision.save_v12(w, scene_part); }
27.668008
120
0.726056
Rikoshet-234
434a512f05e53fd9827c861245143c832012ecc9
25,850
cxx
C++
GPU/GPUTracking/Base/hip/GPUReconstructionHIP.hip.cxx
aknospe/AliRoot
96d76b2078d6b757a2843ae4a890a85021241e70
[ "BSD-3-Clause" ]
null
null
null
GPU/GPUTracking/Base/hip/GPUReconstructionHIP.hip.cxx
aknospe/AliRoot
96d76b2078d6b757a2843ae4a890a85021241e70
[ "BSD-3-Clause" ]
null
null
null
GPU/GPUTracking/Base/hip/GPUReconstructionHIP.hip.cxx
aknospe/AliRoot
96d76b2078d6b757a2843ae4a890a85021241e70
[ "BSD-3-Clause" ]
null
null
null
//**************************************************************************\ //* This file is property of and copyright by the ALICE Project *\ //* ALICE Experiment at CERN, All rights reserved. *\ //* *\ //* Primary Authors: Matthias Richter <[email protected]> *\ //* for The ALICE HLT Project. *\ //* *\ //* Permission to use, copy, modify and distribute this software and its *\ //* documentation strictly for non-commercial purposes is hereby granted *\ //* without fee, provided that the above copyright notice appears in all *\ //* copies and that both the copyright notice and this permission notice *\ //* appear in the supporting documentation. The authors make no claims *\ //* about the suitability of this software for any purpose. It is *\ //* provided "as is" without express or implied warranty. *\ //************************************************************************** /// \file GPUReconstructionHIP.hip.cxx /// \author David Rohr #define GPUCA_GPUTYPE_VEGA #define GPUCA_UNROLL(CUDA, HIP) GPUCA_M_UNROLL_##HIP #include <hip/hip_runtime.h> #ifdef __CUDACC__ #define hipExtLaunchKernelGGL(...) #else #include <hip/hip_ext.h> #endif #include "GPUDef.h" // clang-format off #ifndef GPUCA_NO_CONSTANT_MEMORY #ifdef GPUCA_CONSTANT_AS_ARGUMENT #define GPUCA_CONSMEM_PTR const GPUConstantMemCopyable gGPUConstantMemBufferByValue, #define GPUCA_CONSMEM_CALL gGPUConstantMemBufferHost, #define GPUCA_CONSMEM (const_cast<GPUConstantMem&>(gGPUConstantMemBufferByValue.v)) #else #define GPUCA_CONSMEM_PTR #define GPUCA_CONSMEM_CALL #define GPUCA_CONSMEM (gGPUConstantMemBuffer.v) #endif #else #define GPUCA_CONSMEM_PTR const GPUConstantMem *gGPUConstantMemBuffer, #define GPUCA_CONSMEM_CALL me->mDeviceConstantMem, #define GPUCA_CONSMEM const_cast<GPUConstantMem&>(*gGPUConstantMemBuffer) #endif #define GPUCA_KRNL_BACKEND_CLASS GPUReconstructionHIPBackend // clang-format on #include "GPUReconstructionHIP.h" #include "GPUReconstructionHIPInternals.h" #include "GPUReconstructionIncludes.h" #ifdef GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM __global__ void gGPUConstantMemBuffer_dummy(int* p) { *p = *(int*)&gGPUConstantMemBuffer; } #endif using namespace GPUCA_NAMESPACE::gpu; __global__ void dummyInitKernel(void* foo) {} #if defined(HAVE_O2HEADERS) && !defined(GPUCA_NO_ITS_TRAITS) #include "ITStrackingHIP/VertexerTraitsHIP.h" #else namespace o2 { namespace its { class VertexerTraitsHIP : public VertexerTraits { }; class TrackerTraitsHIP : public TrackerTraits { }; } // namespace its } // namespace o2 #endif class GPUDebugTiming { public: GPUDebugTiming(bool d, void** t, hipStream_t* s, GPUReconstruction::krnlSetup& x, GPUReconstructionHIPBackend* r = nullptr) : mDeviceTimers(t), mStreams(s), mXYZ(x), mRec(r), mDo(d) { if (mDo) { if (mDeviceTimers) { GPUFailedMsg(hipEventRecord((hipEvent_t)mDeviceTimers[0], mStreams[mXYZ.x.stream])); } else { mTimer.ResetStart(); } } } ~GPUDebugTiming() { if (mDo) { if (mDeviceTimers) { GPUFailedMsg(hipEventRecord((hipEvent_t)mDeviceTimers[1], mStreams[mXYZ.x.stream])); GPUFailedMsg(hipEventSynchronize((hipEvent_t)mDeviceTimers[1])); float v; GPUFailedMsg(hipEventElapsedTime(&v, (hipEvent_t)mDeviceTimers[0], (hipEvent_t)mDeviceTimers[1])); mXYZ.t = v * 1.e-3; } else { GPUFailedMsg(hipStreamSynchronize(mStreams[mXYZ.x.stream])); mXYZ.t = mTimer.GetCurrentElapsedTime(); } } } private: void** mDeviceTimers; hipStream_t* mStreams; GPUReconstruction::krnlSetup& mXYZ; GPUReconstructionHIPBackend* mRec; HighResTimer mTimer; bool mDo; }; #include "GPUReconstructionIncludesDevice.h" /* // Not using templated kernel any more, since nvidia profiler does not resolve template names template <class T, int I, typename... Args> GPUg() void runKernelHIP(GPUCA_CONSMEM_PTR int iSlice_internal, Args... args) { GPUshared() typename T::GPUSharedMemory smem; T::template Thread<I>(get_num_groups(0), get_local_size(0), get_group_id(0), get_local_id(0), smem, T::Processor(GPUCA_CONSMEM)[iSlice_internal], args...); } */ #undef GPUCA_KRNL_REG #define GPUCA_KRNL_REG(args) __launch_bounds__(GPUCA_M_STRIP(args)) #undef GPUCA_KRNL_CUSTOM #define GPUCA_KRNL_CUSTOM(args) GPUCA_M_STRIP(args) #undef GPUCA_KRNL_BACKEND_XARGS #define GPUCA_KRNL_BACKEND_XARGS hipEvent_t *start, hipEvent_t *stop, #define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward) \ GPUCA_KRNL_PROP(x_class, x_attributes) \ GPUCA_KRNL_WRAP(GPUCA_KRNL_, x_class, x_attributes, x_arguments, x_forward) #define GPUCA_KRNL_CALL_single(x_class, x_attributes, x_arguments, x_forward) \ if (start == nullptr) { \ hipLaunchKernelGGL(HIP_KERNEL_NAME(GPUCA_M_CAT(krnl_, GPUCA_M_KRNL_NAME(x_class))), dim3(x.nBlocks), dim3(x.nThreads), 0, me->mInternals->Streams[x.stream], GPUCA_CONSMEM_CALL y.start, args...); \ } else { \ hipExtLaunchKernelGGL(HIP_KERNEL_NAME(GPUCA_M_CAT(krnl_, GPUCA_M_KRNL_NAME(x_class))), dim3(x.nBlocks), dim3(x.nThreads), 0, me->mInternals->Streams[x.stream], *start, *stop, 0, GPUCA_CONSMEM_CALL y.start, args...); \ } #define GPUCA_KRNL_CALL_multi(x_class, x_attributes, x_arguments, x_forward) \ if (start == nullptr) { \ hipLaunchKernelGGL(HIP_KERNEL_NAME(GPUCA_M_CAT3(krnl_, GPUCA_M_KRNL_NAME(x_class), _multi)), dim3(x.nBlocks), dim3(x.nThreads), 0, me->mInternals->Streams[x.stream], GPUCA_CONSMEM_CALL y.start, y.num, args...); \ } else { \ hipExtLaunchKernelGGL(HIP_KERNEL_NAME(GPUCA_M_CAT3(krnl_, GPUCA_M_KRNL_NAME(x_class), _multi)), dim3(x.nBlocks), dim3(x.nThreads), 0, me->mInternals->Streams[x.stream], *start, *stop, 0, GPUCA_CONSMEM_CALL y.start, y.num, args...); \ } #include "GPUReconstructionKernels.h" #undef GPUCA_KRNL template <> void GPUReconstructionHIPBackend::runKernelBackendInternal<GPUMemClean16, 0>(krnlSetup& _xyz, void* const& ptr, unsigned long const& size) { GPUDebugTiming timer(mDeviceProcessingSettings.debugLevel, nullptr, mInternals->Streams, _xyz, this); GPUFailedMsg(hipMemsetAsync(ptr, 0, size, mInternals->Streams[_xyz.x.stream])); } template <class T, int I, typename... Args> void GPUReconstructionHIPBackend::runKernelBackendInternal(krnlSetup& _xyz, const Args&... args) { if (mDeviceProcessingSettings.deviceTimers) { #ifdef __CUDACC__ GPUFailedMsg(hipEventRecord((hipEvent_t)mDebugEvents->DebugStart, mInternals->Streams[x.stream])); #endif backendInternal<T, I>::runKernelBackendMacro(_xyz, this, (hipEvent_t*)&mDebugEvents->DebugStart, (hipEvent_t*)&mDebugEvents->DebugStop, args...); #ifdef __CUDACC__ GPUFailedMsg(hipEventRecord((hipEvent_t)mDebugEvents->DebugStop, mInternals->Streams[x.stream])); #endif GPUFailedMsg(hipEventSynchronize((hipEvent_t)mDebugEvents->DebugStop)); float v; GPUFailedMsg(hipEventElapsedTime(&v, (hipEvent_t)mDebugEvents->DebugStart, (hipEvent_t)mDebugEvents->DebugStop)); _xyz.t = v * 1.e-3; } else { backendInternal<T, I>::runKernelBackendMacro(_xyz, this, nullptr, nullptr, args...); } } template <class T, int I, typename... Args> int GPUReconstructionHIPBackend::runKernelBackend(krnlSetup& _xyz, const Args&... args) { auto& x = _xyz.x; auto& z = _xyz.z; if (z.evList) { for (int k = 0; k < z.nEvents; k++) { GPUFailedMsg(hipStreamWaitEvent(mInternals->Streams[x.stream], ((hipEvent_t*)z.evList)[k], 0)); } } runKernelBackendInternal<T, I>(_xyz, args...); GPUFailedMsg(hipGetLastError()); if (z.ev) { GPUFailedMsg(hipEventRecord(*(hipEvent_t*)z.ev, mInternals->Streams[x.stream])); } return 0; } GPUReconstructionHIPBackend::GPUReconstructionHIPBackend(const GPUSettingsProcessing& cfg) : GPUReconstructionDeviceBase(cfg, sizeof(GPUReconstructionDeviceBase)) { if (mMaster == nullptr) { mInternals = new GPUReconstructionHIPInternals; } mProcessingSettings.deviceType = DeviceType::HIP; } GPUReconstructionHIPBackend::~GPUReconstructionHIPBackend() { Exit(); // Make sure we destroy everything (in particular the ITS tracker) before we exit if (mMaster == nullptr) { delete mInternals; } } GPUReconstruction* GPUReconstruction_Create_HIP(const GPUSettingsProcessing& cfg) { return new GPUReconstructionHIP(cfg); } void GPUReconstructionHIPBackend::GetITSTraits(std::unique_ptr<o2::its::TrackerTraits>* trackerTraits, std::unique_ptr<o2::its::VertexerTraits>* vertexerTraits) { // if (trackerTraits) { // trackerTraits->reset(new o2::its::TrackerTraitsNV); // } if (vertexerTraits) { vertexerTraits->reset(new o2::its::VertexerTraitsHIP); } } void GPUReconstructionHIPBackend::UpdateSettings() { GPUCA_GPUReconstructionUpdateDefailts(); } int GPUReconstructionHIPBackend::InitDevice_Runtime() { if (mMaster == nullptr) { hipDeviceProp_t hipDeviceProp; int count, bestDevice = -1; double bestDeviceSpeed = -1, deviceSpeed; if (GPUFailedMsgI(hipGetDeviceCount(&count))) { GPUError("Error getting HIP Device Count"); return (1); } if (mDeviceProcessingSettings.debugLevel >= 2) { GPUInfo("Available HIP devices:"); } std::vector<bool> devicesOK(count, false); for (int i = 0; i < count; i++) { if (mDeviceProcessingSettings.debugLevel >= 4) { GPUInfo("Examining device %d", i); } if (mDeviceProcessingSettings.debugLevel >= 4) { GPUInfo("Obtained current memory usage for device %d", i); } if (GPUFailedMsgI(hipGetDeviceProperties(&hipDeviceProp, i))) { continue; } if (mDeviceProcessingSettings.debugLevel >= 4) { GPUInfo("Obtained device properties for device %d", i); } int deviceOK = true; const char* deviceFailure = ""; deviceSpeed = (double)hipDeviceProp.multiProcessorCount * (double)hipDeviceProp.clockRate * (double)hipDeviceProp.warpSize * (double)hipDeviceProp.major * (double)hipDeviceProp.major; if (mDeviceProcessingSettings.debugLevel >= 2) { GPUImportant("Device %s%2d: %s (Rev: %d.%d - Mem %lld)%s %s", deviceOK ? " " : "[", i, hipDeviceProp.name, hipDeviceProp.major, hipDeviceProp.minor, (long long int)hipDeviceProp.totalGlobalMem, deviceOK ? " " : " ]", deviceOK ? "" : deviceFailure); } if (!deviceOK) { continue; } devicesOK[i] = true; if (deviceSpeed > bestDeviceSpeed) { bestDevice = i; bestDeviceSpeed = deviceSpeed; } else { if (mDeviceProcessingSettings.debugLevel >= 2 && mDeviceProcessingSettings.deviceNum < 0) { GPUInfo("Skipping: Speed %f < %f\n", deviceSpeed, bestDeviceSpeed); } } } if (bestDevice == -1) { GPUWarning("No %sHIP Device available, aborting HIP Initialisation (Required mem: %lld)", count ? "appropriate " : "", (long long int)mDeviceMemorySize); return (1); } if (mDeviceProcessingSettings.deviceNum > -1) { if (mDeviceProcessingSettings.deviceNum >= (signed)count) { GPUWarning("Requested device ID %d does not exist", mDeviceProcessingSettings.deviceNum); return (1); } else if (!devicesOK[mDeviceProcessingSettings.deviceNum]) { GPUWarning("Unsupported device requested (%d)", mDeviceProcessingSettings.deviceNum); return (1); } else { bestDevice = mDeviceProcessingSettings.deviceNum; } } mDeviceId = bestDevice; GPUFailedMsgI(hipGetDeviceProperties(&hipDeviceProp, mDeviceId)); hipDeviceProp.totalConstMem = 65536; // TODO: Remove workaround, fixes incorrectly reported HIP constant memory if (mDeviceProcessingSettings.debugLevel >= 2) { GPUInfo("Using HIP Device %s with Properties:", hipDeviceProp.name); GPUInfo("\ttotalGlobalMem = %lld", (unsigned long long int)hipDeviceProp.totalGlobalMem); GPUInfo("\tsharedMemPerBlock = %lld", (unsigned long long int)hipDeviceProp.sharedMemPerBlock); GPUInfo("\tregsPerBlock = %d", hipDeviceProp.regsPerBlock); GPUInfo("\twarpSize = %d", hipDeviceProp.warpSize); GPUInfo("\tmaxThreadsPerBlock = %d", hipDeviceProp.maxThreadsPerBlock); GPUInfo("\tmaxThreadsDim = %d %d %d", hipDeviceProp.maxThreadsDim[0], hipDeviceProp.maxThreadsDim[1], hipDeviceProp.maxThreadsDim[2]); GPUInfo("\tmaxGridSize = %d %d %d", hipDeviceProp.maxGridSize[0], hipDeviceProp.maxGridSize[1], hipDeviceProp.maxGridSize[2]); GPUInfo("\ttotalConstMem = %lld", (unsigned long long int)hipDeviceProp.totalConstMem); GPUInfo("\tmajor = %d", hipDeviceProp.major); GPUInfo("\tminor = %d", hipDeviceProp.minor); GPUInfo("\tclockRate = %d", hipDeviceProp.clockRate); GPUInfo("\tmemoryClockRate = %d", hipDeviceProp.memoryClockRate); GPUInfo("\tmultiProcessorCount = %d", hipDeviceProp.multiProcessorCount); GPUInfo(" "); } mBlockCount = hipDeviceProp.multiProcessorCount; mMaxThreads = std::max<int>(mMaxThreads, hipDeviceProp.maxThreadsPerBlock * mBlockCount); mWarpSize = 64; mDeviceName = hipDeviceProp.name; mDeviceName += " (HIP GPU)"; if (hipDeviceProp.major < 3) { GPUError("Unsupported HIP Device"); return (1); } #ifndef GPUCA_NO_CONSTANT_MEMORY if (gGPUConstantMemBufferSize > hipDeviceProp.totalConstMem) { GPUError("Insufficient constant memory available on GPU %d < %d!", (int)hipDeviceProp.totalConstMem, (int)gGPUConstantMemBufferSize); return (1); } #endif if (GPUFailedMsgI(hipSetDevice(mDeviceId))) { GPUError("Could not set HIP Device!"); return (1); } /*if (GPUFailedMsgI(hipDeviceSetLimit(hipLimitStackSize, GPUCA_GPU_STACK_SIZE))) { GPUError("Error setting HIP stack size"); GPUFailedMsgI(hipDeviceReset()); return(1); }*/ if (mDeviceMemorySize > hipDeviceProp.totalGlobalMem || GPUFailedMsgI(hipMalloc(&mDeviceMemoryBase, mDeviceMemorySize))) { GPUError("HIP Memory Allocation Error (trying %lld bytes, %lld available)", (long long int)mDeviceMemorySize, (long long int)hipDeviceProp.totalGlobalMem); GPUFailedMsgI(hipDeviceReset()); return (1); } if (GPUFailedMsgI(hipHostMalloc(&mHostMemoryBase, mHostMemorySize))) { GPUError("Error allocating Page Locked Host Memory (trying %lld bytes)", (long long int)mHostMemorySize); GPUFailedMsgI(hipDeviceReset()); return (1); } if (mDeviceProcessingSettings.debugLevel >= 1) { GPUInfo("Memory ptrs: GPU (%lld bytes): %p - Host (%lld bytes): %p", (long long int)mDeviceMemorySize, mDeviceMemoryBase, (long long int)mHostMemorySize, mHostMemoryBase); memset(mHostMemoryBase, 0, mHostMemorySize); if (GPUFailedMsgI(hipMemset(mDeviceMemoryBase, 0xDD, mDeviceMemorySize))) { GPUError("Error during HIP memset"); GPUFailedMsgI(hipDeviceReset()); return (1); } } for (int i = 0; i < mNStreams; i++) { if (GPUFailedMsgI(hipStreamCreate(&mInternals->Streams[i]))) { GPUError("Error creating HIP Stream"); GPUFailedMsgI(hipDeviceReset()); return (1); } } void* devPtrConstantMem; #ifndef GPUCA_NO_CONSTANT_MEMORY if (GPUFailedMsgI(hipGetSymbolAddress(&devPtrConstantMem, HIP_SYMBOL(gGPUConstantMemBuffer)))) { GPUError("Error getting ptr to constant memory"); GPUFailedMsgI(hipDeviceReset()); return 1; } #else if (GPUFailedMsgI(hipMalloc(&devPtrConstantMem, gGPUConstantMemBufferSize))) { GPUError("HIP Memory Allocation Error"); GPUFailedMsgI(hipDeviceReset()); return (1); } #endif mDeviceConstantMem = (GPUConstantMem*)devPtrConstantMem; hipLaunchKernelGGL(HIP_KERNEL_NAME(dummyInitKernel), dim3(mBlockCount), dim3(256), 0, 0, mDeviceMemoryBase); GPUInfo("HIP Initialisation successfull (Device %d: %s (Frequency %d, Cores %d), %lld / %lld bytes host / global memory, Stack frame %d, Constant memory %lld)", mDeviceId, hipDeviceProp.name, hipDeviceProp.clockRate, hipDeviceProp.multiProcessorCount, (long long int)mHostMemorySize, (long long int)mDeviceMemorySize, (int)GPUCA_GPU_STACK_SIZE, (long long int)gGPUConstantMemBufferSize); } else { GPUReconstructionHIPBackend* master = dynamic_cast<GPUReconstructionHIPBackend*>(mMaster); mDeviceId = master->mDeviceId; mBlockCount = master->mBlockCount; mWarpSize = master->mWarpSize; mMaxThreads = master->mMaxThreads; mDeviceName = master->mDeviceName; mDeviceConstantMem = master->mDeviceConstantMem; mInternals = master->mInternals; } for (unsigned int i = 0; i < mEvents.size(); i++) { hipEvent_t* events = (hipEvent_t*)mEvents[i].data(); for (unsigned int j = 0; j < mEvents[i].size(); j++) { if (GPUFailedMsgI(hipEventCreate(&events[j]))) { GPUError("Error creating event"); GPUFailedMsgI(hipDeviceReset()); return 1; } } } return (0); } int GPUReconstructionHIPBackend::ExitDevice_Runtime() { // Uninitialize HIP SynchronizeGPU(); for (unsigned int i = 0; i < mEvents.size(); i++) { hipEvent_t* events = (hipEvent_t*)mEvents[i].data(); for (unsigned int j = 0; j < mEvents[i].size(); j++) { GPUFailedMsgI(hipEventDestroy(events[j])); } } if (mMaster == nullptr) { GPUFailedMsgI(hipFree(mDeviceMemoryBase)); #ifdef GPUCA_NO_CONSTANT_MEMORY GPUFailedMsgI(hipFree(mDeviceConstantMem)); #endif for (int i = 0; i < mNStreams; i++) { GPUFailedMsgI(hipStreamDestroy(mInternals->Streams[i])); } GPUFailedMsgI(hipHostFree(mHostMemoryBase)); GPUInfo("HIP Uninitialized"); } mHostMemoryBase = nullptr; mDeviceMemoryBase = nullptr; /*if (GPUFailedMsgI(hipDeviceReset())) { // No longer doing this, another thread might use the GPU GPUError("Could not uninitialize GPU"); return (1); }*/ return (0); } size_t GPUReconstructionHIPBackend::GPUMemCpy(void* dst, const void* src, size_t size, int stream, int toGPU, deviceEvent* ev, deviceEvent* evList, int nEvents) { if (mDeviceProcessingSettings.debugLevel >= 3) { stream = -1; } if (stream == -1) { SynchronizeGPU(); GPUFailedMsg(hipMemcpy(dst, src, size, toGPU ? hipMemcpyHostToDevice : hipMemcpyDeviceToHost)); } else { if (evList == nullptr) { nEvents = 0; } for (int k = 0; k < nEvents; k++) { GPUFailedMsg(hipStreamWaitEvent(mInternals->Streams[stream], ((hipEvent_t*)evList)[k], 0)); } GPUFailedMsg(hipMemcpyAsync(dst, src, size, toGPU == -2 ? hipMemcpyDeviceToDevice : toGPU ? hipMemcpyHostToDevice : hipMemcpyDeviceToHost, mInternals->Streams[stream])); } if (ev) { GPUFailedMsg(hipEventRecord(*(hipEvent_t*)ev, mInternals->Streams[stream == -1 ? 0 : stream])); } return size; } size_t GPUReconstructionHIPBackend::TransferMemoryInternal(GPUMemoryResource* res, int stream, deviceEvent* ev, deviceEvent* evList, int nEvents, bool toGPU, const void* src, void* dst) { if (!(res->Type() & GPUMemoryResource::MEMORY_GPU)) { if (mDeviceProcessingSettings.debugLevel >= 4) { GPUInfo("Skipped transfer of non-GPU memory resource: %s", res->Name()); } return 0; } if (mDeviceProcessingSettings.debugLevel >= 3) { GPUInfo("Copying to %s: %s - %lld bytes", toGPU ? "GPU" : "Host", res->Name(), (long long int)res->Size()); } return GPUMemCpy(dst, src, res->Size(), stream, toGPU, ev, evList, nEvents); } size_t GPUReconstructionHIPBackend::WriteToConstantMemory(size_t offset, const void* src, size_t size, int stream, deviceEvent* ev) { #ifdef GPUCA_CONSTANT_AS_ARGUMENT memcpy(((char*)&gGPUConstantMemBufferHost) + offset, src, size); #endif #ifndef GPUCA_NO_CONSTANT_MEMORY if (stream == -1) { GPUFailedMsg(hipMemcpyToSymbol(HIP_SYMBOL(gGPUConstantMemBuffer), src, size, offset, hipMemcpyHostToDevice)); } else { GPUFailedMsg(hipMemcpyToSymbolAsync(HIP_SYMBOL(gGPUConstantMemBuffer), src, size, offset, hipMemcpyHostToDevice, mInternals->Streams[stream])); } if (ev && stream != -1) { GPUFailedMsg(hipEventRecord(*(hipEvent_t*)ev, mInternals->Streams[stream])); } #else if (stream == -1) { GPUFailedMsg(hipMemcpy(((char*)mDeviceConstantMem) + offset, src, size, hipMemcpyHostToDevice)); } else { GPUFailedMsg(hipMemcpyAsync(((char*)mDeviceConstantMem) + offset, src, size, hipMemcpyHostToDevice, mInternals->Streams[stream])); } #endif return size; } void GPUReconstructionHIPBackend::ReleaseEvent(deviceEvent* ev) {} void GPUReconstructionHIPBackend::RecordMarker(deviceEvent* ev, int stream) { GPUFailedMsg(hipEventRecord(*(hipEvent_t*)ev, mInternals->Streams[stream])); } void GPUReconstructionHIPBackend::SynchronizeGPU() { GPUFailedMsg(hipDeviceSynchronize()); } void GPUReconstructionHIPBackend::SynchronizeStream(int stream) { GPUFailedMsg(hipStreamSynchronize(mInternals->Streams[stream])); } void GPUReconstructionHIPBackend::SynchronizeEvents(deviceEvent* evList, int nEvents) { for (int i = 0; i < nEvents; i++) { GPUFailedMsg(hipEventSynchronize(((hipEvent_t*)evList)[i])); } } void GPUReconstructionHIPBackend::StreamWaitForEvents(int stream, deviceEvent* evList, int nEvents) { for (int i = 0; i < nEvents; i++) { GPUFailedMsg(hipStreamWaitEvent(mInternals->Streams[stream], ((hipEvent_t*)evList)[i], 0)); } } bool GPUReconstructionHIPBackend::IsEventDone(deviceEvent* evList, int nEvents) { for (int i = 0; i < nEvents; i++) { hipError_t retVal = hipEventSynchronize(((hipEvent_t*)evList)[i]); if (retVal == hipErrorNotReady) { return false; } GPUFailedMsg(retVal); } return (true); } int GPUReconstructionHIPBackend::GPUDebug(const char* state, int stream) { // Wait for HIP-Kernel to finish and check for HIP errors afterwards, in case of debugmode hipError_t cuErr; cuErr = hipGetLastError(); if (cuErr != hipSuccess) { GPUError("HIP Error %s while running kernel (%s) (Stream %d)", hipGetErrorString(cuErr), state, stream); return (1); } if (mDeviceProcessingSettings.debugLevel == 0) { return (0); } if (GPUFailedMsgI(hipDeviceSynchronize())) { GPUError("HIP Error while synchronizing (%s) (Stream %d)", state, stream); return (1); } if (mDeviceProcessingSettings.debugLevel >= 3) { GPUInfo("GPU Sync Done"); } return (0); } int GPUReconstructionHIPBackend::registerMemoryForGPU(const void* ptr, size_t size) { return GPUFailedMsgI(hipHostRegister((void*)ptr, size, hipHostRegisterDefault)); } int GPUReconstructionHIPBackend::unregisterMemoryForGPU(const void* ptr) { return GPUFailedMsgI(hipHostUnregister((void*)ptr)); } void* GPUReconstructionHIPBackend::getGPUPointer(void* ptr) { void* retVal = nullptr; GPUFailedMsg(hipHostGetDevicePointer(&retVal, ptr, 0)); return retVal; } void GPUReconstructionHIPBackend::PrintKernelOccupancies() { unsigned int maxBlocks, threads, suggestedBlocks; #define GPUCA_KRNL(x_class, x_attributes, x_arguments, x_forward) GPUCA_KRNL_WRAP(GPUCA_KRNL_LOAD_, x_class, x_attributes, x_arguments, x_forward) #define GPUCA_KRNL_LOAD_single(x_class, x_attributes, x_arguments, x_forward) \ GPUFailedMsg(hipOccupancyMaxPotentialBlockSize(&suggestedBlocks, &threads, GPUCA_M_CAT(krnl_, GPUCA_M_KRNL_NAME(x_class)), 0, 0)); \ GPUFailedMsg(hipOccupancyMaxActiveBlocksPerMultiprocessor(&maxBlocks, GPUCA_M_CAT(krnl_, GPUCA_M_KRNL_NAME(x_class)), threads, 0)); \ GPUInfo("Kernel: %50s Block size: %34d, Maximum active blocks: %3d, Suggested blocks: %3d", GPUCA_M_STR(GPUCA_M_CAT(krnl_, GPUCA_M_KRNL_NAME(x_class))), threads, maxBlocks, suggestedBlocks); #define GPUCA_KRNL_LOAD_multi(x_class, x_attributes, x_arguments, x_forward) \ GPUFailedMsg(hipOccupancyMaxPotentialBlockSize(&suggestedBlocks, &threads, GPUCA_M_CAT3(krnl_, GPUCA_M_KRNL_NAME(x_class), _multi), 0, 0)); \ GPUFailedMsg(hipOccupancyMaxActiveBlocksPerMultiprocessor(&maxBlocks, GPUCA_M_CAT3(krnl_, GPUCA_M_KRNL_NAME(x_class), _multi), threads, 0)); \ GPUInfo("Kernel: %50s Block size: %4d, Maximum active blocks: %3d, Suggested blocks: %3d", GPUCA_M_STR(GPUCA_M_CAT3(krnl_, GPUCA_M_KRNL_NAME(x_class), _multi)), threads, maxBlocks, suggestedBlocks); #include "GPUReconstructionKernels.h" #undef GPUCA_KRNL #undef GPUCA_KRNL_LOAD_single #undef GPUCA_KRNL_LOAD_multi }
42.727273
287
0.670097
aknospe
434cdbfcf15052e3f8bba86220f599a4623b631c
1,203
hpp
C++
Hog_HLS/solution1/csim/build/HOG.hpp
DoubleGithub/HOG_Zedboard
6fc55c37ee210d7fc8bca919213e96bfc5c9d811
[ "MIT" ]
29
2018-07-09T10:12:47.000Z
2022-01-14T18:57:52.000Z
Hog_HLS/solution1/csim/build/HOG.hpp
DoubleGithub/HOG_Zedboard
6fc55c37ee210d7fc8bca919213e96bfc5c9d811
[ "MIT" ]
10
2018-10-30T10:38:12.000Z
2021-04-14T00:43:29.000Z
Hog_HLS/solution1/csim/build/HOG.hpp
DoubleGithub/HOG_Zedboard
6fc55c37ee210d7fc8bca919213e96bfc5c9d811
[ "MIT" ]
10
2019-07-04T07:39:38.000Z
2021-05-11T13:54:07.000Z
#ifndef HOG_HPP_ #define HOG_HPP_ #include "types.h" #include <iostream> #include "consts.h" #include <string.h> #include "math.h" #define VECTOR_SIZE 3780 using namespace std; // void computeHOG(unsigned char *inputImage , unsigned char *output); void hog(int *specs,unsigned char *image0); //void hog(unsigned int *specs, // unsigned char *image0, // unsigned char *image1, // unsigned char *image2, // unsigned char *image3, // unsigned char *image4, // unsigned char *image5, // unsigned char *image6, // unsigned char *image7, // int *vector); //void hog(unsigned int *specs, // unsigned char *image0, // unsigned char *image1, // unsigned char *image2, // unsigned char *image3, // unsigned char *vector0 //// unsigned char *vector1, //// unsigned char *vector2, //// unsigned char *vector3 // ); // void computeGradient(unsigned int _windowX, unsigned int _windowY,int width,unsigned char *image,float *gradientX,float *gradientY); // void computeHistogram(float *hogDsc,float *gradientX,float *gradientY); // void normalizeHisto(float *hogDsc_in,float *hogDsc_out); void imageDownScale(unsigned char *inputImage,int imageX,int imageY,double scale); #endif /* HOG_HPP_ */
27.976744
135
0.719867
DoubleGithub
434d9303b5bf4fe27f58b07da1dacda0c7dd54af
7,583
cpp
C++
android-31/android/animation/ValueAnimator.cpp
YJBeetle/QtAndroidAPI
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
[ "Apache-2.0" ]
12
2020-03-26T02:38:56.000Z
2022-03-14T08:17:26.000Z
android-28/android/animation/ValueAnimator.cpp
YJBeetle/QtAndroidAPI
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
[ "Apache-2.0" ]
1
2021-01-27T06:07:45.000Z
2021-11-13T19:19:43.000Z
android-30/android/animation/ValueAnimator.cpp
YJBeetle/QtAndroidAPI
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
[ "Apache-2.0" ]
3
2021-02-02T12:34:55.000Z
2022-03-08T07:45:57.000Z
#include "../../JFloatArray.hpp" #include "../../JIntArray.hpp" #include "../../JArray.hpp" #include "../../JObjectArray.hpp" #include "./Animator.hpp" #include "../../JObject.hpp" #include "../../JString.hpp" #include "./ValueAnimator.hpp" namespace android::animation { // Fields jint ValueAnimator::INFINITE() { return getStaticField<jint>( "android.animation.ValueAnimator", "INFINITE" ); } jint ValueAnimator::RESTART() { return getStaticField<jint>( "android.animation.ValueAnimator", "RESTART" ); } jint ValueAnimator::REVERSE() { return getStaticField<jint>( "android.animation.ValueAnimator", "REVERSE" ); } // QJniObject forward ValueAnimator::ValueAnimator(QJniObject obj) : android::animation::Animator(obj) {} // Constructors ValueAnimator::ValueAnimator() : android::animation::Animator( "android.animation.ValueAnimator", "()V" ) {} // Methods jboolean ValueAnimator::areAnimatorsEnabled() { return callStaticMethod<jboolean>( "android.animation.ValueAnimator", "areAnimatorsEnabled", "()Z" ); } jlong ValueAnimator::getFrameDelay() { return callStaticMethod<jlong>( "android.animation.ValueAnimator", "getFrameDelay", "()J" ); } android::animation::ValueAnimator ValueAnimator::ofArgb(JIntArray arg0) { return callStaticObjectMethod( "android.animation.ValueAnimator", "ofArgb", "([I)Landroid/animation/ValueAnimator;", arg0.object<jintArray>() ); } android::animation::ValueAnimator ValueAnimator::ofFloat(JFloatArray arg0) { return callStaticObjectMethod( "android.animation.ValueAnimator", "ofFloat", "([F)Landroid/animation/ValueAnimator;", arg0.object<jfloatArray>() ); } android::animation::ValueAnimator ValueAnimator::ofInt(JIntArray arg0) { return callStaticObjectMethod( "android.animation.ValueAnimator", "ofInt", "([I)Landroid/animation/ValueAnimator;", arg0.object<jintArray>() ); } android::animation::ValueAnimator ValueAnimator::ofObject(JObject arg0, JObjectArray arg1) { return callStaticObjectMethod( "android.animation.ValueAnimator", "ofObject", "(Landroid/animation/TypeEvaluator;[Ljava/lang/Object;)Landroid/animation/ValueAnimator;", arg0.object(), arg1.object<jobjectArray>() ); } android::animation::ValueAnimator ValueAnimator::ofPropertyValuesHolder(JArray arg0) { return callStaticObjectMethod( "android.animation.ValueAnimator", "ofPropertyValuesHolder", "([Landroid/animation/PropertyValuesHolder;)Landroid/animation/ValueAnimator;", arg0.object<jarray>() ); } void ValueAnimator::setFrameDelay(jlong arg0) { callStaticMethod<void>( "android.animation.ValueAnimator", "setFrameDelay", "(J)V", arg0 ); } void ValueAnimator::addUpdateListener(JObject arg0) const { callMethod<void>( "addUpdateListener", "(Landroid/animation/ValueAnimator$AnimatorUpdateListener;)V", arg0.object() ); } void ValueAnimator::cancel() const { callMethod<void>( "cancel", "()V" ); } android::animation::ValueAnimator ValueAnimator::clone() const { return callObjectMethod( "clone", "()Landroid/animation/ValueAnimator;" ); } void ValueAnimator::end() const { callMethod<void>( "end", "()V" ); } jfloat ValueAnimator::getAnimatedFraction() const { return callMethod<jfloat>( "getAnimatedFraction", "()F" ); } JObject ValueAnimator::getAnimatedValue() const { return callObjectMethod( "getAnimatedValue", "()Ljava/lang/Object;" ); } JObject ValueAnimator::getAnimatedValue(JString arg0) const { return callObjectMethod( "getAnimatedValue", "(Ljava/lang/String;)Ljava/lang/Object;", arg0.object<jstring>() ); } jlong ValueAnimator::getCurrentPlayTime() const { return callMethod<jlong>( "getCurrentPlayTime", "()J" ); } jlong ValueAnimator::getDuration() const { return callMethod<jlong>( "getDuration", "()J" ); } JObject ValueAnimator::getInterpolator() const { return callObjectMethod( "getInterpolator", "()Landroid/animation/TimeInterpolator;" ); } jint ValueAnimator::getRepeatCount() const { return callMethod<jint>( "getRepeatCount", "()I" ); } jint ValueAnimator::getRepeatMode() const { return callMethod<jint>( "getRepeatMode", "()I" ); } jlong ValueAnimator::getStartDelay() const { return callMethod<jlong>( "getStartDelay", "()J" ); } jlong ValueAnimator::getTotalDuration() const { return callMethod<jlong>( "getTotalDuration", "()J" ); } JArray ValueAnimator::getValues() const { return callObjectMethod( "getValues", "()[Landroid/animation/PropertyValuesHolder;" ); } jboolean ValueAnimator::isRunning() const { return callMethod<jboolean>( "isRunning", "()Z" ); } jboolean ValueAnimator::isStarted() const { return callMethod<jboolean>( "isStarted", "()Z" ); } void ValueAnimator::pause() const { callMethod<void>( "pause", "()V" ); } void ValueAnimator::removeAllUpdateListeners() const { callMethod<void>( "removeAllUpdateListeners", "()V" ); } void ValueAnimator::removeUpdateListener(JObject arg0) const { callMethod<void>( "removeUpdateListener", "(Landroid/animation/ValueAnimator$AnimatorUpdateListener;)V", arg0.object() ); } void ValueAnimator::resume() const { callMethod<void>( "resume", "()V" ); } void ValueAnimator::reverse() const { callMethod<void>( "reverse", "()V" ); } void ValueAnimator::setCurrentFraction(jfloat arg0) const { callMethod<void>( "setCurrentFraction", "(F)V", arg0 ); } void ValueAnimator::setCurrentPlayTime(jlong arg0) const { callMethod<void>( "setCurrentPlayTime", "(J)V", arg0 ); } android::animation::ValueAnimator ValueAnimator::setDuration(jlong arg0) const { return callObjectMethod( "setDuration", "(J)Landroid/animation/ValueAnimator;", arg0 ); } void ValueAnimator::setEvaluator(JObject arg0) const { callMethod<void>( "setEvaluator", "(Landroid/animation/TypeEvaluator;)V", arg0.object() ); } void ValueAnimator::setFloatValues(JFloatArray arg0) const { callMethod<void>( "setFloatValues", "([F)V", arg0.object<jfloatArray>() ); } void ValueAnimator::setIntValues(JIntArray arg0) const { callMethod<void>( "setIntValues", "([I)V", arg0.object<jintArray>() ); } void ValueAnimator::setInterpolator(JObject arg0) const { callMethod<void>( "setInterpolator", "(Landroid/animation/TimeInterpolator;)V", arg0.object() ); } void ValueAnimator::setObjectValues(JObjectArray arg0) const { callMethod<void>( "setObjectValues", "([Ljava/lang/Object;)V", arg0.object<jobjectArray>() ); } void ValueAnimator::setRepeatCount(jint arg0) const { callMethod<void>( "setRepeatCount", "(I)V", arg0 ); } void ValueAnimator::setRepeatMode(jint arg0) const { callMethod<void>( "setRepeatMode", "(I)V", arg0 ); } void ValueAnimator::setStartDelay(jlong arg0) const { callMethod<void>( "setStartDelay", "(J)V", arg0 ); } void ValueAnimator::setValues(JArray arg0) const { callMethod<void>( "setValues", "([Landroid/animation/PropertyValuesHolder;)V", arg0.object<jarray>() ); } void ValueAnimator::start() const { callMethod<void>( "start", "()V" ); } JString ValueAnimator::toString() const { return callObjectMethod( "toString", "()Ljava/lang/String;" ); } } // namespace android::animation
19.645078
93
0.678359
YJBeetle
4350204c4b39af95b64e3d43058cd7f9c46b4bd4
2,425
cpp
C++
EngineTests/Platforms.GAPI/Compute/CApp_UpdateBuffer.cpp
azhirnov/GraphicsGenFramework-modular
348be601f1991f102defa0c99250529f5e44c4d3
[ "BSD-2-Clause" ]
12
2017-12-23T14:24:57.000Z
2020-10-02T19:52:12.000Z
EngineTests/Platforms.GAPI/Compute/CApp_UpdateBuffer.cpp
azhirnov/ModularGraphicsFramework
348be601f1991f102defa0c99250529f5e44c4d3
[ "BSD-2-Clause" ]
null
null
null
EngineTests/Platforms.GAPI/Compute/CApp_UpdateBuffer.cpp
azhirnov/ModularGraphicsFramework
348be601f1991f102defa0c99250529f5e44c4d3
[ "BSD-2-Clause" ]
null
null
null
// Copyright (c) Zhirnov Andrey. For more information see 'LICENSE.txt' #include "CApp.h" bool CApp::_Test_UpdateBuffer () { // generate data BinaryArray data; data.Resize( 512 ); BinaryArray data2; data2.Resize( 256 ); FOR( i, data ) { data[i] = Random::Int<ubyte>(); } FOR( i, data2 ) { data2[i] = Random::Int<ubyte>(); } // create resources auto factory = ms->GlobalSystems()->modulesFactory; GpuMsg::CreateFence fence_ctor; syncManager->Send( fence_ctor ); ModulePtr cmd_buffer; CHECK_ERR( factory->Create( gpuIDs.commandBuffer, gpuThread->GlobalSystems(), CreateInfo::GpuCommandBuffer{}, OUT cmd_buffer ) ); cmdBuilder->Send( ModuleMsg::AttachModule{ cmd_buffer }); ModulePtr buffer; CHECK_ERR( factory->Create( gpuIDs.buffer, gpuThread->GlobalSystems(), CreateInfo::GpuBuffer{ BufferDescription{ data.Size(), EBufferUsage::TransferSrc | EBufferUsage::TransferDst }, EGpuMemory::CoherentWithCPU }, OUT buffer ) ); ModuleUtils::Initialize({ cmd_buffer, buffer }); // write data to buffer GpuMsg::WriteToGpuMemory write_cmd{ data }; buffer->Send( write_cmd ); CHECK_ERR( *write_cmd.wasWritten == data.Size() ); // build command buffer cmdBuilder->Send( GpuMsg::CmdBegin{ cmd_buffer }); const usize subdata_size = 128; BinArrayCRef subdata1 = data2.SubArray( 0, subdata_size ); BinArrayCRef subdata2 = data2.SubArray( subdata_size, data2.Count() - subdata_size ); cmdBuilder->Send( GpuMsg::CmdUpdateBuffer{ buffer, subdata1, data.Size() - data2.Size() }); cmdBuilder->Send( GpuMsg::CmdUpdateBuffer{ buffer, subdata2, data.Size() - subdata2.Size() }); GpuMsg::CmdEnd cmd_end; cmdBuilder->Send( cmd_end ); // submit and sync gpuThread->Send( GpuMsg::SubmitCommands{ *cmd_end.result }.SetFence( *fence_ctor.result )); syncManager->Send( GpuMsg::ClientWaitFence{ *fence_ctor.result }); // read BinaryArray dst_data; dst_data.Resize( data.Count() ); GpuMsg::ReadFromGpuMemory read_cmd{ dst_data }; buffer->Send( read_cmd ); CHECK_ERR( data.Size() == read_cmd.result->Size() ); bool equals = true; usize offset = usize(data.Size() - data2.Size()); FOR( i, data ) { if ( i < offset ) equals &= (data[i] == read_cmd.result->operator[](i)); else equals &= (data2[i - offset] == read_cmd.result->operator[](i)); } CHECK_ERR( equals ); LOG( "UpdateBuffer - OK", ELog::Info ); return true; }
25.526316
95
0.686598
azhirnov
435145bddef934ff52ae533a1b85648ac45db1d9
4,818
cpp
C++
src/lib/src/sat/dimacs/parser.cpp
black-sat/black
80902240987312fb0e6f00227a06e9f9c9728a67
[ "MIT" ]
4
2020-09-30T15:16:22.000Z
2021-09-20T15:02:39.000Z
src/lib/src/sat/dimacs/parser.cpp
teodorov/black
4de280ded5e99cc515141b4acc35137ba32c2469
[ "MIT" ]
42
2020-07-15T13:46:11.000Z
2022-03-10T09:42:43.000Z
src/lib/src/sat/dimacs/parser.cpp
teodorov/black
4de280ded5e99cc515141b4acc35137ba32c2469
[ "MIT" ]
3
2020-03-30T14:39:17.000Z
2022-03-18T14:05:33.000Z
// // BLACK - Bounded Ltl sAtisfiability ChecKer // // (C) 2021 Nicola Gigante // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. #include <black/sat/dimacs.hpp> #include <black/support/config.hpp> #include <cctype> #include <cmath> #include <fmt/format.h> namespace black::sat::dimacs::internal { struct _parser_t { std::istream &in; std::function<void(std::string)> handler; _parser_t(std::istream &_in, std::function<void(std::string)> _handler) : in{_in}, handler{_handler} { } void skip_comment(); void skip(); bool parse_header(); std::optional<literal> parse_literal(); std::vector<clause> parse_clauses(); std::optional<problem> parse(); }; void _parser_t::skip_comment() { if(in.peek() != 'c') return; while(in.good() && in.peek() != '\n') in.get(); } void _parser_t::skip() { while(in.good() && (isspace(in.peek()) || in.peek() == 'c')) { skip_comment(); in.get(); } } bool _parser_t::parse_header() { if(!in.good()) return false; std::string h; for(int i = 0; i < 5; ++i) h += (char)in.get(); if(h != "p cnf") { handler("expected problem header"); return false; } uint32_t nvars = 0; uint64_t nclauses = 0; in >> nvars; // we ignore nvars and nclauses, but they must be there in >> nclauses; if(in.fail()) { handler("expected nbvars and nbclauses in problem header"); return false; } return true; } std::optional<literal> _parser_t::parse_literal() { if(in.eof()) return std::nullopt; int32_t v = 0; if(!(in >> v)) { handler("expected literal"); return std::nullopt; } return literal{ // LCOV_EXCL_LINE /*sign=*/ (v >= 0), /*var=*/ static_cast<uint32_t>(abs(v)) }; } std::vector<clause> _parser_t::parse_clauses() { std::vector<clause> clauses; clause cl; do { skip(); std::optional<literal> l = parse_literal(); if(!l) { if(cl.literals.size() > 0) handler("expected '0' at the end of clause"); return clauses; } if(l->var == 0) { clauses.push_back(cl); cl.literals.clear(); } else { cl.literals.push_back(*l); } } while (!in.eof()); return clauses; } std::optional<problem> _parser_t::parse() { skip(); if(!parse_header()) return std::nullopt; skip(); return problem{parse_clauses()}; } std::optional<problem> parse( std::istream &in, std::function<void(std::string)> handler ) { _parser_t parser{in, handler}; return parser.parse(); } std::string to_string(literal l) { return fmt::format("{}{}", l.sign ? "" : "-", l.var); } // void print(std::ostream &out, problem p) { // out << fmt::format("c BLACK v{}\n", black::version); // size_t nclauses = p.clauses.size(); // uint32_t nvars = 0; // for(dimacs::clause c : p.clauses) // for(dimacs::literal l : c.literals) // nvars = l.var > nvars ? l.var : nvars; // out << fmt::format("p cnf {} {}\n", nvars, nclauses); // for(dimacs::clause c : p.clauses) { // for(dimacs::literal l : c.literals) { // out << to_string(l) << ' '; // } // out << "0\n"; // } // } void print(std::ostream &out, std::optional<solution> const& s) { out << fmt::format("c BLACK v{}\n", black::version); if(!s) { out << "s UNSATISFIABLE\n"; return; } out << "s SATISFIABLE\n"; out << "v "; int i = 0; for(dimacs::literal l : s->assignments) { if(i % 4 == 0) out << "\nv "; out << to_string(l) << ' '; ++i; } out << '\n'; } }
24.835052
80
0.585305
black-sat
43517c785d6fc5a398a8df3ccbe4ec4568611f3a
4,377
cpp
C++
SimpleSocks/cl_TCPServer.cpp
SimpleRepos/SimpleSocks
7c5fe41d8a119d2ad285d0e98087cd4a0ed45859
[ "MIT" ]
null
null
null
SimpleSocks/cl_TCPServer.cpp
SimpleRepos/SimpleSocks
7c5fe41d8a119d2ad285d0e98087cd4a0ed45859
[ "MIT" ]
null
null
null
SimpleSocks/cl_TCPServer.cpp
SimpleRepos/SimpleSocks
7c5fe41d8a119d2ad285d0e98087cd4a0ed45859
[ "MIT" ]
null
null
null
#include "cl_TCPServer.h" #include <WS2tcpip.h> //Set members to default values. //SOCKET_ERROR is used here to indicate that the socket is closed SSocks::TCPServer::TCPServer() : sock(SOCKET_ERROR), blocking(true) { //nothing } //invoke the default constructor and then call start() SSocks::TCPServer::TCPServer(uint16_t port, bool forceBind, const std::string& localHostAddr) : TCPServer() { start(port, forceBind, localHostAddr); } //release the socket SSocks::TCPServer::~TCPServer() { stop(); } //copy values from source and then break its ownership of the socket SSocks::TCPServer::TCPServer(TCPServer&& moveFrom) : sock(moveFrom.sock), blocking(moveFrom.blocking) { //force source to disown resource so that it won't be released when source destructs moveFrom.sock = SOCKET_ERROR; } void SSocks::TCPServer::operator=(TCPServer&& moveFrom) { sock = moveFrom.sock; blocking = moveFrom.blocking; moveFrom.sock = SOCKET_ERROR; } void SSocks::TCPServer::start(uint16_t port, bool forceBind, const std::string& localHostAddr) { //halt service if already running if(isOpen()) { stop(); } //We need a sockaddr_in to bind the server to a port and interface. sockaddr_in sain = {0}; sain.sin_family = AF_INET; sain.sin_port = htons(port); if(port == 0) { throw std::runtime_error("SSocks::TCPSever does not support port zero."); } //This shouldn't fail unless the user types in gibberish, but let's be safe. int result = inet_pton(AF_INET, localHostAddr.c_str(), &sain.sin_addr); switch(result) { case 0: throw std::runtime_error("Attempted to start server on interaface with invalid address string."); case -1: throw std::runtime_error(Utility::lastErrStr(WSAGetLastError())); } //TSock helps here because if an exception is thrown it ensures that the socket resource is released. Utility::TSock tsock(SOCK_STREAM, IPPROTO_TCP); //forceBind will allow the bind to take over from an existing bind. See comments in header. if(forceBind) { //Here's another nasty legacy call... BOOL temp = TRUE; result = setsockopt(tsock, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char*>(&temp), sizeof(temp)); if(result) { throw std::runtime_error(Utility::lastErrStr(WSAGetLastError())); } } //bind the socket result = bind(tsock, reinterpret_cast<sockaddr*>(&sain), sizeof(sain)); if(result) { throw std::runtime_error(Utility::lastErrStr(WSAGetLastError())); } //start listening for connections result = listen(tsock, SOMAXCONN); if(result) { throw std::runtime_error(Utility::lastErrStr(WSAGetLastError())); } //everything seems okay, so take ownership of the resource sock = tsock.validate(); } void SSocks::TCPServer::stop() { //release the resource if it exists if(isOpen()) { closesocket(sock); } //and reset to defaults sock = SOCKET_ERROR; blocking = true; } SSocks::TCPSocket SSocks::TCPServer::accept() { if(!isOpen()) { throw std::runtime_error("Attemtped to wait for connections on closed TCPServer."); } //Create a TCPSocket object TCPSocket nuSock; //and inject the incoming connection into it nuSock.sock = ::accept(sock, nullptr, nullptr); if(nuSock.sock == SOCKET_ERROR) { //WSAEWOULDBLOCK happens on a non-blocking socket when there's no incoming connection. //We can just return the unconnected socket to indicate that. (It will simply be an unopened TCPSocket.) int err = WSAGetLastError(); if(err != WSAEWOULDBLOCK) { throw std::runtime_error(Utility::lastErrStr(err)); } } return nuSock; } bool SSocks::TCPServer::isOpen() const { return sock != SOCKET_ERROR; } bool SSocks::TCPServer::isBlocking() const { return blocking; } void SSocks::TCPServer::setBlocking(bool block) { if(!isOpen()) { throw std::runtime_error("Attemtped to set blocking state on closed TCPServer."); } //avoid needless system calls if(block == blocking) { return; } //I really hate all this legacy crap that tries to make one function do everything. //It makes the interfaces really unpleasant. unsigned long temp = block ? 0 : 1; //set actual socket behavior according to state info int result = ioctlsocket(sock, FIONBIO, &temp); if(result == SOCKET_ERROR) { stop(); //assume socket is invalidated throw std::runtime_error(Utility::lastErrStr(WSAGetLastError())); } //update state info blocking = block; }
33.930233
109
0.720356
SimpleRepos
43518db909e026f9a4e402d831480b411057e047
2,120
cpp
C++
core/driver/disk.cpp
JartC0ding/horizon
2b9a75b45ac768a8da0f7a98f164a37690dc583f
[ "MIT" ]
4
2022-01-06T09:19:46.000Z
2022-03-27T18:08:36.000Z
core/driver/disk.cpp
JartC0ding/horizon
2b9a75b45ac768a8da0f7a98f164a37690dc583f
[ "MIT" ]
null
null
null
core/driver/disk.cpp
JartC0ding/horizon
2b9a75b45ac768a8da0f7a98f164a37690dc583f
[ "MIT" ]
1
2022-03-22T19:10:05.000Z
2022-03-22T19:10:05.000Z
#include <driver/disk.h> #include <utils/log.h> using namespace driver; disk_driver_manager* driver::global_disk_manager; disk_device::disk_device() { } disk_device::~disk_device() { } void disk_device::read(uint64_t sector, uint32_t sector_count, void* buffer) { } void disk_device::write(uint64_t sector, uint32_t sector_count, void* buffer) { } bool disk_device::get_disk_label(char* out, fs::vfs::vfs_mount* mount) { fs::vfs::file_t* file = mount->open((char*) "/FOXCFG/dn.fox"); if (file == nullptr) { debugf("Failed to open /dn.fox\n"); return false; } mount->read(file, out, file->size, 0); out[file->size] = 0; mount->close(file); debugf("Disk label: %s\n", out); return true; } disk_driver_manager::disk_driver_manager() { this->num_disks = 0; } int disk_driver_manager::add_disk(disk_device* disk) { this->disks[this->num_disks] = disk; debugf("Adding new disk at idx %d!\n", this->num_disks); this->num_disks++; return this->num_disks - 1; } void disk_driver_manager::read(int disk_num, uint64_t sector, uint32_t sector_count, void* buffer) { this->disks[disk_num]->read(sector, sector_count, buffer); } void disk_driver_manager::write(int disk_num, uint64_t sector, uint32_t sector_count, void* buffer) { this->disks[disk_num]->write(sector, sector_count, buffer); } raw_disk_dev_fs::raw_disk_dev_fs(int disk_num) { memset(this->name, 0, 32); sprintf(this->name, "disk_%d", disk_num); this->disk_num = disk_num; } char* raw_disk_dev_fs::get_name() { return this->name; } void raw_disk_dev_fs::write(fs::file_t* file, void* buffer, size_t size, size_t offset) { raw_disk_dev_fs_command* cmd = (raw_disk_dev_fs_command*) buffer; switch (cmd->command) { case 0: // opcode read { driver::global_disk_manager->read(this->disk_num, cmd->sector, cmd->sector_count, (void*) cmd->buffer); } break; case 1: // opcode write { driver::global_disk_manager->write(this->disk_num, cmd->sector, cmd->sector_count, (void*) cmd->buffer); } break; default: { debugf("Unknown disk command %d\n", cmd->command); } break; } }
21.85567
108
0.696226
JartC0ding
4354429a7f3731314acf1f40f94f8661a6e197e9
8,839
hpp
C++
include/boost/compute/types/tuple.hpp
roshanr95/compute
377e509acd16af466cdb133d70e2dcd525ec1a87
[ "BSL-1.0" ]
null
null
null
include/boost/compute/types/tuple.hpp
roshanr95/compute
377e509acd16af466cdb133d70e2dcd525ec1a87
[ "BSL-1.0" ]
null
null
null
include/boost/compute/types/tuple.hpp
roshanr95/compute
377e509acd16af466cdb133d70e2dcd525ec1a87
[ "BSL-1.0" ]
1
2020-04-09T15:56:37.000Z
2020-04-09T15:56:37.000Z
//---------------------------------------------------------------------------// // Copyright (c) 2013 Kyle Lutz <[email protected]> // // Distributed under the Boost Software License, Version 1.0 // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // // See http://boostorg.github.com/compute for more information. //---------------------------------------------------------------------------// #ifndef BOOST_COMPUTE_TYPES_TUPLE_HPP #define BOOST_COMPUTE_TYPES_TUPLE_HPP #include <string> #include <utility> #include <boost/preprocessor/enum.hpp> #include <boost/preprocessor/expr_if.hpp> #include <boost/preprocessor/repetition.hpp> #include <boost/tuple/tuple.hpp> #include <boost/compute/config.hpp> #include <boost/compute/functional/get.hpp> #include <boost/compute/type_traits/type_name.hpp> #include <boost/compute/detail/meta_kernel.hpp> #ifndef BOOST_COMPUTE_DETAIL_NO_STD_TUPLE #include <tuple> #endif namespace boost { namespace compute { namespace detail { // meta_kernel operators for boost::tuple literals #define BOOST_COMPUTE_PRINT_ELEM(z, n, unused) \ BOOST_PP_EXPR_IF(n, << ", ") \ << kernel.make_lit(boost::get<n>(x)) #define BOOST_COMPUTE_PRINT_TUPLE(z, n, unused) \ template<BOOST_PP_ENUM_PARAMS(n, class T)> \ inline meta_kernel& \ operator<<(meta_kernel &kernel, \ const boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> &x) \ { \ return kernel \ << "(" \ << type_name<boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> >() \ << ")" \ << "{" \ BOOST_PP_REPEAT(n, BOOST_COMPUTE_PRINT_ELEM, ~) \ << "}"; \ } BOOST_PP_REPEAT_FROM_TO(1, BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_PRINT_TUPLE, ~) #undef BOOST_COMPUTE_PRINT_TUPLE #undef BOOST_COMPUTE_PRINT_ELEM // inject_type() specializations for boost::tuple #define BOOST_COMPUTE_INJECT_TYPE(z, n, unused) \ kernel.inject_type<T ## n>(); #define BOOST_COMPUTE_INJECT_DECL(z, n, unused) \ << " " << type_name<T ## n>() << " v" #n ";\n" #define BOOST_COMPUTE_INJECT_IMPL(z, n, unused) \ template<BOOST_PP_ENUM_PARAMS(n, class T)> \ struct inject_type_impl<boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> > \ { \ void operator()(meta_kernel &kernel) \ { \ typedef boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> tuple_type; \ BOOST_PP_REPEAT(n, BOOST_COMPUTE_INJECT_TYPE, ~) \ std::stringstream declaration; \ declaration << "typedef struct {\n" \ BOOST_PP_REPEAT(n, BOOST_COMPUTE_INJECT_DECL, ~) \ << "} " << type_name<tuple_type>() << ";\n"; \ kernel.add_type_declaration<tuple_type>(declaration.str()); \ } \ }; BOOST_PP_REPEAT_FROM_TO(1, BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_INJECT_IMPL, ~) #undef BOOST_COMPUTE_INJECT_IMPL #undef BOOST_COMPUTE_INJECT_DECL #undef BOOST_COMPUTE_INJECT_TYPE #ifdef BOOST_COMPUTE_DETAIL_NO_VARIADIC_TEMPLATES // type_name() specializations for boost::tuple (without variadic templates) #define BOOST_COMPUTE_PRINT_TYPE(z, n, unused) \ + type_name<T ## n>() + "_" #define BOOST_COMPUTE_PRINT_TYPE_NAME(z, n, unused) \ template<BOOST_PP_ENUM_PARAMS(n, class T)> \ struct type_name_trait<boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> > \ { \ static const char* value() \ { \ static std::string name = \ std::string("boost_tuple_") \ BOOST_PP_REPEAT(n, BOOST_COMPUTE_PRINT_TYPE, ~) \ "t"; \ return name.c_str(); \ } \ }; BOOST_PP_REPEAT_FROM_TO(1, BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_PRINT_TYPE_NAME, ~) #undef BOOST_COMPUTE_PRINT_TYPE_NAME #undef BOOST_COMPUTE_PRINT_TYPE #else template<size_t N, class T, class... Rest> struct write_tuple_type_names { void operator()(std::ostream &os) { os << type_name<T>() << "_"; write_tuple_type_names<N-1, Rest...>()(os); } }; template<class T, class... Rest> struct write_tuple_type_names<1, T, Rest...> { void operator()(std::ostream &os) { os << type_name<T>(); } }; // type_name<> specialization for boost::tuple<...> (with variadic templates) template<class... T> struct type_name_trait<boost::tuple<T...>> { static const char* value() { static std::string str = make_type_name(); return str.c_str(); } static std::string make_type_name() { typedef typename boost::tuple<T...> tuple_type; std::stringstream s; s << "boost_tuple_"; write_tuple_type_names< boost::tuples::length<tuple_type>::value, T... >()(s); s << "_t"; return s.str(); } }; #endif // BOOST_COMPUTE_DETAIL_NO_VARIADIC_TEMPLATES #ifndef BOOST_COMPUTE_DETAIL_NO_STD_TUPLE // type_name<> specialization for std::tuple<T...> template<class... T> struct type_name_trait<std::tuple<T...>> { static const char* value() { static std::string str = make_type_name(); return str.c_str(); } static std::string make_type_name() { typedef typename std::tuple<T...> tuple_type; std::stringstream s; s << "std_tuple_"; write_tuple_type_names< std::tuple_size<tuple_type>::value, T... >()(s); s << "_t"; return s.str(); } }; #endif // BOOST_COMPUTE_DETAIL_NO_STD_TUPLE // get<N>() result type specialization for boost::tuple<> #define BOOST_COMPUTE_GET_RESULT_TYPE(z, n, unused) \ template<size_t N, BOOST_PP_ENUM_PARAMS(n, class T)> \ struct get_result_type<N, boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> > \ { \ typedef typename boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> T; \ typedef typename boost::tuples::element<N, T>::type type; \ }; BOOST_PP_REPEAT_FROM_TO(1, BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_GET_RESULT_TYPE, ~) #undef BOOST_COMPUTE_GET_RESULT_TYPE // get<N>() specialization for boost::tuple<> #define BOOST_COMPUTE_GET_N(z, n, unused) \ template<size_t N, class Arg, BOOST_PP_ENUM_PARAMS(n, class T)> \ inline meta_kernel& operator<<(meta_kernel &kernel, \ const invoked_get<N, Arg, boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> > &expr) \ { \ typedef typename boost::tuple<BOOST_PP_ENUM_PARAMS(n, T)> T; \ BOOST_STATIC_ASSERT(N < size_t(boost::tuples::length<T>::value)); \ kernel.inject_type<T>(); \ return kernel << expr.m_arg << ".v" << uint_(N); \ } BOOST_PP_REPEAT_FROM_TO(1, BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_GET_N, ~) #undef BOOST_COMPUTE_GET_N } // end detail namespace } // end compute namespace } // end boost namespace #endif // BOOST_COMPUTE_TYPES_TUPLE_HPP
39.995475
85
0.489874
roshanr95
4354fd8c8bc205aea0c35010ebf1c532539fe372
24,512
cpp
C++
Project/Source/Scene.cpp
TBD-org/RealBugEngine
0131fde0abc2d86137500acd6f63ed8f0fc2835f
[ "MIT" ]
7
2021-04-26T21:32:12.000Z
2022-02-14T13:48:53.000Z
Project/Source/Scene.cpp
TBD-org/RealBugEngine
0131fde0abc2d86137500acd6f63ed8f0fc2835f
[ "MIT" ]
66
2021-04-24T10:08:07.000Z
2021-10-05T16:52:56.000Z
Project/Source/Scene.cpp
TBD-org/Tesseract
0131fde0abc2d86137500acd6f63ed8f0fc2835f
[ "MIT" ]
1
2021-07-13T21:26:13.000Z
2021-07-13T21:26:13.000Z
#include "Scene.h" #include "GameObject.h" #include "Application.h" #include "Modules/ModuleTime.h" #include "Modules/ModuleEditor.h" #include "Modules/ModuleRender.h" #include "Modules/ModulePhysics.h" #include "Modules/ModuleTime.h" #include "Modules/ModuleCamera.h" #include "Modules/ModuleWindow.h" #include "Modules/ModuleProject.h" #include "Modules/ModuleResources.h" #include "Scripting/PropertyMap.h" #include "Resources/ResourceMesh.h" #include "Utils/Logging.h" #include "Utils/Leaks.h" #define JSON_TAG_ROOT "Root" #define JSON_TAG_QUADTREE_BOUNDS "QuadtreeBounds" #define JSON_TAG_QUADTREE_MAX_DEPTH "QuadtreeMaxDepth" #define JSON_TAG_QUADTREE_ELEMENTS_PER_NODE "QuadtreeElementsPerNode" #define JSON_TAG_GAME_CAMERA "GameCamera" #define JSON_TAG_AMBIENTLIGHT "AmbientLight" #define JSON_TAG_NAVMESH "NavMesh" #define JSON_TAG_CURSOR_WIDTH "CursorWidth" #define JSON_TAG_CURSOR_HEIGHT "CursorHeight" #define JSON_TAG_CURSOR "Cursor" Scene::Scene(unsigned numGameObjects) { gameObjects.Allocate(numGameObjects); transformComponents.Allocate(numGameObjects); meshRendererComponents.Allocate(numGameObjects); boundingBoxComponents.Allocate(numGameObjects); cameraComponents.Allocate(numGameObjects); lightComponents.Allocate(numGameObjects); canvasComponents.Allocate(numGameObjects); canvasRendererComponents.Allocate(numGameObjects); imageComponents.Allocate(numGameObjects); transform2DComponents.Allocate(numGameObjects); boundingBox2DComponents.Allocate(numGameObjects); eventSystemComponents.Allocate(numGameObjects); toggleComponents.Allocate(numGameObjects); textComponents.Allocate(numGameObjects); buttonComponents.Allocate(numGameObjects); selectableComponents.Allocate(numGameObjects); sliderComponents.Allocate(numGameObjects); skyboxComponents.Allocate(numGameObjects); scriptComponents.Allocate(numGameObjects); animationComponents.Allocate(numGameObjects); particleComponents.Allocate(numGameObjects); trailComponents.Allocate(numGameObjects); audioSourceComponents.Allocate(numGameObjects); audioListenerComponents.Allocate(numGameObjects); progressbarsComponents.Allocate(numGameObjects); billboardComponents.Allocate(numGameObjects); sphereColliderComponents.Allocate(numGameObjects); boxColliderComponents.Allocate(numGameObjects); capsuleColliderComponents.Allocate(numGameObjects); agentComponents.Allocate(numGameObjects); obstacleComponents.Allocate(numGameObjects); fogComponents.Allocate(numGameObjects); videoComponents.Allocate(numGameObjects); } Scene::~Scene() { ClearScene(); } void Scene::ClearScene() { App->resources->DecreaseReferenceCount(cursorId); DestroyGameObject(root); root = nullptr; quadtree.Clear(); assert(gameObjects.Count() == 0); // There should be no GameObjects outside the scene hierarchy gameObjects.Clear(); // This looks redundant, but it resets the free list so that GameObject order is mantained when saving/loading staticShadowCasters.clear(); dynamicShadowCasters.clear(); mainEntitiesShadowCasters.clear(); } void Scene::RebuildQuadtree() { quadtree.Initialize(quadtreeBounds, quadtreeMaxDepth, quadtreeElementsPerNode); for (ComponentBoundingBox& boundingBox : boundingBoxComponents) { GameObject& gameObject = boundingBox.GetOwner(); if (gameObject.IsStatic()) { boundingBox.CalculateWorldBoundingBox(); const AABB& worldAABB = boundingBox.GetWorldAABB(); quadtree.Add(&gameObject, AABB2D(worldAABB.minPoint.xz(), worldAABB.maxPoint.xz())); gameObject.isInQuadtree = true; } } quadtree.Optimize(); } void Scene::ClearQuadtree() { quadtree.Clear(); for (GameObject& gameObject : gameObjects) { gameObject.isInQuadtree = false; } } void Scene::Init() { App->resources->IncreaseReferenceCount(cursorId); root->Init(); } void Scene::Start() { App->time->ResetDeltaTime(); if (App->camera->GetGameCamera()) { // Set the Game Camera as active App->camera->ChangeActiveCamera(App->camera->GetGameCamera(), true); App->camera->ChangeCullingCamera(App->camera->GetGameCamera(), true); } else { LOG("Error: Game camera not set."); } App->window->SetCursor(cursorId, widthCursor, heightCursor); App->window->ActivateCursor(true); root->Start(); } void Scene::Load(JsonValue jScene) { ClearScene(); // Load GameObjects JsonValue jRoot = jScene[JSON_TAG_ROOT]; root = gameObjects.Obtain(0); root->scene = this; root->Load(jRoot); // Quadtree generation JsonValue jQuadtreeBounds = jScene[JSON_TAG_QUADTREE_BOUNDS]; quadtreeBounds = {{jQuadtreeBounds[0], jQuadtreeBounds[1]}, {jQuadtreeBounds[2], jQuadtreeBounds[3]}}; quadtreeMaxDepth = jScene[JSON_TAG_QUADTREE_MAX_DEPTH]; quadtreeElementsPerNode = jScene[JSON_TAG_QUADTREE_ELEMENTS_PER_NODE]; RebuildQuadtree(); // Game Camera gameCameraId = jScene[JSON_TAG_GAME_CAMERA]; // Ambient Light JsonValue ambientLight = jScene[JSON_TAG_AMBIENTLIGHT]; ambientColor = {ambientLight[0], ambientLight[1], ambientLight[2]}; // NavMesh navMeshId = jScene[JSON_TAG_NAVMESH]; // Cursor heightCursor = jScene[JSON_TAG_CURSOR_HEIGHT]; widthCursor = jScene[JSON_TAG_CURSOR_WIDTH]; cursorId = jScene[JSON_TAG_CURSOR]; } void Scene::Save(JsonValue jScene) const { // Save scene information JsonValue jQuadtreeBounds = jScene[JSON_TAG_QUADTREE_BOUNDS]; jQuadtreeBounds[0] = quadtreeBounds.minPoint.x; jQuadtreeBounds[1] = quadtreeBounds.minPoint.y; jQuadtreeBounds[2] = quadtreeBounds.maxPoint.x; jQuadtreeBounds[3] = quadtreeBounds.maxPoint.y; jScene[JSON_TAG_QUADTREE_MAX_DEPTH] = quadtreeMaxDepth; jScene[JSON_TAG_QUADTREE_ELEMENTS_PER_NODE] = quadtreeElementsPerNode; jScene[JSON_TAG_GAME_CAMERA] = gameCameraId; JsonValue ambientLight = jScene[JSON_TAG_AMBIENTLIGHT]; ambientLight[0] = ambientColor.x; ambientLight[1] = ambientColor.y; ambientLight[2] = ambientColor.z; // NavMesh jScene[JSON_TAG_NAVMESH] = navMeshId; // Cursor jScene[JSON_TAG_CURSOR_HEIGHT] = heightCursor; jScene[JSON_TAG_CURSOR_WIDTH] = widthCursor; jScene[JSON_TAG_CURSOR] = cursorId; // Save GameObjects JsonValue jRoot = jScene[JSON_TAG_ROOT]; root->Save(jRoot); } GameObject* Scene::CreateGameObject(GameObject* parent, UID id, const char* name) { GameObject* gameObject = gameObjects.Obtain(id); gameObject->scene = this; gameObject->id = id; gameObject->name = name; gameObject->SetParent(parent); return gameObject; } void Scene::DestroyGameObject(GameObject* gameObject) { if (gameObject == nullptr) return; // If the removed GameObject is the directionalLight of the scene, set it to nullptr if (gameObject == directionalLight) directionalLight = nullptr; // We need a copy because we are invalidating the iterator by removing GameObjects std::vector<GameObject*> children = gameObject->GetChildren(); for (GameObject* child : children) { DestroyGameObject(child); } if (gameObject->isInQuadtree) { quadtree.Remove(gameObject); } bool selected = App->editor->selectedGameObject == gameObject; if (selected) App->editor->selectedGameObject = nullptr; gameObject->RemoveAllComponents(); gameObject->SetParent(nullptr); gameObjects.Release(gameObject->GetID()); } GameObject* Scene::GetGameObject(UID id) const { return gameObjects.Find(id); } Component* Scene::GetComponentByTypeAndId(ComponentType type, UID componentId) { switch (type) { case ComponentType::TRANSFORM: return transformComponents.Find(componentId); case ComponentType::MESH_RENDERER: return meshRendererComponents.Find(componentId); case ComponentType::BOUNDING_BOX: return boundingBoxComponents.Find(componentId); case ComponentType::CAMERA: return cameraComponents.Find(componentId); case ComponentType::LIGHT: return lightComponents.Find(componentId); case ComponentType::CANVAS: return canvasComponents.Find(componentId); case ComponentType::CANVASRENDERER: return canvasRendererComponents.Find(componentId); case ComponentType::IMAGE: return imageComponents.Find(componentId); case ComponentType::TRANSFORM2D: return transform2DComponents.Find(componentId); case ComponentType::BUTTON: return buttonComponents.Find(componentId); case ComponentType::EVENT_SYSTEM: return eventSystemComponents.Find(componentId); case ComponentType::BOUNDING_BOX_2D: return boundingBox2DComponents.Find(componentId); case ComponentType::TOGGLE: return toggleComponents.Find(componentId); case ComponentType::TEXT: return textComponents.Find(componentId); case ComponentType::SELECTABLE: return selectableComponents.Find(componentId); case ComponentType::SLIDER: return sliderComponents.Find(componentId); case ComponentType::SKYBOX: return skyboxComponents.Find(componentId); case ComponentType::ANIMATION: return animationComponents.Find(componentId); case ComponentType::SCRIPT: return scriptComponents.Find(componentId); case ComponentType::PARTICLE: return particleComponents.Find(componentId); case ComponentType::TRAIL: return trailComponents.Find(componentId); case ComponentType::BILLBOARD: return billboardComponents.Find(componentId); case ComponentType::AUDIO_SOURCE: return audioSourceComponents.Find(componentId); case ComponentType::AUDIO_LISTENER: return audioListenerComponents.Find(componentId); case ComponentType::PROGRESS_BAR: return progressbarsComponents.Find(componentId); case ComponentType::SPHERE_COLLIDER: return sphereColliderComponents.Find(componentId); case ComponentType::BOX_COLLIDER: return boxColliderComponents.Find(componentId); case ComponentType::CAPSULE_COLLIDER: return capsuleColliderComponents.Find(componentId); case ComponentType::AGENT: return agentComponents.Find(componentId); case ComponentType::OBSTACLE: return obstacleComponents.Find(componentId); case ComponentType::FOG: return fogComponents.Find(componentId); case ComponentType::VIDEO: return videoComponents.Find(componentId); default: LOG("Component of type %i hasn't been registered in Scene::GetComponentByTypeAndId.", (unsigned) type); assert(false); return nullptr; } } Component* Scene::CreateComponentByTypeAndId(GameObject* owner, ComponentType type, UID componentId) { switch (type) { case ComponentType::TRANSFORM: return transformComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::MESH_RENDERER: return meshRendererComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::BOUNDING_BOX: return boundingBoxComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::CAMERA: return cameraComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::LIGHT: return lightComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::CANVAS: return canvasComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::CANVASRENDERER: return canvasRendererComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::IMAGE: return imageComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::TRANSFORM2D: return transform2DComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::BUTTON: return buttonComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::EVENT_SYSTEM: return eventSystemComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::BOUNDING_BOX_2D: return boundingBox2DComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::TOGGLE: return toggleComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::TEXT: return textComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::SELECTABLE: return selectableComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::SLIDER: return sliderComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::SKYBOX: return skyboxComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::ANIMATION: return animationComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::SCRIPT: return scriptComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::PARTICLE: return particleComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::TRAIL: return trailComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::BILLBOARD: return billboardComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::AUDIO_SOURCE: return audioSourceComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::AUDIO_LISTENER: return audioListenerComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::PROGRESS_BAR: return progressbarsComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::SPHERE_COLLIDER: return sphereColliderComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::BOX_COLLIDER: return boxColliderComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::CAPSULE_COLLIDER: return capsuleColliderComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::AGENT: return agentComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::OBSTACLE: return obstacleComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::FOG: return fogComponents.Obtain(componentId, owner, componentId, owner->IsActive()); case ComponentType::VIDEO: return videoComponents.Obtain(componentId, owner, componentId, owner->IsActive()); default: LOG("Component of type %i hasn't been registered in Scene::CreateComponentByTypeAndId.", (unsigned) type); assert(false); return nullptr; } } void Scene::RemoveComponentByTypeAndId(ComponentType type, UID componentId) { switch (type) { case ComponentType::TRANSFORM: transformComponents.Release(componentId); break; case ComponentType::MESH_RENDERER: meshRendererComponents.Release(componentId); break; case ComponentType::BOUNDING_BOX: boundingBoxComponents.Release(componentId); break; case ComponentType::CAMERA: cameraComponents.Release(componentId); break; case ComponentType::LIGHT: lightComponents.Release(componentId); break; case ComponentType::CANVAS: canvasComponents.Release(componentId); break; case ComponentType::CANVASRENDERER: canvasRendererComponents.Release(componentId); break; case ComponentType::IMAGE: imageComponents.Release(componentId); break; case ComponentType::TRANSFORM2D: transform2DComponents.Release(componentId); break; case ComponentType::BUTTON: buttonComponents.Release(componentId); break; case ComponentType::EVENT_SYSTEM: eventSystemComponents.Release(componentId); break; case ComponentType::BOUNDING_BOX_2D: boundingBox2DComponents.Release(componentId); break; case ComponentType::TOGGLE: toggleComponents.Release(componentId); break; case ComponentType::TEXT: textComponents.Release(componentId); break; case ComponentType::SELECTABLE: selectableComponents.Release(componentId); break; case ComponentType::SLIDER: sliderComponents.Release(componentId); break; case ComponentType::SKYBOX: skyboxComponents.Release(componentId); break; case ComponentType::ANIMATION: animationComponents.Release(componentId); break; case ComponentType::SCRIPT: scriptComponents.Release(componentId); break; case ComponentType::PARTICLE: particleComponents.Release(componentId); break; case ComponentType::TRAIL: trailComponents.Release(componentId); break; case ComponentType::BILLBOARD: billboardComponents.Release(componentId); break; case ComponentType::AUDIO_SOURCE: audioSourceComponents.Release(componentId); break; case ComponentType::AUDIO_LISTENER: audioListenerComponents.Release(componentId); break; case ComponentType::PROGRESS_BAR: progressbarsComponents.Release(componentId); break; case ComponentType::SPHERE_COLLIDER: if (App->time->IsGameRunning()) App->physics->RemoveSphereRigidbody(sphereColliderComponents.Find(componentId)); sphereColliderComponents.Release(componentId); break; case ComponentType::BOX_COLLIDER: if (App->time->IsGameRunning()) App->physics->RemoveBoxRigidbody(boxColliderComponents.Find(componentId)); boxColliderComponents.Release(componentId); break; case ComponentType::CAPSULE_COLLIDER: if (App->time->IsGameRunning()) App->physics->RemoveCapsuleRigidbody(capsuleColliderComponents.Find(componentId)); capsuleColliderComponents.Release(componentId); break; case ComponentType::AGENT: agentComponents.Release(componentId); break; case ComponentType::OBSTACLE: obstacleComponents.Release(componentId); break; case ComponentType::FOG: fogComponents.Release(componentId); break; case ComponentType::VIDEO: videoComponents.Release(componentId); break; default: LOG("Component of type %i hasn't been registered in Scene::RemoveComponentByTypeAndId.", (unsigned) type); assert(false); break; } } int Scene::GetTotalTriangles() const { int triangles = 0; for (const ComponentMeshRenderer& meshComponent : meshRendererComponents) { ResourceMesh* mesh = App->resources->GetResource<ResourceMesh>(meshComponent.GetMesh()); if (mesh != nullptr) { triangles += mesh->indices.size() / 3; } } return triangles; } std::vector<float> Scene::GetVertices() { std::vector<float> result; for (ComponentMeshRenderer& meshRenderer : meshRendererComponents) { ResourceMesh* mesh = App->resources->GetResource<ResourceMesh>(meshRenderer.GetMesh()); ComponentTransform* transform = meshRenderer.GetOwner().GetComponent<ComponentTransform>(); if (mesh != nullptr && transform->GetOwner().IsStatic()) { for (const ResourceMesh::Vertex& vertex : mesh->vertices) { float4 transformedVertex = transform->GetGlobalMatrix() * float4(vertex.position, 1.0f); result.push_back(transformedVertex.x); result.push_back(transformedVertex.y); result.push_back(transformedVertex.z); } } } return result; } std::vector<int> Scene::GetTriangles() { int triangles = 0; std::vector<int> maxVertMesh; maxVertMesh.push_back(0); for (ComponentMeshRenderer& meshRenderer : meshRendererComponents) { ResourceMesh* mesh = App->resources->GetResource<ResourceMesh>(meshRenderer.GetMesh()); if (mesh != nullptr && meshRenderer.GetOwner().IsStatic()) { triangles += mesh->indices.size() / 3; maxVertMesh.push_back(mesh->vertices.size()); } } std::vector<int> result(triangles * 3); int currentGlobalTri = 0; int vertOverload = 0; int i = 0; for (ComponentMeshRenderer& meshRenderer : meshRendererComponents) { ResourceMesh* mesh = App->resources->GetResource<ResourceMesh>(meshRenderer.GetMesh()); if (mesh != nullptr && meshRenderer.GetOwner().IsStatic()) { vertOverload += maxVertMesh[i]; for (unsigned j = 0; j < mesh->indices.size(); j += 3) { result[currentGlobalTri] = mesh->indices[j] + vertOverload; result[currentGlobalTri + 1] = mesh->indices[j + 1] + vertOverload; result[currentGlobalTri + 2] = mesh->indices[j + 2] + vertOverload; currentGlobalTri += 3; } i++; } } return result; } std::vector<float> Scene::GetNormals() { std::vector<float> result; for (ComponentMeshRenderer& meshRenderer : meshRendererComponents) { ResourceMesh* mesh = App->resources->GetResource<ResourceMesh>(meshRenderer.GetMesh()); ComponentTransform* transform = meshRenderer.GetOwner().GetComponent<ComponentTransform>(); if (mesh != nullptr && transform->GetOwner().IsStatic()) { for (const ResourceMesh::Vertex& vertex : mesh->vertices) { float4 transformedVertex = transform->GetGlobalMatrix() * float4(vertex.normal, 1.0f); result.push_back(transformedVertex.x); result.push_back(transformedVertex.y); result.push_back(transformedVertex.z); } } } return result; } const std::vector<GameObject*>& Scene::GetStaticShadowCasters() const { return staticShadowCasters; } const std::vector<GameObject*>& Scene::GetDynamicShadowCasters() const { return dynamicShadowCasters; } const std::vector<GameObject*>& Scene::GetMainEntitiesShadowCasters() const { return mainEntitiesShadowCasters; } bool Scene::InsideFrustumPlanes(const FrustumPlanes& planes, const GameObject* go) { ComponentBoundingBox* boundingBox = go->GetComponent<ComponentBoundingBox>(); if (boundingBox && planes.CheckIfInsideFrustumPlanes(boundingBox->GetWorldAABB(), boundingBox->GetWorldOBB())) { return true; } return false; } std::vector<GameObject*> Scene::GetCulledMeshes(const FrustumPlanes& planes, const int mask) { std::vector<GameObject*> meshes; for (ComponentMeshRenderer componentMR : meshRendererComponents) { GameObject* go = &componentMR.GetOwner(); Mask& maskGo = go->GetMask(); if ((maskGo.bitMask & mask) != 0) { if (InsideFrustumPlanes(planes, go)) { meshes.push_back(go); } } } return meshes; } std::vector<GameObject*> Scene::GetStaticCulledShadowCasters(const FrustumPlanes& planes) { std::vector<GameObject*> meshes; for (GameObject* go : staticShadowCasters) { if (InsideFrustumPlanes(planes, go)) { meshes.push_back(go); } } return meshes; } std::vector<GameObject*> Scene::GetDynamicCulledShadowCasters(const FrustumPlanes& planes) { std::vector<GameObject*> meshes; for (GameObject* go : dynamicShadowCasters) { if (InsideFrustumPlanes(planes, go)) { meshes.push_back(go); } } return meshes; } std::vector<GameObject*> Scene::GetMainEntitiesCulledShadowCasters(const FrustumPlanes& planes) { std::vector<GameObject*> meshes; for (GameObject* go : mainEntitiesShadowCasters) { if (InsideFrustumPlanes(planes, go)) { meshes.push_back(go); } } return meshes; } void Scene::RemoveStaticShadowCaster(const GameObject* go) { auto it = std::find(staticShadowCasters.begin(), staticShadowCasters.end(), go); if (it == staticShadowCasters.end()) return; staticShadowCasters.erase(it); App->renderer->lightFrustumStatic.Invalidate(); } void Scene::AddStaticShadowCaster(GameObject* go) { auto it = std::find(staticShadowCasters.begin(), staticShadowCasters.end(), go); if (it != staticShadowCasters.end()) return; staticShadowCasters.push_back(go); App->renderer->lightFrustumStatic.Invalidate(); } void Scene::RemoveDynamicShadowCaster(const GameObject* go) { auto it = std::find(dynamicShadowCasters.begin(), dynamicShadowCasters.end(), go); if (it == dynamicShadowCasters.end()) return; dynamicShadowCasters.erase(it); App->renderer->lightFrustumDynamic.Invalidate(); } void Scene::AddDynamicShadowCaster(GameObject* go) { auto it = std::find(dynamicShadowCasters.begin(), dynamicShadowCasters.end(), go); if (it != dynamicShadowCasters.end()) return; dynamicShadowCasters.push_back(go); App->renderer->lightFrustumDynamic.Invalidate(); } void Scene::RemoveMainEntityShadowCaster(const GameObject* go) { auto it = std::find(mainEntitiesShadowCasters.begin(), mainEntitiesShadowCasters.end(), go); if (it == mainEntitiesShadowCasters.end()) return; mainEntitiesShadowCasters.erase(it); App->renderer->lightFrustumMainEntities.Invalidate(); } void Scene::AddMainEntityShadowCaster(GameObject* go) { auto it = std::find(mainEntitiesShadowCasters.begin(), mainEntitiesShadowCasters.end(), go); if (it != mainEntitiesShadowCasters.end()) return; mainEntitiesShadowCasters.push_back(go); App->renderer->lightFrustumMainEntities.Invalidate(); } void Scene::SetCursor(UID cursor) { if (cursorId != 0) { App->resources->DecreaseReferenceCount(cursorId); } cursorId = cursor; if (cursor != 0) { App->resources->IncreaseReferenceCount(cursor); } App->window->SetCursor(cursorId, widthCursor, heightCursor); #if GAME App->window->ActivateCursor(true); #endif } UID Scene::GetCursor() { return cursorId; } void Scene::SetCursorWidth(int width) { widthCursor = width; } int Scene::GetCursorWidth() { return widthCursor; } void Scene::SetCursorHeight(int height) { heightCursor = height; } int Scene::GetCursorHeight() { return heightCursor; }
33.214092
136
0.777945
TBD-org
435552d931ccffb65e45704f1b5909b4cb708ba0
1,606
cpp
C++
modules/argument_game/grid_controller_base.cpp
Niluk93/ArgumentGame
e934399578d3aa0852faed3175b8675439632c9e
[ "CC-BY-3.0", "Apache-2.0", "MIT" ]
1
2020-03-08T21:31:15.000Z
2020-03-08T21:31:15.000Z
modules/argument_game/grid_controller_base.cpp
Niluk93/ArgumentGame
e934399578d3aa0852faed3175b8675439632c9e
[ "CC-BY-3.0", "Apache-2.0", "MIT" ]
null
null
null
modules/argument_game/grid_controller_base.cpp
Niluk93/ArgumentGame
e934399578d3aa0852faed3175b8675439632c9e
[ "CC-BY-3.0", "Apache-2.0", "MIT" ]
null
null
null
#include "grid_controller_base.h" #include "grid_state.h" #include "game_grid.h" #include <stdexcept> GridControllerBase::GridControllerBase() : bAcceptingInput(true) { } void GridControllerBase::_bind_methods() { ClassDB::bind_method(D_METHOD("init", "owner"), &GridControllerBase::init); ClassDB::bind_method(D_METHOD("process_tileHover", "oldTileIndex", "newTileIndex"), &GridControllerBase::process_tileHover); ClassDB::bind_method(D_METHOD("process_tileSelected", "tileIndex"), &GridControllerBase::process_tileSelected); ClassDB::bind_method(D_METHOD("process_gridStateChanged", "bNext"), &GridControllerBase::process_gridStateChanged); ClassDB::bind_method(D_METHOD("toggle_acceptingInput", "bAcceptingInput"), &GridControllerBase::toggleAcceptingInput); } void GridControllerBase::init(Variant owner) { OwningGrid = owner; GridStateRef.instance(); GridStateRef->set_GridRef(owner); } void GridControllerBase::process_tileHoverImpl(int oldTileIndex, int newTileIndex) { throw std::logic_error("The method or operation is not implemented."); } void GridControllerBase::process_tileSelectedImpl(int tileIndex) { throw std::logic_error("The method or operation is not implemented."); } void GridControllerBase::process_gridStateChangedImpl(bool bNext) { throw std::logic_error("The method or operation is not implemented."); } void GridControllerBase::toggleAcceptingInput(bool toggleTo) { GridStateRef->set_GridRef(OwningGrid); bAcceptingInput = toggleTo; } GridTextures GridControllerBase::get_GridStateAtNode(int nodeIndex) { return GridStateRef->get_NodeState(nodeIndex); }
30.301887
125
0.800125
Niluk93
435df21ddd9ee3e897aae0f2896d3766695c88d1
12,938
cpp
C++
tests/unique_handle.cpp
DNKpp/Simple-Utility
db2d6cb1cc3849704f18272f8ce2d2bc05ad06a7
[ "BSL-1.0" ]
null
null
null
tests/unique_handle.cpp
DNKpp/Simple-Utility
db2d6cb1cc3849704f18272f8ce2d2bc05ad06a7
[ "BSL-1.0" ]
8
2021-12-30T22:07:39.000Z
2022-02-04T21:13:53.000Z
tests/unique_handle.cpp
DNKpp/Simple-Utility
db2d6cb1cc3849704f18272f8ce2d2bc05ad06a7
[ "BSL-1.0" ]
1
2020-08-19T13:02:58.000Z
2020-08-19T13:02:58.000Z
// Copyright Dominic Koepke 2019 - 2022. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) #include <catch2/catch.hpp> #include "helper.hpp" #include "Simple-Utility/unique_handle.hpp" using namespace sl; namespace { struct value_t { int a{}; int z{}; constexpr value_t(int a) : a{ a } { } constexpr value_t(int a, int z) : a{ a }, z{ z } { } constexpr value_t(value_t&&) noexcept = default; constexpr value_t& operator =(value_t&&) noexcept = default; constexpr auto operator <=>(const value_t&) const = default; }; struct delete_action_mock { int* invoke_counter{}; constexpr void operator ()(auto&) noexcept { if (invoke_counter) ++(*invoke_counter); } }; using test_handle = unique_handle<int, delete_action_mock>; } TEST_CASE("unique_handle should be default constructible.", "[unique_handle]") { STATIC_REQUIRE(std::default_initializable<test_handle>); } TEST_CASE("unique_handle should neither be copy constructible nor assignable.", "[unique_handle]") { STATIC_REQUIRE(!std::copy_constructible<test_handle>); STATIC_REQUIRE(!std::assignable_from<test_handle&, const test_handle&>); } TEST_CASE("default constructed unique_handle should not contain a value.", "[unique_handle]") { constexpr test_handle handle{}; STATIC_REQUIRE(!handle.is_valid()); STATIC_REQUIRE(!handle); } TEST_CASE("unique_handle should be explicitly null constructible by nullhandle.", "[unique_handle]") { constexpr test_handle handle{ nullhandle }; STATIC_REQUIRE(!handle.is_valid()); STATIC_REQUIRE(!handle); } TEST_CASE("unique_handle should be empty constructible by nullhandle and deleteAction.", "[unique_handle]") { constexpr bool result = [] { int testValue = 1337; const test_handle handle{ nullhandle, delete_action_mock{ &testValue } }; return !handle && *handle.delete_action().invoke_counter == 1337; }(); REQUIRE(result); } TEST_CASE("unique_handle should be assignable by nullhandle.", "[unique_handle]") { SL_UNIQUE_HANDLE_FULL_CONSTEXPR const test_handle handle = [] { // ReSharper disable once CppInitializedValueIsAlwaysRewritten test_handle temp{}; temp = nullhandle; return temp; }(); REQUIRE(!handle.is_valid()); REQUIRE(!handle); } TEST_CASE("unique_handle should be empty constructible by deleteAction.", "[unique_handle]") { constexpr bool result = [] { int testValue = 1337; const test_handle handle{ delete_action_mock{ &testValue } }; return !handle && *handle.delete_action().invoke_counter == 1337; }(); REQUIRE(result); } TEST_CASE("unique_handle should be constructible by value.", "[unique_handle]") { constexpr test_handle handle{ 42 }; STATIC_REQUIRE(handle.is_valid()); STATIC_REQUIRE(handle); } TEST_CASE("unique_handle should be constructible by value and deleteAction.", "[unique_handle]") { constexpr bool result = [] { int testValue = 1337; const test_handle handle{ 42, delete_action_mock{ &testValue } }; return *handle == 42 && *handle.delete_action().invoke_counter == 1337; }(); REQUIRE(result); } TEST_CASE("unique_handle should be assignable by value.", "[unique_handle]") { SL_UNIQUE_HANDLE_FULL_CONSTEXPR const test_handle handle = [] { // ReSharper disable once CppInitializedValueIsAlwaysRewritten test_handle temp{}; temp = 42; return temp; }(); REQUIRE(handle.is_valid()); REQUIRE(handle); } TEST_CASE ( "unique_handle should automatically deduct its template arguments when constructed by value and deleteAction.", "[unique_handle]" ) { constexpr unique_handle handle{ 42, delete_action_mock{} }; STATIC_REQUIRE(std::same_as<int, decltype(handle)::value_type>); STATIC_REQUIRE(std::same_as<delete_action_mock, decltype(handle)::delete_action_type>); } TEST_CASE("unique_handle should automatically deduct its template arguments when constructed by value.", "[unique_handle]") { constexpr unique_handle handle{ 42 }; STATIC_REQUIRE(std::same_as<decltype(handle)::value_type, int>); STATIC_REQUIRE(std::same_as<decltype(handle)::delete_action_type, default_delete_action>); } TEST_CASE("unique_handle should be explicitly in-place construct value when std::in_place token is used.", "[unique_handle]") { constexpr unique_handle<value_t> handle{ std::in_place, 42, 1337 }; STATIC_REQUIRE(handle->a == 42); STATIC_REQUIRE(handle->z == 1337); } TEST_CASE ( "unique_handle should be explicitly in-place construct value and deleteAction when std::in_place token is used.", "[unique_handle]" ) { constexpr bool result = [] { int testValue = 1337; const unique_handle<value_t, delete_action_mock> handle{ std::in_place, delete_action_mock{ &testValue }, 42, -1 }; return handle->a == 42 && handle->z == -1 && *handle.delete_action().invoke_counter == 1337; }(); REQUIRE(result); } TEST_CASE("unique_handle::emplace constructs value in place.", "[unique_handle]") { SL_UNIQUE_HANDLE_FULL_CONSTEXPR const bool result = [] { unique_handle<value_t> handle{}; handle.emplace(1337, 42); return handle->a == 1337 && handle->z == 42; }(); REQUIRE(result); } #pragma warning(disable: 26444) TEMPLATE_TEST_CASE_SIG ( "delete action on assignment must only be invoked if unique_handle holds a value.", "[unique_handle]", ((class TInit, class TAssign, bool VExpected), TInit, TAssign, VExpected), (int, int, true), (int, nullhandle_t, true), (nullhandle_t, int, false), (nullhandle_t, nullhandle_t, false) ) #pragma warning(disable: 26444) { SL_UNIQUE_HANDLE_FULL_CONSTEXPR const bool result = [] { int counter{}; test_handle temp{ TInit{}, delete_action_mock{ .invoke_counter = &counter } }; temp = TAssign{}; return counter == 1; }(); REQUIRE(result == VExpected); } TEST_CASE("unique_handle should be move constructible and invalidate the source.", "[unique_handle]") { SL_UNIQUE_HANDLE_FULL_CONSTEXPR const bool result = [] { test_handle source{ 42 }; const test_handle target{ std::move(source) }; return !source.is_valid() && target.is_valid(); }(); REQUIRE(result); } TEST_CASE("unique_handle should be move constructible and receive the value of other.", "[unique_handle]") { SL_UNIQUE_HANDLE_FULL_CONSTEXPR const bool result = [] { // ReSharper disable once CppInitializedValueIsAlwaysRewritten test_handle source{ 42 }; const test_handle target{ std::move(source) }; return target.raw() == 42; }(); REQUIRE(result); } TEST_CASE("unique_handle should be move assignable and invalidate the source.", "[unique_handle]") { SL_UNIQUE_HANDLE_FULL_CONSTEXPR const bool result = [] { test_handle source{ 42 }; // ReSharper disable once CppInitializedValueIsAlwaysRewritten test_handle target{ nullhandle }; target = std::move(source); return !source.is_valid() && target.is_valid(); }(); REQUIRE(result); } TEST_CASE("unique_handle should be move assignable and receive the value of other.", "[unique_handle]") { SL_UNIQUE_HANDLE_FULL_CONSTEXPR const bool result = [] { test_handle source{ 1337 }; // ReSharper disable once CppInitializedValueIsAlwaysRewritten test_handle target{ nullhandle }; target = std::move(source); return target.raw() == 1337; }(); REQUIRE(result); } TEST_CASE("moving unique_handle with itself should change nothing.", "[unique_handle]") { SL_UNIQUE_HANDLE_FULL_CONSTEXPR const bool result = [] { test_handle handle{ 1337 }; handle = std::move(handle); return handle.is_valid() && *handle == 1337; }(); REQUIRE(result); } TEST_CASE("swapping unique_handle with itself should change nothing.", "[unique_handle]") { SL_UNIQUE_HANDLE_FULL_CONSTEXPR const bool result = [] { test_handle handle{ 1337 }; handle.swap(handle); return handle.is_valid() && *handle == 1337; }(); REQUIRE(result); } TEST_CASE("unique_handle should be swapable.", "[unique_handle]") { SL_UNIQUE_HANDLE_FULL_CONSTEXPR const bool result = [] { test_handle lhs{ 1337 }; test_handle rhs{ 42 }; lhs.swap(rhs); return *lhs == 42 && *rhs == 1337; }(); REQUIRE(result); } TEST_CASE("unique_handle::raw should expose a const reference of its value.", "[unique_handle]") { constexpr bool result = [] { const test_handle handle{ 1337 }; const int& ref{ handle.raw() }; return ref == 1337; }(); STATIC_REQUIRE(result); } TEST_CASE("unique_handle::raw should throw bad_handle_access if no value is hold.", "[unique_handle]") { constexpr test_handle handle{}; REQUIRE_THROWS_AS(handle.raw(), bad_handle_access); } TEST_CASE("unique_handle's operator * should expose a const reference of its value.", "[unique_handle]") { constexpr bool result = [] { const test_handle handle{ 42 }; const int& ref{ *handle }; return ref == 42; }(); REQUIRE(result); } TEMPLATE_TEST_CASE ( "unique_handle's operator -> overload should expose a pointer to its value.", "[unique_handle]", test_handle, const test_handle ) { constexpr bool result = [] { TestType handle{ 1337 }; auto* ptr = handle.operator ->(); return *ptr == 1337; }(); STATIC_REQUIRE(result); } TEST_CASE("unique_handle::reset should reset to a nullhandle.", "[unique_handle]") { SL_UNIQUE_HANDLE_FULL_CONSTEXPR const test_handle handle = [] { test_handle temp{ 42 }; temp.reset(); return temp; }(); REQUIRE(!handle); } TEST_CASE("resetting a handle without value should do nothing.", "[unique_handle]") { REQUIRE_NOTHROW ( [] { test_handle temp{ nullhandle }; temp.reset(); }() ); } #pragma warning(disable: 26444) TEMPLATE_TEST_CASE_SIG ( "delete action on reset must only be invoked if unique_handle holds a value.", "[unique_handle]", ((class TInit, bool VExpected), TInit, VExpected), (int, true), (nullhandle_t, false) ) #pragma warning(disable: 26444) { SL_UNIQUE_HANDLE_FULL_CONSTEXPR const bool result = [] { int counter{}; test_handle temp{ TInit{}, delete_action_mock{ .invoke_counter = &counter } }; temp.reset(); return counter == 1; }(); REQUIRE(result == VExpected); } TEST_CASE("unique_handle::delete_action should return a reference to the used deleter action object.", "[unique_handle]") { constexpr bool result = [] { test_handle temp{ 42 }; return &temp.delete_action() == &std::as_const(temp).delete_action(); }(); STATIC_REQUIRE(result); } #pragma warning(disable: 26444) TEMPLATE_TEST_CASE_SIG ( "delete action on destruction must only be invoked if unique_handle holds a value.", "[unique_handle]", ((class TInit, bool VExpected), TInit, VExpected), (int, true), (nullhandle_t, false) ) #pragma warning(disable: 26444) { constexpr bool result = [] { int counter{}; { const test_handle temp{ TInit{}, delete_action_mock{ .invoke_counter = &counter } }; } return counter == 1; }(); REQUIRE(result == VExpected); } TEST_CASE("unique_handle should be three-way-comparable with unqiue_handle of same type.", "[unique_handle]") { STATIC_REQUIRE((test_handle{} <=> test_handle{}) == std::strong_ordering::equal); STATIC_REQUIRE((test_handle{} <=> test_handle{ 42 }) == std::strong_ordering::less); STATIC_REQUIRE((test_handle{42 } <=> test_handle{}) == std::strong_ordering::greater); STATIC_REQUIRE((test_handle{42 } <=> test_handle{1337}) == std::strong_ordering::less); } TEST_CASE("unique_handle should be three-way-comparable with nullhandle.", "[unique_handle]") { STATIC_REQUIRE((nullhandle <=> test_handle{ 42 }) == std::strong_ordering::less); STATIC_REQUIRE((nullhandle <=> test_handle{}) == std::strong_ordering::equal); STATIC_REQUIRE((test_handle{ 42 } <=> nullhandle) == std::strong_ordering::greater); STATIC_REQUIRE((test_handle{} <=> nullhandle) == std::strong_ordering::equal); } TEST_CASE("unique_handle should be three-way-comparable with value type.", "[unique_handle]") { STATIC_REQUIRE((42 <=> test_handle{ 1337 }) == std::strong_ordering::less); STATIC_REQUIRE((1337 <=> test_handle{ 42 }) == std::strong_ordering::greater); STATIC_REQUIRE((test_handle{ 1337 } <=> 42 ) == std::strong_ordering::greater); STATIC_REQUIRE((test_handle{ 42 } <=> 1337) == std::strong_ordering::less); STATIC_REQUIRE((1337 <=> test_handle{}) == std::strong_ordering::greater); STATIC_REQUIRE((test_handle{} <=> 1337) == std::strong_ordering::less); STATIC_REQUIRE((42 <=> test_handle{ 42 }) == std::strong_ordering::equal); STATIC_REQUIRE((test_handle{ 42 } <=> 42) == std::strong_ordering::equal); } TEST_CASE("unique_handle should be equality-comparable with specific types.", "[unique_handle]") { STATIC_REQUIRE(1337 != test_handle{}); STATIC_REQUIRE(1337 == test_handle{ 1337 }); STATIC_REQUIRE(test_handle{ 1337 } != test_handle{}); STATIC_REQUIRE(test_handle{ 1337 } != test_handle{ 42 }); STATIC_REQUIRE(test_handle{ 1337 } == test_handle{ 1337 }); STATIC_REQUIRE(nullhandle == test_handle{}); STATIC_REQUIRE(nullhandle != test_handle{ 42 }); }
25.269531
125
0.715257
DNKpp
cb196e35fc623b3aa0f1ca9511afa22f3352f8c7
750
cpp
C++
lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp
kkeita/llvm_autofdo
9ecd435b55a3e58e1e3f71d478ff02c57840a900
[ "Apache-2.0" ]
34
2019-05-29T03:15:48.000Z
2022-03-24T03:14:58.000Z
lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp
kkeita/llvm_autofdo
9ecd435b55a3e58e1e3f71d478ff02c57840a900
[ "Apache-2.0" ]
1
2020-05-21T11:44:22.000Z
2020-05-21T11:44:22.000Z
lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp
kkeita/llvm_autofdo
9ecd435b55a3e58e1e3f71d478ff02c57840a900
[ "Apache-2.0" ]
4
2019-12-16T18:49:42.000Z
2021-10-11T18:41:54.000Z
//===-- AVRTargetInfo.cpp - AVR Target Implementation ---------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "llvm/IR/Module.h" #include "llvm/Support/TargetRegistry.h" namespace llvm { Target &getTheAVRTarget() { static Target TheAVRTarget; return TheAVRTarget; } } extern "C" void LLVMInitializeAVRTargetInfo() { llvm::RegisterTarget<llvm::Triple::avr> X(llvm::getTheAVRTarget(), "avr", "Atmel AVR Microcontroller", "AVR"); }
32.608696
80
0.586667
kkeita
cb1ecaceb1f1cbd84409850879b41f210ceaf3a1
487
hpp
C++
include/render/Triangle.hpp
nsentout/project-lambda-client
3b6f84e90ebf1319bbbfd6649b1e9e94b96f1469
[ "MIT" ]
null
null
null
include/render/Triangle.hpp
nsentout/project-lambda-client
3b6f84e90ebf1319bbbfd6649b1e9e94b96f1469
[ "MIT" ]
null
null
null
include/render/Triangle.hpp
nsentout/project-lambda-client
3b6f84e90ebf1319bbbfd6649b1e9e94b96f1469
[ "MIT" ]
null
null
null
#ifndef TRIANGLE_HPP #define TRIANGLE_HPP #include <GL/glew.h> #include <GLFW/glfw3.h> #include "GameObject.hpp" #include "Position.h" #include "Color.h" //TODO: manage width and color class Triangle : public GameObject { public: Triangle(); void init() override; void draw() const override; void erase() const override; void moveX(unsigned int movement) override; void moveY(unsigned int movement) override; void setXY(int x, int y) override; }; #endif
18.730769
47
0.704312
nsentout
cb1ef2b1565387a58e53630a76e8cbac8b92347c
12,997
cpp
C++
src/openms/source/ANALYSIS/TARGETED/TargetedExperiment.cpp
mrurik/OpenMS
3bf48247423dc28a7df7b12b72fbc7751965c321
[ "Zlib", "Apache-2.0" ]
null
null
null
src/openms/source/ANALYSIS/TARGETED/TargetedExperiment.cpp
mrurik/OpenMS
3bf48247423dc28a7df7b12b72fbc7751965c321
[ "Zlib", "Apache-2.0" ]
null
null
null
src/openms/source/ANALYSIS/TARGETED/TargetedExperiment.cpp
mrurik/OpenMS
3bf48247423dc28a7df7b12b72fbc7751965c321
[ "Zlib", "Apache-2.0" ]
null
null
null
// -------------------------------------------------------------------------- // OpenMS -- Open-Source Mass Spectrometry // -------------------------------------------------------------------------- // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen, // ETH Zurich, and Freie Universitaet Berlin 2002-2016. // // This software is released under a three-clause BSD license: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of any author or any participating institution // may be used to endorse or promote products derived from this software // without specific prior written permission. // For a full list of authors, refer to the file AUTHORS. // -------------------------------------------------------------------------- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // -------------------------------------------------------------------------- // $Maintainer: Hannes Roest $ // $Authors: Andreas Bertsch $ // -------------------------------------------------------------------------- #include <OpenMS/ANALYSIS/TARGETED/TargetedExperiment.h> #include <algorithm> namespace OpenMS { TargetedExperiment::TargetedExperiment() { } TargetedExperiment::TargetedExperiment(const TargetedExperiment & rhs) : cvs_(rhs.cvs_), contacts_(rhs.contacts_), publications_(rhs.publications_), instruments_(rhs.instruments_), targets_(rhs.targets_), software_(rhs.software_), proteins_(rhs.proteins_), compounds_(rhs.compounds_), peptides_(rhs.peptides_), transitions_(rhs.transitions_), include_targets_(rhs.include_targets_), exclude_targets_(rhs.exclude_targets_), source_files_(rhs.source_files_), protein_reference_map_dirty_(true), peptide_reference_map_dirty_(true) { } TargetedExperiment::~TargetedExperiment() { } TargetedExperiment & TargetedExperiment::operator=(const TargetedExperiment & rhs) { if (&rhs != this) { cvs_ = rhs.cvs_; contacts_ = rhs.contacts_; publications_ = rhs.publications_; instruments_ = rhs.instruments_; targets_ = rhs.targets_; software_ = rhs.software_; proteins_ = rhs.proteins_; compounds_ = rhs.compounds_; peptides_ = rhs.peptides_; transitions_ = rhs.transitions_; include_targets_ = rhs.include_targets_; exclude_targets_ = rhs.exclude_targets_; source_files_ = rhs.source_files_; protein_reference_map_dirty_ = true; peptide_reference_map_dirty_ = true; } return *this; } TargetedExperiment TargetedExperiment::operator+(const TargetedExperiment & rhs) const { TargetedExperiment tmp(*this); tmp += rhs; return tmp; } TargetedExperiment & TargetedExperiment::operator+=(const TargetedExperiment & rhs) { protein_reference_map_dirty_ = true; peptide_reference_map_dirty_ = true; // merge these: cvs_.insert(cvs_.end(), rhs.cvs_.begin(), rhs.cvs_.end()); contacts_.insert(contacts_.end(), rhs.contacts_.begin(), rhs.contacts_.end()); publications_.insert(publications_.end(), rhs.publications_.begin(), rhs.publications_.end()); instruments_.insert(instruments_.end(), rhs.instruments_.begin(), rhs.instruments_.end()); software_.insert(software_.end(), rhs.software_.begin(), rhs.software_.end()); proteins_.insert(proteins_.end(), rhs.proteins_.begin(), rhs.proteins_.end()); compounds_.insert(compounds_.end(), rhs.compounds_.begin(), rhs.compounds_.end()); peptides_.insert(peptides_.end(), rhs.peptides_.begin(), rhs.peptides_.end()); transitions_.insert(transitions_.end(), rhs.transitions_.begin(), rhs.transitions_.end()); include_targets_.insert(include_targets_.end(), rhs.include_targets_.begin(), rhs.include_targets_.end()); exclude_targets_.insert(exclude_targets_.end(), rhs.exclude_targets_.begin(), rhs.exclude_targets_.end()); source_files_.insert(source_files_.end(), rhs.source_files_.begin(), rhs.source_files_.end()); for (Map<String, std::vector<CVTerm> >::const_iterator targ_it = rhs.targets_.getCVTerms().begin(); targ_it != rhs.targets_.getCVTerms().end(); ++targ_it) { for (std::vector<CVTerm>::const_iterator term_it = targ_it->second.begin(); term_it != targ_it->second.end(); ++term_it) { targets_.addCVTerm(*term_it); } } // todo: check for double entries // transitions, peptides, proteins return *this; } bool TargetedExperiment::operator==(const TargetedExperiment & rhs) const { return cvs_ == rhs.cvs_ && contacts_ == rhs.contacts_ && publications_ == rhs.publications_ && instruments_ == rhs.instruments_ && targets_ == rhs.targets_ && software_ == rhs.software_ && proteins_ == rhs.proteins_ && compounds_ == rhs.compounds_ && peptides_ == rhs.peptides_ && transitions_ == rhs.transitions_ && include_targets_ == rhs.include_targets_ && exclude_targets_ == rhs.exclude_targets_ && source_files_ == rhs.source_files_; } bool TargetedExperiment::operator!=(const TargetedExperiment & rhs) const { return !(operator==(rhs)); } void TargetedExperiment::clear(bool clear_meta_data) { transitions_.clear(); if (clear_meta_data) { cvs_.clear(); contacts_.clear(); publications_.clear(); instruments_.clear(); targets_ = CVTermList(); software_.clear(); proteins_.clear(); compounds_.clear(); peptides_.clear(); include_targets_.clear(); exclude_targets_.clear(); source_files_.clear(); protein_reference_map_.clear(); peptide_reference_map_.clear(); protein_reference_map_dirty_ = true; peptide_reference_map_dirty_ = true; } } void TargetedExperiment::setCVs(const std::vector<CV> & cvs) { cvs_ = cvs; } const std::vector<TargetedExperiment::CV> & TargetedExperiment::getCVs() const { return cvs_; } void TargetedExperiment::addCV(const CV & cv) { cvs_.push_back(cv); } void TargetedExperiment::setContacts(const std::vector<Contact> & contacts) { contacts_ = contacts; } const std::vector<TargetedExperiment::Contact> & TargetedExperiment::getContacts() const { return contacts_; } void TargetedExperiment::addContact(const Contact & contact) { contacts_.push_back(contact); } void TargetedExperiment::setPublications(const std::vector<Publication> & publications) { publications_ = publications; } const std::vector<TargetedExperiment::Publication> & TargetedExperiment::getPublications() const { return publications_; } void TargetedExperiment::addPublication(const Publication & publication) { publications_.push_back(publication); } void TargetedExperiment::setTargetCVTerms(const CVTermList & cv_terms) { targets_ = cv_terms; } const CVTermList & TargetedExperiment::getTargetCVTerms() const { return targets_; } void TargetedExperiment::addTargetCVTerm(const CVTerm & cv_term) { targets_.addCVTerm(cv_term); } void TargetedExperiment::setTargetMetaValue(const String & name, const DataValue & value) { targets_.setMetaValue(name, value); } void TargetedExperiment::setInstruments(const std::vector<Instrument> & instruments) { instruments_ = instruments; } const std::vector<TargetedExperiment::Instrument> & TargetedExperiment::getInstruments() const { return instruments_; } void TargetedExperiment::addInstrument(const Instrument & instrument) { instruments_.push_back(instrument); } void TargetedExperiment::setSoftware(const std::vector<Software> & software) { software_ = software; } const std::vector<Software> & TargetedExperiment::getSoftware() const { return software_; } void TargetedExperiment::addSoftware(const Software & software) { software_.push_back(software); } void TargetedExperiment::setProteins(const std::vector<Protein> & proteins) { protein_reference_map_dirty_ = true; proteins_ = proteins; } const std::vector<TargetedExperiment::Protein> & TargetedExperiment::getProteins() const { return proteins_; } const TargetedExperiment::Protein & TargetedExperiment::getProteinByRef(const String & ref) { if (protein_reference_map_dirty_) { createProteinReferenceMap_(); } return *(protein_reference_map_[ref]); } void TargetedExperiment::addProtein(const Protein & protein) { protein_reference_map_dirty_ = true; proteins_.push_back(protein); } void TargetedExperiment::setCompounds(const std::vector<Compound> & compounds) { compounds_ = compounds; } const std::vector<TargetedExperiment::Compound> & TargetedExperiment::getCompounds() const { return compounds_; } void TargetedExperiment::addCompound(const Compound & rhs) { compounds_.push_back(rhs); } void TargetedExperiment::setPeptides(const std::vector<Peptide> & peptides) { peptide_reference_map_dirty_ = true; peptides_ = peptides; } const std::vector<TargetedExperiment::Peptide> & TargetedExperiment::getPeptides() const { return peptides_; } const TargetedExperiment::Peptide & TargetedExperiment::getPeptideByRef(const String & ref) { if (peptide_reference_map_dirty_) { createPeptideReferenceMap_(); } return *(peptide_reference_map_[ref]); } void TargetedExperiment::addPeptide(const Peptide & rhs) { peptide_reference_map_dirty_ = true; peptides_.push_back(rhs); } void TargetedExperiment::setTransitions(const std::vector<ReactionMonitoringTransition> & transitions) { transitions_ = transitions; } const std::vector<ReactionMonitoringTransition> & TargetedExperiment::getTransitions() const { return transitions_; } void TargetedExperiment::addTransition(const ReactionMonitoringTransition & transition) { transitions_.push_back(transition); } void TargetedExperiment::setIncludeTargets(const std::vector<IncludeExcludeTarget> & targets) { include_targets_ = targets; } const std::vector<IncludeExcludeTarget> & TargetedExperiment::getIncludeTargets() const { return include_targets_; } void TargetedExperiment::addIncludeTarget(const IncludeExcludeTarget & target) { include_targets_.push_back(target); } void TargetedExperiment::setExcludeTargets(const std::vector<IncludeExcludeTarget> & targets) { exclude_targets_ = targets; } const std::vector<IncludeExcludeTarget> & TargetedExperiment::getExcludeTargets() const { return exclude_targets_; } void TargetedExperiment::addExcludeTarget(const IncludeExcludeTarget & target) { exclude_targets_.push_back(target); } void TargetedExperiment::setSourceFiles(const std::vector<SourceFile> & source_files) { source_files_ = source_files; } const std::vector<SourceFile> & TargetedExperiment::getSourceFiles() const { return source_files_; } void TargetedExperiment::addSourceFile(const SourceFile & source_file) { source_files_.push_back(source_file); } void TargetedExperiment::sortTransitionsByProductMZ() { std::sort(transitions_.begin(), transitions_.end(), ReactionMonitoringTransition::ProductMZLess()); } void TargetedExperiment::createProteinReferenceMap_() { for (Size i = 0; i < getProteins().size(); i++) { protein_reference_map_[getProteins()[i].id] = &getProteins()[i]; } protein_reference_map_dirty_ = false; } void TargetedExperiment::createPeptideReferenceMap_() { for (Size i = 0; i < getPeptides().size(); i++) { peptide_reference_map_[getPeptides()[i].id] = &getPeptides()[i]; } peptide_reference_map_dirty_ = false; } } // namespace OpenMS
30.50939
158
0.689467
mrurik
cb2704acf1688c0dd55810183741f63121b92191
196,624
cpp
C++
HTML_Lectures/Virtualization_Lecture/vbox/src/VBox/Devices/Audio/DevHDA.cpp
roughk/CSCI-49XX-OpenSource
74268cbca8bcda3023b2350d046e2dca2853a3ef
[ "BSD-2-Clause", "CC-BY-4.0" ]
null
null
null
HTML_Lectures/Virtualization_Lecture/vbox/src/VBox/Devices/Audio/DevHDA.cpp
roughk/CSCI-49XX-OpenSource
74268cbca8bcda3023b2350d046e2dca2853a3ef
[ "BSD-2-Clause", "CC-BY-4.0" ]
null
null
null
HTML_Lectures/Virtualization_Lecture/vbox/src/VBox/Devices/Audio/DevHDA.cpp
roughk/CSCI-49XX-OpenSource
74268cbca8bcda3023b2350d046e2dca2853a3ef
[ "BSD-2-Clause", "CC-BY-4.0" ]
null
null
null
/* $Id: DevHDA.cpp 73466 2018-08-03 09:41:27Z vboxsync $ */ /** @file * DevHDA.cpp - VBox Intel HD Audio Controller. * * Implemented against the specifications found in "High Definition Audio * Specification", Revision 1.0a June 17, 2010, and "Intel I/O Controller * HUB 6 (ICH6) Family, Datasheet", document number 301473-002. */ /* * Copyright (C) 2006-2018 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. */ /********************************************************************************************************************************* * Header Files * *********************************************************************************************************************************/ #define LOG_GROUP LOG_GROUP_DEV_HDA #include <VBox/log.h> #include <VBox/vmm/pdmdev.h> #include <VBox/vmm/pdmaudioifs.h> #include <VBox/version.h> #include <VBox/AssertGuest.h> #include <iprt/assert.h> #include <iprt/asm.h> #include <iprt/asm-math.h> #include <iprt/file.h> #include <iprt/list.h> #ifdef IN_RING3 # include <iprt/mem.h> # include <iprt/semaphore.h> # include <iprt/string.h> # include <iprt/uuid.h> #endif #include "VBoxDD.h" #include "AudioMixBuffer.h" #include "AudioMixer.h" #include "DevHDA.h" #include "DevHDACommon.h" #include "HDACodec.h" #include "HDAStream.h" # if defined(VBOX_WITH_HDA_AUDIO_INTERLEAVING_STREAMS_SUPPORT) || defined(VBOX_WITH_AUDIO_HDA_51_SURROUND) # include "HDAStreamChannel.h" # endif #include "HDAStreamMap.h" #include "HDAStreamPeriod.h" #include "DrvAudio.h" /********************************************************************************************************************************* * Defined Constants And Macros * *********************************************************************************************************************************/ //#define HDA_AS_PCI_EXPRESS /* Installs a DMA access handler (via PGM callback) to monitor * HDA's DMA operations, that is, writing / reading audio stream data. * * !!! Note: Certain guests are *that* timing sensitive that when enabling !!! * !!! such a handler will mess up audio completely (e.g. Windows 7). !!! */ //#define HDA_USE_DMA_ACCESS_HANDLER #ifdef HDA_USE_DMA_ACCESS_HANDLER # include <VBox/vmm/pgm.h> #endif /* Uses the DMA access handler to read the written DMA audio (output) data. * Only valid if HDA_USE_DMA_ACCESS_HANDLER is set. * * Also see the note / warning for HDA_USE_DMA_ACCESS_HANDLER. */ //# define HDA_USE_DMA_ACCESS_HANDLER_WRITING /* Useful to debug the device' timing. */ //#define HDA_DEBUG_TIMING /* To debug silence coming from the guest in form of audio gaps. * Very crude implementation for now. */ //#define HDA_DEBUG_SILENCE #if defined(VBOX_WITH_HP_HDA) /* HP Pavilion dv4t-1300 */ # define HDA_PCI_VENDOR_ID 0x103c # define HDA_PCI_DEVICE_ID 0x30f7 #elif defined(VBOX_WITH_INTEL_HDA) /* Intel HDA controller */ # define HDA_PCI_VENDOR_ID 0x8086 # define HDA_PCI_DEVICE_ID 0x2668 #elif defined(VBOX_WITH_NVIDIA_HDA) /* nVidia HDA controller */ # define HDA_PCI_VENDOR_ID 0x10de # define HDA_PCI_DEVICE_ID 0x0ac0 #else # error "Please specify your HDA device vendor/device IDs" #endif /* Make sure that interleaving streams support is enabled if the 5.1 surround code is being used. */ #if defined (VBOX_WITH_AUDIO_HDA_51_SURROUND) && !defined(VBOX_WITH_HDA_AUDIO_INTERLEAVING_STREAMS_SUPPORT) # define VBOX_WITH_HDA_AUDIO_INTERLEAVING_STREAMS_SUPPORT #endif /** * Acquires the HDA lock. */ #define DEVHDA_LOCK(a_pThis) \ do { \ int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \ AssertRC(rcLock); \ } while (0) /** * Acquires the HDA lock or returns. */ # define DEVHDA_LOCK_RETURN(a_pThis, a_rcBusy) \ do { \ int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, a_rcBusy); \ if (rcLock != VINF_SUCCESS) \ { \ AssertRC(rcLock); \ return rcLock; \ } \ } while (0) /** * Acquires the HDA lock or returns. */ # define DEVHDA_LOCK_RETURN_VOID(a_pThis) \ do { \ int rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \ if (rcLock != VINF_SUCCESS) \ { \ AssertRC(rcLock); \ return; \ } \ } while (0) /** * Releases the HDA lock. */ #define DEVHDA_UNLOCK(a_pThis) \ do { PDMCritSectLeave(&(a_pThis)->CritSect); } while (0) /** * Acquires the TM lock and HDA lock, returns on failure. */ #define DEVHDA_LOCK_BOTH_RETURN_VOID(a_pThis, a_SD) \ do { \ int rcLock = TMTimerLock((a_pThis)->pTimer[a_SD], VERR_IGNORED); \ if (rcLock != VINF_SUCCESS) \ { \ AssertRC(rcLock); \ return; \ } \ rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, VERR_IGNORED); \ if (rcLock != VINF_SUCCESS) \ { \ AssertRC(rcLock); \ TMTimerUnlock((a_pThis)->pTimer[a_SD]); \ return; \ } \ } while (0) /** * Acquires the TM lock and HDA lock, returns on failure. */ #define DEVHDA_LOCK_BOTH_RETURN(a_pThis, a_SD, a_rcBusy) \ do { \ int rcLock = TMTimerLock((a_pThis)->pTimer[a_SD], (a_rcBusy)); \ if (rcLock != VINF_SUCCESS) \ return rcLock; \ rcLock = PDMCritSectEnter(&(a_pThis)->CritSect, (a_rcBusy)); \ if (rcLock != VINF_SUCCESS) \ { \ AssertRC(rcLock); \ TMTimerUnlock((a_pThis)->pTimer[a_SD]); \ return rcLock; \ } \ } while (0) /** * Releases the HDA lock and TM lock. */ #define DEVHDA_UNLOCK_BOTH(a_pThis, a_SD) \ do { \ PDMCritSectLeave(&(a_pThis)->CritSect); \ TMTimerUnlock((a_pThis)->pTimer[a_SD]); \ } while (0) /********************************************************************************************************************************* * Structures and Typedefs * *********************************************************************************************************************************/ /** * Structure defining a (host backend) driver stream. * Each driver has its own instances of audio mixer streams, which then * can go into the same (or even different) audio mixer sinks. */ typedef struct HDADRIVERSTREAM { union { /** Desired playback destination (for an output stream). */ PDMAUDIOPLAYBACKDEST Dest; /** Desired recording source (for an input stream). */ PDMAUDIORECSOURCE Source; } DestSource; uint8_t Padding1[4]; /** Associated mixer handle. */ R3PTRTYPE(PAUDMIXSTREAM) pMixStrm; } HDADRIVERSTREAM, *PHDADRIVERSTREAM; #ifdef HDA_USE_DMA_ACCESS_HANDLER /** * Struct for keeping an HDA DMA access handler context. */ typedef struct HDADMAACCESSHANDLER { /** Node for storing this handler in our list in HDASTREAMSTATE. */ RTLISTNODER3 Node; /** Pointer to stream to which this access handler is assigned to. */ R3PTRTYPE(PHDASTREAM) pStream; /** Access handler type handle. */ PGMPHYSHANDLERTYPE hAccessHandlerType; /** First address this handler uses. */ RTGCPHYS GCPhysFirst; /** Last address this handler uses. */ RTGCPHYS GCPhysLast; /** Actual BDLE address to handle. */ RTGCPHYS BDLEAddr; /** Actual BDLE buffer size to handle. */ RTGCPHYS BDLESize; /** Whether the access handler has been registered or not. */ bool fRegistered; uint8_t Padding[3]; } HDADMAACCESSHANDLER, *PHDADMAACCESSHANDLER; #endif /** * Struct for maintaining a host backend driver. * This driver must be associated to one, and only one, * HDA codec. The HDA controller does the actual multiplexing * of HDA codec data to various host backend drivers then. * * This HDA device uses a timer in order to synchronize all * read/write accesses across all attached LUNs / backends. */ typedef struct HDADRIVER { /** Node for storing this driver in our device driver list of HDASTATE. */ RTLISTNODER3 Node; /** Pointer to HDA controller (state). */ R3PTRTYPE(PHDASTATE) pHDAState; /** Driver flags. */ PDMAUDIODRVFLAGS fFlags; uint8_t u32Padding0[2]; /** LUN to which this driver has been assigned. */ uint8_t uLUN; /** Whether this driver is in an attached state or not. */ bool fAttached; /** Pointer to attached driver base interface. */ R3PTRTYPE(PPDMIBASE) pDrvBase; /** Audio connector interface to the underlying host backend. */ R3PTRTYPE(PPDMIAUDIOCONNECTOR) pConnector; /** Mixer stream for line input. */ HDADRIVERSTREAM LineIn; #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN /** Mixer stream for mic input. */ HDADRIVERSTREAM MicIn; #endif /** Mixer stream for front output. */ HDADRIVERSTREAM Front; #ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND /** Mixer stream for center/LFE output. */ HDADRIVERSTREAM CenterLFE; /** Mixer stream for rear output. */ HDADRIVERSTREAM Rear; #endif } HDADRIVER; /********************************************************************************************************************************* * Internal Functions * *********************************************************************************************************************************/ #ifndef VBOX_DEVICE_STRUCT_TESTCASE #ifdef IN_RING3 static void hdaR3GCTLReset(PHDASTATE pThis); #endif /** @name Register read/write stubs. * @{ */ static int hdaRegReadUnimpl(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); static int hdaRegWriteUnimpl(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value); /** @} */ /** @name Global register set read/write functions. * @{ */ static int hdaRegWriteGCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegReadLPIB(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); static int hdaRegReadWALCLK(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); static int hdaRegWriteCORBWP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteCORBRP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteCORBCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteCORBSIZE(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteCORBSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteRINTCNT(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value); static int hdaRegWriteRIRBWP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteRIRBSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteSTATESTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteIRS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegReadIRS(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); static int hdaRegWriteBase(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); /** @} */ /** @name {IOB}SDn write functions. * @{ */ static int hdaRegWriteSDCBL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteSDCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteSDSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteSDLVI(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteSDFIFOW(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteSDFIFOS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteSDFMT(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegWriteSDBDPU(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); /** @} */ /** @name Generic register read/write functions. * @{ */ static int hdaRegReadU32(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); static int hdaRegWriteU32(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegReadU24(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); #ifdef IN_RING3 static int hdaRegWriteU24(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); #endif static int hdaRegReadU16(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); static int hdaRegWriteU16(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); static int hdaRegReadU8(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value); static int hdaRegWriteU8(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value); /** @} */ /** @name HDA device functions. * @{ */ #ifdef IN_RING3 static int hdaR3AddStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg); static int hdaR3RemoveStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg); static int hdaR3UpdateStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg); # ifdef HDA_USE_DMA_ACCESS_HANDLER static DECLCALLBACK(VBOXSTRICTRC) hdaR3DMAAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser); # endif #endif /* IN_RING3 */ /** @} */ /********************************************************************************************************************************* * Global Variables * *********************************************************************************************************************************/ /** No register description (RD) flags defined. */ #define HDA_RD_FLAG_NONE 0 /** Writes to SD are allowed while RUN bit is set. */ #define HDA_RD_FLAG_SD_WRITE_RUN RT_BIT(0) /** Emits a single audio stream register set (e.g. OSD0) at a specified offset. */ #define HDA_REG_MAP_STRM(offset, name) \ /* offset size read mask write mask flags read callback write callback index + abbrev description */ \ /* ------- ------- ---------- ---------- ------------------------- -------------- ----------------- ----------------------------- ----------- */ \ /* Offset 0x80 (SD0) */ \ { offset, 0x00003, 0x00FF001F, 0x00F0001F, HDA_RD_FLAG_SD_WRITE_RUN, hdaRegReadU24 , hdaRegWriteSDCTL , HDA_REG_IDX_STRM(name, CTL) , #name " Stream Descriptor Control" }, \ /* Offset 0x83 (SD0) */ \ { offset + 0x3, 0x00001, 0x0000003C, 0x0000001C, HDA_RD_FLAG_SD_WRITE_RUN, hdaRegReadU8 , hdaRegWriteSDSTS , HDA_REG_IDX_STRM(name, STS) , #name " Status" }, \ /* Offset 0x84 (SD0) */ \ { offset + 0x4, 0x00004, 0xFFFFFFFF, 0x00000000, HDA_RD_FLAG_NONE, hdaRegReadLPIB, hdaRegWriteU32 , HDA_REG_IDX_STRM(name, LPIB) , #name " Link Position In Buffer" }, \ /* Offset 0x88 (SD0) */ \ { offset + 0x8, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteSDCBL , HDA_REG_IDX_STRM(name, CBL) , #name " Cyclic Buffer Length" }, \ /* Offset 0x8C (SD0) */ \ { offset + 0xC, 0x00002, 0x0000FFFF, 0x0000FFFF, HDA_RD_FLAG_NONE, hdaRegReadU16 , hdaRegWriteSDLVI , HDA_REG_IDX_STRM(name, LVI) , #name " Last Valid Index" }, \ /* Reserved: FIFO Watermark. ** @todo Document this! */ \ { offset + 0xE, 0x00002, 0x00000007, 0x00000007, HDA_RD_FLAG_NONE, hdaRegReadU16 , hdaRegWriteSDFIFOW, HDA_REG_IDX_STRM(name, FIFOW), #name " FIFO Watermark" }, \ /* Offset 0x90 (SD0) */ \ { offset + 0x10, 0x00002, 0x000000FF, 0x000000FF, HDA_RD_FLAG_NONE, hdaRegReadU16 , hdaRegWriteSDFIFOS, HDA_REG_IDX_STRM(name, FIFOS), #name " FIFO Size" }, \ /* Offset 0x92 (SD0) */ \ { offset + 0x12, 0x00002, 0x00007F7F, 0x00007F7F, HDA_RD_FLAG_NONE, hdaRegReadU16 , hdaRegWriteSDFMT , HDA_REG_IDX_STRM(name, FMT) , #name " Stream Format" }, \ /* Reserved: 0x94 - 0x98. */ \ /* Offset 0x98 (SD0) */ \ { offset + 0x18, 0x00004, 0xFFFFFF80, 0xFFFFFF80, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteSDBDPL , HDA_REG_IDX_STRM(name, BDPL) , #name " Buffer Descriptor List Pointer-Lower Base Address" }, \ /* Offset 0x9C (SD0) */ \ { offset + 0x1C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteSDBDPU , HDA_REG_IDX_STRM(name, BDPU) , #name " Buffer Descriptor List Pointer-Upper Base Address" } /** Defines a single audio stream register set (e.g. OSD0). */ #define HDA_REG_MAP_DEF_STREAM(index, name) \ HDA_REG_MAP_STRM(HDA_REG_DESC_SD0_BASE + (index * 32 /* 0x20 */), name) /* See 302349 p 6.2. */ const HDAREGDESC g_aHdaRegMap[HDA_NUM_REGS] = { /* offset size read mask write mask flags read callback write callback index + abbrev */ /*------- ------- ---------- ---------- ----------------- ---------------- ------------------- ------------------------ */ { 0x00000, 0x00002, 0x0000FFFB, 0x00000000, HDA_RD_FLAG_NONE, hdaRegReadU16 , hdaRegWriteUnimpl , HDA_REG_IDX(GCAP) }, /* Global Capabilities */ { 0x00002, 0x00001, 0x000000FF, 0x00000000, HDA_RD_FLAG_NONE, hdaRegReadU8 , hdaRegWriteUnimpl , HDA_REG_IDX(VMIN) }, /* Minor Version */ { 0x00003, 0x00001, 0x000000FF, 0x00000000, HDA_RD_FLAG_NONE, hdaRegReadU8 , hdaRegWriteUnimpl , HDA_REG_IDX(VMAJ) }, /* Major Version */ { 0x00004, 0x00002, 0x0000FFFF, 0x00000000, HDA_RD_FLAG_NONE, hdaRegReadU16 , hdaRegWriteU16 , HDA_REG_IDX(OUTPAY) }, /* Output Payload Capabilities */ { 0x00006, 0x00002, 0x0000FFFF, 0x00000000, HDA_RD_FLAG_NONE, hdaRegReadU16 , hdaRegWriteUnimpl , HDA_REG_IDX(INPAY) }, /* Input Payload Capabilities */ { 0x00008, 0x00004, 0x00000103, 0x00000103, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteGCTL , HDA_REG_IDX(GCTL) }, /* Global Control */ { 0x0000c, 0x00002, 0x00007FFF, 0x00007FFF, HDA_RD_FLAG_NONE, hdaRegReadU16 , hdaRegWriteU16 , HDA_REG_IDX(WAKEEN) }, /* Wake Enable */ { 0x0000e, 0x00002, 0x00000007, 0x00000007, HDA_RD_FLAG_NONE, hdaRegReadU8 , hdaRegWriteSTATESTS, HDA_REG_IDX(STATESTS) }, /* State Change Status */ { 0x00010, 0x00002, 0xFFFFFFFF, 0x00000000, HDA_RD_FLAG_NONE, hdaRegReadUnimpl, hdaRegWriteUnimpl , HDA_REG_IDX(GSTS) }, /* Global Status */ { 0x00018, 0x00002, 0x0000FFFF, 0x00000000, HDA_RD_FLAG_NONE, hdaRegReadU16 , hdaRegWriteU16 , HDA_REG_IDX(OUTSTRMPAY) }, /* Output Stream Payload Capability */ { 0x0001A, 0x00002, 0x0000FFFF, 0x00000000, HDA_RD_FLAG_NONE, hdaRegReadU16 , hdaRegWriteUnimpl , HDA_REG_IDX(INSTRMPAY) }, /* Input Stream Payload Capability */ { 0x00020, 0x00004, 0xC00000FF, 0xC00000FF, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteU32 , HDA_REG_IDX(INTCTL) }, /* Interrupt Control */ { 0x00024, 0x00004, 0xC00000FF, 0x00000000, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteUnimpl , HDA_REG_IDX(INTSTS) }, /* Interrupt Status */ { 0x00030, 0x00004, 0xFFFFFFFF, 0x00000000, HDA_RD_FLAG_NONE, hdaRegReadWALCLK, hdaRegWriteUnimpl , HDA_REG_IDX_NOMEM(WALCLK) }, /* Wall Clock Counter */ { 0x00034, 0x00004, 0x000000FF, 0x000000FF, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteU32 , HDA_REG_IDX(SSYNC) }, /* Stream Synchronization */ { 0x00040, 0x00004, 0xFFFFFF80, 0xFFFFFF80, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteBase , HDA_REG_IDX(CORBLBASE) }, /* CORB Lower Base Address */ { 0x00044, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteBase , HDA_REG_IDX(CORBUBASE) }, /* CORB Upper Base Address */ { 0x00048, 0x00002, 0x000000FF, 0x000000FF, HDA_RD_FLAG_NONE, hdaRegReadU16 , hdaRegWriteCORBWP , HDA_REG_IDX(CORBWP) }, /* CORB Write Pointer */ { 0x0004A, 0x00002, 0x000080FF, 0x00008000, HDA_RD_FLAG_NONE, hdaRegReadU16 , hdaRegWriteCORBRP , HDA_REG_IDX(CORBRP) }, /* CORB Read Pointer */ { 0x0004C, 0x00001, 0x00000003, 0x00000003, HDA_RD_FLAG_NONE, hdaRegReadU8 , hdaRegWriteCORBCTL , HDA_REG_IDX(CORBCTL) }, /* CORB Control */ { 0x0004D, 0x00001, 0x00000001, 0x00000001, HDA_RD_FLAG_NONE, hdaRegReadU8 , hdaRegWriteCORBSTS , HDA_REG_IDX(CORBSTS) }, /* CORB Status */ { 0x0004E, 0x00001, 0x000000F3, 0x00000003, HDA_RD_FLAG_NONE, hdaRegReadU8 , hdaRegWriteCORBSIZE, HDA_REG_IDX(CORBSIZE) }, /* CORB Size */ { 0x00050, 0x00004, 0xFFFFFF80, 0xFFFFFF80, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteBase , HDA_REG_IDX(RIRBLBASE) }, /* RIRB Lower Base Address */ { 0x00054, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteBase , HDA_REG_IDX(RIRBUBASE) }, /* RIRB Upper Base Address */ { 0x00058, 0x00002, 0x000000FF, 0x00008000, HDA_RD_FLAG_NONE, hdaRegReadU8 , hdaRegWriteRIRBWP , HDA_REG_IDX(RIRBWP) }, /* RIRB Write Pointer */ { 0x0005A, 0x00002, 0x000000FF, 0x000000FF, HDA_RD_FLAG_NONE, hdaRegReadU16 , hdaRegWriteRINTCNT , HDA_REG_IDX(RINTCNT) }, /* Response Interrupt Count */ { 0x0005C, 0x00001, 0x00000007, 0x00000007, HDA_RD_FLAG_NONE, hdaRegReadU8 , hdaRegWriteU8 , HDA_REG_IDX(RIRBCTL) }, /* RIRB Control */ { 0x0005D, 0x00001, 0x00000005, 0x00000005, HDA_RD_FLAG_NONE, hdaRegReadU8 , hdaRegWriteRIRBSTS , HDA_REG_IDX(RIRBSTS) }, /* RIRB Status */ { 0x0005E, 0x00001, 0x000000F3, 0x00000000, HDA_RD_FLAG_NONE, hdaRegReadU8 , hdaRegWriteUnimpl , HDA_REG_IDX(RIRBSIZE) }, /* RIRB Size */ { 0x00060, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteU32 , HDA_REG_IDX(IC) }, /* Immediate Command */ { 0x00064, 0x00004, 0x00000000, 0xFFFFFFFF, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteUnimpl , HDA_REG_IDX(IR) }, /* Immediate Response */ { 0x00068, 0x00002, 0x00000002, 0x00000002, HDA_RD_FLAG_NONE, hdaRegReadIRS , hdaRegWriteIRS , HDA_REG_IDX(IRS) }, /* Immediate Command Status */ { 0x00070, 0x00004, 0xFFFFFFFF, 0xFFFFFF81, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteBase , HDA_REG_IDX(DPLBASE) }, /* DMA Position Lower Base */ { 0x00074, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, HDA_RD_FLAG_NONE, hdaRegReadU32 , hdaRegWriteBase , HDA_REG_IDX(DPUBASE) }, /* DMA Position Upper Base */ /* 4 Serial Data In (SDI). */ HDA_REG_MAP_DEF_STREAM(0, SD0), HDA_REG_MAP_DEF_STREAM(1, SD1), HDA_REG_MAP_DEF_STREAM(2, SD2), HDA_REG_MAP_DEF_STREAM(3, SD3), /* 4 Serial Data Out (SDO). */ HDA_REG_MAP_DEF_STREAM(4, SD4), HDA_REG_MAP_DEF_STREAM(5, SD5), HDA_REG_MAP_DEF_STREAM(6, SD6), HDA_REG_MAP_DEF_STREAM(7, SD7) }; const HDAREGALIAS g_aHdaRegAliases[] = { { 0x2084, HDA_REG_SD0LPIB }, { 0x20a4, HDA_REG_SD1LPIB }, { 0x20c4, HDA_REG_SD2LPIB }, { 0x20e4, HDA_REG_SD3LPIB }, { 0x2104, HDA_REG_SD4LPIB }, { 0x2124, HDA_REG_SD5LPIB }, { 0x2144, HDA_REG_SD6LPIB }, { 0x2164, HDA_REG_SD7LPIB } }; #ifdef IN_RING3 /** HDABDLEDESC field descriptors for the v7 saved state. */ static SSMFIELD const g_aSSMBDLEDescFields7[] = { SSMFIELD_ENTRY(HDABDLEDESC, u64BufAdr), SSMFIELD_ENTRY(HDABDLEDESC, u32BufSize), SSMFIELD_ENTRY(HDABDLEDESC, fFlags), SSMFIELD_ENTRY_TERM() }; /** HDABDLESTATE field descriptors for the v6+ saved state. */ static SSMFIELD const g_aSSMBDLEStateFields6[] = { SSMFIELD_ENTRY(HDABDLESTATE, u32BDLIndex), SSMFIELD_ENTRY(HDABDLESTATE, cbBelowFIFOW), SSMFIELD_ENTRY_OLD(FIFO, HDA_FIFO_MAX), /* Deprecated; now is handled in the stream's circular buffer. */ SSMFIELD_ENTRY(HDABDLESTATE, u32BufOff), SSMFIELD_ENTRY_TERM() }; /** HDABDLESTATE field descriptors for the v7 saved state. */ static SSMFIELD const g_aSSMBDLEStateFields7[] = { SSMFIELD_ENTRY(HDABDLESTATE, u32BDLIndex), SSMFIELD_ENTRY(HDABDLESTATE, cbBelowFIFOW), SSMFIELD_ENTRY(HDABDLESTATE, u32BufOff), SSMFIELD_ENTRY_TERM() }; /** HDASTREAMSTATE field descriptors for the v6 saved state. */ static SSMFIELD const g_aSSMStreamStateFields6[] = { SSMFIELD_ENTRY_OLD(cBDLE, sizeof(uint16_t)), /* Deprecated. */ SSMFIELD_ENTRY(HDASTREAMSTATE, uCurBDLE), SSMFIELD_ENTRY_OLD(fStop, 1), /* Deprecated; see SSMR3PutBool(). */ SSMFIELD_ENTRY_OLD(fRunning, 1), /* Deprecated; using the HDA_SDCTL_RUN bit is sufficient. */ SSMFIELD_ENTRY(HDASTREAMSTATE, fInReset), SSMFIELD_ENTRY_TERM() }; /** HDASTREAMSTATE field descriptors for the v7 saved state. */ static SSMFIELD const g_aSSMStreamStateFields7[] = { SSMFIELD_ENTRY(HDASTREAMSTATE, uCurBDLE), SSMFIELD_ENTRY(HDASTREAMSTATE, fInReset), SSMFIELD_ENTRY(HDASTREAMSTATE, tsTransferNext), SSMFIELD_ENTRY_TERM() }; /** HDASTREAMPERIOD field descriptors for the v7 saved state. */ static SSMFIELD const g_aSSMStreamPeriodFields7[] = { SSMFIELD_ENTRY(HDASTREAMPERIOD, u64StartWalClk), SSMFIELD_ENTRY(HDASTREAMPERIOD, u64ElapsedWalClk), SSMFIELD_ENTRY(HDASTREAMPERIOD, framesTransferred), SSMFIELD_ENTRY(HDASTREAMPERIOD, cIntPending), SSMFIELD_ENTRY_TERM() }; /** * 32-bit size indexed masks, i.e. g_afMasks[2 bytes] = 0xffff. */ static uint32_t const g_afMasks[5] = { UINT32_C(0), UINT32_C(0x000000ff), UINT32_C(0x0000ffff), UINT32_C(0x00ffffff), UINT32_C(0xffffffff) }; #endif /* IN_RING3 */ /** * Retrieves the number of bytes of a FIFOW register. * * @return Number of bytes of a given FIFOW register. */ DECLINLINE(uint8_t) hdaSDFIFOWToBytes(uint32_t u32RegFIFOW) { uint32_t cb; switch (u32RegFIFOW) { case HDA_SDFIFOW_8B: cb = 8; break; case HDA_SDFIFOW_16B: cb = 16; break; case HDA_SDFIFOW_32B: cb = 32; break; default: cb = 0; break; } Assert(RT_IS_POWER_OF_TWO(cb)); return cb; } #ifdef IN_RING3 /** * Reschedules pending interrupts for all audio streams which have complete * audio periods but did not have the chance to issue their (pending) interrupts yet. * * @param pThis The HDA device state. */ static void hdaR3ReschedulePendingInterrupts(PHDASTATE pThis) { bool fInterrupt = false; for (uint8_t i = 0; i < HDA_MAX_STREAMS; ++i) { PHDASTREAM pStream = hdaGetStreamFromSD(pThis, i); if (!pStream) continue; if ( hdaR3StreamPeriodIsComplete (&pStream->State.Period) && hdaR3StreamPeriodNeedsInterrupt(&pStream->State.Period) && hdaR3WalClkSet(pThis, hdaR3StreamPeriodGetAbsElapsedWalClk(&pStream->State.Period), false /* fForce */)) { fInterrupt = true; break; } } LogFunc(("fInterrupt=%RTbool\n", fInterrupt)); # ifndef LOG_ENABLED hdaProcessInterrupt(pThis); # else hdaProcessInterrupt(pThis, __FUNCTION__); # endif } #endif /* IN_RING3 */ /** * Looks up a register at the exact offset given by @a offReg. * * @returns Register index on success, -1 if not found. * @param offReg The register offset. */ static int hdaRegLookup(uint32_t offReg) { /* * Aliases. */ if (offReg >= g_aHdaRegAliases[0].offReg) { for (unsigned i = 0; i < RT_ELEMENTS(g_aHdaRegAliases); i++) if (offReg == g_aHdaRegAliases[i].offReg) return g_aHdaRegAliases[i].idxAlias; Assert(g_aHdaRegMap[RT_ELEMENTS(g_aHdaRegMap) - 1].offset < offReg); return -1; } /* * Binary search the */ int idxEnd = RT_ELEMENTS(g_aHdaRegMap); int idxLow = 0; for (;;) { int idxMiddle = idxLow + (idxEnd - idxLow) / 2; if (offReg < g_aHdaRegMap[idxMiddle].offset) { if (idxLow == idxMiddle) break; idxEnd = idxMiddle; } else if (offReg > g_aHdaRegMap[idxMiddle].offset) { idxLow = idxMiddle + 1; if (idxLow >= idxEnd) break; } else return idxMiddle; } #ifdef RT_STRICT for (unsigned i = 0; i < RT_ELEMENTS(g_aHdaRegMap); i++) Assert(g_aHdaRegMap[i].offset != offReg); #endif return -1; } #ifdef IN_RING3 /** * Looks up a register covering the offset given by @a offReg. * * @returns Register index on success, -1 if not found. * @param offReg The register offset. */ static int hdaR3RegLookupWithin(uint32_t offReg) { /* * Aliases. */ if (offReg >= g_aHdaRegAliases[0].offReg) { for (unsigned i = 0; i < RT_ELEMENTS(g_aHdaRegAliases); i++) { uint32_t off = offReg - g_aHdaRegAliases[i].offReg; if (off < 4 && off < g_aHdaRegMap[g_aHdaRegAliases[i].idxAlias].size) return g_aHdaRegAliases[i].idxAlias; } Assert(g_aHdaRegMap[RT_ELEMENTS(g_aHdaRegMap) - 1].offset < offReg); return -1; } /* * Binary search the register map. */ int idxEnd = RT_ELEMENTS(g_aHdaRegMap); int idxLow = 0; for (;;) { int idxMiddle = idxLow + (idxEnd - idxLow) / 2; if (offReg < g_aHdaRegMap[idxMiddle].offset) { if (idxLow == idxMiddle) break; idxEnd = idxMiddle; } else if (offReg >= g_aHdaRegMap[idxMiddle].offset + g_aHdaRegMap[idxMiddle].size) { idxLow = idxMiddle + 1; if (idxLow >= idxEnd) break; } else return idxMiddle; } # ifdef RT_STRICT for (unsigned i = 0; i < RT_ELEMENTS(g_aHdaRegMap); i++) Assert(offReg - g_aHdaRegMap[i].offset >= g_aHdaRegMap[i].size); # endif return -1; } /** * Synchronizes the CORB / RIRB buffers between internal <-> device state. * * @returns IPRT status code. * @param pThis HDA state. * @param fLocal Specify true to synchronize HDA state's CORB buffer with the device state, * or false to synchronize the device state's RIRB buffer with the HDA state. * * @todo r=andy Break this up into two functions? */ static int hdaR3CmdSync(PHDASTATE pThis, bool fLocal) { int rc = VINF_SUCCESS; if (fLocal) { if (pThis->u64CORBBase) { AssertPtr(pThis->pu32CorbBuf); Assert(pThis->cbCorbBuf); /** @todo r=bird: An explanation is required why PDMDevHlpPhysRead is used with * the CORB and PDMDevHlpPCIPhysWrite with RIRB below. There are * similar unexplained inconsistencies in DevHDACommon.cpp. */ rc = PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), pThis->u64CORBBase, pThis->pu32CorbBuf, pThis->cbCorbBuf); Log(("hdaR3CmdSync/CORB: read %RGp LB %#x (%Rrc)\n", pThis->u64CORBBase, pThis->cbCorbBuf, rc)); AssertRCReturn(rc, rc); } } else { if (pThis->u64RIRBBase) { AssertPtr(pThis->pu64RirbBuf); Assert(pThis->cbRirbBuf); rc = PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), pThis->u64RIRBBase, pThis->pu64RirbBuf, pThis->cbRirbBuf); Log(("hdaR3CmdSync/RIRB: phys read %RGp LB %#x (%Rrc)\n", pThis->u64RIRBBase, pThis->pu64RirbBuf, rc)); AssertRCReturn(rc, rc); } } # ifdef DEBUG_CMD_BUFFER LogFunc(("fLocal=%RTbool\n", fLocal)); uint8_t i = 0; do { LogFunc(("CORB%02x: ", i)); uint8_t j = 0; do { const char *pszPrefix; if ((i + j) == HDA_REG(pThis, CORBRP)) pszPrefix = "[R]"; else if ((i + j) == HDA_REG(pThis, CORBWP)) pszPrefix = "[W]"; else pszPrefix = " "; /* three spaces */ Log((" %s%08x", pszPrefix, pThis->pu32CorbBuf[i + j])); j++; } while (j < 8); Log(("\n")); i += 8; } while(i != 0); do { LogFunc(("RIRB%02x: ", i)); uint8_t j = 0; do { const char *prefix; if ((i + j) == HDA_REG(pThis, RIRBWP)) prefix = "[W]"; else prefix = " "; Log((" %s%016lx", prefix, pThis->pu64RirbBuf[i + j])); } while (++j < 8); Log(("\n")); i += 8; } while (i != 0); # endif return rc; } /** * Processes the next CORB buffer command in the queue. * * This will invoke the HDA codec verb dispatcher. * * @returns IPRT status code. * @param pThis HDA state. */ static int hdaR3CORBCmdProcess(PHDASTATE pThis) { uint8_t corbRp = HDA_REG(pThis, CORBRP); uint8_t corbWp = HDA_REG(pThis, CORBWP); uint8_t rirbWp = HDA_REG(pThis, RIRBWP); Log3Func(("CORB(RP:%x, WP:%x) RIRBWP:%x\n", corbRp, corbWp, rirbWp)); if (!(HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA)) { LogFunc(("CORB DMA not active, skipping\n")); return VINF_SUCCESS; } Assert(pThis->cbCorbBuf); int rc = hdaR3CmdSync(pThis, true /* Sync from guest */); AssertRCReturn(rc, rc); uint16_t cIntCnt = HDA_REG(pThis, RINTCNT) & 0xff; if (!cIntCnt) /* 0 means 256 interrupts. */ cIntCnt = HDA_MAX_RINTCNT; Log3Func(("START CORB(RP:%x, WP:%x) RIRBWP:%x, RINTCNT:%RU8/%RU8\n", corbRp, corbWp, rirbWp, pThis->u16RespIntCnt, cIntCnt)); while (corbRp != corbWp) { corbRp = (corbRp + 1) % (pThis->cbCorbBuf / HDA_CORB_ELEMENT_SIZE); /* Advance +1 as the first command(s) are at CORBWP + 1. */ uint32_t uCmd = pThis->pu32CorbBuf[corbRp]; uint64_t uResp = 0; rc = pThis->pCodec->pfnLookup(pThis->pCodec, HDA_CODEC_CMD(uCmd, 0 /* Codec index */), &uResp); if (RT_FAILURE(rc)) LogFunc(("Codec lookup failed with rc=%Rrc\n", rc)); Log3Func(("Codec verb %08x -> response %016lx\n", uCmd, uResp)); if ( (uResp & CODEC_RESPONSE_UNSOLICITED) && !(HDA_REG(pThis, GCTL) & HDA_GCTL_UNSOL)) { LogFunc(("Unexpected unsolicited response.\n")); HDA_REG(pThis, CORBRP) = corbRp; /** @todo r=andy No CORB/RIRB syncing to guest required in that case? */ return rc; } rirbWp = (rirbWp + 1) % HDA_RIRB_SIZE; pThis->pu64RirbBuf[rirbWp] = uResp; pThis->u16RespIntCnt++; bool fSendInterrupt = false; if (pThis->u16RespIntCnt == cIntCnt) /* Response interrupt count reached? */ { pThis->u16RespIntCnt = 0; /* Reset internal interrupt response counter. */ Log3Func(("Response interrupt count reached (%RU16)\n", pThis->u16RespIntCnt)); fSendInterrupt = true; } else if (corbRp == corbWp) /* Did we reach the end of the current command buffer? */ { Log3Func(("Command buffer empty\n")); fSendInterrupt = true; } if (fSendInterrupt) { if (HDA_REG(pThis, RIRBCTL) & HDA_RIRBCTL_RINTCTL) /* Response Interrupt Control (RINTCTL) enabled? */ { HDA_REG(pThis, RIRBSTS) |= HDA_RIRBSTS_RINTFL; # ifndef LOG_ENABLED rc = hdaProcessInterrupt(pThis); # else rc = hdaProcessInterrupt(pThis, __FUNCTION__); # endif } } } Log3Func(("END CORB(RP:%x, WP:%x) RIRBWP:%x, RINTCNT:%RU8/%RU8\n", corbRp, corbWp, rirbWp, pThis->u16RespIntCnt, cIntCnt)); HDA_REG(pThis, CORBRP) = corbRp; HDA_REG(pThis, RIRBWP) = rirbWp; rc = hdaR3CmdSync(pThis, false /* Sync to guest */); AssertRCReturn(rc, rc); if (RT_FAILURE(rc)) AssertRCReturn(rc, rc); return rc; } #endif /* IN_RING3 */ /* Register access handlers. */ static int hdaRegReadUnimpl(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) { RT_NOREF_PV(pThis); RT_NOREF_PV(iReg); *pu32Value = 0; return VINF_SUCCESS; } static int hdaRegWriteUnimpl(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { RT_NOREF_PV(pThis); RT_NOREF_PV(iReg); RT_NOREF_PV(u32Value); return VINF_SUCCESS; } /* U8 */ static int hdaRegReadU8(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) { Assert(((pThis->au32Regs[g_aHdaRegMap[iReg].mem_idx] & g_aHdaRegMap[iReg].readable) & 0xffffff00) == 0); return hdaRegReadU32(pThis, iReg, pu32Value); } static int hdaRegWriteU8(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { Assert((u32Value & 0xffffff00) == 0); return hdaRegWriteU32(pThis, iReg, u32Value); } /* U16 */ static int hdaRegReadU16(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) { Assert(((pThis->au32Regs[g_aHdaRegMap[iReg].mem_idx] & g_aHdaRegMap[iReg].readable) & 0xffff0000) == 0); return hdaRegReadU32(pThis, iReg, pu32Value); } static int hdaRegWriteU16(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { Assert((u32Value & 0xffff0000) == 0); return hdaRegWriteU32(pThis, iReg, u32Value); } /* U24 */ static int hdaRegReadU24(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) { Assert(((pThis->au32Regs[g_aHdaRegMap[iReg].mem_idx] & g_aHdaRegMap[iReg].readable) & 0xff000000) == 0); return hdaRegReadU32(pThis, iReg, pu32Value); } #ifdef IN_RING3 static int hdaRegWriteU24(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { Assert((u32Value & 0xff000000) == 0); return hdaRegWriteU32(pThis, iReg, u32Value); } #endif /* U32 */ static int hdaRegReadU32(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) { uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx; DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_READ); *pu32Value = pThis->au32Regs[iRegMem] & g_aHdaRegMap[iReg].readable; DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } static int hdaRegWriteU32(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx; DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); pThis->au32Regs[iRegMem] = (u32Value & g_aHdaRegMap[iReg].writable) | (pThis->au32Regs[iRegMem] & ~g_aHdaRegMap[iReg].writable); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } static int hdaRegWriteGCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { RT_NOREF_PV(iReg); #ifdef IN_RING3 DEVHDA_LOCK(pThis); #else if (!(u32Value & HDA_GCTL_CRST)) return VINF_IOM_R3_MMIO_WRITE; DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); #endif if (u32Value & HDA_GCTL_CRST) { /* Set the CRST bit to indicate that we're leaving reset mode. */ HDA_REG(pThis, GCTL) |= HDA_GCTL_CRST; LogFunc(("Guest leaving HDA reset\n")); } else { #ifdef IN_RING3 /* Enter reset state. */ LogFunc(("Guest entering HDA reset with DMA(RIRB:%s, CORB:%s)\n", HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA ? "on" : "off", HDA_REG(pThis, RIRBCTL) & HDA_RIRBCTL_RDMAEN ? "on" : "off")); /* Clear the CRST bit to indicate that we're in reset state. */ HDA_REG(pThis, GCTL) &= ~HDA_GCTL_CRST; hdaR3GCTLReset(pThis); #else AssertFailedReturnStmt(DEVHDA_UNLOCK(pThis), VINF_IOM_R3_MMIO_WRITE); #endif } if (u32Value & HDA_GCTL_FCNTRL) { /* Flush: GSTS:1 set, see 6.2.6. */ HDA_REG(pThis, GSTS) |= HDA_GSTS_FSTS; /* Set the flush status. */ /* DPLBASE and DPUBASE should be initialized with initial value (see 6.2.6). */ } DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } static int hdaRegWriteSTATESTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); uint32_t v = HDA_REG_IND(pThis, iReg); uint32_t nv = u32Value & HDA_STATESTS_SCSF_MASK; HDA_REG(pThis, STATESTS) &= ~(v & nv); /* Write of 1 clears corresponding bit. */ DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } static int hdaRegReadLPIB(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) { DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_READ); const uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, LPIB, iReg); uint32_t u32LPIB = HDA_STREAM_REG(pThis, LPIB, uSD); #ifdef LOG_ENABLED const uint32_t u32CBL = HDA_STREAM_REG(pThis, CBL, uSD); LogFlowFunc(("[SD%RU8] LPIB=%RU32, CBL=%RU32\n", uSD, u32LPIB, u32CBL)); #endif *pu32Value = u32LPIB; DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } #ifdef IN_RING3 /** * Returns the current maximum value the wall clock counter can be set to. * This maximum value depends on all currently handled HDA streams and their own current timing. * * @return Current maximum value the wall clock counter can be set to. * @param pThis HDA state. * * @remark Does not actually set the wall clock counter. */ static uint64_t hdaR3WalClkGetMax(PHDASTATE pThis) { const uint64_t u64WalClkCur = ASMAtomicReadU64(&pThis->u64WalClk); const uint64_t u64FrontAbsWalClk = pThis->SinkFront.pStream ? hdaR3StreamPeriodGetAbsElapsedWalClk(&pThis->SinkFront.pStream->State.Period) : 0; # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND # error "Implement me!" # endif const uint64_t u64LineInAbsWalClk = pThis->SinkLineIn.pStream ? hdaR3StreamPeriodGetAbsElapsedWalClk(&pThis->SinkLineIn.pStream->State.Period) : 0; # ifdef VBOX_WITH_HDA_MIC_IN const uint64_t u64MicInAbsWalClk = pThis->SinkMicIn.pStream ? hdaR3StreamPeriodGetAbsElapsedWalClk(&pThis->SinkMicIn.pStream->State.Period) : 0; # endif uint64_t u64WalClkNew = RT_MAX(u64WalClkCur, u64FrontAbsWalClk); # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND # error "Implement me!" # endif u64WalClkNew = RT_MAX(u64WalClkNew, u64LineInAbsWalClk); # ifdef VBOX_WITH_HDA_MIC_IN u64WalClkNew = RT_MAX(u64WalClkNew, u64MicInAbsWalClk); # endif Log3Func(("%RU64 -> Front=%RU64, LineIn=%RU64 -> %RU64\n", u64WalClkCur, u64FrontAbsWalClk, u64LineInAbsWalClk, u64WalClkNew)); return u64WalClkNew; } #endif /* IN_RING3 */ static int hdaRegReadWALCLK(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) { #ifdef IN_RING3 RT_NOREF(iReg); DEVHDA_LOCK(pThis); *pu32Value = RT_LO_U32(ASMAtomicReadU64(&pThis->u64WalClk)); Log3Func(("%RU32 (max @ %RU64)\n",*pu32Value, hdaR3WalClkGetMax(pThis))); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; #else RT_NOREF(pThis, iReg, pu32Value); return VINF_IOM_R3_MMIO_READ; #endif } static int hdaRegWriteCORBRP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { RT_NOREF(iReg); DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); if (u32Value & HDA_CORBRP_RST) { /* Do a CORB reset. */ if (pThis->cbCorbBuf) { #ifdef IN_RING3 Assert(pThis->pu32CorbBuf); RT_BZERO((void *)pThis->pu32CorbBuf, pThis->cbCorbBuf); #else DEVHDA_UNLOCK(pThis); return VINF_IOM_R3_MMIO_WRITE; #endif } LogRel2(("HDA: CORB reset\n")); HDA_REG(pThis, CORBRP) = HDA_CORBRP_RST; /* Clears the pointer. */ } else HDA_REG(pThis, CORBRP) &= ~HDA_CORBRP_RST; /* Only CORBRP_RST bit is writable. */ DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } static int hdaRegWriteCORBCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { #ifdef IN_RING3 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); int rc = hdaRegWriteU8(pThis, iReg, u32Value); AssertRC(rc); if (HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA) /* Start DMA engine. */ { rc = hdaR3CORBCmdProcess(pThis); } else LogFunc(("CORB DMA not running, skipping\n")); DEVHDA_UNLOCK(pThis); return rc; #else RT_NOREF(pThis, iReg, u32Value); return VINF_IOM_R3_MMIO_WRITE; #endif } static int hdaRegWriteCORBSIZE(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { #ifdef IN_RING3 RT_NOREF(iReg); DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); if (HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA) /* Ignore request if CORB DMA engine is (still) running. */ { LogFunc(("CORB DMA is (still) running, skipping\n")); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } u32Value = (u32Value & HDA_CORBSIZE_SZ); uint16_t cEntries = HDA_CORB_SIZE; /* Set default. */ switch (u32Value) { case 0: /* 8 byte; 2 entries. */ cEntries = 2; break; case 1: /* 64 byte; 16 entries. */ cEntries = 16; break; case 2: /* 1 KB; 256 entries. */ /* Use default size. */ break; default: LogRel(("HDA: Guest tried to set an invalid CORB size (0x%x), keeping default\n", u32Value)); u32Value = 2; /* Use default size. */ break; } uint32_t cbCorbBuf = cEntries * HDA_CORB_ELEMENT_SIZE; Assert(cbCorbBuf <= HDA_CORB_SIZE * HDA_CORB_ELEMENT_SIZE); /* Paranoia. */ if (cbCorbBuf != pThis->cbCorbBuf) { RT_BZERO(pThis->pu32CorbBuf, HDA_CORB_SIZE * HDA_CORB_ELEMENT_SIZE); /* Clear CORB when setting a new size. */ pThis->cbCorbBuf = cbCorbBuf; } LogFunc(("CORB buffer size is now %RU32 bytes (%u entries)\n", pThis->cbCorbBuf, pThis->cbCorbBuf / HDA_CORB_ELEMENT_SIZE)); HDA_REG(pThis, CORBSIZE) = u32Value; DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; #else RT_NOREF(pThis, iReg, u32Value); return VINF_IOM_R3_MMIO_WRITE; #endif } static int hdaRegWriteCORBSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { RT_NOREF_PV(iReg); DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); uint32_t v = HDA_REG(pThis, CORBSTS); HDA_REG(pThis, CORBSTS) &= ~(v & u32Value); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } static int hdaRegWriteCORBWP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { #ifdef IN_RING3 DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); int rc = hdaRegWriteU16(pThis, iReg, u32Value); AssertRCSuccess(rc); rc = hdaR3CORBCmdProcess(pThis); DEVHDA_UNLOCK(pThis); return rc; #else RT_NOREF(pThis, iReg, u32Value); return VINF_IOM_R3_MMIO_WRITE; #endif } static int hdaRegWriteSDCBL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); PHDASTREAM pStream = hdaGetStreamFromSD(pThis, HDA_SD_NUM_FROM_REG(pThis, CBL, iReg)); if (pStream) { pStream->u32CBL = u32Value; LogFlowFunc(("[SD%RU8] CBL=%RU32\n", pStream->u8SD, u32Value)); } else LogFunc(("[SD%RU8] Warning: Changing SDCBL on non-attached stream (0x%x)\n", HDA_SD_NUM_FROM_REG(pThis, CTL, iReg), u32Value)); int rc = hdaRegWriteU32(pThis, iReg, u32Value); AssertRCSuccess(rc); DEVHDA_UNLOCK(pThis); return rc; } static int hdaRegWriteSDCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { #ifdef IN_RING3 /* Get the stream descriptor. */ const uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, CTL, iReg); DEVHDA_LOCK_BOTH_RETURN(pThis, uSD, VINF_IOM_R3_MMIO_WRITE); /* * Some guests write too much (that is, 32-bit with the top 8 bit being junk) * instead of 24-bit required for SDCTL. So just mask this here to be safe. */ u32Value &= 0x00ffffff; bool fRun = RT_BOOL(u32Value & HDA_SDCTL_RUN); bool fInRun = RT_BOOL(HDA_REG_IND(pThis, iReg) & HDA_SDCTL_RUN); bool fReset = RT_BOOL(u32Value & HDA_SDCTL_SRST); bool fInReset = RT_BOOL(HDA_REG_IND(pThis, iReg) & HDA_SDCTL_SRST); LogFunc(("[SD%RU8] fRun=%RTbool, fInRun=%RTbool, fReset=%RTbool, fInReset=%RTbool, %R[sdctl]\n", uSD, fRun, fInRun, fReset, fInReset, u32Value)); /* * Extract the stream tag the guest wants to use for this specific * stream descriptor (SDn). This only can happen if the stream is in a non-running * state, so we're doing the lookup and assignment here. * * So depending on the guest OS, SD3 can use stream tag 4, for example. */ uint8_t uTag = (u32Value >> HDA_SDCTL_NUM_SHIFT) & HDA_SDCTL_NUM_MASK; if (uTag > HDA_MAX_TAGS) { LogFunc(("[SD%RU8] Warning: Invalid stream tag %RU8 specified!\n", uSD, uTag)); int rc = hdaRegWriteU24(pThis, iReg, u32Value); DEVHDA_UNLOCK_BOTH(pThis, uSD); return rc; } PHDATAG pTag = &pThis->aTags[uTag]; AssertPtr(pTag); LogFunc(("[SD%RU8] Using stream tag=%RU8\n", uSD, uTag)); /* Assign new values. */ pTag->uTag = uTag; pTag->pStream = hdaGetStreamFromSD(pThis, uSD); PHDASTREAM pStream = pTag->pStream; AssertPtr(pStream); if (fInReset) { Assert(!fReset); Assert(!fInRun && !fRun); /* Exit reset state. */ ASMAtomicXchgBool(&pStream->State.fInReset, false); /* Report that we're done resetting this stream by clearing SRST. */ HDA_STREAM_REG(pThis, CTL, uSD) &= ~HDA_SDCTL_SRST; LogFunc(("[SD%RU8] Reset exit\n", uSD)); } else if (fReset) { /* ICH6 datasheet 18.2.33 says that RUN bit should be cleared before initiation of reset. */ Assert(!fInRun && !fRun); LogFunc(("[SD%RU8] Reset enter\n", uSD)); hdaR3StreamLock(pStream); # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO hdaR3StreamAsyncIOLock(pStream); hdaR3StreamAsyncIOEnable(pStream, false /* fEnable */); # endif /* Make sure to remove the run bit before doing the actual stream reset. */ HDA_STREAM_REG(pThis, CTL, uSD) &= ~HDA_SDCTL_RUN; hdaR3StreamReset(pThis, pStream, pStream->u8SD); # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO hdaR3StreamAsyncIOUnlock(pStream); # endif hdaR3StreamUnlock(pStream); } else { /* * We enter here to change DMA states only. */ if (fInRun != fRun) { Assert(!fReset && !fInReset); LogFunc(("[SD%RU8] State changed (fRun=%RTbool)\n", uSD, fRun)); hdaR3StreamLock(pStream); int rc2; # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO if (fRun) rc2 = hdaR3StreamAsyncIOCreate(pStream); hdaR3StreamAsyncIOLock(pStream); # endif if (fRun) { # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO hdaR3StreamAsyncIOEnable(pStream, fRun /* fEnable */); # endif /* (Re-)initialize the stream with current values. */ rc2 = hdaR3StreamInit(pStream, pStream->u8SD); AssertRC(rc2); /* Remove the old stream from the device setup. */ hdaR3RemoveStream(pThis, &pStream->State.Cfg); /* Add the stream to the device setup. */ rc2 = hdaR3AddStream(pThis, &pStream->State.Cfg); AssertRC(rc2); } /* Enable/disable the stream. */ rc2 = hdaR3StreamEnable(pStream, fRun /* fEnable */); AssertRC(rc2); if (fRun) { /* Keep track of running streams. */ pThis->cStreamsActive++; /* (Re-)init the stream's period. */ hdaR3StreamPeriodInit(&pStream->State.Period, pStream->u8SD, pStream->u16LVI, pStream->u32CBL, &pStream->State.Cfg); /* Begin a new period for this stream. */ rc2 = hdaR3StreamPeriodBegin(&pStream->State.Period, hdaWalClkGetCurrent(pThis)/* Use current wall clock time */); AssertRC(rc2); rc2 = hdaR3TimerSet(pThis, pStream, TMTimerGet(pThis->pTimer[pStream->u8SD]) + pStream->State.cTransferTicks, false /* fForce */); AssertRC(rc2); } else { /* Keep track of running streams. */ Assert(pThis->cStreamsActive); if (pThis->cStreamsActive) pThis->cStreamsActive--; /* Make sure to (re-)schedule outstanding (delayed) interrupts. */ hdaR3ReschedulePendingInterrupts(pThis); /* Reset the period. */ hdaR3StreamPeriodReset(&pStream->State.Period); } # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO hdaR3StreamAsyncIOUnlock(pStream); # endif /* Make sure to leave the lock before (eventually) starting the timer. */ hdaR3StreamUnlock(pStream); } } int rc2 = hdaRegWriteU24(pThis, iReg, u32Value); AssertRC(rc2); DEVHDA_UNLOCK_BOTH(pThis, uSD); return VINF_SUCCESS; /* Always return success to the MMIO handler. */ #else /* !IN_RING3 */ RT_NOREF_PV(pThis); RT_NOREF_PV(iReg); RT_NOREF_PV(u32Value); return VINF_IOM_R3_MMIO_WRITE; #endif /* IN_RING3 */ } static int hdaRegWriteSDSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { #ifdef IN_RING3 const uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, STS, iReg); DEVHDA_LOCK_BOTH_RETURN(pThis, uSD, VINF_IOM_R3_MMIO_WRITE); PHDASTREAM pStream = hdaGetStreamFromSD(pThis, uSD); if (!pStream) { AssertMsgFailed(("[SD%RU8] Warning: Writing SDSTS on non-attached stream (0x%x)\n", HDA_SD_NUM_FROM_REG(pThis, STS, iReg), u32Value)); int rc = hdaRegWriteU16(pThis, iReg, u32Value); DEVHDA_UNLOCK_BOTH(pThis, uSD); return rc; } hdaR3StreamLock(pStream); uint32_t v = HDA_REG_IND(pThis, iReg); /* Clear (zero) FIFOE, DESE and BCIS bits when writing 1 to it (6.2.33). */ HDA_REG_IND(pThis, iReg) &= ~(u32Value & v); /* Some guests tend to write SDnSTS even if the stream is not running. * So make sure to check if the RUN bit is set first. */ const bool fRunning = pStream->State.fRunning; Log3Func(("[SD%RU8] fRunning=%RTbool %R[sdsts]\n", pStream->u8SD, fRunning, v)); PHDASTREAMPERIOD pPeriod = &pStream->State.Period; if (hdaR3StreamPeriodLock(pPeriod)) { const bool fNeedsInterrupt = hdaR3StreamPeriodNeedsInterrupt(pPeriod); if (fNeedsInterrupt) hdaR3StreamPeriodReleaseInterrupt(pPeriod); if (hdaR3StreamPeriodIsComplete(pPeriod)) { /* Make sure to try to update the WALCLK register if a period is complete. * Use the maximum WALCLK value all (active) streams agree to. */ const uint64_t uWalClkMax = hdaR3WalClkGetMax(pThis); if (uWalClkMax > hdaWalClkGetCurrent(pThis)) hdaR3WalClkSet(pThis, uWalClkMax, false /* fForce */); hdaR3StreamPeriodEnd(pPeriod); if (fRunning) hdaR3StreamPeriodBegin(pPeriod, hdaWalClkGetCurrent(pThis) /* Use current wall clock time */); } hdaR3StreamPeriodUnlock(pPeriod); /* Unlock before processing interrupt. */ } # ifndef LOG_ENABLED hdaProcessInterrupt(pThis); # else hdaProcessInterrupt(pThis, __FUNCTION__); # endif const uint64_t tsNow = TMTimerGet(pThis->pTimer[uSD]); Assert(tsNow >= pStream->State.tsTransferLast); const uint64_t cTicksElapsed = tsNow - pStream->State.tsTransferLast; # ifdef LOG_ENABLED const uint64_t cTicksTransferred = pStream->State.cbTransferProcessed * pStream->State.cTicksPerByte; # endif uint64_t cTicksToNext = pStream->State.cTransferTicks; if (cTicksToNext) /* Only do any calculations if the stream currently is set up for transfers. */ { Log3Func(("[SD%RU8] cTicksElapsed=%RU64, cTicksTransferred=%RU64, cTicksToNext=%RU64\n", pStream->u8SD, cTicksElapsed, cTicksTransferred, cTicksToNext)); Log3Func(("[SD%RU8] cbTransferProcessed=%RU32, cbTransferChunk=%RU32, cbTransferSize=%RU32\n", pStream->u8SD, pStream->State.cbTransferProcessed, pStream->State.cbTransferChunk, pStream->State.cbTransferSize)); if (cTicksElapsed <= cTicksToNext) { cTicksToNext = cTicksToNext - cTicksElapsed; } else /* Catch up. */ { Log3Func(("[SD%RU8] Warning: Lagging behind (%RU64 ticks elapsed, maximum allowed is %RU64)\n", pStream->u8SD, cTicksElapsed, cTicksToNext)); LogRelMax2(64, ("HDA: Stream #%RU8 interrupt lagging behind (expected %uus, got %uus), trying to catch up ...\n", pStream->u8SD, (TMTimerGetFreq(pThis->pTimer[pStream->u8SD]) / pThis->u16TimerHz) / 1000,(tsNow - pStream->State.tsTransferLast) / 1000)); cTicksToNext = 0; } Log3Func(("[SD%RU8] -> cTicksToNext=%RU64\n", pStream->u8SD, cTicksToNext)); /* Reset processed data counter. */ pStream->State.cbTransferProcessed = 0; pStream->State.tsTransferNext = tsNow + cTicksToNext; /* Only re-arm the timer if there were pending transfer interrupts left * -- it could happen that we land in here if a guest writes to SDnSTS * unconditionally. */ if (pStream->State.cTransferPendingInterrupts) { pStream->State.cTransferPendingInterrupts--; /* Re-arm the timer. */ LogFunc(("Timer set SD%RU8\n", pStream->u8SD)); hdaR3TimerSet(pThis, pStream, tsNow + cTicksToNext, false /* fForce */); } } hdaR3StreamUnlock(pStream); DEVHDA_UNLOCK_BOTH(pThis, uSD); return VINF_SUCCESS; #else /* IN_RING3 */ RT_NOREF(pThis, iReg, u32Value); return VINF_IOM_R3_MMIO_WRITE; #endif /* !IN_RING3 */ } static int hdaRegWriteSDLVI(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); if (HDA_REG_IND(pThis, iReg) == u32Value) /* Value already set? */ { /* nothing to do */ } else { uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, LVI, iReg); PHDASTREAM pStream = hdaGetStreamFromSD(pThis, uSD); if (pStream) { /** @todo Validate LVI. */ pStream->u16LVI = u32Value; LogFunc(("[SD%RU8] Updating LVI to %RU16\n", uSD, pStream->u16LVI)); #ifdef HDA_USE_DMA_ACCESS_HANDLER if (hdaGetDirFromSD(uSD) == PDMAUDIODIR_OUT) { /* Try registering the DMA handlers. * As we can't be sure in which order LVI + BDL base are set, try registering in both routines. */ if (hdaR3StreamRegisterDMAHandlers(pThis, pStream)) LogFunc(("[SD%RU8] DMA logging enabled\n", pStream->u8SD)); } #endif } else AssertMsgFailed(("[SD%RU8] Warning: Changing SDLVI on non-attached stream (0x%x)\n", uSD, u32Value)); int rc2 = hdaRegWriteU16(pThis, iReg, u32Value); AssertRC(rc2); } DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; /* Always return success to the MMIO handler. */ } static int hdaRegWriteSDFIFOW(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, FIFOW, iReg); if (hdaGetDirFromSD(uSD) != PDMAUDIODIR_IN) /* FIFOW for input streams only. */ { #ifndef IN_RING0 LogRel(("HDA: Warning: Guest tried to write read-only FIFOW to output stream #%RU8, ignoring\n", uSD)); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; #else DEVHDA_UNLOCK(pThis); return VINF_IOM_R3_MMIO_WRITE; #endif } PHDASTREAM pStream = hdaGetStreamFromSD(pThis, HDA_SD_NUM_FROM_REG(pThis, FIFOW, iReg)); if (!pStream) { AssertMsgFailed(("[SD%RU8] Warning: Changing FIFOW on non-attached stream (0x%x)\n", uSD, u32Value)); int rc = hdaRegWriteU16(pThis, iReg, u32Value); DEVHDA_UNLOCK(pThis); return rc; } uint32_t u32FIFOW = 0; switch (u32Value) { case HDA_SDFIFOW_8B: case HDA_SDFIFOW_16B: case HDA_SDFIFOW_32B: u32FIFOW = u32Value; break; default: ASSERT_GUEST_LOGREL_MSG_FAILED(("Guest tried write unsupported FIFOW (0x%x) to stream #%RU8, defaulting to 32 bytes\n", u32Value, uSD)); u32FIFOW = HDA_SDFIFOW_32B; break; } if (u32FIFOW) { pStream->u16FIFOW = hdaSDFIFOWToBytes(u32FIFOW); LogFunc(("[SD%RU8] Updating FIFOW to %RU32 bytes\n", uSD, pStream->u16FIFOW)); int rc2 = hdaRegWriteU16(pThis, iReg, u32FIFOW); AssertRC(rc2); } DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; /* Always return success to the MMIO handler. */ } /** * @note This method could be called for changing value on Output Streams only (ICH6 datasheet 18.2.39). */ static int hdaRegWriteSDFIFOS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); uint8_t uSD = HDA_SD_NUM_FROM_REG(pThis, FIFOS, iReg); if (hdaGetDirFromSD(uSD) != PDMAUDIODIR_OUT) /* FIFOS for output streams only. */ { LogRel(("HDA: Warning: Guest tried to write read-only FIFOS to input stream #%RU8, ignoring\n", uSD)); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } PHDASTREAM pStream = hdaGetStreamFromSD(pThis, uSD); if (!pStream) { AssertMsgFailed(("[SD%RU8] Warning: Changing FIFOS on non-attached stream (0x%x)\n", uSD, u32Value)); int rc = hdaRegWriteU16(pThis, iReg, u32Value); DEVHDA_UNLOCK(pThis); return rc; } uint32_t u32FIFOS = 0; switch(u32Value) { case HDA_SDOFIFO_16B: case HDA_SDOFIFO_32B: case HDA_SDOFIFO_64B: case HDA_SDOFIFO_128B: case HDA_SDOFIFO_192B: case HDA_SDOFIFO_256B: u32FIFOS = u32Value; break; default: ASSERT_GUEST_LOGREL_MSG_FAILED(("Guest tried write unsupported FIFOS (0x%x) to stream #%RU8, defaulting to 192 bytes\n", u32Value, uSD)); u32FIFOS = HDA_SDOFIFO_192B; break; } if (u32FIFOS) { pStream->u16FIFOS = u32FIFOS + 1; LogFunc(("[SD%RU8] Updating FIFOS to %RU32 bytes\n", uSD, pStream->u16FIFOS)); int rc2 = hdaRegWriteU16(pThis, iReg, u32FIFOS); AssertRC(rc2); } DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; /* Always return success to the MMIO handler. */ } #ifdef IN_RING3 /** * Adds an audio output stream to the device setup using the given configuration. * * @returns IPRT status code. * @param pThis Device state. * @param pCfg Stream configuration to use for adding a stream. */ static int hdaR3AddStreamOut(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg) { AssertPtrReturn(pThis, VERR_INVALID_POINTER); AssertPtrReturn(pCfg, VERR_INVALID_POINTER); AssertReturn(pCfg->enmDir == PDMAUDIODIR_OUT, VERR_INVALID_PARAMETER); LogFlowFunc(("Stream=%s\n", pCfg->szName)); int rc = VINF_SUCCESS; bool fUseFront = true; /* Always use front out by default. */ # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND bool fUseRear; bool fUseCenter; bool fUseLFE; fUseRear = fUseCenter = fUseLFE = false; /* * Use commonly used setups for speaker configurations. */ /** @todo Make the following configurable through mixer API and/or CFGM? */ switch (pCfg->Props.cChannels) { case 3: /* 2.1: Front (Stereo) + LFE. */ { fUseLFE = true; break; } case 4: /* Quadrophonic: Front (Stereo) + Rear (Stereo). */ { fUseRear = true; break; } case 5: /* 4.1: Front (Stereo) + Rear (Stereo) + LFE. */ { fUseRear = true; fUseLFE = true; break; } case 6: /* 5.1: Front (Stereo) + Rear (Stereo) + Center/LFE. */ { fUseRear = true; fUseCenter = true; fUseLFE = true; break; } default: /* Unknown; fall back to 2 front channels (stereo). */ { rc = VERR_NOT_SUPPORTED; break; } } # else /* !VBOX_WITH_AUDIO_HDA_51_SURROUND */ /* Only support mono or stereo channels. */ if ( pCfg->Props.cChannels != 1 /* Mono */ && pCfg->Props.cChannels != 2 /* Stereo */) { rc = VERR_NOT_SUPPORTED; } # endif /* !VBOX_WITH_AUDIO_HDA_51_SURROUND */ if (rc == VERR_NOT_SUPPORTED) { LogRel2(("HDA: Warning: Unsupported channel count (%RU8), falling back to stereo channels (2)\n", pCfg->Props.cChannels)); /* Fall back to 2 channels (see below in fUseFront block). */ rc = VINF_SUCCESS; } do { if (RT_FAILURE(rc)) break; if (fUseFront) { RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Front"); pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT; pCfg->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; pCfg->Props.cChannels = 2; pCfg->Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels); rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_FRONT, pCfg); } # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND if ( RT_SUCCESS(rc) && (fUseCenter || fUseLFE)) { RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Center/LFE"); pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_CENTER_LFE; pCfg->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; pCfg->Props.cChannels = (fUseCenter && fUseLFE) ? 2 : 1; pCfg->Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels); rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_CENTER_LFE, pCfg); } if ( RT_SUCCESS(rc) && fUseRear) { RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Rear"); pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_REAR; pCfg->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; pCfg->Props.cChannels = 2; pCfg->Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels); rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_REAR, pCfg); } # endif /* VBOX_WITH_AUDIO_HDA_51_SURROUND */ } while (0); LogFlowFuncLeaveRC(rc); return rc; } /** * Adds an audio input stream to the device setup using the given configuration. * * @returns IPRT status code. * @param pThis Device state. * @param pCfg Stream configuration to use for adding a stream. */ static int hdaR3AddStreamIn(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg) { AssertPtrReturn(pThis, VERR_INVALID_POINTER); AssertPtrReturn(pCfg, VERR_INVALID_POINTER); AssertReturn(pCfg->enmDir == PDMAUDIODIR_IN, VERR_INVALID_PARAMETER); LogFlowFunc(("Stream=%s, Source=%ld\n", pCfg->szName, pCfg->DestSource.Source)); int rc; switch (pCfg->DestSource.Source) { case PDMAUDIORECSOURCE_LINE: { rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_LINE_IN, pCfg); break; } # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN case PDMAUDIORECSOURCE_MIC: { rc = hdaCodecAddStream(pThis->pCodec, PDMAUDIOMIXERCTL_MIC_IN, pCfg); break; } # endif default: rc = VERR_NOT_SUPPORTED; break; } LogFlowFuncLeaveRC(rc); return rc; } /** * Adds an audio stream to the device setup using the given configuration. * * @returns IPRT status code. * @param pThis Device state. * @param pCfg Stream configuration to use for adding a stream. */ static int hdaR3AddStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg) { AssertPtrReturn(pThis, VERR_INVALID_POINTER); AssertPtrReturn(pCfg, VERR_INVALID_POINTER); int rc; LogFlowFuncEnter(); switch (pCfg->enmDir) { case PDMAUDIODIR_OUT: rc = hdaR3AddStreamOut(pThis, pCfg); break; case PDMAUDIODIR_IN: rc = hdaR3AddStreamIn(pThis, pCfg); break; default: rc = VERR_NOT_SUPPORTED; AssertFailed(); break; } LogFlowFunc(("Returning %Rrc\n", rc)); return rc; } /** * Removes an audio stream from the device setup using the given configuration. * * @returns IPRT status code. * @param pThis Device state. * @param pCfg Stream configuration to use for removing a stream. */ static int hdaR3RemoveStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg) { AssertPtrReturn(pThis, VERR_INVALID_POINTER); AssertPtrReturn(pCfg, VERR_INVALID_POINTER); int rc = VINF_SUCCESS; PDMAUDIOMIXERCTL enmMixerCtl = PDMAUDIOMIXERCTL_UNKNOWN; switch (pCfg->enmDir) { case PDMAUDIODIR_IN: { LogFlowFunc(("Stream=%s, Source=%ld\n", pCfg->szName, pCfg->DestSource.Source)); switch (pCfg->DestSource.Source) { case PDMAUDIORECSOURCE_LINE: enmMixerCtl = PDMAUDIOMIXERCTL_LINE_IN; break; # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN case PDMAUDIORECSOURCE_MIC: enmMixerCtl = PDMAUDIOMIXERCTL_MIC_IN; break; # endif default: rc = VERR_NOT_SUPPORTED; break; } break; } case PDMAUDIODIR_OUT: { LogFlowFunc(("Stream=%s, Source=%ld\n", pCfg->szName, pCfg->DestSource.Dest)); switch (pCfg->DestSource.Dest) { case PDMAUDIOPLAYBACKDEST_FRONT: enmMixerCtl = PDMAUDIOMIXERCTL_FRONT; break; # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND case PDMAUDIOPLAYBACKDEST_CENTER_LFE: enmMixerCtl = PDMAUDIOMIXERCTL_CENTER_LFE; break; case PDMAUDIOPLAYBACKDEST_REAR: enmMixerCtl = PDMAUDIOMIXERCTL_REAR; break; # endif default: rc = VERR_NOT_SUPPORTED; break; } break; } default: rc = VERR_NOT_SUPPORTED; break; } if (RT_SUCCESS(rc)) rc = hdaCodecRemoveStream(pThis->pCodec, enmMixerCtl); LogFlowFuncLeaveRC(rc); return rc; } /** * Updates an audio device stream with the given configuration. * * @returns IPRT status code. * @param pThis HDA state. * @param pCfg Stream configuration to apply. */ static int hdaR3UpdateStream(PHDASTATE pThis, PPDMAUDIOSTREAMCFG pCfg) { /* Remove the old stream from the device setup. */ hdaR3RemoveStream(pThis, pCfg); /* Add the stream to the device setup. */ return hdaR3AddStream(pThis, pCfg); } #endif /* IN_RING3 */ static int hdaRegWriteSDFMT(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { DEVHDA_LOCK(pThis); # ifdef LOG_ENABLED if (!hdaGetStreamFromSD(pThis, HDA_SD_NUM_FROM_REG(pThis, FMT, iReg))) LogFunc(("[SD%RU8] Warning: Changing SDFMT on non-attached stream (0x%x)\n", HDA_SD_NUM_FROM_REG(pThis, FMT, iReg), u32Value)); # endif /* Write the wanted stream format into the register in any case. * * This is important for e.g. MacOS guests, as those try to initialize streams which are not reported * by the device emulation (wants 4 channels, only have 2 channels at the moment). * * When ignoring those (invalid) formats, this leads to MacOS thinking that the device is malfunctioning * and therefore disabling the device completely. */ int rc = hdaRegWriteU16(pThis, iReg, u32Value); AssertRC(rc); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; /* Never return failure. */ } /* Note: Will be called for both, BDPL and BDPU, registers. */ DECLINLINE(int) hdaRegWriteSDBDPX(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value, uint8_t uSD) { #ifdef IN_RING3 DEVHDA_LOCK(pThis); int rc2 = hdaRegWriteU32(pThis, iReg, u32Value); AssertRC(rc2); PHDASTREAM pStream = hdaGetStreamFromSD(pThis, uSD); if (!pStream) { DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } /* Update BDL base. */ pStream->u64BDLBase = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, uSD), HDA_STREAM_REG(pThis, BDPU, uSD)); # ifdef HDA_USE_DMA_ACCESS_HANDLER if (hdaGetDirFromSD(uSD) == PDMAUDIODIR_OUT) { /* Try registering the DMA handlers. * As we can't be sure in which order LVI + BDL base are set, try registering in both routines. */ if (hdaR3StreamRegisterDMAHandlers(pThis, pStream)) LogFunc(("[SD%RU8] DMA logging enabled\n", pStream->u8SD)); } # endif LogFlowFunc(("[SD%RU8] BDLBase=0x%x\n", pStream->u8SD, pStream->u64BDLBase)); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; /* Always return success to the MMIO handler. */ #else /* !IN_RING3 */ RT_NOREF_PV(pThis); RT_NOREF_PV(iReg); RT_NOREF_PV(u32Value); RT_NOREF_PV(uSD); return VINF_IOM_R3_MMIO_WRITE; #endif /* IN_RING3 */ } static int hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { return hdaRegWriteSDBDPX(pThis, iReg, u32Value, HDA_SD_NUM_FROM_REG(pThis, BDPL, iReg)); } static int hdaRegWriteSDBDPU(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { return hdaRegWriteSDBDPX(pThis, iReg, u32Value, HDA_SD_NUM_FROM_REG(pThis, BDPU, iReg)); } static int hdaRegReadIRS(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value) { DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_READ); /* regarding 3.4.3 we should mark IRS as busy in case CORB is active */ if ( HDA_REG(pThis, CORBWP) != HDA_REG(pThis, CORBRP) || (HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA)) { HDA_REG(pThis, IRS) = HDA_IRS_ICB; /* busy */ } int rc = hdaRegReadU32(pThis, iReg, pu32Value); DEVHDA_UNLOCK(pThis); return rc; } static int hdaRegWriteIRS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { RT_NOREF_PV(iReg); DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); /* * If the guest set the ICB bit of IRS register, HDA should process the verb in IC register, * write the response to IR register, and set the IRV (valid in case of success) bit of IRS register. */ if ( (u32Value & HDA_IRS_ICB) && !(HDA_REG(pThis, IRS) & HDA_IRS_ICB)) { #ifdef IN_RING3 uint32_t uCmd = HDA_REG(pThis, IC); if (HDA_REG(pThis, CORBWP) != HDA_REG(pThis, CORBRP)) { DEVHDA_UNLOCK(pThis); /* * 3.4.3: Defines behavior of immediate Command status register. */ LogRel(("HDA: Guest attempted process immediate verb (%x) with active CORB\n", uCmd)); return VINF_SUCCESS; } HDA_REG(pThis, IRS) = HDA_IRS_ICB; /* busy */ uint64_t uResp; int rc2 = pThis->pCodec->pfnLookup(pThis->pCodec, HDA_CODEC_CMD(uCmd, 0 /* LUN */), &uResp); if (RT_FAILURE(rc2)) LogFunc(("Codec lookup failed with rc2=%Rrc\n", rc2)); HDA_REG(pThis, IR) = (uint32_t)uResp; /** @todo r=andy Do we need a 64-bit response? */ HDA_REG(pThis, IRS) = HDA_IRS_IRV; /* result is ready */ /** @todo r=michaln We just set the IRS value, why are we clearing unset bits? */ HDA_REG(pThis, IRS) &= ~HDA_IRS_ICB; /* busy is clear */ DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; #else /* !IN_RING3 */ DEVHDA_UNLOCK(pThis); return VINF_IOM_R3_MMIO_WRITE; #endif /* !IN_RING3 */ } /* * Once the guest read the response, it should clear the IRV bit of the IRS register. */ HDA_REG(pThis, IRS) &= ~(u32Value & HDA_IRS_IRV); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } static int hdaRegWriteRIRBWP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { RT_NOREF(iReg); DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); if (HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA) /* Ignore request if CORB DMA engine is (still) running. */ { LogFunc(("CORB DMA (still) running, skipping\n")); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } if (u32Value & HDA_RIRBWP_RST) { /* Do a RIRB reset. */ if (pThis->cbRirbBuf) { Assert(pThis->pu64RirbBuf); RT_BZERO((void *)pThis->pu64RirbBuf, pThis->cbRirbBuf); } LogRel2(("HDA: RIRB reset\n")); HDA_REG(pThis, RIRBWP) = 0; } /* The remaining bits are O, see 6.2.22. */ DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } static int hdaRegWriteRINTCNT(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); if (HDA_REG(pThis, CORBCTL) & HDA_CORBCTL_DMA) /* Ignore request if CORB DMA engine is (still) running. */ { LogFunc(("CORB DMA is (still) running, skipping\n")); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } int rc = hdaRegWriteU16(pThis, iReg, u32Value); AssertRC(rc); LogFunc(("Response interrupt count is now %RU8\n", HDA_REG(pThis, RINTCNT) & 0xFF)); DEVHDA_UNLOCK(pThis); return rc; } static int hdaRegWriteBase(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx; DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); int rc = hdaRegWriteU32(pThis, iReg, u32Value); AssertRCSuccess(rc); switch (iReg) { case HDA_REG_CORBLBASE: pThis->u64CORBBase &= UINT64_C(0xFFFFFFFF00000000); pThis->u64CORBBase |= pThis->au32Regs[iRegMem]; break; case HDA_REG_CORBUBASE: pThis->u64CORBBase &= UINT64_C(0x00000000FFFFFFFF); pThis->u64CORBBase |= ((uint64_t)pThis->au32Regs[iRegMem] << 32); break; case HDA_REG_RIRBLBASE: pThis->u64RIRBBase &= UINT64_C(0xFFFFFFFF00000000); pThis->u64RIRBBase |= pThis->au32Regs[iRegMem]; break; case HDA_REG_RIRBUBASE: pThis->u64RIRBBase &= UINT64_C(0x00000000FFFFFFFF); pThis->u64RIRBBase |= ((uint64_t)pThis->au32Regs[iRegMem] << 32); break; case HDA_REG_DPLBASE: { pThis->u64DPBase = pThis->au32Regs[iRegMem] & DPBASE_ADDR_MASK; Assert(pThis->u64DPBase % 128 == 0); /* Must be 128-byte aligned. */ /* Also make sure to handle the DMA position enable bit. */ pThis->fDMAPosition = pThis->au32Regs[iRegMem] & RT_BIT_32(0); LogRel(("HDA: %s DMA position buffer\n", pThis->fDMAPosition ? "Enabled" : "Disabled")); break; } case HDA_REG_DPUBASE: pThis->u64DPBase = RT_MAKE_U64(RT_LO_U32(pThis->u64DPBase) & DPBASE_ADDR_MASK, pThis->au32Regs[iRegMem]); break; default: AssertMsgFailed(("Invalid index\n")); break; } LogFunc(("CORB base:%llx RIRB base: %llx DP base: %llx\n", pThis->u64CORBBase, pThis->u64RIRBBase, pThis->u64DPBase)); DEVHDA_UNLOCK(pThis); return rc; } static int hdaRegWriteRIRBSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value) { RT_NOREF_PV(iReg); DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); uint8_t v = HDA_REG(pThis, RIRBSTS); HDA_REG(pThis, RIRBSTS) &= ~(v & u32Value); #ifndef LOG_ENABLED int rc = hdaProcessInterrupt(pThis); #else int rc = hdaProcessInterrupt(pThis, __FUNCTION__); #endif DEVHDA_UNLOCK(pThis); return rc; } #ifdef IN_RING3 /** * Retrieves a corresponding sink for a given mixer control. * Returns NULL if no sink is found. * * @return PHDAMIXERSINK * @param pThis HDA state. * @param enmMixerCtl Mixer control to get the corresponding sink for. */ static PHDAMIXERSINK hdaR3MixerControlToSink(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl) { PHDAMIXERSINK pSink; switch (enmMixerCtl) { case PDMAUDIOMIXERCTL_VOLUME_MASTER: /* Fall through is intentional. */ case PDMAUDIOMIXERCTL_FRONT: pSink = &pThis->SinkFront; break; # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND case PDMAUDIOMIXERCTL_CENTER_LFE: pSink = &pThis->SinkCenterLFE; break; case PDMAUDIOMIXERCTL_REAR: pSink = &pThis->SinkRear; break; # endif case PDMAUDIOMIXERCTL_LINE_IN: pSink = &pThis->SinkLineIn; break; # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN case PDMAUDIOMIXERCTL_MIC_IN: pSink = &pThis->SinkMicIn; break; # endif default: pSink = NULL; AssertMsgFailed(("Unhandled mixer control\n")); break; } return pSink; } /** * Adds a driver stream to a specific mixer sink. * * @returns IPRT status code (ignored by caller). * @param pThis HDA state. * @param pMixSink Audio mixer sink to add audio streams to. * @param pCfg Audio stream configuration to use for the audio streams to add. * @param pDrv Driver stream to add. */ static int hdaR3MixerAddDrvStream(PHDASTATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PHDADRIVER pDrv) { AssertPtrReturn(pThis, VERR_INVALID_POINTER); AssertPtrReturn(pMixSink, VERR_INVALID_POINTER); AssertPtrReturn(pCfg, VERR_INVALID_POINTER); LogFunc(("Sink=%s, Stream=%s\n", pMixSink->pszName, pCfg->szName)); PPDMAUDIOSTREAMCFG pStreamCfg = DrvAudioHlpStreamCfgDup(pCfg); if (!pStreamCfg) return VERR_NO_MEMORY; LogFunc(("[LUN#%RU8] %s\n", pDrv->uLUN, pStreamCfg->szName)); int rc = VINF_SUCCESS; PHDADRIVERSTREAM pDrvStream = NULL; if (pStreamCfg->enmDir == PDMAUDIODIR_IN) { LogFunc(("enmRecSource=%d\n", pStreamCfg->DestSource.Source)); switch (pStreamCfg->DestSource.Source) { case PDMAUDIORECSOURCE_LINE: pDrvStream = &pDrv->LineIn; break; # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN case PDMAUDIORECSOURCE_MIC: pDrvStream = &pDrv->MicIn; break; # endif default: rc = VERR_NOT_SUPPORTED; break; } } else if (pStreamCfg->enmDir == PDMAUDIODIR_OUT) { LogFunc(("enmPlaybackDest=%d\n", pStreamCfg->DestSource.Dest)); switch (pStreamCfg->DestSource.Dest) { case PDMAUDIOPLAYBACKDEST_FRONT: pDrvStream = &pDrv->Front; break; # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND case PDMAUDIOPLAYBACKDEST_CENTER_LFE: pDrvStream = &pDrv->CenterLFE; break; case PDMAUDIOPLAYBACKDEST_REAR: pDrvStream = &pDrv->Rear; break; # endif default: rc = VERR_NOT_SUPPORTED; break; } } else rc = VERR_NOT_SUPPORTED; if (RT_SUCCESS(rc)) { AssertPtr(pDrvStream); AssertMsg(pDrvStream->pMixStrm == NULL, ("[LUN#%RU8] Driver stream already present when it must not\n", pDrv->uLUN)); PAUDMIXSTREAM pMixStrm; rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, pStreamCfg, 0 /* fFlags */, &pMixStrm); LogFlowFunc(("LUN#%RU8: Created stream \"%s\" for sink, rc=%Rrc\n", pDrv->uLUN, pStreamCfg->szName, rc)); if (RT_SUCCESS(rc)) { rc = AudioMixerSinkAddStream(pMixSink, pMixStrm); LogFlowFunc(("LUN#%RU8: Added stream \"%s\" to sink, rc=%Rrc\n", pDrv->uLUN, pStreamCfg->szName, rc)); if (RT_SUCCESS(rc)) { /* If this is an input stream, always set the latest (added) stream * as the recording source. * @todo Make the recording source dynamic (CFGM?). */ if (pStreamCfg->enmDir == PDMAUDIODIR_IN) { PDMAUDIOBACKENDCFG Cfg; rc = pDrv->pConnector->pfnGetConfig(pDrv->pConnector, &Cfg); if ( RT_SUCCESS(rc) && Cfg.cMaxStreamsIn) /* At least one input source available? */ { rc = AudioMixerSinkSetRecordingSource(pMixSink, pMixStrm); LogFlowFunc(("LUN#%RU8: Recording source is now '%s', rc=%Rrc\n", pDrv->uLUN, pStreamCfg->szName, rc)); LogRel2(("HDA: Set recording source to '%s'\n", pStreamCfg->szName)); } else if (RT_FAILURE(rc)) LogFunc(("LUN#%RU8: Unable to retrieve backend configuratio for '%s', rc=%Rrc\n", pDrv->uLUN, pStreamCfg->szName, rc)); } } } if (RT_SUCCESS(rc)) pDrvStream->pMixStrm = pMixStrm; } RTMemFree(pStreamCfg); LogFlowFuncLeaveRC(rc); return rc; } /** * Adds all current driver streams to a specific mixer sink. * * @returns IPRT status code. * @param pThis HDA state. * @param pMixSink Audio mixer sink to add stream to. * @param pCfg Audio stream configuration to use for the audio streams to add. */ static int hdaR3MixerAddDrvStreams(PHDASTATE pThis, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg) { AssertPtrReturn(pThis, VERR_INVALID_POINTER); AssertPtrReturn(pMixSink, VERR_INVALID_POINTER); AssertPtrReturn(pCfg, VERR_INVALID_POINTER); LogFunc(("Sink=%s, Stream=%s\n", pMixSink->pszName, pCfg->szName)); if (!DrvAudioHlpStreamCfgIsValid(pCfg)) return VERR_INVALID_PARAMETER; int rc = AudioMixerSinkSetFormat(pMixSink, &pCfg->Props); if (RT_FAILURE(rc)) return rc; PHDADRIVER pDrv; RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) { int rc2 = hdaR3MixerAddDrvStream(pThis, pMixSink, pCfg, pDrv); if (RT_FAILURE(rc2)) LogFunc(("Attaching stream failed with %Rrc\n", rc2)); /* Do not pass failure to rc here, as there might be drivers which aren't * configured / ready yet. */ } return rc; } /** * @interface_method_impl{HDACODEC,pfnCbMixerAddStream} * * Adds a new audio stream to a specific mixer control. * * Depending on the mixer control the stream then gets assigned to one of the internal * mixer sinks, which in turn then handle the mixing of all connected streams to that sink. * * @return IPRT status code. * @param pThis HDA state. * @param enmMixerCtl Mixer control to assign new stream to. * @param pCfg Stream configuration for the new stream. */ static DECLCALLBACK(int) hdaR3MixerAddStream(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOSTREAMCFG pCfg) { AssertPtrReturn(pThis, VERR_INVALID_POINTER); AssertPtrReturn(pCfg, VERR_INVALID_POINTER); int rc; PHDAMIXERSINK pSink = hdaR3MixerControlToSink(pThis, enmMixerCtl); if (pSink) { rc = hdaR3MixerAddDrvStreams(pThis, pSink->pMixSink, pCfg); AssertPtr(pSink->pMixSink); LogFlowFunc(("Sink=%s, Mixer control=%s\n", pSink->pMixSink->pszName, DrvAudioHlpAudMixerCtlToStr(enmMixerCtl))); } else rc = VERR_NOT_FOUND; LogFlowFuncLeaveRC(rc); return rc; } /** * @interface_method_impl{HDACODEC,pfnCbMixerRemoveStream} * * Removes a specified mixer control from the HDA's mixer. * * @return IPRT status code. * @param pThis HDA state. * @param enmMixerCtl Mixer control to remove. * * @remarks Can be called as a callback by the HDA codec. */ static DECLCALLBACK(int) hdaR3MixerRemoveStream(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl) { AssertPtrReturn(pThis, VERR_INVALID_POINTER); int rc; PHDAMIXERSINK pSink = hdaR3MixerControlToSink(pThis, enmMixerCtl); if (pSink) { PHDADRIVER pDrv; RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) { PAUDMIXSTREAM pMixStream = NULL; switch (enmMixerCtl) { /* * Input. */ case PDMAUDIOMIXERCTL_LINE_IN: pMixStream = pDrv->LineIn.pMixStrm; pDrv->LineIn.pMixStrm = NULL; break; # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN case PDMAUDIOMIXERCTL_MIC_IN: pMixStream = pDrv->MicIn.pMixStrm; pDrv->MicIn.pMixStrm = NULL; break; # endif /* * Output. */ case PDMAUDIOMIXERCTL_FRONT: pMixStream = pDrv->Front.pMixStrm; pDrv->Front.pMixStrm = NULL; break; # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND case PDMAUDIOMIXERCTL_CENTER_LFE: pMixStream = pDrv->CenterLFE.pMixStrm; pDrv->CenterLFE.pMixStrm = NULL; break; case PDMAUDIOMIXERCTL_REAR: pMixStream = pDrv->Rear.pMixStrm; pDrv->Rear.pMixStrm = NULL; break; # endif default: AssertMsgFailed(("Mixer control %d not implemented\n", enmMixerCtl)); break; } if (pMixStream) { AudioMixerSinkRemoveStream(pSink->pMixSink, pMixStream); AudioMixerStreamDestroy(pMixStream); pMixStream = NULL; } } AudioMixerSinkRemoveAllStreams(pSink->pMixSink); rc = VINF_SUCCESS; } else rc = VERR_NOT_FOUND; LogFunc(("Mixer control=%s, rc=%Rrc\n", DrvAudioHlpAudMixerCtlToStr(enmMixerCtl), rc)); return rc; } /** * @interface_method_impl{HDACODEC,pfnCbMixerControl} * * Controls an input / output converter widget, that is, which converter is connected * to which stream (and channel). * * @returns IPRT status code. * @param pThis HDA State. * @param enmMixerCtl Mixer control to set SD stream number and channel for. * @param uSD SD stream number (number + 1) to set. Set to 0 for unassign. * @param uChannel Channel to set. Only valid if a valid SD stream number is specified. * * @remarks Can be called as a callback by the HDA codec. */ static DECLCALLBACK(int) hdaR3MixerControl(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, uint8_t uSD, uint8_t uChannel) { LogFunc(("enmMixerCtl=%s, uSD=%RU8, uChannel=%RU8\n", DrvAudioHlpAudMixerCtlToStr(enmMixerCtl), uSD, uChannel)); if (uSD == 0) /* Stream number 0 is reserved. */ { Log2Func(("Invalid SDn (%RU8) number for mixer control '%s', ignoring\n", uSD, DrvAudioHlpAudMixerCtlToStr(enmMixerCtl))); return VINF_SUCCESS; } /* uChannel is optional. */ /* SDn0 starts as 1. */ Assert(uSD); uSD--; # ifndef VBOX_WITH_AUDIO_HDA_MIC_IN /* Only SDI0 (Line-In) is supported. */ if ( hdaGetDirFromSD(uSD) == PDMAUDIODIR_IN && uSD >= 1) { LogRel2(("HDA: Dedicated Mic-In support not imlpemented / built-in (stream #%RU8), using Line-In (stream #0) instead\n", uSD)); uSD = 0; } # endif int rc = VINF_SUCCESS; PHDAMIXERSINK pSink = hdaR3MixerControlToSink(pThis, enmMixerCtl); if (pSink) { AssertPtr(pSink->pMixSink); /* If this an output stream, determine the correct SD#. */ if ( (uSD < HDA_MAX_SDI) && AudioMixerSinkGetDir(pSink->pMixSink) == AUDMIXSINKDIR_OUTPUT) { uSD += HDA_MAX_SDI; } /* Detach the existing stream from the sink. */ if ( pSink->pStream && ( pSink->pStream->u8SD != uSD || pSink->pStream->u8Channel != uChannel) ) { LogFunc(("Sink '%s' was assigned to stream #%RU8 (channel %RU8) before\n", pSink->pMixSink->pszName, pSink->pStream->u8SD, pSink->pStream->u8Channel)); hdaR3StreamLock(pSink->pStream); /* Only disable the stream if the stream descriptor # has changed. */ if (pSink->pStream->u8SD != uSD) hdaR3StreamEnable(pSink->pStream, false); pSink->pStream->pMixSink = NULL; hdaR3StreamUnlock(pSink->pStream); pSink->pStream = NULL; } Assert(uSD < HDA_MAX_STREAMS); /* Attach the new stream to the sink. * Enabling the stream will be done by the gust via a separate SDnCTL call then. */ if (pSink->pStream == NULL) { LogRel2(("HDA: Setting sink '%s' to stream #%RU8 (channel %RU8), mixer control=%s\n", pSink->pMixSink->pszName, uSD, uChannel, DrvAudioHlpAudMixerCtlToStr(enmMixerCtl))); PHDASTREAM pStream = hdaGetStreamFromSD(pThis, uSD); if (pStream) { hdaR3StreamLock(pStream); pSink->pStream = pStream; pStream->u8Channel = uChannel; pStream->pMixSink = pSink; hdaR3StreamUnlock(pStream); rc = VINF_SUCCESS; } else rc = VERR_NOT_IMPLEMENTED; } } else rc = VERR_NOT_FOUND; if (RT_FAILURE(rc)) LogRel(("HDA: Converter control for stream #%RU8 (channel %RU8) / mixer control '%s' failed with %Rrc, skipping\n", uSD, uChannel, DrvAudioHlpAudMixerCtlToStr(enmMixerCtl), rc)); LogFlowFuncLeaveRC(rc); return rc; } /** * @interface_method_impl{HDACODEC,pfnCbMixerSetVolume} * * Sets the volume of a specified mixer control. * * @return IPRT status code. * @param pThis HDA State. * @param enmMixerCtl Mixer control to set volume for. * @param pVol Pointer to volume data to set. * * @remarks Can be called as a callback by the HDA codec. */ static DECLCALLBACK(int) hdaR3MixerSetVolume(PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOVOLUME pVol) { int rc; PHDAMIXERSINK pSink = hdaR3MixerControlToSink(pThis, enmMixerCtl); if ( pSink && pSink->pMixSink) { LogRel2(("HDA: Setting volume for mixer sink '%s' to %RU8/%RU8 (%s)\n", pSink->pMixSink->pszName, pVol->uLeft, pVol->uRight, pVol->fMuted ? "Muted" : "Unmuted")); /* Set the volume. * We assume that the codec already converted it to the correct range. */ rc = AudioMixerSinkSetVolume(pSink->pMixSink, pVol); } else rc = VERR_NOT_FOUND; LogFlowFuncLeaveRC(rc); return rc; } /** * Main routine for the stream's timer. * * @param pDevIns Device instance. * @param pTimer Timer this callback was called for. * @param pvUser Pointer to associated HDASTREAM. */ static DECLCALLBACK(void) hdaR3Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) { RT_NOREF(pDevIns, pTimer); PHDASTREAM pStream = (PHDASTREAM)pvUser; AssertPtr(pStream); PHDASTATE pThis = pStream->pHDAState; DEVHDA_LOCK_BOTH_RETURN_VOID(pStream->pHDAState, pStream->u8SD); hdaR3StreamUpdate(pStream, true /* fInTimer */); /* Flag indicating whether to kick the timer again for a * new data processing round. */ const bool fSinkActive = AudioMixerSinkIsActive(pStream->pMixSink->pMixSink); if (fSinkActive) { const bool fTimerScheduled = hdaR3StreamTransferIsScheduled(pStream); Log3Func(("fSinksActive=%RTbool, fTimerScheduled=%RTbool\n", fSinkActive, fTimerScheduled)); if (!fTimerScheduled) hdaR3TimerSet(pThis, pStream, TMTimerGet(pThis->pTimer[pStream->u8SD]) + TMTimerGetFreq(pThis->pTimer[pStream->u8SD]) / pStream->pHDAState->u16TimerHz, true /* fForce */); } else Log3Func(("fSinksActive=%RTbool\n", fSinkActive)); DEVHDA_UNLOCK_BOTH(pThis, pStream->u8SD); } # ifdef HDA_USE_DMA_ACCESS_HANDLER /** * HC access handler for the FIFO. * * @returns VINF_SUCCESS if the handler have carried out the operation. * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation. * @param pVM VM Handle. * @param pVCpu The cross context CPU structure for the calling EMT. * @param GCPhys The physical address the guest is writing to. * @param pvPhys The HC mapping of that address. * @param pvBuf What the guest is reading/writing. * @param cbBuf How much it's reading/writing. * @param enmAccessType The access type. * @param enmOrigin Who is making the access. * @param pvUser User argument. */ static DECLCALLBACK(VBOXSTRICTRC) hdaR3DMAAccessHandler(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser) { RT_NOREF(pVM, pVCpu, pvPhys, pvBuf, enmOrigin); PHDADMAACCESSHANDLER pHandler = (PHDADMAACCESSHANDLER)pvUser; AssertPtr(pHandler); PHDASTREAM pStream = pHandler->pStream; AssertPtr(pStream); Assert(GCPhys >= pHandler->GCPhysFirst); Assert(GCPhys <= pHandler->GCPhysLast); Assert(enmAccessType == PGMACCESSTYPE_WRITE); /* Not within BDLE range? Bail out. */ if ( (GCPhys < pHandler->BDLEAddr) || (GCPhys + cbBuf > pHandler->BDLEAddr + pHandler->BDLESize)) { return VINF_PGM_HANDLER_DO_DEFAULT; } switch(enmAccessType) { case PGMACCESSTYPE_WRITE: { # ifdef DEBUG PHDASTREAMDBGINFO pStreamDbg = &pStream->Dbg; const uint64_t tsNowNs = RTTimeNanoTS(); const uint32_t tsElapsedMs = (tsNowNs - pStreamDbg->tsWriteSlotBegin) / 1000 / 1000; uint64_t cWritesHz = ASMAtomicReadU64(&pStreamDbg->cWritesHz); uint64_t cbWrittenHz = ASMAtomicReadU64(&pStreamDbg->cbWrittenHz); if (tsElapsedMs >= (1000 / HDA_TIMER_HZ_DEFAULT)) { LogFunc(("[SD%RU8] %RU32ms elapsed, cbWritten=%RU64, cWritten=%RU64 -- %RU32 bytes on average per time slot (%zums)\n", pStream->u8SD, tsElapsedMs, cbWrittenHz, cWritesHz, ASMDivU64ByU32RetU32(cbWrittenHz, cWritesHz ? cWritesHz : 1), 1000 / HDA_TIMER_HZ_DEFAULT)); pStreamDbg->tsWriteSlotBegin = tsNowNs; cWritesHz = 0; cbWrittenHz = 0; } cWritesHz += 1; cbWrittenHz += cbBuf; ASMAtomicIncU64(&pStreamDbg->cWritesTotal); ASMAtomicAddU64(&pStreamDbg->cbWrittenTotal, cbBuf); ASMAtomicWriteU64(&pStreamDbg->cWritesHz, cWritesHz); ASMAtomicWriteU64(&pStreamDbg->cbWrittenHz, cbWrittenHz); LogFunc(("[SD%RU8] Writing %3zu @ 0x%x (off %zu)\n", pStream->u8SD, cbBuf, GCPhys, GCPhys - pHandler->BDLEAddr)); LogFunc(("[SD%RU8] cWrites=%RU64, cbWritten=%RU64 -> %RU32 bytes on average\n", pStream->u8SD, pStreamDbg->cWritesTotal, pStreamDbg->cbWrittenTotal, ASMDivU64ByU32RetU32(pStreamDbg->cbWrittenTotal, pStreamDbg->cWritesTotal))); # endif if (pThis->fDebugEnabled) { RTFILE fh; RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "hdaDMAAccessWrite.pcm", RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE); RTFileWrite(fh, pvBuf, cbBuf, NULL); RTFileClose(fh); } # ifdef HDA_USE_DMA_ACCESS_HANDLER_WRITING PRTCIRCBUF pCircBuf = pStream->State.pCircBuf; AssertPtr(pCircBuf); uint8_t *pbBuf = (uint8_t *)pvBuf; while (cbBuf) { /* Make sure we only copy as much as the stream's FIFO can hold (SDFIFOS, 18.2.39). */ void *pvChunk; size_t cbChunk; RTCircBufAcquireWriteBlock(pCircBuf, cbBuf, &pvChunk, &cbChunk); if (cbChunk) { memcpy(pvChunk, pbBuf, cbChunk); pbBuf += cbChunk; Assert(cbBuf >= cbChunk); cbBuf -= cbChunk; } else { //AssertMsg(RTCircBufFree(pCircBuf), ("No more space but still %zu bytes to write\n", cbBuf)); break; } LogFunc(("[SD%RU8] cbChunk=%zu\n", pStream->u8SD, cbChunk)); RTCircBufReleaseWriteBlock(pCircBuf, cbChunk); } # endif /* HDA_USE_DMA_ACCESS_HANDLER_WRITING */ break; } default: AssertMsgFailed(("Access type not implemented\n")); break; } return VINF_PGM_HANDLER_DO_DEFAULT; } # endif /* HDA_USE_DMA_ACCESS_HANDLER */ /** * Soft reset of the device triggered via GCTL. * * @param pThis HDA state. * */ static void hdaR3GCTLReset(PHDASTATE pThis) { LogFlowFuncEnter(); pThis->cStreamsActive = 0; HDA_REG(pThis, GCAP) = HDA_MAKE_GCAP(HDA_MAX_SDO, HDA_MAX_SDI, 0, 0, 1); /* see 6.2.1 */ HDA_REG(pThis, VMIN) = 0x00; /* see 6.2.2 */ HDA_REG(pThis, VMAJ) = 0x01; /* see 6.2.3 */ HDA_REG(pThis, OUTPAY) = 0x003C; /* see 6.2.4 */ HDA_REG(pThis, INPAY) = 0x001D; /* see 6.2.5 */ HDA_REG(pThis, CORBSIZE) = 0x42; /* Up to 256 CORB entries see 6.2.1 */ HDA_REG(pThis, RIRBSIZE) = 0x42; /* Up to 256 RIRB entries see 6.2.1 */ HDA_REG(pThis, CORBRP) = 0x0; HDA_REG(pThis, CORBWP) = 0x0; HDA_REG(pThis, RIRBWP) = 0x0; /* Some guests (like Haiku) don't set RINTCNT explicitly but expect an interrupt after each * RIRB response -- so initialize RINTCNT to 1 by default. */ HDA_REG(pThis, RINTCNT) = 0x1; /* * Stop any audio currently playing and/or recording. */ pThis->SinkFront.pStream = NULL; if (pThis->SinkFront.pMixSink) AudioMixerSinkReset(pThis->SinkFront.pMixSink); # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN pThis->SinkMicIn.pStream = NULL; if (pThis->SinkMicIn.pMixSink) AudioMixerSinkReset(pThis->SinkMicIn.pMixSink); # endif pThis->SinkLineIn.pStream = NULL; if (pThis->SinkLineIn.pMixSink) AudioMixerSinkReset(pThis->SinkLineIn.pMixSink); # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND pThis->SinkCenterLFE = NULL; if (pThis->SinkCenterLFE.pMixSink) AudioMixerSinkReset(pThis->SinkCenterLFE.pMixSink); pThis->SinkRear.pStream = NULL; if (pThis->SinkRear.pMixSink) AudioMixerSinkReset(pThis->SinkRear.pMixSink); # endif /* * Reset the codec. */ if ( pThis->pCodec && pThis->pCodec->pfnReset) { pThis->pCodec->pfnReset(pThis->pCodec); } /* * Set some sensible defaults for which HDA sinks * are connected to which stream number. * * We use SD0 for input and SD4 for output by default. * These stream numbers can be changed by the guest dynamically lateron. */ # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_MIC_IN , 1 /* SD0 */, 0 /* Channel */); # endif hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_LINE_IN , 1 /* SD0 */, 0 /* Channel */); hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_FRONT , 5 /* SD4 */, 0 /* Channel */); # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_CENTER_LFE, 5 /* SD4 */, 0 /* Channel */); hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_REAR , 5 /* SD4 */, 0 /* Channel */); # endif /* Reset CORB. */ pThis->cbCorbBuf = HDA_CORB_SIZE * HDA_CORB_ELEMENT_SIZE; RT_BZERO(pThis->pu32CorbBuf, pThis->cbCorbBuf); /* Reset RIRB. */ pThis->cbRirbBuf = HDA_RIRB_SIZE * HDA_RIRB_ELEMENT_SIZE; RT_BZERO(pThis->pu64RirbBuf, pThis->cbRirbBuf); /* Clear our internal response interrupt counter. */ pThis->u16RespIntCnt = 0; for (uint8_t uSD = 0; uSD < HDA_MAX_STREAMS; ++uSD) { int rc2 = hdaR3StreamEnable(&pThis->aStreams[uSD], false /* fEnable */); if (RT_SUCCESS(rc2)) { /* Remove the RUN bit from SDnCTL in case the stream was in a running state before. */ HDA_STREAM_REG(pThis, CTL, uSD) &= ~HDA_SDCTL_RUN; hdaR3StreamReset(pThis, &pThis->aStreams[uSD], uSD); } } /* Clear stream tags <-> objects mapping table. */ RT_ZERO(pThis->aTags); /* Emulation of codec "wake up" (HDA spec 5.5.1 and 6.5). */ HDA_REG(pThis, STATESTS) = 0x1; LogFlowFuncLeave(); LogRel(("HDA: Reset\n")); } #endif /* IN_RING3 */ /* MMIO callbacks */ /** * @callback_method_impl{FNIOMMMIOREAD, Looks up and calls the appropriate handler.} * * @note During implementation, we discovered so-called "forgotten" or "hole" * registers whose description is not listed in the RPM, datasheet, or * spec. */ PDMBOTHCBDECL(int) hdaMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); int rc; RT_NOREF_PV(pvUser); Assert(pThis->uAlignmentCheckMagic == HDASTATE_ALIGNMENT_CHECK_MAGIC); /* * Look up and log. */ uint32_t offReg = GCPhysAddr - pThis->MMIOBaseAddr; int idxRegDsc = hdaRegLookup(offReg); /* Register descriptor index. */ #ifdef LOG_ENABLED unsigned const cbLog = cb; uint32_t offRegLog = offReg; #endif Log3Func(("offReg=%#x cb=%#x\n", offReg, cb)); Assert(cb == 4); Assert((offReg & 3) == 0); DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_READ); if (!(HDA_REG(pThis, GCTL) & HDA_GCTL_CRST) && idxRegDsc != HDA_REG_GCTL) LogFunc(("Access to registers except GCTL is blocked while reset\n")); if (idxRegDsc == -1) LogRel(("HDA: Invalid read access @0x%x (bytes=%u)\n", offReg, cb)); if (idxRegDsc != -1) { /* Leave lock before calling read function. */ DEVHDA_UNLOCK(pThis); /* ASSUMES gapless DWORD at end of map. */ if (g_aHdaRegMap[idxRegDsc].size == 4) { /* * Straight forward DWORD access. */ rc = g_aHdaRegMap[idxRegDsc].pfnRead(pThis, idxRegDsc, (uint32_t *)pv); Log3Func(("\tRead %s => %x (%Rrc)\n", g_aHdaRegMap[idxRegDsc].abbrev, *(uint32_t *)pv, rc)); } else { /* * Multi register read (unless there are trailing gaps). * ASSUMES that only DWORD reads have sideeffects. */ #ifdef IN_RING3 uint32_t u32Value = 0; unsigned cbLeft = 4; do { uint32_t const cbReg = g_aHdaRegMap[idxRegDsc].size; uint32_t u32Tmp = 0; rc = g_aHdaRegMap[idxRegDsc].pfnRead(pThis, idxRegDsc, &u32Tmp); Log3Func(("\tRead %s[%db] => %x (%Rrc)*\n", g_aHdaRegMap[idxRegDsc].abbrev, cbReg, u32Tmp, rc)); if (rc != VINF_SUCCESS) break; u32Value |= (u32Tmp & g_afMasks[cbReg]) << ((4 - cbLeft) * 8); cbLeft -= cbReg; offReg += cbReg; idxRegDsc++; } while (cbLeft > 0 && g_aHdaRegMap[idxRegDsc].offset == offReg); if (rc == VINF_SUCCESS) *(uint32_t *)pv = u32Value; else Assert(!IOM_SUCCESS(rc)); #else /* !IN_RING3 */ /* Take the easy way out. */ rc = VINF_IOM_R3_MMIO_READ; #endif /* !IN_RING3 */ } } else { DEVHDA_UNLOCK(pThis); rc = VINF_IOM_MMIO_UNUSED_FF; Log3Func(("\tHole at %x is accessed for read\n", offReg)); } /* * Log the outcome. */ #ifdef LOG_ENABLED if (cbLog == 4) Log3Func(("\tReturning @%#05x -> %#010x %Rrc\n", offRegLog, *(uint32_t *)pv, rc)); else if (cbLog == 2) Log3Func(("\tReturning @%#05x -> %#06x %Rrc\n", offRegLog, *(uint16_t *)pv, rc)); else if (cbLog == 1) Log3Func(("\tReturning @%#05x -> %#04x %Rrc\n", offRegLog, *(uint8_t *)pv, rc)); #endif return rc; } DECLINLINE(int) hdaWriteReg(PHDASTATE pThis, int idxRegDsc, uint32_t u32Value, char const *pszLog) { DEVHDA_LOCK_RETURN(pThis, VINF_IOM_R3_MMIO_WRITE); if (!(HDA_REG(pThis, GCTL) & HDA_GCTL_CRST) && idxRegDsc != HDA_REG_GCTL) { Log(("hdaWriteReg: Warning: Access to %s is blocked while controller is in reset mode\n", g_aHdaRegMap[idxRegDsc].abbrev)); LogRel2(("HDA: Warning: Access to register %s is blocked while controller is in reset mode\n", g_aHdaRegMap[idxRegDsc].abbrev)); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } /* * Handle RD (register description) flags. */ /* For SDI / SDO: Check if writes to those registers are allowed while SDCTL's RUN bit is set. */ if (idxRegDsc >= HDA_NUM_GENERAL_REGS) { const uint32_t uSDCTL = HDA_STREAM_REG(pThis, CTL, HDA_SD_NUM_FROM_REG(pThis, CTL, idxRegDsc)); /* * Some OSes (like Win 10 AU) violate the spec by writing stuff to registers which are not supposed to be be touched * while SDCTL's RUN bit is set. So just ignore those values. */ /* Is the RUN bit currently set? */ if ( RT_BOOL(uSDCTL & HDA_SDCTL_RUN) /* Are writes to the register denied if RUN bit is set? */ && !(g_aHdaRegMap[idxRegDsc].fFlags & HDA_RD_FLAG_SD_WRITE_RUN)) { Log(("hdaWriteReg: Warning: Access to %s is blocked! %R[sdctl]\n", g_aHdaRegMap[idxRegDsc].abbrev, uSDCTL)); LogRel2(("HDA: Warning: Access to register %s is blocked while the stream's RUN bit is set\n", g_aHdaRegMap[idxRegDsc].abbrev)); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } } /* Leave the lock before calling write function. */ /** @todo r=bird: Why do we need to do that?? There is no * explanation why this is necessary here... * * More or less all write functions retake the lock, so why not let * those who need to drop the lock or take additional locks release * it? See, releasing a lock you already got always runs the risk * of someone else grabbing it and forcing you to wait, better to * do the two-three things a write handle needs to do than enter * and exit the lock all the time. */ DEVHDA_UNLOCK(pThis); #ifdef LOG_ENABLED uint32_t const idxRegMem = g_aHdaRegMap[idxRegDsc].mem_idx; uint32_t const u32OldValue = pThis->au32Regs[idxRegMem]; #endif int rc = g_aHdaRegMap[idxRegDsc].pfnWrite(pThis, idxRegDsc, u32Value); Log3Func(("Written value %#x to %s[%d byte]; %x => %x%s, rc=%d\n", u32Value, g_aHdaRegMap[idxRegDsc].abbrev, g_aHdaRegMap[idxRegDsc].size, u32OldValue, pThis->au32Regs[idxRegMem], pszLog, rc)); RT_NOREF(pszLog); return rc; } /** * @callback_method_impl{FNIOMMMIOWRITE, Looks up and calls the appropriate handler.} */ PDMBOTHCBDECL(int) hdaMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); int rc; RT_NOREF_PV(pvUser); Assert(pThis->uAlignmentCheckMagic == HDASTATE_ALIGNMENT_CHECK_MAGIC); /* * The behavior of accesses that aren't aligned on natural boundraries is * undefined. Just reject them outright. */ /** @todo IOM could check this, it could also split the 8 byte accesses for us. */ Assert(cb == 1 || cb == 2 || cb == 4 || cb == 8); if (GCPhysAddr & (cb - 1)) return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "misaligned write access: GCPhysAddr=%RGp cb=%u\n", GCPhysAddr, cb); /* * Look up and log the access. */ uint32_t offReg = GCPhysAddr - pThis->MMIOBaseAddr; int idxRegDsc = hdaRegLookup(offReg); #if defined(IN_RING3) || defined(LOG_ENABLED) uint32_t idxRegMem = idxRegDsc != -1 ? g_aHdaRegMap[idxRegDsc].mem_idx : UINT32_MAX; #endif uint64_t u64Value; if (cb == 4) u64Value = *(uint32_t const *)pv; else if (cb == 2) u64Value = *(uint16_t const *)pv; else if (cb == 1) u64Value = *(uint8_t const *)pv; else if (cb == 8) u64Value = *(uint64_t const *)pv; else { u64Value = 0; /* shut up gcc. */ AssertReleaseMsgFailed(("%u\n", cb)); } #ifdef LOG_ENABLED uint32_t const u32LogOldValue = idxRegDsc >= 0 ? pThis->au32Regs[idxRegMem] : UINT32_MAX; if (idxRegDsc == -1) Log3Func(("@%#05x u32=%#010x cb=%d\n", offReg, *(uint32_t const *)pv, cb)); else if (cb == 4) Log3Func(("@%#05x u32=%#010x %s\n", offReg, *(uint32_t *)pv, g_aHdaRegMap[idxRegDsc].abbrev)); else if (cb == 2) Log3Func(("@%#05x u16=%#06x (%#010x) %s\n", offReg, *(uint16_t *)pv, *(uint32_t *)pv, g_aHdaRegMap[idxRegDsc].abbrev)); else if (cb == 1) Log3Func(("@%#05x u8=%#04x (%#010x) %s\n", offReg, *(uint8_t *)pv, *(uint32_t *)pv, g_aHdaRegMap[idxRegDsc].abbrev)); if (idxRegDsc >= 0 && g_aHdaRegMap[idxRegDsc].size != cb) Log3Func(("\tsize=%RU32 != cb=%u!!\n", g_aHdaRegMap[idxRegDsc].size, cb)); #endif /* * Try for a direct hit first. */ if (idxRegDsc != -1 && g_aHdaRegMap[idxRegDsc].size == cb) { rc = hdaWriteReg(pThis, idxRegDsc, u64Value, ""); Log3Func(("\t%#x -> %#x\n", u32LogOldValue, idxRegMem != UINT32_MAX ? pThis->au32Regs[idxRegMem] : UINT32_MAX)); } /* * Partial or multiple register access, loop thru the requested memory. */ else { #ifdef IN_RING3 /* * If it's an access beyond the start of the register, shift the input * value and fill in missing bits. Natural alignment rules means we * will only see 1 or 2 byte accesses of this kind, so no risk of * shifting out input values. */ if (idxRegDsc == -1 && (idxRegDsc = hdaR3RegLookupWithin(offReg)) != -1) { uint32_t const cbBefore = offReg - g_aHdaRegMap[idxRegDsc].offset; Assert(cbBefore > 0 && cbBefore < 4); offReg -= cbBefore; idxRegMem = g_aHdaRegMap[idxRegDsc].mem_idx; u64Value <<= cbBefore * 8; u64Value |= pThis->au32Regs[idxRegMem] & g_afMasks[cbBefore]; Log3Func(("\tWithin register, supplied %u leading bits: %#llx -> %#llx ...\n", cbBefore * 8, ~g_afMasks[cbBefore] & u64Value, u64Value)); } /* Loop thru the write area, it may cover multiple registers. */ rc = VINF_SUCCESS; for (;;) { uint32_t cbReg; if (idxRegDsc != -1) { idxRegMem = g_aHdaRegMap[idxRegDsc].mem_idx; cbReg = g_aHdaRegMap[idxRegDsc].size; if (cb < cbReg) { u64Value |= pThis->au32Regs[idxRegMem] & g_afMasks[cbReg] & ~g_afMasks[cb]; Log3Func(("\tSupplying missing bits (%#x): %#llx -> %#llx ...\n", g_afMasks[cbReg] & ~g_afMasks[cb], u64Value & g_afMasks[cb], u64Value)); } # ifdef LOG_ENABLED uint32_t uLogOldVal = pThis->au32Regs[idxRegMem]; # endif rc = hdaWriteReg(pThis, idxRegDsc, u64Value, "*"); Log3Func(("\t%#x -> %#x\n", uLogOldVal, pThis->au32Regs[idxRegMem])); } else { LogRel(("HDA: Invalid write access @0x%x\n", offReg)); cbReg = 1; } if (rc != VINF_SUCCESS) break; if (cbReg >= cb) break; /* Advance. */ offReg += cbReg; cb -= cbReg; u64Value >>= cbReg * 8; if (idxRegDsc == -1) idxRegDsc = hdaRegLookup(offReg); else { idxRegDsc++; if ( (unsigned)idxRegDsc >= RT_ELEMENTS(g_aHdaRegMap) || g_aHdaRegMap[idxRegDsc].offset != offReg) { idxRegDsc = -1; } } } #else /* !IN_RING3 */ /* Take the simple way out. */ rc = VINF_IOM_R3_MMIO_WRITE; #endif /* !IN_RING3 */ } return rc; } /* PCI callback. */ #ifdef IN_RING3 /** * @callback_method_impl{FNPCIIOREGIONMAP} */ static DECLCALLBACK(int) hdaR3PciIoRegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType) { RT_NOREF(iRegion, enmType); PHDASTATE pThis = RT_FROM_MEMBER(pPciDev, HDASTATE, PciDev); /* * 18.2 of the ICH6 datasheet defines the valid access widths as byte, word, and double word. * * Let IOM talk DWORDs when reading, saves a lot of complications. On * writing though, we have to do it all ourselves because of sideeffects. */ Assert(enmType == PCI_ADDRESS_SPACE_MEM); int rc = PDMDevHlpMMIORegister(pDevIns, GCPhysAddress, cb, NULL /*pvUser*/, IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_PASSTHRU, hdaMMIOWrite, hdaMMIORead, "HDA"); if (RT_FAILURE(rc)) return rc; if (pThis->fRZEnabled) { rc = PDMDevHlpMMIORegisterR0(pDevIns, GCPhysAddress, cb, NIL_RTR0PTR /*pvUser*/, "hdaMMIOWrite", "hdaMMIORead"); if (RT_FAILURE(rc)) return rc; rc = PDMDevHlpMMIORegisterRC(pDevIns, GCPhysAddress, cb, NIL_RTRCPTR /*pvUser*/, "hdaMMIOWrite", "hdaMMIORead"); if (RT_FAILURE(rc)) return rc; } pThis->MMIOBaseAddr = GCPhysAddress; return VINF_SUCCESS; } /* Saved state workers and callbacks. */ static int hdaR3SaveStream(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, PHDASTREAM pStream) { RT_NOREF(pDevIns); #ifdef VBOX_STRICT PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); #endif Log2Func(("[SD%RU8]\n", pStream->u8SD)); /* Save stream ID. */ int rc = SSMR3PutU8(pSSM, pStream->u8SD); AssertRCReturn(rc, rc); Assert(pStream->u8SD < HDA_MAX_STREAMS); rc = SSMR3PutStructEx(pSSM, &pStream->State, sizeof(HDASTREAMSTATE), 0 /*fFlags*/, g_aSSMStreamStateFields7, NULL); AssertRCReturn(rc, rc); #ifdef VBOX_STRICT /* Sanity checks. */ uint64_t u64BaseDMA = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, pStream->u8SD), HDA_STREAM_REG(pThis, BDPU, pStream->u8SD)); uint16_t u16LVI = HDA_STREAM_REG(pThis, LVI, pStream->u8SD); uint32_t u32CBL = HDA_STREAM_REG(pThis, CBL, pStream->u8SD); Assert(u64BaseDMA == pStream->u64BDLBase); Assert(u16LVI == pStream->u16LVI); Assert(u32CBL == pStream->u32CBL); #endif rc = SSMR3PutStructEx(pSSM, &pStream->State.BDLE.Desc, sizeof(HDABDLEDESC), 0 /*fFlags*/, g_aSSMBDLEDescFields7, NULL); AssertRCReturn(rc, rc); rc = SSMR3PutStructEx(pSSM, &pStream->State.BDLE.State, sizeof(HDABDLESTATE), 0 /*fFlags*/, g_aSSMBDLEStateFields7, NULL); AssertRCReturn(rc, rc); rc = SSMR3PutStructEx(pSSM, &pStream->State.Period, sizeof(HDASTREAMPERIOD), 0 /* fFlags */, g_aSSMStreamPeriodFields7, NULL); AssertRCReturn(rc, rc); #ifdef VBOX_STRICT /* Sanity checks. */ PHDABDLE pBDLE = &pStream->State.BDLE; if (u64BaseDMA) { Assert(pStream->State.uCurBDLE <= u16LVI + 1); HDABDLE curBDLE; rc = hdaR3BDLEFetch(pThis, &curBDLE, u64BaseDMA, pStream->State.uCurBDLE); AssertRC(rc); Assert(curBDLE.Desc.u32BufSize == pBDLE->Desc.u32BufSize); Assert(curBDLE.Desc.u64BufAdr == pBDLE->Desc.u64BufAdr); Assert(curBDLE.Desc.fFlags == pBDLE->Desc.fFlags); } else { Assert(pBDLE->Desc.u64BufAdr == 0); Assert(pBDLE->Desc.u32BufSize == 0); } #endif uint32_t cbCircBufSize = 0; uint32_t cbCircBufUsed = 0; if (pStream->State.pCircBuf) { cbCircBufSize = (uint32_t)RTCircBufSize(pStream->State.pCircBuf); cbCircBufUsed = (uint32_t)RTCircBufUsed(pStream->State.pCircBuf); } rc = SSMR3PutU32(pSSM, cbCircBufSize); AssertRCReturn(rc, rc); rc = SSMR3PutU32(pSSM, cbCircBufUsed); AssertRCReturn(rc, rc); if (cbCircBufUsed) { /* * We now need to get the circular buffer's data without actually modifying * the internal read / used offsets -- otherwise we would end up with broken audio * data after saving the state. * * So get the current read offset and serialize the buffer data manually based on that. */ size_t cbCircBufOffRead = RTCircBufOffsetRead(pStream->State.pCircBuf); void *pvBuf; size_t cbBuf; RTCircBufAcquireReadBlock(pStream->State.pCircBuf, cbCircBufUsed, &pvBuf, &cbBuf); if (cbBuf) { size_t cbToRead = cbCircBufUsed; size_t cbEnd = 0; if (cbCircBufUsed > cbCircBufOffRead) cbEnd = cbCircBufUsed - cbCircBufOffRead; if (cbEnd) /* Save end of buffer first. */ { rc = SSMR3PutMem(pSSM, (uint8_t *)pvBuf + cbCircBufSize - cbEnd /* End of buffer */, cbEnd); AssertRCReturn(rc, rc); Assert(cbToRead >= cbEnd); cbToRead -= cbEnd; } if (cbToRead) /* Save remaining stuff at start of buffer (if any). */ { rc = SSMR3PutMem(pSSM, (uint8_t *)pvBuf - cbCircBufUsed /* Start of buffer */, cbToRead); AssertRCReturn(rc, rc); } } RTCircBufReleaseReadBlock(pStream->State.pCircBuf, 0 /* Don't advance read pointer -- see comment above */); } Log2Func(("[SD%RU8] LPIB=%RU32, CBL=%RU32, LVI=%RU32\n", pStream->u8SD, HDA_STREAM_REG(pThis, LPIB, pStream->u8SD), HDA_STREAM_REG(pThis, CBL, pStream->u8SD), HDA_STREAM_REG(pThis, LVI, pStream->u8SD))); #ifdef LOG_ENABLED hdaR3BDLEDumpAll(pThis, pStream->u64BDLBase, pStream->u16LVI + 1); #endif return rc; } /** * @callback_method_impl{FNSSMDEVSAVEEXEC} */ static DECLCALLBACK(int) hdaR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); /* Save Codec nodes states. */ hdaCodecSaveState(pThis->pCodec, pSSM); /* Save MMIO registers. */ SSMR3PutU32(pSSM, RT_ELEMENTS(pThis->au32Regs)); SSMR3PutMem(pSSM, pThis->au32Regs, sizeof(pThis->au32Regs)); /* Save controller-specifc internals. */ SSMR3PutU64(pSSM, pThis->u64WalClk); SSMR3PutU8(pSSM, pThis->u8IRQL); /* Save number of streams. */ SSMR3PutU32(pSSM, HDA_MAX_STREAMS); /* Save stream states. */ for (uint8_t i = 0; i < HDA_MAX_STREAMS; i++) { int rc = hdaR3SaveStream(pDevIns, pSSM, &pThis->aStreams[i]); AssertRCReturn(rc, rc); } return VINF_SUCCESS; } /** * Does required post processing when loading a saved state. * * @param pThis Pointer to HDA state. */ static int hdaR3LoadExecPost(PHDASTATE pThis) { int rc = VINF_SUCCESS; /* * Enable all previously active streams. */ for (uint8_t i = 0; i < HDA_MAX_STREAMS; i++) { PHDASTREAM pStream = hdaGetStreamFromSD(pThis, i); if (pStream) { int rc2; bool fActive = RT_BOOL(HDA_STREAM_REG(pThis, CTL, i) & HDA_SDCTL_RUN); if (fActive) { #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO /* Make sure to also create the async I/O thread before actually enabling the stream. */ rc2 = hdaR3StreamAsyncIOCreate(pStream); AssertRC(rc2); /* ... and enabling it. */ hdaR3StreamAsyncIOEnable(pStream, true /* fEnable */); #endif /* Resume the stream's period. */ hdaR3StreamPeriodResume(&pStream->State.Period); /* (Re-)enable the stream. */ rc2 = hdaR3StreamEnable(pStream, true /* fEnable */); AssertRC(rc2); /* Add the stream to the device setup. */ rc2 = hdaR3AddStream(pThis, &pStream->State.Cfg); AssertRC(rc2); #ifdef HDA_USE_DMA_ACCESS_HANDLER /* (Re-)install the DMA handler. */ hdaR3StreamRegisterDMAHandlers(pThis, pStream); #endif if (hdaR3StreamTransferIsScheduled(pStream)) hdaR3TimerSet(pThis, pStream, hdaR3StreamTransferGetNext(pStream), true /* fForce */); /* Also keep track of the currently active streams. */ pThis->cStreamsActive++; } } } LogFlowFuncLeaveRC(rc); return rc; } /** * Handles loading of all saved state versions older than the current one. * * @param pThis Pointer to HDA state. * @param pSSM Pointer to SSM handle. * @param uVersion Saved state version to load. * @param uPass Loading stage to handle. */ static int hdaR3LoadExecLegacy(PHDASTATE pThis, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) { RT_NOREF(uPass); int rc = VINF_SUCCESS; /* * Load MMIO registers. */ uint32_t cRegs; switch (uVersion) { case HDA_SSM_VERSION_1: /* Starting with r71199, we would save 112 instead of 113 registers due to some code cleanups. This only affected trunk builds in the 4.1 development period. */ cRegs = 113; if (SSMR3HandleRevision(pSSM) >= 71199) { uint32_t uVer = SSMR3HandleVersion(pSSM); if ( VBOX_FULL_VERSION_GET_MAJOR(uVer) == 4 && VBOX_FULL_VERSION_GET_MINOR(uVer) == 0 && VBOX_FULL_VERSION_GET_BUILD(uVer) >= 51) cRegs = 112; } break; case HDA_SSM_VERSION_2: case HDA_SSM_VERSION_3: cRegs = 112; AssertCompile(RT_ELEMENTS(pThis->au32Regs) >= 112); break; /* Since version 4 we store the register count to stay flexible. */ case HDA_SSM_VERSION_4: case HDA_SSM_VERSION_5: case HDA_SSM_VERSION_6: rc = SSMR3GetU32(pSSM, &cRegs); AssertRCReturn(rc, rc); if (cRegs != RT_ELEMENTS(pThis->au32Regs)) LogRel(("HDA: SSM version cRegs is %RU32, expected %RU32\n", cRegs, RT_ELEMENTS(pThis->au32Regs))); break; default: LogRel(("HDA: Warning: Unsupported / too new saved state version (%RU32)\n", uVersion)); return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; } if (cRegs >= RT_ELEMENTS(pThis->au32Regs)) { SSMR3GetMem(pSSM, pThis->au32Regs, sizeof(pThis->au32Regs)); SSMR3Skip(pSSM, sizeof(uint32_t) * (cRegs - RT_ELEMENTS(pThis->au32Regs))); } else SSMR3GetMem(pSSM, pThis->au32Regs, sizeof(uint32_t) * cRegs); /* Make sure to update the base addresses first before initializing any streams down below. */ pThis->u64CORBBase = RT_MAKE_U64(HDA_REG(pThis, CORBLBASE), HDA_REG(pThis, CORBUBASE)); pThis->u64RIRBBase = RT_MAKE_U64(HDA_REG(pThis, RIRBLBASE), HDA_REG(pThis, RIRBUBASE)); pThis->u64DPBase = RT_MAKE_U64(HDA_REG(pThis, DPLBASE) & DPBASE_ADDR_MASK, HDA_REG(pThis, DPUBASE)); /* Also make sure to update the DMA position bit if this was enabled when saving the state. */ pThis->fDMAPosition = RT_BOOL(HDA_REG(pThis, DPLBASE) & RT_BIT_32(0)); /* * Note: Saved states < v5 store LVI (u32BdleMaxCvi) for * *every* BDLE state, whereas it only needs to be stored * *once* for every stream. Most of the BDLE state we can * get out of the registers anyway, so just ignore those values. * * Also, only the current BDLE was saved, regardless whether * there were more than one (and there are at least two entries, * according to the spec). */ #define HDA_SSM_LOAD_BDLE_STATE_PRE_V5(v, x) \ { \ rc = SSMR3Skip(pSSM, sizeof(uint32_t)); /* Begin marker */ \ AssertRCReturn(rc, rc); \ rc = SSMR3GetU64(pSSM, &x.Desc.u64BufAdr); /* u64BdleCviAddr */ \ AssertRCReturn(rc, rc); \ rc = SSMR3Skip(pSSM, sizeof(uint32_t)); /* u32BdleMaxCvi */ \ AssertRCReturn(rc, rc); \ rc = SSMR3GetU32(pSSM, &x.State.u32BDLIndex); /* u32BdleCvi */ \ AssertRCReturn(rc, rc); \ rc = SSMR3GetU32(pSSM, &x.Desc.u32BufSize); /* u32BdleCviLen */ \ AssertRCReturn(rc, rc); \ rc = SSMR3GetU32(pSSM, &x.State.u32BufOff); /* u32BdleCviPos */ \ AssertRCReturn(rc, rc); \ bool fIOC; \ rc = SSMR3GetBool(pSSM, &fIOC); /* fBdleCviIoc */ \ AssertRCReturn(rc, rc); \ x.Desc.fFlags = fIOC ? HDA_BDLE_FLAG_IOC : 0; \ rc = SSMR3GetU32(pSSM, &x.State.cbBelowFIFOW); /* cbUnderFifoW */ \ AssertRCReturn(rc, rc); \ rc = SSMR3Skip(pSSM, sizeof(uint8_t) * 256); /* FIFO */ \ AssertRCReturn(rc, rc); \ rc = SSMR3Skip(pSSM, sizeof(uint32_t)); /* End marker */ \ AssertRCReturn(rc, rc); \ } /* * Load BDLEs (Buffer Descriptor List Entries) and DMA counters. */ switch (uVersion) { case HDA_SSM_VERSION_1: case HDA_SSM_VERSION_2: case HDA_SSM_VERSION_3: case HDA_SSM_VERSION_4: { /* Only load the internal states. * The rest will be initialized from the saved registers later. */ /* Note 1: Only the *current* BDLE for a stream was saved! */ /* Note 2: The stream's saving order is/was fixed, so don't touch! */ /* Output */ PHDASTREAM pStream = &pThis->aStreams[4]; rc = hdaR3StreamInit(pStream, 4 /* Stream descriptor, hardcoded */); if (RT_FAILURE(rc)) break; HDA_SSM_LOAD_BDLE_STATE_PRE_V5(uVersion, pStream->State.BDLE); pStream->State.uCurBDLE = pStream->State.BDLE.State.u32BDLIndex; /* Microphone-In */ pStream = &pThis->aStreams[2]; rc = hdaR3StreamInit(pStream, 2 /* Stream descriptor, hardcoded */); if (RT_FAILURE(rc)) break; HDA_SSM_LOAD_BDLE_STATE_PRE_V5(uVersion, pStream->State.BDLE); pStream->State.uCurBDLE = pStream->State.BDLE.State.u32BDLIndex; /* Line-In */ pStream = &pThis->aStreams[0]; rc = hdaR3StreamInit(pStream, 0 /* Stream descriptor, hardcoded */); if (RT_FAILURE(rc)) break; HDA_SSM_LOAD_BDLE_STATE_PRE_V5(uVersion, pStream->State.BDLE); pStream->State.uCurBDLE = pStream->State.BDLE.State.u32BDLIndex; break; } #undef HDA_SSM_LOAD_BDLE_STATE_PRE_V5 default: /* Since v5 we support flexible stream and BDLE counts. */ { uint32_t cStreams; rc = SSMR3GetU32(pSSM, &cStreams); if (RT_FAILURE(rc)) break; if (cStreams > HDA_MAX_STREAMS) cStreams = HDA_MAX_STREAMS; /* Sanity. */ /* Load stream states. */ for (uint32_t i = 0; i < cStreams; i++) { uint8_t uStreamID; rc = SSMR3GetU8(pSSM, &uStreamID); if (RT_FAILURE(rc)) break; PHDASTREAM pStream = hdaGetStreamFromSD(pThis, uStreamID); HDASTREAM StreamDummy; if (!pStream) { pStream = &StreamDummy; LogRel2(("HDA: Warning: Stream ID=%RU32 not supported, skipping to load ...\n", uStreamID)); } rc = hdaR3StreamInit(pStream, uStreamID); if (RT_FAILURE(rc)) { LogRel(("HDA: Stream #%RU32: Initialization of stream %RU8 failed, rc=%Rrc\n", i, uStreamID, rc)); break; } /* * Load BDLEs (Buffer Descriptor List Entries) and DMA counters. */ if (uVersion == HDA_SSM_VERSION_5) { /* Get the current BDLE entry and skip the rest. */ uint16_t cBDLE; rc = SSMR3Skip(pSSM, sizeof(uint32_t)); /* Begin marker */ AssertRC(rc); rc = SSMR3GetU16(pSSM, &cBDLE); /* cBDLE */ AssertRC(rc); rc = SSMR3GetU16(pSSM, &pStream->State.uCurBDLE); /* uCurBDLE */ AssertRC(rc); rc = SSMR3Skip(pSSM, sizeof(uint32_t)); /* End marker */ AssertRC(rc); uint32_t u32BDLEIndex; for (uint16_t a = 0; a < cBDLE; a++) { rc = SSMR3Skip(pSSM, sizeof(uint32_t)); /* Begin marker */ AssertRC(rc); rc = SSMR3GetU32(pSSM, &u32BDLEIndex); /* u32BDLIndex */ AssertRC(rc); /* Does the current BDLE index match the current BDLE to process? */ if (u32BDLEIndex == pStream->State.uCurBDLE) { rc = SSMR3GetU32(pSSM, &pStream->State.BDLE.State.cbBelowFIFOW); /* cbBelowFIFOW */ AssertRC(rc); rc = SSMR3Skip(pSSM, sizeof(uint8_t) * 256); /* FIFO, deprecated */ AssertRC(rc); rc = SSMR3GetU32(pSSM, &pStream->State.BDLE.State.u32BufOff); /* u32BufOff */ AssertRC(rc); rc = SSMR3Skip(pSSM, sizeof(uint32_t)); /* End marker */ AssertRC(rc); } else /* Skip not current BDLEs. */ { rc = SSMR3Skip(pSSM, sizeof(uint32_t) /* cbBelowFIFOW */ + sizeof(uint8_t) * 256 /* au8FIFO */ + sizeof(uint32_t) /* u32BufOff */ + sizeof(uint32_t)); /* End marker */ AssertRC(rc); } } } else { rc = SSMR3GetStructEx(pSSM, &pStream->State, sizeof(HDASTREAMSTATE), 0 /* fFlags */, g_aSSMStreamStateFields6, NULL); if (RT_FAILURE(rc)) break; /* Get HDABDLEDESC. */ uint32_t uMarker; rc = SSMR3GetU32(pSSM, &uMarker); /* Begin marker. */ AssertRC(rc); Assert(uMarker == UINT32_C(0x19200102) /* SSMR3STRUCT_BEGIN */); rc = SSMR3GetU64(pSSM, &pStream->State.BDLE.Desc.u64BufAdr); AssertRC(rc); rc = SSMR3GetU32(pSSM, &pStream->State.BDLE.Desc.u32BufSize); AssertRC(rc); bool fFlags = false; rc = SSMR3GetBool(pSSM, &fFlags); /* Saved states < v7 only stored the IOC as boolean flag. */ AssertRC(rc); pStream->State.BDLE.Desc.fFlags = fFlags ? HDA_BDLE_FLAG_IOC : 0; rc = SSMR3GetU32(pSSM, &uMarker); /* End marker. */ AssertRC(rc); Assert(uMarker == UINT32_C(0x19920406) /* SSMR3STRUCT_END */); rc = SSMR3GetStructEx(pSSM, &pStream->State.BDLE.State, sizeof(HDABDLESTATE), 0 /* fFlags */, g_aSSMBDLEStateFields6, NULL); if (RT_FAILURE(rc)) break; Log2Func(("[SD%RU8] LPIB=%RU32, CBL=%RU32, LVI=%RU32\n", uStreamID, HDA_STREAM_REG(pThis, LPIB, uStreamID), HDA_STREAM_REG(pThis, CBL, uStreamID), HDA_STREAM_REG(pThis, LVI, uStreamID))); #ifdef LOG_ENABLED hdaR3BDLEDumpAll(pThis, pStream->u64BDLBase, pStream->u16LVI + 1); #endif } } /* for cStreams */ break; } /* default */ } return rc; } /** * @callback_method_impl{FNSSMDEVLOADEXEC} */ static DECLCALLBACK(int) hdaR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); LogRel2(("hdaR3LoadExec: uVersion=%RU32, uPass=0x%x\n", uVersion, uPass)); /* * Load Codec nodes states. */ int rc = hdaCodecLoadState(pThis->pCodec, pSSM, uVersion); if (RT_FAILURE(rc)) { LogRel(("HDA: Failed loading codec state (version %RU32, pass 0x%x), rc=%Rrc\n", uVersion, uPass, rc)); return rc; } if (uVersion < HDA_SSM_VERSION) /* Handle older saved states? */ { rc = hdaR3LoadExecLegacy(pThis, pSSM, uVersion, uPass); if (RT_SUCCESS(rc)) rc = hdaR3LoadExecPost(pThis); return rc; } /* * Load MMIO registers. */ uint32_t cRegs; rc = SSMR3GetU32(pSSM, &cRegs); AssertRCReturn(rc, rc); if (cRegs != RT_ELEMENTS(pThis->au32Regs)) LogRel(("HDA: SSM version cRegs is %RU32, expected %RU32\n", cRegs, RT_ELEMENTS(pThis->au32Regs))); if (cRegs >= RT_ELEMENTS(pThis->au32Regs)) { SSMR3GetMem(pSSM, pThis->au32Regs, sizeof(pThis->au32Regs)); SSMR3Skip(pSSM, sizeof(uint32_t) * (cRegs - RT_ELEMENTS(pThis->au32Regs))); } else SSMR3GetMem(pSSM, pThis->au32Regs, sizeof(uint32_t) * cRegs); /* Make sure to update the base addresses first before initializing any streams down below. */ pThis->u64CORBBase = RT_MAKE_U64(HDA_REG(pThis, CORBLBASE), HDA_REG(pThis, CORBUBASE)); pThis->u64RIRBBase = RT_MAKE_U64(HDA_REG(pThis, RIRBLBASE), HDA_REG(pThis, RIRBUBASE)); pThis->u64DPBase = RT_MAKE_U64(HDA_REG(pThis, DPLBASE) & DPBASE_ADDR_MASK, HDA_REG(pThis, DPUBASE)); /* Also make sure to update the DMA position bit if this was enabled when saving the state. */ pThis->fDMAPosition = RT_BOOL(HDA_REG(pThis, DPLBASE) & RT_BIT_32(0)); /* * Load controller-specifc internals. * Don't annoy other team mates (forgot this for state v7). */ if ( SSMR3HandleRevision(pSSM) >= 116273 || SSMR3HandleVersion(pSSM) >= VBOX_FULL_VERSION_MAKE(5, 2, 0)) { rc = SSMR3GetU64(pSSM, &pThis->u64WalClk); AssertRC(rc); rc = SSMR3GetU8(pSSM, &pThis->u8IRQL); AssertRC(rc); } /* * Load streams. */ uint32_t cStreams; rc = SSMR3GetU32(pSSM, &cStreams); AssertRC(rc); if (cStreams > HDA_MAX_STREAMS) cStreams = HDA_MAX_STREAMS; /* Sanity. */ Log2Func(("cStreams=%RU32\n", cStreams)); /* Load stream states. */ for (uint32_t i = 0; i < cStreams; i++) { uint8_t uStreamID; rc = SSMR3GetU8(pSSM, &uStreamID); AssertRC(rc); PHDASTREAM pStream = hdaGetStreamFromSD(pThis, uStreamID); HDASTREAM StreamDummy; if (!pStream) { pStream = &StreamDummy; LogRel2(("HDA: Warning: Loading of stream #%RU8 not supported, skipping to load ...\n", uStreamID)); } rc = hdaR3StreamInit(pStream, uStreamID); if (RT_FAILURE(rc)) { LogRel(("HDA: Stream #%RU8: Loading initialization failed, rc=%Rrc\n", uStreamID, rc)); /* Continue. */ } rc = SSMR3GetStructEx(pSSM, &pStream->State, sizeof(HDASTREAMSTATE), 0 /* fFlags */, g_aSSMStreamStateFields7, NULL); AssertRC(rc); /* * Load BDLEs (Buffer Descriptor List Entries) and DMA counters. */ rc = SSMR3GetStructEx(pSSM, &pStream->State.BDLE.Desc, sizeof(HDABDLEDESC), 0 /* fFlags */, g_aSSMBDLEDescFields7, NULL); AssertRC(rc); rc = SSMR3GetStructEx(pSSM, &pStream->State.BDLE.State, sizeof(HDABDLESTATE), 0 /* fFlags */, g_aSSMBDLEStateFields7, NULL); AssertRC(rc); Log2Func(("[SD%RU8] %R[bdle]\n", pStream->u8SD, &pStream->State.BDLE)); /* * Load period state. * Don't annoy other team mates (forgot this for state v7). */ hdaR3StreamPeriodInit(&pStream->State.Period, pStream->u8SD, pStream->u16LVI, pStream->u32CBL, &pStream->State.Cfg); if ( SSMR3HandleRevision(pSSM) >= 116273 || SSMR3HandleVersion(pSSM) >= VBOX_FULL_VERSION_MAKE(5, 2, 0)) { rc = SSMR3GetStructEx(pSSM, &pStream->State.Period, sizeof(HDASTREAMPERIOD), 0 /* fFlags */, g_aSSMStreamPeriodFields7, NULL); AssertRC(rc); } /* * Load internal (FIFO) buffer. */ uint32_t cbCircBufSize = 0; rc = SSMR3GetU32(pSSM, &cbCircBufSize); /* cbCircBuf */ AssertRC(rc); uint32_t cbCircBufUsed = 0; rc = SSMR3GetU32(pSSM, &cbCircBufUsed); /* cbCircBuf */ AssertRC(rc); if (cbCircBufSize) /* If 0, skip the buffer. */ { /* Paranoia. */ AssertReleaseMsg(cbCircBufSize <= _1M, ("HDA: Saved state contains bogus DMA buffer size (%RU32) for stream #%RU8", cbCircBufSize, uStreamID)); AssertReleaseMsg(cbCircBufUsed <= cbCircBufSize, ("HDA: Saved state contains invalid DMA buffer usage (%RU32/%RU32) for stream #%RU8", cbCircBufUsed, cbCircBufSize, uStreamID)); AssertPtr(pStream->State.pCircBuf); /* Do we need to cre-create the circular buffer do fit the data size? */ if (cbCircBufSize != (uint32_t)RTCircBufSize(pStream->State.pCircBuf)) { RTCircBufDestroy(pStream->State.pCircBuf); pStream->State.pCircBuf = NULL; rc = RTCircBufCreate(&pStream->State.pCircBuf, cbCircBufSize); AssertRC(rc); } if ( RT_SUCCESS(rc) && cbCircBufUsed) { void *pvBuf; size_t cbBuf; RTCircBufAcquireWriteBlock(pStream->State.pCircBuf, cbCircBufUsed, &pvBuf, &cbBuf); if (cbBuf) { rc = SSMR3GetMem(pSSM, pvBuf, cbBuf); AssertRC(rc); } RTCircBufReleaseWriteBlock(pStream->State.pCircBuf, cbBuf); Assert(cbBuf == cbCircBufUsed); } } Log2Func(("[SD%RU8] LPIB=%RU32, CBL=%RU32, LVI=%RU32\n", uStreamID, HDA_STREAM_REG(pThis, LPIB, uStreamID), HDA_STREAM_REG(pThis, CBL, uStreamID), HDA_STREAM_REG(pThis, LVI, uStreamID))); #ifdef LOG_ENABLED hdaR3BDLEDumpAll(pThis, pStream->u64BDLBase, pStream->u16LVI + 1); #endif /** @todo (Re-)initialize active periods? */ } /* for cStreams */ rc = hdaR3LoadExecPost(pThis); AssertRC(rc); LogFlowFuncLeaveRC(rc); return rc; } /* IPRT format type handlers. */ /** * @callback_method_impl{FNRTSTRFORMATTYPE} */ static DECLCALLBACK(size_t) hdaR3StrFmtBDLE(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char *pszType, void const *pvValue, int cchWidth, int cchPrecision, unsigned fFlags, void *pvUser) { RT_NOREF(pszType, cchWidth, cchPrecision, fFlags, pvUser); PHDABDLE pBDLE = (PHDABDLE)pvValue; return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "BDLE(idx:%RU32, off:%RU32, fifow:%RU32, IOC:%RTbool, DMA[%RU32 bytes @ 0x%x])", pBDLE->State.u32BDLIndex, pBDLE->State.u32BufOff, pBDLE->State.cbBelowFIFOW, pBDLE->Desc.fFlags & HDA_BDLE_FLAG_IOC, pBDLE->Desc.u32BufSize, pBDLE->Desc.u64BufAdr); } /** * @callback_method_impl{FNRTSTRFORMATTYPE} */ static DECLCALLBACK(size_t) hdaR3StrFmtSDCTL(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char *pszType, void const *pvValue, int cchWidth, int cchPrecision, unsigned fFlags, void *pvUser) { RT_NOREF(pszType, cchWidth, cchPrecision, fFlags, pvUser); uint32_t uSDCTL = (uint32_t)(uintptr_t)pvValue; return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SDCTL(raw:%#x, DIR:%s, TP:%RTbool, STRIPE:%x, DEIE:%RTbool, FEIE:%RTbool, IOCE:%RTbool, RUN:%RTbool, RESET:%RTbool)", uSDCTL, uSDCTL & HDA_SDCTL_DIR ? "OUT" : "IN", RT_BOOL(uSDCTL & HDA_SDCTL_TP), (uSDCTL & HDA_SDCTL_STRIPE_MASK) >> HDA_SDCTL_STRIPE_SHIFT, RT_BOOL(uSDCTL & HDA_SDCTL_DEIE), RT_BOOL(uSDCTL & HDA_SDCTL_FEIE), RT_BOOL(uSDCTL & HDA_SDCTL_IOCE), RT_BOOL(uSDCTL & HDA_SDCTL_RUN), RT_BOOL(uSDCTL & HDA_SDCTL_SRST)); } /** * @callback_method_impl{FNRTSTRFORMATTYPE} */ static DECLCALLBACK(size_t) hdaR3StrFmtSDFIFOS(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char *pszType, void const *pvValue, int cchWidth, int cchPrecision, unsigned fFlags, void *pvUser) { RT_NOREF(pszType, cchWidth, cchPrecision, fFlags, pvUser); uint32_t uSDFIFOS = (uint32_t)(uintptr_t)pvValue; return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SDFIFOS(raw:%#x, sdfifos:%RU8 B)", uSDFIFOS, uSDFIFOS ? uSDFIFOS + 1 : 0); } /** * @callback_method_impl{FNRTSTRFORMATTYPE} */ static DECLCALLBACK(size_t) hdaR3StrFmtSDFIFOW(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char *pszType, void const *pvValue, int cchWidth, int cchPrecision, unsigned fFlags, void *pvUser) { RT_NOREF(pszType, cchWidth, cchPrecision, fFlags, pvUser); uint32_t uSDFIFOW = (uint32_t)(uintptr_t)pvValue; return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SDFIFOW(raw: %#0x, sdfifow:%d B)", uSDFIFOW, hdaSDFIFOWToBytes(uSDFIFOW)); } /** * @callback_method_impl{FNRTSTRFORMATTYPE} */ static DECLCALLBACK(size_t) hdaR3StrFmtSDSTS(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char *pszType, void const *pvValue, int cchWidth, int cchPrecision, unsigned fFlags, void *pvUser) { RT_NOREF(pszType, cchWidth, cchPrecision, fFlags, pvUser); uint32_t uSdSts = (uint32_t)(uintptr_t)pvValue; return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SDSTS(raw:%#0x, fifordy:%RTbool, dese:%RTbool, fifoe:%RTbool, bcis:%RTbool)", uSdSts, RT_BOOL(uSdSts & HDA_SDSTS_FIFORDY), RT_BOOL(uSdSts & HDA_SDSTS_DESE), RT_BOOL(uSdSts & HDA_SDSTS_FIFOE), RT_BOOL(uSdSts & HDA_SDSTS_BCIS)); } /* Debug info dumpers */ static int hdaR3DbgLookupRegByName(const char *pszArgs) { int iReg = 0; for (; iReg < HDA_NUM_REGS; ++iReg) if (!RTStrICmp(g_aHdaRegMap[iReg].abbrev, pszArgs)) return iReg; return -1; } static void hdaR3DbgPrintRegister(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iHdaIndex) { Assert( pThis && iHdaIndex >= 0 && iHdaIndex < HDA_NUM_REGS); pHlp->pfnPrintf(pHlp, "%s: 0x%x\n", g_aHdaRegMap[iHdaIndex].abbrev, pThis->au32Regs[g_aHdaRegMap[iHdaIndex].mem_idx]); } /** * @callback_method_impl{FNDBGFHANDLERDEV} */ static DECLCALLBACK(void) hdaR3DbgInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); int iHdaRegisterIndex = hdaR3DbgLookupRegByName(pszArgs); if (iHdaRegisterIndex != -1) hdaR3DbgPrintRegister(pThis, pHlp, iHdaRegisterIndex); else { for(iHdaRegisterIndex = 0; (unsigned int)iHdaRegisterIndex < HDA_NUM_REGS; ++iHdaRegisterIndex) hdaR3DbgPrintRegister(pThis, pHlp, iHdaRegisterIndex); } } static void hdaR3DbgPrintStream(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iIdx) { Assert( pThis && iIdx >= 0 && iIdx < HDA_MAX_STREAMS); const PHDASTREAM pStream = &pThis->aStreams[iIdx]; pHlp->pfnPrintf(pHlp, "Stream #%d:\n", iIdx); pHlp->pfnPrintf(pHlp, "\tSD%dCTL : %R[sdctl]\n", iIdx, HDA_STREAM_REG(pThis, CTL, iIdx)); pHlp->pfnPrintf(pHlp, "\tSD%dCTS : %R[sdsts]\n", iIdx, HDA_STREAM_REG(pThis, STS, iIdx)); pHlp->pfnPrintf(pHlp, "\tSD%dFIFOS: %R[sdfifos]\n", iIdx, HDA_STREAM_REG(pThis, FIFOS, iIdx)); pHlp->pfnPrintf(pHlp, "\tSD%dFIFOW: %R[sdfifow]\n", iIdx, HDA_STREAM_REG(pThis, FIFOW, iIdx)); pHlp->pfnPrintf(pHlp, "\tBDLE : %R[bdle]\n", &pStream->State.BDLE); } static void hdaR3DbgPrintBDLE(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iIdx) { Assert( pThis && iIdx >= 0 && iIdx < HDA_MAX_STREAMS); const PHDASTREAM pStream = &pThis->aStreams[iIdx]; const PHDABDLE pBDLE = &pStream->State.BDLE; pHlp->pfnPrintf(pHlp, "Stream #%d BDLE:\n", iIdx); uint64_t u64BaseDMA = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, iIdx), HDA_STREAM_REG(pThis, BDPU, iIdx)); uint16_t u16LVI = HDA_STREAM_REG(pThis, LVI, iIdx); uint32_t u32CBL = HDA_STREAM_REG(pThis, CBL, iIdx); if (!u64BaseDMA) return; pHlp->pfnPrintf(pHlp, "\tCurrent: %R[bdle]\n\n", pBDLE); pHlp->pfnPrintf(pHlp, "\tMemory:\n"); uint32_t cbBDLE = 0; for (uint16_t i = 0; i < u16LVI + 1; i++) { HDABDLEDESC bd; PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), u64BaseDMA + i * sizeof(HDABDLEDESC), &bd, sizeof(bd)); pHlp->pfnPrintf(pHlp, "\t\t%s #%03d BDLE(adr:0x%llx, size:%RU32, ioc:%RTbool)\n", pBDLE->State.u32BDLIndex == i ? "*" : " ", i, bd.u64BufAdr, bd.u32BufSize, bd.fFlags & HDA_BDLE_FLAG_IOC); cbBDLE += bd.u32BufSize; } pHlp->pfnPrintf(pHlp, "Total: %RU32 bytes\n", cbBDLE); if (cbBDLE != u32CBL) pHlp->pfnPrintf(pHlp, "Warning: %RU32 bytes does not match CBL (%RU32)!\n", cbBDLE, u32CBL); pHlp->pfnPrintf(pHlp, "DMA counters (base @ 0x%llx):\n", u64BaseDMA); if (!u64BaseDMA) /* No DMA base given? Bail out. */ { pHlp->pfnPrintf(pHlp, "\tNo counters found\n"); return; } for (int i = 0; i < u16LVI + 1; i++) { uint32_t uDMACnt; PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), (pThis->u64DPBase & DPBASE_ADDR_MASK) + (i * 2 * sizeof(uint32_t)), &uDMACnt, sizeof(uDMACnt)); pHlp->pfnPrintf(pHlp, "\t#%03d DMA @ 0x%x\n", i , uDMACnt); } } static int hdaR3DbgLookupStrmIdx(PHDASTATE pThis, const char *pszArgs) { RT_NOREF(pThis, pszArgs); /** @todo Add args parsing. */ return -1; } /** * @callback_method_impl{FNDBGFHANDLERDEV} */ static DECLCALLBACK(void) hdaR3DbgInfoStream(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); int iHdaStreamdex = hdaR3DbgLookupStrmIdx(pThis, pszArgs); if (iHdaStreamdex != -1) hdaR3DbgPrintStream(pThis, pHlp, iHdaStreamdex); else for(iHdaStreamdex = 0; iHdaStreamdex < HDA_MAX_STREAMS; ++iHdaStreamdex) hdaR3DbgPrintStream(pThis, pHlp, iHdaStreamdex); } /** * @callback_method_impl{FNDBGFHANDLERDEV} */ static DECLCALLBACK(void) hdaR3DbgInfoBDLE(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); int iHdaStreamdex = hdaR3DbgLookupStrmIdx(pThis, pszArgs); if (iHdaStreamdex != -1) hdaR3DbgPrintBDLE(pThis, pHlp, iHdaStreamdex); else for (iHdaStreamdex = 0; iHdaStreamdex < HDA_MAX_STREAMS; ++iHdaStreamdex) hdaR3DbgPrintBDLE(pThis, pHlp, iHdaStreamdex); } /** * @callback_method_impl{FNDBGFHANDLERDEV} */ static DECLCALLBACK(void) hdaR3DbgInfoCodecNodes(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); if (pThis->pCodec->pfnDbgListNodes) pThis->pCodec->pfnDbgListNodes(pThis->pCodec, pHlp, pszArgs); else pHlp->pfnPrintf(pHlp, "Codec implementation doesn't provide corresponding callback\n"); } /** * @callback_method_impl{FNDBGFHANDLERDEV} */ static DECLCALLBACK(void) hdaR3DbgInfoCodecSelector(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); if (pThis->pCodec->pfnDbgSelector) pThis->pCodec->pfnDbgSelector(pThis->pCodec, pHlp, pszArgs); else pHlp->pfnPrintf(pHlp, "Codec implementation doesn't provide corresponding callback\n"); } /** * @callback_method_impl{FNDBGFHANDLERDEV} */ static DECLCALLBACK(void) hdaR3DbgInfoMixer(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); if (pThis->pMixer) AudioMixerDebug(pThis->pMixer, pHlp, pszArgs); else pHlp->pfnPrintf(pHlp, "Mixer not available\n"); } /* PDMIBASE */ /** * @interface_method_impl{PDMIBASE,pfnQueryInterface} */ static DECLCALLBACK(void *) hdaR3QueryInterface(struct PDMIBASE *pInterface, const char *pszIID) { PHDASTATE pThis = RT_FROM_MEMBER(pInterface, HDASTATE, IBase); Assert(&pThis->IBase == pInterface); PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase); return NULL; } /* PDMDEVREG */ /** * Attach command, internal version. * * This is called to let the device attach to a driver for a specified LUN * during runtime. This is not called during VM construction, the device * constructor has to attach to all the available drivers. * * @returns VBox status code. * @param pThis HDA state. * @param uLUN The logical unit which is being detached. * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. * @param ppDrv Attached driver instance on success. Optional. */ static int hdaR3AttachInternal(PHDASTATE pThis, unsigned uLUN, uint32_t fFlags, PHDADRIVER *ppDrv) { RT_NOREF(fFlags); /* * Attach driver. */ char *pszDesc; if (RTStrAPrintf(&pszDesc, "Audio driver port (HDA) for LUN#%u", uLUN) <= 0) AssertLogRelFailedReturn(VERR_NO_MEMORY); PPDMIBASE pDrvBase; int rc = PDMDevHlpDriverAttach(pThis->pDevInsR3, uLUN, &pThis->IBase, &pDrvBase, pszDesc); if (RT_SUCCESS(rc)) { PHDADRIVER pDrv = (PHDADRIVER)RTMemAllocZ(sizeof(HDADRIVER)); if (pDrv) { pDrv->pDrvBase = pDrvBase; pDrv->pConnector = PDMIBASE_QUERY_INTERFACE(pDrvBase, PDMIAUDIOCONNECTOR); AssertMsg(pDrv->pConnector != NULL, ("Configuration error: LUN#%u has no host audio interface, rc=%Rrc\n", uLUN, rc)); pDrv->pHDAState = pThis; pDrv->uLUN = uLUN; /* * For now we always set the driver at LUN 0 as our primary * host backend. This might change in the future. */ if (pDrv->uLUN == 0) pDrv->fFlags |= PDMAUDIODRVFLAGS_PRIMARY; LogFunc(("LUN#%u: pCon=%p, drvFlags=0x%x\n", uLUN, pDrv->pConnector, pDrv->fFlags)); /* Attach to driver list if not attached yet. */ if (!pDrv->fAttached) { RTListAppend(&pThis->lstDrv, &pDrv->Node); pDrv->fAttached = true; } if (ppDrv) *ppDrv = pDrv; } else rc = VERR_NO_MEMORY; } else if (rc == VERR_PDM_NO_ATTACHED_DRIVER) LogFunc(("No attached driver for LUN #%u\n", uLUN)); if (RT_FAILURE(rc)) { /* Only free this string on failure; * must remain valid for the live of the driver instance. */ RTStrFree(pszDesc); } LogFunc(("uLUN=%u, fFlags=0x%x, rc=%Rrc\n", uLUN, fFlags, rc)); return rc; } /** * Detach command, internal version. * * This is called to let the device detach from a driver for a specified LUN * during runtime. * * @returns VBox status code. * @param pThis HDA state. * @param pDrv Driver to detach device from. * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. */ static int hdaR3DetachInternal(PHDASTATE pThis, PHDADRIVER pDrv, uint32_t fFlags) { RT_NOREF(fFlags); AudioMixerSinkRemoveStream(pThis->SinkFront.pMixSink, pDrv->Front.pMixStrm); AudioMixerStreamDestroy(pDrv->Front.pMixStrm); pDrv->Front.pMixStrm = NULL; #ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND AudioMixerSinkRemoveStream(pThis->SinkCenterLFE.pMixSink, pDrv->CenterLFE.pMixStrm); AudioMixerStreamDestroy(pDrv->CenterLFE.pMixStrm); pDrv->CenterLFE.pMixStrm = NULL; AudioMixerSinkRemoveStream(pThis->SinkRear.pMixSink, pDrv->Rear.pMixStrm); AudioMixerStreamDestroy(pDrv->Rear.pMixStrm); pDrv->Rear.pMixStrm = NULL; #endif AudioMixerSinkRemoveStream(pThis->SinkLineIn.pMixSink, pDrv->LineIn.pMixStrm); AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm); pDrv->LineIn.pMixStrm = NULL; #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN AudioMixerSinkRemoveStream(pThis->SinkMicIn.pMixSink, pDrv->MicIn.pMixStrm); AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm); pDrv->MicIn.pMixStrm = NULL; #endif RTListNodeRemove(&pDrv->Node); LogFunc(("uLUN=%u, fFlags=0x%x\n", pDrv->uLUN, fFlags)); return VINF_SUCCESS; } /** * @interface_method_impl{PDMDEVREG,pfnAttach} */ static DECLCALLBACK(int) hdaR3Attach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); DEVHDA_LOCK_RETURN(pThis, VERR_IGNORED); LogFunc(("uLUN=%u, fFlags=0x%x\n", uLUN, fFlags)); PHDADRIVER pDrv; int rc2 = hdaR3AttachInternal(pThis, uLUN, fFlags, &pDrv); if (RT_SUCCESS(rc2)) { PHDASTREAM pStream = hdaR3GetStreamFromSink(pThis, &pThis->SinkFront); if (DrvAudioHlpStreamCfgIsValid(&pStream->State.Cfg)) { rc2 = hdaR3UpdateStream(pThis, &pStream->State.Cfg); AssertRC(rc2); } #ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND pStream = hdaR3GetStreamFromSink(pThis, &pThis->SinkCenterLFE); if (DrvAudioHlpStreamCfgIsValid(&pStream->State.Cfg)) { rc2 = hdaR3UpdateStream(pThis, &pStream->State.Cfg); AssertRC(rc2); } pStream = hdaR3GetStreamFromSink(pThis, &pThis->SinkRear); if (DrvAudioHlpStreamCfgIsValid(&pStream->State.Cfg)) { rc2 = hdaR3UpdateStream(pThis, &pStream->State.Cfg); AssertRC(rc2); } #endif pStream = hdaR3GetStreamFromSink(pThis, &pThis->SinkLineIn); if (DrvAudioHlpStreamCfgIsValid(&pStream->State.Cfg)) { rc2 = hdaR3UpdateStream(pThis, &pStream->State.Cfg); AssertRC(rc2); } #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN pStream = hdaR3GetStreamFromSink(pThis, &pThis->SinkMicIn); if (DrvAudioHlpStreamCfgIsValid(&pStream->State.Cfg)) { rc2 = hdaR3UpdateStream(pThis, &pStream->State.Cfg); AssertRC(rc2); } #endif } DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } /** * @interface_method_impl{PDMDEVREG,pfnDetach} */ static DECLCALLBACK(void) hdaR3Detach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); DEVHDA_LOCK(pThis); LogFunc(("uLUN=%u, fFlags=0x%x\n", uLUN, fFlags)); PHDADRIVER pDrv, pDrvNext; RTListForEachSafe(&pThis->lstDrv, pDrv, pDrvNext, HDADRIVER, Node) { if (pDrv->uLUN == uLUN) { int rc2 = hdaR3DetachInternal(pThis, pDrv, fFlags); if (RT_SUCCESS(rc2)) { RTMemFree(pDrv); pDrv = NULL; } break; } } DEVHDA_UNLOCK(pThis); } /** * Powers off the device. * * @param pDevIns Device instance to power off. */ static DECLCALLBACK(void) hdaR3PowerOff(PPDMDEVINS pDevIns) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); DEVHDA_LOCK_RETURN_VOID(pThis); LogRel2(("HDA: Powering off ...\n")); /* Ditto goes for the codec, which in turn uses the mixer. */ hdaCodecPowerOff(pThis->pCodec); /* * Note: Destroy the mixer while powering off and *not* in hdaR3Destruct, * giving the mixer the chance to release any references held to * PDM audio streams it maintains. */ if (pThis->pMixer) { AudioMixerDestroy(pThis->pMixer); pThis->pMixer = NULL; } DEVHDA_UNLOCK(pThis); } /** * Re-attaches (replaces) a driver with a new driver. * * This is only used by to attach the Null driver when it failed to attach the * one that was configured. * * @returns VBox status code. * @param pThis Device instance to re-attach driver to. * @param pDrv Driver instance used for attaching to. * If NULL is specified, a new driver will be created and appended * to the driver list. * @param uLUN The logical unit which is being re-detached. * @param pszDriver New driver name to attach. */ static int hdaR3ReattachInternal(PHDASTATE pThis, PHDADRIVER pDrv, uint8_t uLUN, const char *pszDriver) { AssertPtrReturn(pThis, VERR_INVALID_POINTER); AssertPtrReturn(pszDriver, VERR_INVALID_POINTER); int rc; if (pDrv) { rc = hdaR3DetachInternal(pThis, pDrv, 0 /* fFlags */); if (RT_SUCCESS(rc)) rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */); if (RT_FAILURE(rc)) return rc; pDrv = NULL; } PVM pVM = PDMDevHlpGetVM(pThis->pDevInsR3); PCFGMNODE pRoot = CFGMR3GetRoot(pVM); PCFGMNODE pDev0 = CFGMR3GetChild(pRoot, "Devices/hda/0/"); /* Remove LUN branch. */ CFGMR3RemoveNode(CFGMR3GetChildF(pDev0, "LUN#%u/", uLUN)); #define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; } do { PCFGMNODE pLunL0; rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", uLUN); RC_CHECK(); rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK(); rc = CFGMR3InsertNode(pLunL0, "Config/", NULL); RC_CHECK(); PCFGMNODE pLunL1, pLunL2; rc = CFGMR3InsertNode (pLunL0, "AttachedDriver/", &pLunL1); RC_CHECK(); rc = CFGMR3InsertNode (pLunL1, "Config/", &pLunL2); RC_CHECK(); rc = CFGMR3InsertString(pLunL1, "Driver", pszDriver); RC_CHECK(); rc = CFGMR3InsertString(pLunL2, "AudioDriver", pszDriver); RC_CHECK(); } while (0); if (RT_SUCCESS(rc)) rc = hdaR3AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */); LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, uLUN, pszDriver, rc)); #undef RC_CHECK return rc; } /** * @interface_method_impl{PDMDEVREG,pfnReset} */ static DECLCALLBACK(void) hdaR3Reset(PPDMDEVINS pDevIns) { PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); LogFlowFuncEnter(); DEVHDA_LOCK_RETURN_VOID(pThis); /* * 18.2.6,7 defines that values of this registers might be cleared on power on/reset * hdaR3Reset shouldn't affects these registers. */ HDA_REG(pThis, WAKEEN) = 0x0; hdaR3GCTLReset(pThis); /* Indicate that HDA is not in reset. The firmware is supposed to (un)reset HDA, * but we can take a shortcut. */ HDA_REG(pThis, GCTL) = HDA_GCTL_CRST; DEVHDA_UNLOCK(pThis); } /** * @interface_method_impl{PDMDEVREG,pfnRelocate} */ static DECLCALLBACK(void) hdaR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) { NOREF(offDelta); PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); } /** * @interface_method_impl{PDMDEVREG,pfnDestruct} */ static DECLCALLBACK(int) hdaR3Destruct(PPDMDEVINS pDevIns) { PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); /* this shall come first */ PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); DEVHDA_LOCK(pThis); /** @todo r=bird: this will fail on early constructor failure. */ PHDADRIVER pDrv; while (!RTListIsEmpty(&pThis->lstDrv)) { pDrv = RTListGetFirst(&pThis->lstDrv, HDADRIVER, Node); RTListNodeRemove(&pDrv->Node); RTMemFree(pDrv); } if (pThis->pCodec) { hdaCodecDestruct(pThis->pCodec); RTMemFree(pThis->pCodec); pThis->pCodec = NULL; } RTMemFree(pThis->pu32CorbBuf); pThis->pu32CorbBuf = NULL; RTMemFree(pThis->pu64RirbBuf); pThis->pu64RirbBuf = NULL; for (uint8_t i = 0; i < HDA_MAX_STREAMS; i++) hdaR3StreamDestroy(&pThis->aStreams[i]); DEVHDA_UNLOCK(pThis); return VINF_SUCCESS; } /** * @interface_method_impl{PDMDEVREG,pfnConstruct} */ static DECLCALLBACK(int) hdaR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) { PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); /* this shall come first */ PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); Assert(iInstance == 0); RT_NOREF(iInstance); /* * Initialize the state sufficently to make the destructor work. */ pThis->uAlignmentCheckMagic = HDASTATE_ALIGNMENT_CHECK_MAGIC; RTListInit(&pThis->lstDrv); /** @todo r=bird: There are probably other things which should be * initialized here before we start failing. */ /* * Validations. */ if (!CFGMR3AreValuesValid(pCfg, "RZEnabled\0" "TimerHz\0" "PosAdjustEnabled\0" "PosAdjustFrames\0" "DebugEnabled\0" "DebugPathOut\0")) { return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES, N_ ("Invalid configuration for the Intel HDA device")); } int rc = CFGMR3QueryBoolDef(pCfg, "RZEnabled", &pThis->fRZEnabled, true); if (RT_FAILURE(rc)) return PDMDEV_SET_ERROR(pDevIns, rc, N_("HDA configuration error: failed to read RCEnabled as boolean")); rc = CFGMR3QueryU16Def(pCfg, "TimerHz", &pThis->u16TimerHz, HDA_TIMER_HZ_DEFAULT /* Default value, if not set. */); if (RT_FAILURE(rc)) return PDMDEV_SET_ERROR(pDevIns, rc, N_("HDA configuration error: failed to read Hertz (Hz) rate as unsigned integer")); if (pThis->u16TimerHz != HDA_TIMER_HZ_DEFAULT) LogRel(("HDA: Using custom device timer rate (%RU16Hz)\n", pThis->u16TimerHz)); rc = CFGMR3QueryBoolDef(pCfg, "PosAdjustEnabled", &pThis->fPosAdjustEnabled, true); if (RT_FAILURE(rc)) return PDMDEV_SET_ERROR(pDevIns, rc, N_("HDA configuration error: failed to read position adjustment enabled as boolean")); if (!pThis->fPosAdjustEnabled) LogRel(("HDA: Position adjustment is disabled\n")); rc = CFGMR3QueryU16Def(pCfg, "PosAdjustFrames", &pThis->cPosAdjustFrames, HDA_POS_ADJUST_DEFAULT); if (RT_FAILURE(rc)) return PDMDEV_SET_ERROR(pDevIns, rc, N_("HDA configuration error: failed to read position adjustment frames as unsigned integer")); if (pThis->cPosAdjustFrames) LogRel(("HDA: Using custom position adjustment (%RU16 audio frames)\n", pThis->cPosAdjustFrames)); rc = CFGMR3QueryBoolDef(pCfg, "DebugEnabled", &pThis->Dbg.fEnabled, false); if (RT_FAILURE(rc)) return PDMDEV_SET_ERROR(pDevIns, rc, N_("HDA configuration error: failed to read debugging enabled flag as boolean")); rc = CFGMR3QueryStringDef(pCfg, "DebugPathOut", pThis->Dbg.szOutPath, sizeof(pThis->Dbg.szOutPath), VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH); if (RT_FAILURE(rc)) return PDMDEV_SET_ERROR(pDevIns, rc, N_("HDA configuration error: failed to read debugging output path flag as string")); if (!strlen(pThis->Dbg.szOutPath)) RTStrPrintf(pThis->Dbg.szOutPath, sizeof(pThis->Dbg.szOutPath), VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH); if (pThis->Dbg.fEnabled) LogRel2(("HDA: Debug output will be saved to '%s'\n", pThis->Dbg.szOutPath)); /* * Use an own critical section for the device instead of the default * one provided by PDM. This allows fine-grained locking in combination * with TM when timer-specific stuff is being called in e.g. the MMIO handlers. */ rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSect, RT_SRC_POS, "HDA"); AssertRCReturn(rc, rc); rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns)); AssertRCReturn(rc, rc); /* * Initialize data (most of it anyway). */ pThis->pDevInsR3 = pDevIns; pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); /* IBase */ pThis->IBase.pfnQueryInterface = hdaR3QueryInterface; /* PCI Device */ PCIDevSetVendorId (&pThis->PciDev, HDA_PCI_VENDOR_ID); /* nVidia */ PCIDevSetDeviceId (&pThis->PciDev, HDA_PCI_DEVICE_ID); /* HDA */ PCIDevSetCommand (&pThis->PciDev, 0x0000); /* 04 rw,ro - pcicmd. */ PCIDevSetStatus (&pThis->PciDev, VBOX_PCI_STATUS_CAP_LIST); /* 06 rwc?,ro? - pcists. */ PCIDevSetRevisionId (&pThis->PciDev, 0x01); /* 08 ro - rid. */ PCIDevSetClassProg (&pThis->PciDev, 0x00); /* 09 ro - pi. */ PCIDevSetClassSub (&pThis->PciDev, 0x03); /* 0a ro - scc; 03 == HDA. */ PCIDevSetClassBase (&pThis->PciDev, 0x04); /* 0b ro - bcc; 04 == multimedia. */ PCIDevSetHeaderType (&pThis->PciDev, 0x00); /* 0e ro - headtyp. */ PCIDevSetBaseAddress (&pThis->PciDev, 0, /* 10 rw - MMIO */ false /* fIoSpace */, false /* fPrefetchable */, true /* f64Bit */, 0x00000000); PCIDevSetInterruptLine (&pThis->PciDev, 0x00); /* 3c rw. */ PCIDevSetInterruptPin (&pThis->PciDev, 0x01); /* 3d ro - INTA#. */ #if defined(HDA_AS_PCI_EXPRESS) PCIDevSetCapabilityList (&pThis->PciDev, 0x80); #elif defined(VBOX_WITH_MSI_DEVICES) PCIDevSetCapabilityList (&pThis->PciDev, 0x60); #else PCIDevSetCapabilityList (&pThis->PciDev, 0x50); /* ICH6 datasheet 18.1.16 */ #endif /// @todo r=michaln: If there are really no PCIDevSetXx for these, the meaning /// of these values needs to be properly documented! /* HDCTL off 0x40 bit 0 selects signaling mode (1-HDA, 0 - Ac97) 18.1.19 */ PCIDevSetByte(&pThis->PciDev, 0x40, 0x01); /* Power Management */ PCIDevSetByte(&pThis->PciDev, 0x50 + 0, VBOX_PCI_CAP_ID_PM); PCIDevSetByte(&pThis->PciDev, 0x50 + 1, 0x0); /* next */ PCIDevSetWord(&pThis->PciDev, 0x50 + 2, VBOX_PCI_PM_CAP_DSI | 0x02 /* version, PM1.1 */ ); #ifdef HDA_AS_PCI_EXPRESS /* PCI Express */ PCIDevSetByte(&pThis->PciDev, 0x80 + 0, VBOX_PCI_CAP_ID_EXP); /* PCI_Express */ PCIDevSetByte(&pThis->PciDev, 0x80 + 1, 0x60); /* next */ /* Device flags */ PCIDevSetWord(&pThis->PciDev, 0x80 + 2, /* version */ 0x1 | /* Root Complex Integrated Endpoint */ (VBOX_PCI_EXP_TYPE_ROOT_INT_EP << 4) | /* MSI */ (100) << 9 ); /* Device capabilities */ PCIDevSetDWord(&pThis->PciDev, 0x80 + 4, VBOX_PCI_EXP_DEVCAP_FLRESET); /* Device control */ PCIDevSetWord( &pThis->PciDev, 0x80 + 8, 0); /* Device status */ PCIDevSetWord( &pThis->PciDev, 0x80 + 10, 0); /* Link caps */ PCIDevSetDWord(&pThis->PciDev, 0x80 + 12, 0); /* Link control */ PCIDevSetWord( &pThis->PciDev, 0x80 + 16, 0); /* Link status */ PCIDevSetWord( &pThis->PciDev, 0x80 + 18, 0); /* Slot capabilities */ PCIDevSetDWord(&pThis->PciDev, 0x80 + 20, 0); /* Slot control */ PCIDevSetWord( &pThis->PciDev, 0x80 + 24, 0); /* Slot status */ PCIDevSetWord( &pThis->PciDev, 0x80 + 26, 0); /* Root control */ PCIDevSetWord( &pThis->PciDev, 0x80 + 28, 0); /* Root capabilities */ PCIDevSetWord( &pThis->PciDev, 0x80 + 30, 0); /* Root status */ PCIDevSetDWord(&pThis->PciDev, 0x80 + 32, 0); /* Device capabilities 2 */ PCIDevSetDWord(&pThis->PciDev, 0x80 + 36, 0); /* Device control 2 */ PCIDevSetQWord(&pThis->PciDev, 0x80 + 40, 0); /* Link control 2 */ PCIDevSetQWord(&pThis->PciDev, 0x80 + 48, 0); /* Slot control 2 */ PCIDevSetWord( &pThis->PciDev, 0x80 + 56, 0); #endif /* * Register the PCI device. */ rc = PDMDevHlpPCIRegister(pDevIns, &pThis->PciDev); if (RT_FAILURE(rc)) return rc; rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 0x4000, PCI_ADDRESS_SPACE_MEM, hdaR3PciIoRegionMap); if (RT_FAILURE(rc)) return rc; #ifdef VBOX_WITH_MSI_DEVICES PDMMSIREG MsiReg; RT_ZERO(MsiReg); MsiReg.cMsiVectors = 1; MsiReg.iMsiCapOffset = 0x60; MsiReg.iMsiNextOffset = 0x50; rc = PDMDevHlpPCIRegisterMsi(pDevIns, &MsiReg); if (RT_FAILURE(rc)) { /* That's OK, we can work without MSI */ PCIDevSetCapabilityList(&pThis->PciDev, 0x50); } #endif rc = PDMDevHlpSSMRegister(pDevIns, HDA_SSM_VERSION, sizeof(*pThis), hdaR3SaveExec, hdaR3LoadExec); if (RT_FAILURE(rc)) return rc; #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO LogRel(("HDA: Asynchronous I/O enabled\n")); #endif uint8_t uLUN; for (uLUN = 0; uLUN < UINT8_MAX; ++uLUN) { LogFunc(("Trying to attach driver for LUN #%RU32 ...\n", uLUN)); rc = hdaR3AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */); if (RT_FAILURE(rc)) { if (rc == VERR_PDM_NO_ATTACHED_DRIVER) rc = VINF_SUCCESS; else if (rc == VERR_AUDIO_BACKEND_INIT_FAILED) { hdaR3ReattachInternal(pThis, NULL /* pDrv */, uLUN, "NullAudio"); PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", N_("Host audio backend initialization has failed. Selecting the NULL audio backend " "with the consequence that no sound is audible")); /* Attaching to the NULL audio backend will never fail. */ rc = VINF_SUCCESS; } break; } } LogFunc(("cLUNs=%RU8, rc=%Rrc\n", uLUN, rc)); if (RT_SUCCESS(rc)) { rc = AudioMixerCreate("HDA Mixer", 0 /* uFlags */, &pThis->pMixer); if (RT_SUCCESS(rc)) { /* * Add mixer output sinks. */ #ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND rc = AudioMixerCreateSink(pThis->pMixer, "[Playback] Front", AUDMIXSINKDIR_OUTPUT, &pThis->SinkFront.pMixSink); AssertRC(rc); rc = AudioMixerCreateSink(pThis->pMixer, "[Playback] Center / Subwoofer", AUDMIXSINKDIR_OUTPUT, &pThis->SinkCenterLFE.pMixSink); AssertRC(rc); rc = AudioMixerCreateSink(pThis->pMixer, "[Playback] Rear", AUDMIXSINKDIR_OUTPUT, &pThis->SinkRear.pMixSink); AssertRC(rc); #else rc = AudioMixerCreateSink(pThis->pMixer, "[Playback] PCM Output", AUDMIXSINKDIR_OUTPUT, &pThis->SinkFront.pMixSink); AssertRC(rc); #endif /* * Add mixer input sinks. */ rc = AudioMixerCreateSink(pThis->pMixer, "[Recording] Line In", AUDMIXSINKDIR_INPUT, &pThis->SinkLineIn.pMixSink); AssertRC(rc); #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN rc = AudioMixerCreateSink(pThis->pMixer, "[Recording] Microphone In", AUDMIXSINKDIR_INPUT, &pThis->SinkMicIn.pMixSink); AssertRC(rc); #endif /* There is no master volume control. Set the master to max. */ PDMAUDIOVOLUME vol = { false, 255, 255 }; rc = AudioMixerSetMasterVolume(pThis->pMixer, &vol); AssertRC(rc); } } if (RT_SUCCESS(rc)) { /* Allocate CORB buffer. */ pThis->cbCorbBuf = HDA_CORB_SIZE * HDA_CORB_ELEMENT_SIZE; pThis->pu32CorbBuf = (uint32_t *)RTMemAllocZ(pThis->cbCorbBuf); if (pThis->pu32CorbBuf) { /* Allocate RIRB buffer. */ pThis->cbRirbBuf = HDA_RIRB_SIZE * HDA_RIRB_ELEMENT_SIZE; pThis->pu64RirbBuf = (uint64_t *)RTMemAllocZ(pThis->cbRirbBuf); if (pThis->pu64RirbBuf) { /* Allocate codec. */ pThis->pCodec = (PHDACODEC)RTMemAllocZ(sizeof(HDACODEC)); if (!pThis->pCodec) rc = PDMDEV_SET_ERROR(pDevIns, VERR_NO_MEMORY, N_("Out of memory allocating HDA codec state")); } else rc = PDMDEV_SET_ERROR(pDevIns, VERR_NO_MEMORY, N_("Out of memory allocating RIRB")); } else rc = PDMDEV_SET_ERROR(pDevIns, VERR_NO_MEMORY, N_("Out of memory allocating CORB")); if (RT_SUCCESS(rc)) { /* Set codec callbacks to this controller. */ pThis->pCodec->pfnCbMixerAddStream = hdaR3MixerAddStream; pThis->pCodec->pfnCbMixerRemoveStream = hdaR3MixerRemoveStream; pThis->pCodec->pfnCbMixerControl = hdaR3MixerControl; pThis->pCodec->pfnCbMixerSetVolume = hdaR3MixerSetVolume; pThis->pCodec->pHDAState = pThis; /* Assign HDA controller state to codec. */ /* Construct the codec. */ rc = hdaCodecConstruct(pDevIns, pThis->pCodec, 0 /* Codec index */, pCfg); if (RT_FAILURE(rc)) AssertRCReturn(rc, rc); /* ICH6 datasheet defines 0 values for SVID and SID (18.1.14-15), which together with values returned for verb F20 should provide device/codec recognition. */ Assert(pThis->pCodec->u16VendorId); Assert(pThis->pCodec->u16DeviceId); PCIDevSetSubSystemVendorId(&pThis->PciDev, pThis->pCodec->u16VendorId); /* 2c ro - intel.) */ PCIDevSetSubSystemId( &pThis->PciDev, pThis->pCodec->u16DeviceId); /* 2e ro. */ } } if (RT_SUCCESS(rc)) { /* * Create all hardware streams. */ for (uint8_t i = 0; i < HDA_MAX_STREAMS; ++i) { /* Create the emulation timer (per stream). * * Note: Use TMCLOCK_VIRTUAL_SYNC here, as the guest's HDA driver * relies on exact (virtual) DMA timing and uses DMA Position Buffers * instead of the LPIB registers. */ char szTimer[16]; RTStrPrintf2(szTimer, sizeof(szTimer), "HDA SD%RU8", i); rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, hdaR3Timer, &pThis->aStreams[i], TMTIMER_FLAGS_NO_CRIT_SECT, szTimer, &pThis->pTimer[i]); AssertRCReturn(rc, rc); /* Use our own critcal section for the device timer. * That way we can control more fine-grained when to lock what. */ rc = TMR3TimerSetCritSect(pThis->pTimer[i], &pThis->CritSect); AssertRCReturn(rc, rc); rc = hdaR3StreamCreate(&pThis->aStreams[i], pThis, i /* u8SD */); AssertRC(rc); } #ifdef VBOX_WITH_AUDIO_HDA_ONETIME_INIT /* * Initialize the driver chain. */ PHDADRIVER pDrv; RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) { /* * Only primary drivers are critical for the VM to run. Everything else * might not worth showing an own error message box in the GUI. */ if (!(pDrv->fFlags & PDMAUDIODRVFLAGS_PRIMARY)) continue; PPDMIAUDIOCONNECTOR pCon = pDrv->pConnector; AssertPtr(pCon); bool fValidLineIn = AudioMixerStreamIsValid(pDrv->LineIn.pMixStrm); # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN bool fValidMicIn = AudioMixerStreamIsValid(pDrv->MicIn.pMixStrm); # endif bool fValidOut = AudioMixerStreamIsValid(pDrv->Front.pMixStrm); # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND /** @todo Anything to do here? */ # endif if ( !fValidLineIn # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN && !fValidMicIn # endif && !fValidOut) { LogRel(("HDA: Falling back to NULL backend (no sound audible)\n")); hdaR3Reset(pDevIns); hdaR3ReattachInternal(pThis, pDrv, pDrv->uLUN, "NullAudio"); PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", N_("No audio devices could be opened. Selecting the NULL audio backend " "with the consequence that no sound is audible")); } else { bool fWarn = false; PDMAUDIOBACKENDCFG backendCfg; int rc2 = pCon->pfnGetConfig(pCon, &backendCfg); if (RT_SUCCESS(rc2)) { if (backendCfg.cMaxStreamsIn) { # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN /* If the audio backend supports two or more input streams at once, * warn if one of our two inputs (microphone-in and line-in) failed to initialize. */ if (backendCfg.cMaxStreamsIn >= 2) fWarn = !fValidLineIn || !fValidMicIn; /* If the audio backend only supports one input stream at once (e.g. pure ALSA, and * *not* ALSA via PulseAudio plugin!), only warn if both of our inputs failed to initialize. * One of the two simply is not in use then. */ else if (backendCfg.cMaxStreamsIn == 1) fWarn = !fValidLineIn && !fValidMicIn; /* Don't warn if our backend is not able of supporting any input streams at all. */ # else /* !VBOX_WITH_AUDIO_HDA_MIC_IN */ /* We only have line-in as input source. */ fWarn = !fValidLineIn; # endif /* VBOX_WITH_AUDIO_HDA_MIC_IN */ } if ( !fWarn && backendCfg.cMaxStreamsOut) { fWarn = !fValidOut; } } else { LogRel(("HDA: Unable to retrieve audio backend configuration for LUN #%RU8, rc=%Rrc\n", pDrv->uLUN, rc2)); fWarn = true; } if (fWarn) { char szMissingStreams[255]; size_t len = 0; if (!fValidLineIn) { LogRel(("HDA: WARNING: Unable to open PCM line input for LUN #%RU8!\n", pDrv->uLUN)); len = RTStrPrintf(szMissingStreams, sizeof(szMissingStreams), "PCM Input"); } # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN if (!fValidMicIn) { LogRel(("HDA: WARNING: Unable to open PCM microphone input for LUN #%RU8!\n", pDrv->uLUN)); len += RTStrPrintf(szMissingStreams + len, sizeof(szMissingStreams) - len, len ? ", PCM Microphone" : "PCM Microphone"); } # endif /* VBOX_WITH_AUDIO_HDA_MIC_IN */ if (!fValidOut) { LogRel(("HDA: WARNING: Unable to open PCM output for LUN #%RU8!\n", pDrv->uLUN)); len += RTStrPrintf(szMissingStreams + len, sizeof(szMissingStreams) - len, len ? ", PCM Output" : "PCM Output"); } PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", N_("Some HDA audio streams (%s) could not be opened. Guest applications generating audio " "output or depending on audio input may hang. Make sure your host audio device " "is working properly. Check the logfile for error messages of the audio " "subsystem"), szMissingStreams); } } } #endif /* VBOX_WITH_AUDIO_HDA_ONETIME_INIT */ } if (RT_SUCCESS(rc)) { hdaR3Reset(pDevIns); /* * Debug and string formatter types. */ PDMDevHlpDBGFInfoRegister(pDevIns, "hda", "HDA info. (hda [register case-insensitive])", hdaR3DbgInfo); PDMDevHlpDBGFInfoRegister(pDevIns, "hdabdle", "HDA stream BDLE info. (hdabdle [stream number])", hdaR3DbgInfoBDLE); PDMDevHlpDBGFInfoRegister(pDevIns, "hdastream", "HDA stream info. (hdastream [stream number])", hdaR3DbgInfoStream); PDMDevHlpDBGFInfoRegister(pDevIns, "hdcnodes", "HDA codec nodes.", hdaR3DbgInfoCodecNodes); PDMDevHlpDBGFInfoRegister(pDevIns, "hdcselector", "HDA codec's selector states [node number].", hdaR3DbgInfoCodecSelector); PDMDevHlpDBGFInfoRegister(pDevIns, "hdamixer", "HDA mixer state.", hdaR3DbgInfoMixer); rc = RTStrFormatTypeRegister("bdle", hdaR3StrFmtBDLE, NULL); AssertRC(rc); rc = RTStrFormatTypeRegister("sdctl", hdaR3StrFmtSDCTL, NULL); AssertRC(rc); rc = RTStrFormatTypeRegister("sdsts", hdaR3StrFmtSDSTS, NULL); AssertRC(rc); rc = RTStrFormatTypeRegister("sdfifos", hdaR3StrFmtSDFIFOS, NULL); AssertRC(rc); rc = RTStrFormatTypeRegister("sdfifow", hdaR3StrFmtSDFIFOW, NULL); AssertRC(rc); /* * Some debug assertions. */ for (unsigned i = 0; i < RT_ELEMENTS(g_aHdaRegMap); i++) { struct HDAREGDESC const *pReg = &g_aHdaRegMap[i]; struct HDAREGDESC const *pNextReg = i + 1 < RT_ELEMENTS(g_aHdaRegMap) ? &g_aHdaRegMap[i + 1] : NULL; /* binary search order. */ AssertReleaseMsg(!pNextReg || pReg->offset + pReg->size <= pNextReg->offset, ("[%#x] = {%#x LB %#x} vs. [%#x] = {%#x LB %#x}\n", i, pReg->offset, pReg->size, i + 1, pNextReg->offset, pNextReg->size)); /* alignment. */ AssertReleaseMsg( pReg->size == 1 || (pReg->size == 2 && (pReg->offset & 1) == 0) || (pReg->size == 3 && (pReg->offset & 3) == 0) || (pReg->size == 4 && (pReg->offset & 3) == 0), ("[%#x] = {%#x LB %#x}\n", i, pReg->offset, pReg->size)); /* registers are packed into dwords - with 3 exceptions with gaps at the end of the dword. */ AssertRelease(((pReg->offset + pReg->size) & 3) == 0 || pNextReg); if (pReg->offset & 3) { struct HDAREGDESC const *pPrevReg = i > 0 ? &g_aHdaRegMap[i - 1] : NULL; AssertReleaseMsg(pPrevReg, ("[%#x] = {%#x LB %#x}\n", i, pReg->offset, pReg->size)); if (pPrevReg) AssertReleaseMsg(pPrevReg->offset + pPrevReg->size == pReg->offset, ("[%#x] = {%#x LB %#x} vs. [%#x] = {%#x LB %#x}\n", i - 1, pPrevReg->offset, pPrevReg->size, i + 1, pReg->offset, pReg->size)); } #if 0 if ((pReg->offset + pReg->size) & 3) { AssertReleaseMsg(pNextReg, ("[%#x] = {%#x LB %#x}\n", i, pReg->offset, pReg->size)); if (pNextReg) AssertReleaseMsg(pReg->offset + pReg->size == pNextReg->offset, ("[%#x] = {%#x LB %#x} vs. [%#x] = {%#x LB %#x}\n", i, pReg->offset, pReg->size, i + 1, pNextReg->offset, pNextReg->size)); } #endif /* The final entry is a full DWORD, no gaps! Allows shortcuts. */ AssertReleaseMsg(pNextReg || ((pReg->offset + pReg->size) & 3) == 0, ("[%#x] = {%#x LB %#x}\n", i, pReg->offset, pReg->size)); } } # ifdef VBOX_WITH_STATISTICS if (RT_SUCCESS(rc)) { /* * Register statistics. */ PDMDevHlpSTAMRegister(pDevIns, &pThis->StatTimer, STAMTYPE_PROFILE, "/Devices/HDA/Timer", STAMUNIT_TICKS_PER_CALL, "Profiling hdaR3Timer."); PDMDevHlpSTAMRegister(pDevIns, &pThis->StatIn, STAMTYPE_PROFILE, "/Devices/HDA/Input", STAMUNIT_TICKS_PER_CALL, "Profiling input."); PDMDevHlpSTAMRegister(pDevIns, &pThis->StatOut, STAMTYPE_PROFILE, "/Devices/HDA/Output", STAMUNIT_TICKS_PER_CALL, "Profiling output."); PDMDevHlpSTAMRegister(pDevIns, &pThis->StatBytesRead, STAMTYPE_COUNTER, "/Devices/HDA/BytesRead" , STAMUNIT_BYTES, "Bytes read from HDA emulation."); PDMDevHlpSTAMRegister(pDevIns, &pThis->StatBytesWritten, STAMTYPE_COUNTER, "/Devices/HDA/BytesWritten", STAMUNIT_BYTES, "Bytes written to HDA emulation."); } # endif LogFlowFuncLeaveRC(rc); return rc; } /** * The device registration structure. */ const PDMDEVREG g_DeviceHDA = { /* u32Version */ PDM_DEVREG_VERSION, /* szName */ "hda", /* szRCMod */ "VBoxDDRC.rc", /* szR0Mod */ "VBoxDDR0.r0", /* pszDescription */ "Intel HD Audio Controller", /* fFlags */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0, /* fClass */ PDM_DEVREG_CLASS_AUDIO, /* cMaxInstances */ 1, /* cbInstance */ sizeof(HDASTATE), /* pfnConstruct */ hdaR3Construct, /* pfnDestruct */ hdaR3Destruct, /* pfnRelocate */ hdaR3Relocate, /* pfnMemSetup */ NULL, /* pfnPowerOn */ NULL, /* pfnReset */ hdaR3Reset, /* pfnSuspend */ NULL, /* pfnResume */ NULL, /* pfnAttach */ hdaR3Attach, /* pfnDetach */ hdaR3Detach, /* pfnQueryInterface. */ NULL, /* pfnInitComplete */ NULL, /* pfnPowerOff */ hdaR3PowerOff, /* pfnSoftReset */ NULL, /* u32VersionEnd */ PDM_DEVREG_VERSION }; #endif /* IN_RING3 */ #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
36.351266
210
0.595126
roughk
cb288eb1f968c86b8b67164743a542a058b9c6f1
3,376
hpp
C++
include/boost/application/detail/posix/path_impl.hpp
mlegenovic/Boost.Application
e69d4926027274dadb7d89c45964ddafa1edd7f5
[ "BSL-1.0" ]
null
null
null
include/boost/application/detail/posix/path_impl.hpp
mlegenovic/Boost.Application
e69d4926027274dadb7d89c45964ddafa1edd7f5
[ "BSL-1.0" ]
null
null
null
include/boost/application/detail/posix/path_impl.hpp
mlegenovic/Boost.Application
e69d4926027274dadb7d89c45964ddafa1edd7f5
[ "BSL-1.0" ]
null
null
null
// Copyright 2014 Renato Tegon Forti // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_APPLICATION_DETAIL_POSIX_PATH_FROM_ME_HPP #define BOOST_APPLICATION_DETAIL_POSIX_PATH_FROM_ME_HPP #include <boost/application/config.hpp> #include <boost/predef/os.h> #include <filesystem> #include <system_error> #include <cstdlib> #include <pwd.h> #include <unistd.h> #ifdef BOOST_HAS_PRAGMA_ONCE # pragma once #endif namespace boost::application::detail { class default_path_impl { std::filesystem::path full_path_; std::filesystem::path path_from_me(std::error_code &ec) { return std::filesystem::read_symlink("/proc/self/exe", ec); } std::filesystem::path getenv(const char* env_name) { const char* res = ::getenv(env_name); return res ? res : std::filesystem::path(); } public: std::filesystem::path current_path() { return std::filesystem::current_path(); } const std::filesystem::path& location(std::error_code &ec) { if(!full_path_.empty()) return full_path_; std::filesystem::path full_path = path_from_me(ec); if(ec) full_path_ = std::filesystem::path(); full_path_ = full_path; return full_path_; } const std::filesystem::path& location() { if(!full_path_.empty()) return full_path_; std::error_code ec; full_path_ = location(ec); if (ec) { boost::throw_exception( std::system_error( ec, "location() failed" )); } return full_path_; } inline std::filesystem::path home_path() { std::filesystem::path path = getenv("HOME"); if(path.empty()) { struct passwd* pwd = getpwuid(getuid()); if(pwd) return pwd->pw_dir; return "."; } return path; } inline std::filesystem::path app_data_path() { std::filesystem::path path = getenv("XDG_DATA_HOME"); if(path.empty()) { #if BOOST_OS_MACOS return home_path() / "Library/Preferences/"; #else return home_path() / ".local/share"; #endif } return path; } inline std::filesystem::path config_path() { std::filesystem::path path = getenv("XDG_CONFIG_HOME"); if(path.empty()) { #if BOOST_OS_MACOS return home_path() / "Library/Preferences/"; #else return home_path() / ".config"; #endif } return path; } inline std::filesystem::path temp_path() { std::filesystem::path path = getenv("TMPDIR"); if(path.empty()) return "/tmp"; // Fallback if TMPDIR not available return path; } }; } // namespace boost::application::detail #endif // BOOST_APPLICATION_DETAIL_POSIX_PATH_FROM_ME_HPP
25.575758
71
0.534656
mlegenovic
cb29e7e9b4f4ea40ec91653b818bad6bada86e65
3,316
cpp
C++
M3ScriptHook/src/LuaStateManager.cpp
MartinJK/Mafia3ScriptHook
b27da0dfcc93118aa4eb5c45a82d0ddf70205bfc
[ "MIT" ]
10
2016-10-09T19:23:18.000Z
2019-03-20T21:10:48.000Z
M3ScriptHook/src/LuaStateManager.cpp
MartinJK/Mafia3ScriptHook
b27da0dfcc93118aa4eb5c45a82d0ddf70205bfc
[ "MIT" ]
5
2016-10-12T01:55:32.000Z
2017-05-31T09:50:19.000Z
M3ScriptHook/src/LuaStateManager.cpp
MartinJK/Mafia3ScriptHook
b27da0dfcc93118aa4eb5c45a82d0ddf70205bfc
[ "MIT" ]
5
2016-10-20T21:51:22.000Z
2018-11-25T22:42:58.000Z
// Base Application taken from Klusark (GPLv2) // https://code.google.com/archive/p/mafia2injector/ /* * Copyright (c) 2010 Barzakh (martinjk 'at' outlook 'dot' com) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source * distribution. * 4. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include <LuaStateManager.h> #include <Windows.h> #include <LuaFunctions.h> #include <M3ScriptHook.h> #include <ScriptSystem.h> #include <chrono> #include <thread> LuaStateManager::LuaStateManager() { m_pLuaState = nullptr; m_bEnded = false; } LuaStateManager::~LuaStateManager() { m_bEnded = true; } void LuaStateManager::StartThread() { M3ScriptHook::instance()->Log(__FUNCTION__); CreateThread(0, 0, (LPTHREAD_START_ROUTINE)LuaStateManager::WatcherThread, 0, 0, 0); } void LuaStateManager::StateChanged(lua_State *L) { M3ScriptHook::instance()->Log(__FUNCTION__); ++this->m_stateChangeCount; this->m_pLuaState = L; LuaFunctions::instance()->Setup(); this->m_stateChangeCount == 1 ? PluginSystem::instance()->StartPlugins() :PluginSystem::instance()->RelaunchPlugins(); ScriptSystem::instance()->ReloadScripts(); } lua_State* LuaStateManager::GetState() { if (this->m_pLuaState) { return lua_newthread_(this->m_pLuaState); } else { return nullptr; } } bool LuaStateManager::IsStateGood(lua_State *L) { return L != nullptr; } bool LuaStateManager::HasEnded() { return this->m_bEnded; } uint32_t WINAPI LuaStateManager::WatcherThread(LPVOID) { do { std::this_thread::sleep_for(std::chrono::seconds(1)); } while (!LuaFunctions::instance()->IsMainScriptMachineReady()); static lua_State *lastState = nullptr; static C_ScriptGameMachine *machine = nullptr; static LuaStateManager *instance = LuaStateManager::instance(); while (!instance->HasEnded()) { lua_State* nstate = GetL(machine); if (nstate != lastState && nstate) { instance->StateChanged(nstate); lastState = nstate; } std::this_thread::sleep_for(std::chrono::seconds(10)); std::this_thread::yield(); } return 0; }
29.345133
119
0.741255
MartinJK
cb2c4f1e3c5b0b085e6b46dc11719ad005c3738d
2,039
cpp
C++
libraries/render/src/task/Config.cpp
alphaversiond/hifi
735944c912a29e948a557dbff13e0a1cb71d954e
[ "Apache-2.0" ]
2
2018-05-07T16:12:38.000Z
2019-04-28T17:32:01.000Z
libraries/render/src/task/Config.cpp
alphaversiond/hifi
735944c912a29e948a557dbff13e0a1cb71d954e
[ "Apache-2.0" ]
null
null
null
libraries/render/src/task/Config.cpp
alphaversiond/hifi
735944c912a29e948a557dbff13e0a1cb71d954e
[ "Apache-2.0" ]
null
null
null
// // Config.cpp // render/src/task // // Created by Zach Pomerantz on 1/21/2016. // Copyright 2016 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "Config.h" #include "Task.h" #include <QtCore/QThread> using namespace task; void JobConfig::setPresetList(const QJsonObject& object) { for (auto it = object.begin(); it != object.end(); it++) { JobConfig* child = findChild<JobConfig*>(it.key(), Qt::FindDirectChildrenOnly); if (child) { child->setPresetList(it.value().toObject()); } } } void TaskConfig::connectChildConfig(QConfigPointer childConfig, const std::string& name) { childConfig->setParent(this); childConfig->setObjectName(name.c_str()); // Connect loaded->refresh QObject::connect(childConfig.get(), SIGNAL(loaded()), this, SLOT(refresh())); static const char* DIRTY_SIGNAL = "dirty()"; if (childConfig->metaObject()->indexOfSignal(DIRTY_SIGNAL) != -1) { // Connect dirty->refresh if defined QObject::connect(childConfig.get(), SIGNAL(dirty()), this, SLOT(refresh())); } } void TaskConfig::transferChildrenConfigs(QConfigPointer source) { if (!source) { return; } // Transfer children to the new configuration auto children = source->children(); for (auto& child : children) { child->setParent(this); QObject::connect(child, SIGNAL(loaded()), this, SLOT(refresh())); static const char* DIRTY_SIGNAL = "dirty()"; if (child->metaObject()->indexOfSignal(DIRTY_SIGNAL) != -1) { // Connect dirty->refresh if defined QObject::connect(child, SIGNAL(dirty()), this, SLOT(refresh())); } } } void TaskConfig::refresh() { if (QThread::currentThread() != thread()) { QMetaObject::invokeMethod(this, "refresh", Qt::BlockingQueuedConnection); return; } _task->applyConfiguration(); }
30.893939
90
0.642472
alphaversiond
cb2cb1a3ac7831ef9ceb690cd3bb8be97e3988a9
271
hpp
C++
ResInt.hpp
afarsitio5/javafar-14.github.io
6378758230c1f3ef524d0f7e4b8f32a5660d59b7
[ "CC0-1.0" ]
null
null
null
ResInt.hpp
afarsitio5/javafar-14.github.io
6378758230c1f3ef524d0f7e4b8f32a5660d59b7
[ "CC0-1.0" ]
null
null
null
ResInt.hpp
afarsitio5/javafar-14.github.io
6378758230c1f3ef524d0f7e4b8f32a5660d59b7
[ "CC0-1.0" ]
1
2021-04-07T23:06:03.000Z
2021-04-07T23:06:03.000Z
#ifndef __RES_INT_H__ #define __RES_INT_H__ #include <Arduino.h> class ResInt { public: const int valor; const String error; ResInt(int _valor, String _error ); ResInt(const ResInt& ref ); const char* valida(); }; #endif
16.9375
32
0.612546
afarsitio5
cb312d165ce42f9aa367f53077e484d706e1ba2e
1,081
cpp
C++
Stadium_Seating.cpp
MigPug/C-Plus-Plus
53241378ded0adc509c32abb64cbfc780d7165f3
[ "Apache-2.0" ]
1
2020-12-03T05:17:00.000Z
2020-12-03T05:17:00.000Z
Stadium_Seating.cpp
MigPug/Code
53241378ded0adc509c32abb64cbfc780d7165f3
[ "Apache-2.0" ]
null
null
null
Stadium_Seating.cpp
MigPug/Code
53241378ded0adc509c32abb64cbfc780d7165f3
[ "Apache-2.0" ]
1
2022-01-30T06:11:59.000Z
2022-01-30T06:11:59.000Z
/* Stadium Seating There are three seating categories at a stadium . For a softball game, Class A seats cost $15, Class B seats cost $12, and Class C seats cost $9. Write a program that asks how many tickets for each class of seats were sold, then displays the amount of income generated from ticket sales. Format your dollar amount in a fixed-point notation with two decimal points and make sure the decimal point is always displayed. */ #include <iostream> #include <iomanip> #include <string> using namespace std; int main() { double seatsA = 0, seatsB =0, seatsC = 0, total; cout << "How many seats for Class A were sold? "; cin >> seatsA; seatsA= seatsA * 15; cout << "How many seats for Class B were sold? "; cin >> seatsB; seatsB = seatsB * 12; cout << "How many seats for Class C were sold? "; cin >> seatsC; seatsC = seatsC * 9; total = (seatsA + seatsB + seatsC); cout << setprecision(2) << fixed; cout << "Revenue generated: $" << total << endl; system("pause"); return (0); }
26.365854
92
0.648474
MigPug
cb358c7b84f92119bced642a19a61bcecffcdaaa
6,884
cpp
C++
pin-2.11/source/tools/SignalTests/mtstress.cpp
swchoi1994/Project
e46fa191afe54d6676016d41534c3531eb51ff79
[ "Intel" ]
3
2020-06-26T09:35:19.000Z
2021-01-03T16:58:11.000Z
pin-2.11/source/tools/SignalTests/mtstress.cpp
swchoi1994/Project
e46fa191afe54d6676016d41534c3531eb51ff79
[ "Intel" ]
null
null
null
pin-2.11/source/tools/SignalTests/mtstress.cpp
swchoi1994/Project
e46fa191afe54d6676016d41534c3531eb51ff79
[ "Intel" ]
2
2020-12-27T03:58:38.000Z
2020-12-27T03:58:38.000Z
/*BEGIN_LEGAL Intel Open Source License Copyright (c) 2002-2012 Intel Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. END_LEGAL */ /* * This is a stress test for handling signals in a multi-threaded application. * The root thread creates two classes of worker threads: computers and blockers. * Computers execute a small loop that should run entirely from the Pin code cache * once it is compiled. Blockers iteratively execute a blocking system call. The * root thread randomly sends signals to each of the works as fast as possible. */ #include <cstdlib> #include <iostream> #include <pthread.h> #include <cassert> #include <signal.h> #include <time.h> const unsigned NUM_BLOCKERS = 8; const unsigned NUM_COMPUTERS = 8; const unsigned NUM_SIGNALS = 1000; // The total number of signals received by all threads. // volatile unsigned NumSignalsReceived = 0; pthread_mutex_t SignalReceivedLock = PTHREAD_MUTEX_INITIALIZER; // Information for each worker thread. // struct THREAD_INFO { THREAD_INFO() : _ready(false) { pthread_mutex_init(&_readyLock, 0); pthread_cond_init(&_readyCond, 0); } ~THREAD_INFO() { pthread_cond_destroy(&_readyCond); pthread_mutex_destroy(&_readyLock); } pthread_t _tid; // This is set TRUE when the thread is ready to receive a signal. // bool _ready; pthread_mutex_t _readyLock; pthread_cond_t _readyCond; }; THREAD_INFO *ThreadInfos; // Each thread uses this key to find its own THREAD_INFO. // pthread_key_t MyInfoKey; static void *BlockerRoot(void *); static void *ComputerRoot(void *); static void SetMyInfo(THREAD_INFO *); static void Handle(int); int main() { struct sigaction act; act.sa_handler = Handle; act.sa_flags = 0; sigemptyset(&act.sa_mask); if (sigaction(SIGUSR1, &act, 0) != 0) { std::cerr << "Unable to set SIGUSR1 handler\n"; return 1; } if (pthread_key_create(&MyInfoKey, 0) != 0) { std::cerr << "Unable to create key\n"; return 1; } // Create the worker threads. // ThreadInfos = new THREAD_INFO[NUM_BLOCKERS + NUM_COMPUTERS]; for (unsigned i = 0; i < NUM_BLOCKERS; i++) { THREAD_INFO *info = &ThreadInfos[i]; if (pthread_create(&info->_tid, 0, BlockerRoot, info) != 0) { std::cerr << "Unable to create blocker thread\n"; return 1; } } for (unsigned i = 0; i < NUM_COMPUTERS; i++) { THREAD_INFO *info = &ThreadInfos[NUM_BLOCKERS + i]; if (pthread_create(&info->_tid, 0, ComputerRoot, info) != 0) { std::cerr << "Unable to create computer thread\n"; return 1; } } // Randomly send signals to the workers. // for (unsigned i = 0; i < NUM_SIGNALS; i++) { unsigned index = std::rand() % (NUM_BLOCKERS + NUM_COMPUTERS); THREAD_INFO *info = &ThreadInfos[index]; // Wait for the worker to be ready to handle a signal. // pthread_mutex_lock(&info->_readyLock); while (!info->_ready) pthread_cond_wait(&info->_readyCond, &info->_readyLock); info->_ready = false; pthread_mutex_unlock(&info->_readyLock); std::cout << "Sending signal " << std::dec << i << "\n"; if (pthread_kill(info->_tid, SIGUSR1) != 0) { std::cerr << "Unable to send SIGUSR1 to thread index " << std::dec << index << "\n"; return 1; } } // Wait for all the workers to terminate. // for (unsigned i = 0; i < NUM_BLOCKERS + NUM_COMPUTERS; i++) { if (pthread_join(ThreadInfos[i]._tid, 0) != 0) { std::cerr << "Unable to wait for thread index " << std::dec << i << "\n"; return 1; } } delete [] ThreadInfos; pthread_key_delete(MyInfoKey); return 0; } static void *BlockerRoot(void *vinfo) { SetMyInfo(static_cast<THREAD_INFO *>(vinfo)); while (NumSignalsReceived < NUM_SIGNALS) { struct timespec tv; tv.tv_sec = 10; tv.tv_nsec = 0; nanosleep(&tv, 0); } return 0; } static void *ComputerRoot(void *vinfo) { SetMyInfo(static_cast<THREAD_INFO *>(vinfo)); volatile double x[100]; while (NumSignalsReceived < NUM_SIGNALS) { for (unsigned i = 0; i < 100; i++) x[i] = (double)(i+1); for (unsigned i = 2; i < 100; i++) x[i] = x[i] / x[i-1] * x[i-2] + x[i]; } } static void SetMyInfo(THREAD_INFO *info) { // Initialize the worker's thread-private data to point to it's THREAD_INFO. // Once we do this, we are ready to handle a signal. // pthread_mutex_lock(&info->_readyLock); pthread_setspecific(MyInfoKey, info); info->_ready = true; pthread_cond_signal(&info->_readyCond); pthread_mutex_unlock(&info->_readyLock); } static void Handle(int) { // Count this signal. // pthread_mutex_lock(&SignalReceivedLock); NumSignalsReceived++; pthread_mutex_unlock(&SignalReceivedLock); // Once we count the signal, this thread is ready to handle another signal. // THREAD_INFO *info = static_cast<THREAD_INFO *>(pthread_getspecific(MyInfoKey)); pthread_mutex_lock(&info->_readyLock); assert(!info->_ready); info->_ready = true; pthread_cond_signal(&info->_readyCond); pthread_mutex_unlock(&info->_readyLock); }
29.293617
96
0.662841
swchoi1994
cb369df49755e93fdbbe09fdaefa7a0a84425f02
10,882
cpp
C++
stocks_exchange/unit-test/stock_exchange_kraken_unit_test.cpp
Rapprise/b2s-trader
ac8a3c2221d15c4df8df63842d20dafd6801e535
[ "BSD-2-Clause" ]
21
2020-06-07T20:34:47.000Z
2021-08-10T20:19:59.000Z
stocks_exchange/unit-test/stock_exchange_kraken_unit_test.cpp
Rapprise/b2s-trader
ac8a3c2221d15c4df8df63842d20dafd6801e535
[ "BSD-2-Clause" ]
null
null
null
stocks_exchange/unit-test/stock_exchange_kraken_unit_test.cpp
Rapprise/b2s-trader
ac8a3c2221d15c4df8df63842d20dafd6801e535
[ "BSD-2-Clause" ]
4
2020-07-13T10:19:44.000Z
2022-03-11T12:15:43.000Z
/* * Copyright (c) 2020, Rapprise. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "stock_exchange_kraken_unit_test.h" #include "common/currency.h" #include "common/enumerations/stock_exchange_type.h" #include "common/exceptions/stock_exchange_exception/invalid_stock_exchange_response_exception.h" #include "common/utils.h" #include "gtest/gtest.h" #include "include/query_processor.h" #include "include/stock_exchange_library.h" #include "include/stock_exchange_utils.h" #include "resources/resources.h" namespace auto_trader { namespace stock_exchange { namespace unit_test { const std::string kraken_private = "d5IeAreqJbSoZohpJPiXFh4LWY9O7t/2E43bp7ehIe3OwTIt8BKni1P9xojPshhgtYLLZ+Mpg+uHsAapUfqlbw=="; const std::string kraken_api_key = "TVCtFQP83n14APh9XW+M+PnctIog52q6XsqIp10PnTp9qRUfNvmEhMvB"; const std::string invalidOrderMessage = "Invalid response exception raised : EOrder:Invalid order"; const std::string errorWithoutTradedBalance = "Invalid response exception raised : EGeneral:Invalid arguments:volume"; const double currencyTickOnFakeResponseXRP_USD_ask = 0.31699; TEST(KrakenRealRequest, KrakenRealRequest_MarketHistory_Test) { auto_trader::stock_exchange::StockExchangeLibrary stockExchangeLibrary; auto& queryProcessor = stockExchangeLibrary.getQueryProcessor(); auto query = queryProcessor.getQuery(common::StockExchangeType::Kraken); auto marketHistory = query->getMarketHistory(common::Currency::USD, common::Currency::BTC, common::TickInterval::ONE_DAY); EXPECT_TRUE(marketHistory->marketData_.size() > 0); } TEST(KrakenRealRequest, KrakenRealRequest_CurrencyTickRealResponse_Test) { auto_trader::stock_exchange::StockExchangeLibrary stockExchangeLibrary; auto& queryProcessor = stockExchangeLibrary.getQueryProcessor(); auto query = queryProcessor.getQuery(common::StockExchangeType::Kraken); auto currencyTick = query->getCurrencyTick(common::Currency::XRP, common::Currency::USD); EXPECT_TRUE(currencyTick.ask_ > 0); EXPECT_TRUE(currencyTick.bid_ > 0); EXPECT_TRUE(currencyTick.ask_ > currencyTick.bid_); } TEST(KrakenRealRequest, KrakenRealRequest_GetMarketOpenedOrders_Test) { auto_trader::stock_exchange::StockExchangeLibrary stockExchangeLibrary; auto& queryProcessor = stockExchangeLibrary.getQueryProcessor(); auto query = queryProcessor.getQuery(common::StockExchangeType::Kraken); auto marketOpenedOrders = query->getMarketOpenOrders(common::Currency::DASH, common::Currency::USD); EXPECT_TRUE(marketOpenedOrders.size() > 0); } TEST(KrakenRealRequest, KrakenRealRequest_GetAccountOpenOrders_Test) { auto_trader::stock_exchange::StockExchangeLibrary stockExchangeLibrary; auto& queryProcessor = stockExchangeLibrary.getQueryProcessor(); auto query = queryProcessor.getQuery(common::StockExchangeType::Kraken); query->updateApiKey(kraken_api_key); query->updateSecretKey(kraken_private); auto accountOpenOrders = query->getAccountOpenOrders(common::Currency::BTC, common::Currency::LTC); EXPECT_TRUE(accountOpenOrders.size() == 0); } TEST(KrakenRealRequest, KrakenRealRequest_CancelOrder_Test) { auto_trader::stock_exchange::StockExchangeLibrary stockExchangeLibrary; auto& queryProcessor = stockExchangeLibrary.getQueryProcessor(); auto query = queryProcessor.getQuery(common::StockExchangeType::Kraken); query->updateApiKey(kraken_api_key); query->updateSecretKey(kraken_private); std::string message; try { auto isOrderCanceled = query->cancelOrder(common::Currency::XRP, common::Currency::XRP, "asdasdasdsad"); } catch (const common::exceptions::InvalidStockExchangeResponse& ex) { message = ex.what(); } EXPECT_EQ(invalidOrderMessage, message); } TEST(KrakenRealRequest, KrakenRealRequest_BuyOrder_BadInputData_Test) { auto_trader::stock_exchange::StockExchangeLibrary stockExchangeLibrary; auto& queryProcessor = stockExchangeLibrary.getQueryProcessor(); auto query = queryProcessor.getQuery(common::StockExchangeType::Kraken); query->updateApiKey(kraken_api_key); query->updateSecretKey(kraken_private); std::string message; try { auto buyOrder = query->buyOrder(common::Currency::BTC, common::Currency::XRP, 1, 123123123); } catch (const common::exceptions::InvalidStockExchangeResponse& ex) { message = ex.what(); } EXPECT_EQ(errorWithoutTradedBalance, message); } TEST(KrakenRealRequest, KrakenRealRequest_SellOrder_BadInputData_Test) { auto_trader::stock_exchange::StockExchangeLibrary stockExchangeLibrary; auto& queryProcessor = stockExchangeLibrary.getQueryProcessor(); auto query = queryProcessor.getQuery(common::StockExchangeType::Kraken); query->updateApiKey(kraken_api_key); query->updateSecretKey(kraken_private); std::string message; try { auto sellOrder = query->sellOrder(common::Currency::BTC, common::Currency::XRP, 1, 123123123); } catch (const common::exceptions::InvalidStockExchangeResponse& ex) { message = ex.what(); } EXPECT_EQ(errorWithoutTradedBalance, message); } TEST(KrakenRealRequest, KrakenRealRequest_Kraken_Currencies_On_Valid_Pairs_Test) { auto_trader::stock_exchange::StockExchangeLibrary stockExchangeLibrary; auto& queryProcessor = stockExchangeLibrary.getQueryProcessor(); auto query = queryProcessor.getQuery(common::StockExchangeType::Kraken); common::KrakenCurrency krakenCurrencies; auto base_currencies = krakenCurrencies.getBaseCurrencies(); for (const auto& currency : base_currencies) { auto traded_currencies = krakenCurrencies.getTradedCurrencies(currency); for (const auto& traded_currency : traded_currencies) { EXPECT_NO_THROW(stock_exchange_utils::getKrakenCurrencyStringFromEnum(traded_currency)); EXPECT_NO_THROW(query->getCurrencyTick(currency, traded_currency)); } } } TEST(KrakenRealRequest, KrakenRealRequest_GetAccountOrderResponse_Test) { auto_trader::stock_exchange::StockExchangeLibrary stockExchangeLibrary; auto& queryProcessor = stockExchangeLibrary.getQueryProcessor(); auto query = queryProcessor.getQuery(common::StockExchangeType::Kraken); query->updateApiKey(kraken_api_key); query->updateSecretKey(kraken_private); std::string orderUuid = "OJV7QW-QCXDP-BIGIYH"; auto order = query->getAccountOrder(common::Currency::BTC, common::Currency::QTUM, orderUuid); EXPECT_EQ(order.uuid_, orderUuid); } TEST(KrakenRealRequest, KrakenRealRequest_GetAccountOrderResponse_BadUuid_Test) { auto_trader::stock_exchange::StockExchangeLibrary stockExchangeLibrary; auto& queryProcessor = stockExchangeLibrary.getQueryProcessor(); auto query = queryProcessor.getQuery(common::StockExchangeType::Kraken); query->updateApiKey(kraken_api_key); query->updateSecretKey(kraken_private); std::string orderUuid = "asdasdasd"; auto order = query->getAccountOrder(common::Currency::ADA, common::Currency::USD, orderUuid); EXPECT_TRUE(order.uuid_.empty()); } TEST_F(KrakenQueryFixture, KrakenQueryFixture_getAccountOpenOrders_TestgetAccountOpenOrders) { mockKrakenQuery->DelegateToGetOpenedOrdersResponse(); EXPECT_CALL(*mockKrakenQuery, sendRequest(testing::_)).Times(1); auto openOrders = mockKrakenQuery->getAccountOpenOrders(common::Currency::BTC, common::Currency::LTC); EXPECT_EQ(openOrders.size(), 2); } TEST_F(KrakenQueryFixture, KrakenQueryFixture_getNonZeroBalance_TestgetNonZeroBalance) { mockKrakenQuery->DelegateToGetBalanceResponse(); EXPECT_CALL(*mockKrakenQuery, sendRequest(testing::_)).Times(3); auto ADA_balance = mockKrakenQuery->getBalance(common::Currency::ADA); auto XRP_balance = mockKrakenQuery->getBalance(common::Currency::XRP); auto USD_balance = mockKrakenQuery->getBalance(common::Currency::USD); EXPECT_TRUE(ADA_balance > 0); EXPECT_TRUE(XRP_balance > 0); EXPECT_TRUE(USD_balance > 0); } TEST_F(KrakenQueryFixture, KrakenQueryFixture_getZeroBTC_Balance_Test) { mockKrakenQuery->DelegateToGetBalanceResponse(); EXPECT_CALL(*mockKrakenQuery, sendRequest(testing::_)).Times(1); auto BTC_balance = mockKrakenQuery->getBalance(common::Currency::BTC); EXPECT_EQ(BTC_balance, 0); } TEST_F(KrakenQueryFixture, KrakenQueryFixture_buyOrder_Test) { mockKrakenQuery->DelegateToBuyOrderResponse(); EXPECT_CALL(*mockKrakenQuery, sendRequest(testing::_)).Times(1); auto buy_order = mockKrakenQuery->buyOrder(common::Currency::ADA, common::Currency::USD, 1, 1); EXPECT_TRUE(!buy_order.uuid_.empty()); } TEST_F(KrakenQueryFixture, KrakenQueryFixture_sellOrder_Test) { mockKrakenQuery->DelegateToSellOrderResponse(); EXPECT_CALL(*mockKrakenQuery, sendRequest(testing::_)).Times(1); auto sell_order = mockKrakenQuery->sellOrder(common::Currency::XRP, common::Currency::USD, 1, 1); EXPECT_TRUE(!sell_order.uuid_.empty()); } TEST_F(KrakenQueryFixture, KrakenQueryFixture_cancelOrder_Test) { mockKrakenQuery->DelegateToCancelOrderResponse(); EXPECT_CALL(*mockKrakenQuery, sendRequest(testing::_)).Times(1); auto cancelOrder = mockKrakenQuery->cancelOrder(common::Currency::XRP, common::Currency::USD, "fake"); EXPECT_EQ(cancelOrder, true); } TEST_F(KrakenQueryFixture, KrakenQueryFixture_Get_Currency_Tick_Test) { mockKrakenQuery->DelegateToCurrencyTickResponse(); EXPECT_CALL(*mockKrakenQuery, sendRequest(testing::_)).Times(1); auto tick = mockKrakenQuery->getCurrencyTick(common::Currency::XRP, common::Currency::USD); EXPECT_EQ(tick.ask_, currencyTickOnFakeResponseXRP_USD_ask); } } // namespace unit_test } // namespace stock_exchange } // namespace auto_trader
38.725979
99
0.787723
Rapprise
cb3dbd02009b0b677299e97faebaa34d6ccff415
529,602
cpp
C++
esp32/TinyCPCEMttgovga32/CPCem/Z80.cpp
rpsubc8/ESP32TinyCPC
386a0d1d47fc6f32c0b3dace67a6c2197a846a9d
[ "WTFPL" ]
19
2020-12-04T15:12:45.000Z
2022-02-07T19:46:36.000Z
esp32/TinyCPCEMttgovga32/CPCem/Z80.cpp
rpsubc8/ESP32TinyCPC
386a0d1d47fc6f32c0b3dace67a6c2197a846a9d
[ "WTFPL" ]
3
2021-02-20T08:42:09.000Z
2022-03-11T05:11:26.000Z
esp32/TinyCPCEMttgovga32/CPCem/Z80.cpp
rpsubc8/ESP32TinyCPC
386a0d1d47fc6f32c0b3dace67a6c2197a846a9d
[ "WTFPL" ]
4
2021-02-20T08:07:04.000Z
2022-03-27T21:52:45.000Z
//offset 703 + 45056 = B2BF #include "gbConfig.h" #include <stdlib.h> #include <stdio.h> #include "CPCem.h" #include "DAA.h" #include "Z80.h" #include <string.h> #include "FDC.h" #include "CRTC.h" #include "GA.h" #include "CRTC.h" #include "8255.h" #include "gb_globals.h" #include "dataFlash/gbrom.h" z80reg af,bc,de,hl,ix,iy,ir,saf,sbc,sde,shl; unsigned short pc=0; unsigned short sp; int iff1,iff2; int intreq; int im; int c8d1=0; //JJ int model; int rhigh=0; //JJ int vc,sc; unsigned short ooopc,oopc,opc; int output=0; int cycles=0; int tempc; int ins=0; //JJ unsigned char znptable[256]; //JJ unsigned char znptable16[65536]; #ifdef use_lib_lookup_znptable //Lo metemos a flash const unsigned char znptable[256]={ 0x44,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x08,0x0c,0x0c,0x08,0x0c,0x08,0x08,0x0c, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x0c,0x08,0x08,0x0c,0x08,0x0c,0x0c,0x08, 0x20,0x24,0x24,0x20,0x24,0x20,0x20,0x24,0x2c,0x28,0x28,0x2c,0x28,0x2c,0x2c,0x28, 0x24,0x20,0x20,0x24,0x20,0x24,0x24,0x20,0x28,0x2c,0x2c,0x28,0x2c,0x28,0x28,0x2c, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x0c,0x08,0x08,0x0c,0x08,0x0c,0x0c,0x08, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x08,0x0c,0x0c,0x08,0x0c,0x08,0x08,0x0c, 0x24,0x20,0x20,0x24,0x20,0x24,0x24,0x20,0x28,0x2c,0x2c,0x28,0x2c,0x28,0x28,0x2c, 0x20,0x24,0x24,0x20,0x24,0x20,0x20,0x24,0x2c,0x28,0x28,0x2c,0x28,0x2c,0x2c,0x28, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x8c,0x88,0x88,0x8c,0x88,0x8c,0x8c,0x88, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x88,0x8c,0x8c,0x88,0x8c,0x88,0x88,0x8c, 0xa4,0xa0,0xa0,0xa4,0xa0,0xa4,0xa4,0xa0,0xa8,0xac,0xac,0xa8,0xac,0xa8,0xa8,0xac, 0xa0,0xa4,0xa4,0xa0,0xa4,0xa0,0xa0,0xa4,0xac,0xa8,0xa8,0xac,0xa8,0xac,0xac,0xa8, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x88,0x8c,0x8c,0x88,0x8c,0x88,0x88,0x8c, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x8c,0x88,0x88,0x8c,0x88,0x8c,0x8c,0x88, 0xa0,0xa4,0xa4,0xa0,0xa4,0xa0,0xa0,0xa4,0xac,0xa8,0xa8,0xac,0xa8,0xac,0xac,0xa8, 0xa4,0xa0,0xa0,0xa4,0xa0,0xa4,0xa4,0xa0,0xa8,0xac,0xac,0xa8,0xac,0xa8,0xa8,0xac }; #endif #ifdef use_lib_lookup_znptable16 const unsigned char znptable16[65536]={ 0x44,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84 }; #endif #ifndef use_lib_lookup_znptable //******************************************************** inline unsigned char Get_no_lookup_znptable(unsigned char c) { unsigned char d,g; unsigned char f= 0; if (c == 0) return 0x44; d= (c&0xA8); for (g=0;g<8;g++) { if (c&1) f++; c>>= 1; } if (!(f&1)) d|= 0x04; return d; } #endif #ifndef use_lib_lookup_znptable16 //******************************************************** inline unsigned char Get_no_lookup_znptable16(unsigned short int c) { unsigned char d= 0; unsigned char f= 0; unsigned char g; if (c == 0) return 0x44; if (c&0x8000) d= 0x80; for (g=0;g<16;g++) { if (c&1) f++; c>>=1; } if (!(f&1)) d|= 0x04; return d; } #endif //void makeznptable() //{ // int c,d,e,f,g; // for (c=0;c<256;c++) // { // d=0; // d|=(c&0xA8); // e=c; // f=0; // for (g=0;g<8;g++) // { // if (e&1) f++; // e>>=1; // } // if (!(f&1)) // d|=4; // znptable[c]=d; // } // znptable[0]|=0x40; // for (c=0;c<65536;c++) // { // d=0; // if (c&0x8000) d|=0x80; // e=c; // f=0; // for (g=0;g<16;g++) // { // if (e&1) f++; // e>>=1; // } // if (!(f&1)) // d|=4; // znptable16[c]=d; // } // znptable16[0]|=0x40; //} void dumpram() { /* FILE *f=fopen("ram.dmp","wb"); fwrite(ram,65536,1,f); fclose(f); f=fopen("ram2.dmp","wb"); fwrite(ram+0x10000,65536,1,f); fclose(f);*/ } void rebuildmem() { #ifdef use_lib_mem_blocks readarray[0]=lorom; readarray[1]=ramArray[0]; readarray[2]=ramArray[0]; readarray[3]=ramArray[0]; writearray[0]=ramArray[0]; writearray[1]=ramArray[0]; writearray[2]=ramArray[0]; writearray[3]=ramArray[0]; #else readarray[0]=lorom; readarray[1]=ram; readarray[2]=ram; readarray[3]=ram; writearray[0]=ram; writearray[1]=ram; writearray[2]=ram; writearray[3]=ram; #endif } /*void ImprimeTablaPrecalculada() { int cont=0; printf("Table znptable\n"); for (int i=0;i<256;i++) { printf("0x%02x,",znptable[i]); cont++; if (cont>=16) { cont=0; printf("\n"); } } cont=0; printf("Table znptable16\n"); for (int i=0;i<65536;i++) { printf("0x%02x,",znptable16[i]); cont++; if (cont>=16) { cont=0; printf("\n"); } } }*/ void initz80() { int c; //atexit(dumpram); //makeznptable(); //ImprimeTablaPrecalculada(); //Para la rom en memoria dinamica //JJ lorom=(unsigned char *)calloc(0x4000,1); for (c=0;c<16;c++) { //hirom[c]=(unsigned char *)calloc(0x4000,1); //memset(hirom[c],0,16384); //hirom[c]= NULL; hirom[c]= (unsigned char*)gb_rom_464_1; } #ifdef use_lib_mem_blocks for (c=0;c<2;c++) memset(ramArray[c],1,0x10000); #else #ifdef use_lib_cheat_128k memset(ram,1,0x10000); #else #ifdef use_lib_fix_psram_128k memset(ram,1,0x10000); //Modo 128K psram #else memset(ram,1,0x10000); //Modo 64K #endif #endif #endif //JJ ram=(unsigned char *)calloc(0x20000,1); //Creado en Setup rebuildmem(); } //Lee desde Flash todas las roms void loadroms2FlashModel() { //printf("Modelo %d\n",aModel); if (model == 2) { #if defined(use_lib_128k) || defined(use_lib_cheat_128k) || defined(use_lib_fix_psram_128k) lorom = (unsigned char*)gb_rom_6128_0; //16KB primeros hirom[0]= (unsigned char*)gb_rom_6128_1; #endif //memcpy(lorom,gb_rom_6128,16384); //memcpy(hirom[0],&gb_rom_6128[16384],16384); } else { if (model == 1) { lorom = (unsigned char*)gb_rom_664_0; hirom[0] = (unsigned char*)gb_rom_664_1; //memcpy(lorom,gb_rom_664,16384); //memcpy(hirom[0],&gb_rom_664[16384],16384); } else { lorom = (unsigned char*)gb_rom_464_0; hirom[0] = (unsigned char*)gb_rom_464_1; //memcpy(lorom,gb_rom_464,16384); //memcpy(hirom[0],gb_rom_464_1,16384); } } hirom[7] = (unsigned char *)gb_rom_amsdos; //memcpy(hirom[7],gb_rom_amsdos,16384); ramconfigBefore= 255; //force bank switch curhromBefore= 255; } /*void loadroms() { FILE *f; if (model==2) f=fopen("6128.rom","rb"); else if (model==1) f=fopen("664.rom","rb"); else f=fopen("464.rom","rb"); fread(lorom,16384,1,f); fread(hirom[0],16384,1,f); fclose(f); f=fopen("amsdos.rom","rb"); fread(hirom[7],16384,1,f); fclose(f); }*/ void resetz80() { pc=0; iff1=iff2=0; #ifdef use_lib_mem_blocks for (int i=0;i<2;i++) memset(ramArray[i],0,0x10000); //65536 64 KB ram = ramArray[0]; //Inicio #else #ifdef use_lib_cheat_128k memset(ram,0,0x10000); //truco 122880 bytes #else #ifdef use_lib_fix_psram_128k memset(ram,0,0x10000); //128K psram #else memset(ram,0,0x10000); //hay que setear memoria 64K #endif #endif #endif loromena=1; hiromena=0; galines=0; writega(0,0xC0); } //if (a==0xBE60 && v==0xC3) { dumpregs(); output=1; } #define readmem(a) readarray[(a&0xFFFF)>>14][a&0xFFFF] #define writemem(a,v) writearray[(a&0xFFFF)>>14][a&0xFFFF]=v; #define push(v) { sp--; writearray[sp>>14][sp]=v; } unsigned char readmemf(unsigned short a) { return readarray[(a&0xFFFF)>>14][a&0xFFFF]; } unsigned char readmemf2(unsigned short a) { return writearray[(a&0xFFFF)>>14][a&0xFFFF]; } inline unsigned char pull() { unsigned char temp=readarray[sp>>14][sp]; sp++; return temp; } inline unsigned char z80in(unsigned short a) { if (!(a&0x4000)) return readcrtc(a); if (!(a&0x800)) return read8255(a); if (!(a&0x480)) return readfdc(a); return 0xFF; } inline void z80out(unsigned short a, unsigned char v) { if (!(a&0x8000)) writega(a,v); if (!(a&0x4000)) writecrtc(a,v); if (!(a&0x2000)) { curhrom=v&15; // printf("Current hirom = %i, ena %i\n",hiromena,curhrom); if (hiromena) { //if (hirom[curhrom] == NULL) // printf ("Soy nulo z80out %d\n",curhrom); if (hirom[curhrom] != NULL) {//JJ flash rom readarray[3]=hirom[curhrom]-0xC000; } else { readarray[3]= hirom[0]-0xC000; //fuerzo a rom existente 0 } } } if (!(a&0x800)) write8255(a,v); if (!(a&0x480)) writefdc(a,v); } inline void setzn(unsigned char v) { af.b.l&=~(N_FLAG|Z_FLAG|V_FLAG|0x28|C_FLAG); #ifdef use_lib_lookup_znptable af.b.l|=znptable[v]; #else af.b.l|= Get_no_lookup_znptable(v); #endif } inline void setznc(unsigned char v) { af.b.l&=~(N_FLAG|Z_FLAG|V_FLAG|0x28); #ifdef use_lib_lookup_znptable af.b.l|=znptable[v]; #else af.b.l|= Get_no_lookup_znptable(v); #endif } signed short temps; inline void setadd(unsigned char a, unsigned char b) { #ifdef use_lib_lookup_znptable af.b.l=znptable[(a+b)&0xFF]; #else af.b.l= Get_no_lookup_znptable(((a+b)&0xFF)); #endif af.b.l&=~(C_FLAG|V_FLAG); if ((a+b)&0x100) af.b.l|=C_FLAG; temps=(signed short)(signed char)a+(signed short)(signed char)b; if (temps<-128 || temps>127) af.b.l|=V_FLAG; if (((a&0xF)+(b&0xF))&0x10) af.b.l|=H_FLAG; } inline void setadc(unsigned char a, unsigned char b) { #ifdef use_lib_lookup_znptable af.b.l=znptable[(a+b+tempc)&0xFF]; #else af.b.l= Get_no_lookup_znptable(((a+b+tempc)&0xFF)); #endif af.b.l&=~V_FLAG; if ((a+b+tempc)&0x100) af.b.l|=C_FLAG; temps=(signed short)(signed char)a+(signed short)(signed char)b; if (temps<-128 || temps>127) af.b.l|=V_FLAG; if (((a&0xF)+(b&0xF))&0x10) af.b.l|=H_FLAG; } inline void setadc16(unsigned short a, unsigned short b) { signed long temps2; #ifdef use_lib_lookup_znptable16 af.b.l=znptable16[(a+b+tempc)&0xFFFF]; #else af.b.l= Get_no_lookup_znptable16(((a+b+tempc)&0xFFFF)); #endif af.b.l&=~V_FLAG; temps2=(signed short)a+(signed short)b; if (temps2<-32768 || temps2>32767) af.b.l|=V_FLAG; if (((a&0xFFF)+(b&0xFFF))&0x1000) af.b.l|=H_FLAG; if ((a+b+tempc)&0x10000) af.b.l|=C_FLAG; } inline void setadd16(unsigned short a, unsigned short b) { af.b.l&=~(C_FLAG|S_FLAG|H_FLAG); if ((a+b)&0x10000) af.b.l|=C_FLAG; if ((a&0x1800)==0x800 && ((a+b)&0x1800)==0x1000) af.b.l|=H_FLAG; } inline void setcp(unsigned char a, unsigned char b) { #ifdef use_lib_lookup_znptable af.b.l=znptable[(a-b)&0xFF]|S_FLAG; #else af.b.l= Get_no_lookup_znptable(((a-b)&0xFF))|S_FLAG; #endif af.b.l&=~V_FLAG; temps=(signed short)(signed char)a-(signed short)(signed char)b; if (temps<-128 || temps>127) af.b.l|=V_FLAG; if (!(a&8) && ((a+b)&8)) af.b.l|=H_FLAG; if (a<b) af.b.l|=C_FLAG; } inline void setdec(unsigned char v) { af.b.l&=1; #ifdef use_lib_lookup_znptable af.b.l|=znptable[v]|S_FLAG; #else af.b.l|= Get_no_lookup_znptable(v)|S_FLAG; #endif if (v==0x80) af.b.l|=P_FLAG; else af.b.l&=~P_FLAG; if (((v-1)&0x10) && !(v&0x10)) af.b.l|=H_FLAG; } inline void setinc(unsigned char v) { af.b.l&=0x29; #ifdef use_lib_lookup_znptable af.b.l|=znptable[v]; #else af.b.l|= Get_no_lookup_znptable(v); #endif if (v==0x7F) af.b.l|=P_FLAG; else af.b.l&=~P_FLAG; if (((v-1)&0x8) && !(v&0x8)) af.b.l|=H_FLAG; } inline void setsub(unsigned char a, unsigned char b) { #ifdef use_lib_lookup_znptable af.b.l=znptable[(a-b)&0xFF]|S_FLAG; #else af.b.l= Get_no_lookup_znptable(((a-b)&0xFF))|S_FLAG; #endif af.b.l&=~V_FLAG; temps=(signed short)(signed char)a-(signed short)(signed char)b; if (temps<-128 || temps>127) af.b.l|=V_FLAG; if (!(a&8) && ((a-b)&8)) af.b.l|=H_FLAG; if (a<b) af.b.l|=C_FLAG; } inline void setsbc(unsigned char a, unsigned char b) { #ifdef use_lib_lookup_znptable af.b.l=znptable[(a-(b+tempc))&0xFF]|S_FLAG; #else af.b.l= Get_no_lookup_znptable(((a-(b+tempc))&0xFF))|S_FLAG; #endif af.b.l&=~V_FLAG; temps=(signed short)(signed char)a-(signed short)(signed char)b; if (temps<-128 || temps>127) af.b.l|=V_FLAG; if (!(a&8) && ((a-b)&8)) af.b.l|=H_FLAG; if (a<(b+tempc)) af.b.l|=C_FLAG; } inline void setsbc16(unsigned short a, unsigned short b) { signed long temps2; b+=(af.b.l&C_FLAG); af.b.l&=0x28; #ifdef use_lib_lookup_znptable16 af.b.l|=znptable16[(a-b)&0xFFFF]|S_FLAG; #else af.b.l|= Get_no_lookup_znptable16(((a-b)&0xFFFF))|S_FLAG; #endif af.b.l&=~V_FLAG; temps2=(signed long)(signed short)a-(signed long)(signed short)b; if (temps2<-32768 || temps2>32767) af.b.l|=V_FLAG; if (!(a&0x800) && ((a-b)&0x800)) af.b.l|=H_FLAG; if (a<b) af.b.l|=C_FLAG; } void dumpregs() { /*JJ printf("AF =%04X BC =%04X DE =%04X HL =%04X IX=%04X IY=%04X\n",af.w,bc.w,de.w,hl.w,ix.w,iy.w); printf("AF'=%04X BC'=%04X DE'=%04X HL'=%04X IR=%04X\n",saf.w,sbc.w,sde.w,shl.w,ir.w); printf("%c%c%c%c%c%c PC =%04X SP =%04X %i ins IFF1=%i IFF2=%i\n",(af.b.l&N_FLAG)?'N':' ',(af.b.l&Z_FLAG)?'Z':' ',(af.b.l&H_FLAG)?'H':' ',(af.b.l&V_FLAG)?'V':' ',(af.b.l&S_FLAG)?'S':' ',(af.b.l&C_FLAG)?'C':' ',pc,sp,ins,iff1,iff2); printf("%04X %04X %04X\n",opc,oopc,ooopc); */ } //JJ unsigned short opc,oopc; int a92c=0; //JJunsigned short opc,oldpc; unsigned short oldpc; void execz80() { int c; unsigned char opcode; unsigned short addr,tempw; unsigned char temp,temp2; signed char offset; for (c=0;c<312;c++) { // if ((c&63)==63) intreq=1; pollline(); cpuline++; cycles+=256; while (cycles>0) { oldpc=opc; opc=pc; opcode=readmem(pc); pc++; tempc=af.b.l&C_FLAG; switch (opcode) { // t 4 case 0x00: /*NOP*/ cycles-=4; break; // t 12 case 0x01: /*LD BC,xxxx*/ bc.b.l=readmem(pc); pc++; bc.b.h=readmem(pc); pc++; cycles-=12; break; // t 8 case 0x02: /*LD (BC),A*/ writemem(bc.w,af.b.h); cycles-=8; break; // t 4 case 0x03: /*INC BC*/ bc.w++; cycles-=8; break; // t 4 case 0x04: /*INC B*/ bc.b.h++; setinc(bc.b.h); cycles-=4; break; // t 4 case 0x05: /*DEC B*/ bc.b.h--; setdec(bc.b.h); cycles-=4; break; // t 8 case 0x06: /*LD B,xx*/ bc.b.h=readmem(pc); pc++; cycles-=8; break; // t 4 case 0x07: /*RLCA*/ if (af.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; af.b.h<<=1; if (af.b.l&C_FLAG) af.b.h|=1; //setznc(af.b.h); cycles-=4; break; // t 4 case 0x08: /*EX AF,AF'*/ tempw=af.w; af.w=saf.w; saf.w=tempw; cycles-=4; break; // t 12 case 0x09: /*ADD HL,BC*/ setadd16(hl.w,bc.w); hl.w+=bc.w; cycles-=12; break; // t 8 case 0x0A: /*LD A,(BC)*/ af.b.h=readmem(bc.w); cycles-=8; break; // t 4 case 0x0B: /*DEC BC*/ bc.w--; cycles-=8; break; // t 4 case 0x0C: /*INC C*/ bc.b.l++; setinc(bc.b.l); cycles-=4; break; // t 4 case 0x0D: /*DEC C*/ bc.b.l--; setdec(bc.b.l); cycles-=4; break; // t 8 case 0x0E: /*LD C,xx*/ bc.b.l=readmem(pc); pc++; cycles-=8; break; // t 4 case 0x0F: /*RRCA*/ if (af.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; af.b.h>>=1; if (af.b.l&C_FLAG) af.b.h|=0x80; //setznc(af.b.h); cycles-=4; break; // t 8 8 case 0x10: /*DJNZ*/ offset=(signed char)readmem(pc); pc++; bc.b.h--; if (bc.b.h) { pc+=offset; cycles-=16; } else { cycles-=12; } break; // t 12 case 0x11: /*LD DE,xxxx*/ de.b.l=readmem(pc); pc++; de.b.h=readmem(pc); pc++; cycles-=12; break; // t 8 case 0x12: /*LD (DE),A*/ writemem(de.w,af.b.h); cycles-=8; break; // t 4 case 0x13: /*INC DE*/ de.w++; cycles-=8; break; // t 4 case 0x14: /*INC D*/ de.b.h++; setinc(de.b.h); cycles-=4; break; // t 4 case 0x15: /*DEC D*/ de.b.h--; setdec(de.b.h); cycles-=4; break; // t 8 case 0x16: /*LD D,xx*/ de.b.h=readmem(pc); pc++; cycles-=8; break; // t 8 case 0x17: /*RLA*/ if (af.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; af.b.h<<=1; if (tempc) af.b.h|=1; //setznc(af.b.h); cycles-=4; break; // t 16 case 0x18: /*JR*/ offset=(signed char)readmem(pc); pc++; pc+=offset; cycles-=12; break; // t 12 case 0x19: /*ADD HL,DE*/ setadd16(hl.w,de.w); hl.w+=de.w; cycles-=12; break; // t 8 case 0x1A: /*LD A,(DE)*/ af.b.h=readmem(de.w); cycles-=8; break; // t 4 case 0x1B: /*DEC DE*/ de.w--; cycles-=8; break; // t 4 case 0x1C: /*INC E*/ de.b.l++; setinc(de.b.l); cycles-=4; break; // t 4 case 0x1D: /*DEC E*/ de.b.l--; setdec(de.b.l); cycles-=4; break; // t 8 case 0x1E: /*LD E,xx*/ de.b.l=readmem(pc); pc++; cycles-=8; break; // t 4 case 0x1F: /*RRA*/ tempc=af.b.l&C_FLAG; if (af.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; af.b.h>>=1; if (tempc) af.b.h|=0x80; //setznc(af.b.h); cycles-=4; break; // t 8 8 case 0x20: /*JR NZ*/ offset=(signed char)readmem(pc); pc++; if (!(af.b.l&Z_FLAG)) { pc+=offset; cycles-=12; } else { cycles-=8; } break; // t 12 case 0x21: /*LD HL,xxxx*/ hl.b.l=readmem(pc); pc++; hl.b.h=readmem(pc); pc++; cycles-=12; break; // t 24 case 0x22: /*LD (xxxx),HL*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; writemem(addr,hl.b.l); writemem(addr+1,hl.b.h); cycles-=20; break; // t 4 case 0x23: /*INC HL*/ hl.w++; cycles-=8; break; // t 4 case 0x24: /*INC H*/ hl.b.h++; setinc(hl.b.h); cycles-=4; break; // t 4 case 0x25: /*DEC H*/ hl.b.h--; setdec(hl.b.h); cycles-=4; break; // t 8 case 0x26: /*LD H,xx*/ hl.b.h=readmem(pc); pc++; cycles-=8; break; // t 4 case 0x27: /*DAA*/ addr=af.b.h; if (af.b.l&C_FLAG) addr|=256; if (af.b.l&H_FLAG) addr|=512; if (af.b.l&S_FLAG) addr|=1024; af.w=DAATable[addr]; cycles-=4; break; // t 8 8 case 0x28: /*JR Z*/ offset=(signed char)readmem(pc); pc++; if (af.b.l&Z_FLAG) { pc+=offset; cycles-=12; } else { cycles-=8; } break; // t 12 case 0x29: /*ADD HL,HL*/ setadd16(hl.w,hl.w); hl.w+=hl.w; cycles-=12; break; // t 24 case 0x2A: /*LD HL,(xxxx)*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; hl.b.l=readmem(addr); hl.b.h=readmem(addr+1); cycles-=20; break; // t 4 case 0x2B: /*DEC HL*/ hl.w--; cycles-=8; break; // t 4 case 0x2C: /*INC L*/ hl.b.l++; setinc(hl.b.l); cycles-=4; break; // t 4 case 0x2D: /*DEC L*/ hl.b.l--; setdec(hl.b.l); cycles-=4; break; // t 8 case 0x2E: /*LD L,xx*/ hl.b.l=readmem(pc); pc++; cycles-=8; break; // t 4 case 0x2F: /*CPL*/ af.b.h^=0xFF; af.b.l|=(H_FLAG|S_FLAG); cycles-=4; break; // t 8 8 case 0x30: /*JR NC*/ offset=(signed char)readmem(pc); pc++; if (!(af.b.l&C_FLAG)) { pc+=offset; cycles-=12; } else { cycles-=8; } break; // t 12 case 0x31: /*LD SP,xxxx*/ sp=readmem(pc); pc++; sp|=(readmem(pc))<<8; pc++; cycles-=12; break; // t 16 case 0x32: /*LD (xxxx),A*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; writemem(addr,af.b.h); cycles-=16; break; // t 4 case 0x33: /*INC SP*/ sp++; cycles-=8; break; // t 12 case 0x34: /*INC (HL)*/ temp=readmem(hl.w)+1; setinc(temp); writemem(hl.w,temp); cycles-=12; break; // t 12 case 0x35: /*DEC (HL)*/ temp=readmem(hl.w)-1; setdec(temp); writemem(hl.w,temp); cycles-=12; break; // t 8 case 0x36: /*LD (HL),xx*/ temp=readmem(pc); pc++; writemem(hl.w,temp); cycles-=12; break; // t 4 case 0x37: /*SCF*/ af.b.l|=C_FLAG; cycles-=4; break; // t 8 8 case 0x38: /*JR C*/ offset=(signed char)readmem(pc); pc++; if (af.b.l&C_FLAG) { pc+=offset; cycles-=12; } else { cycles-=8; } break; // t 12 case 0x39: /*ADD HL,SP*/ setadd16(hl.w,sp); hl.w+=sp; cycles-=12; break; // t 16 case 0x3A: /*LD A,(xxxx)*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; af.b.h=readmem(addr); cycles-=16; break; // t 4 case 0x3B: /*DEC SP*/ sp--; cycles-=8; break; // t 4 case 0x3C: /*INC A*/ af.b.h++; setinc(af.b.h); cycles-=4; break; // t 4 case 0x3D: /*DEC A*/ af.b.h--; setdec(af.b.h); cycles-=4; break; // t 8 case 0x3E: /*LD A,xx*/ af.b.h=readmem(pc); pc++; cycles-=8; break; // t 4 case 0x3F: /*CCF*/ if (af.b.l&C_FLAG) af.b.l|=H_FLAG; else af.b.l&=~H_FLAG; af.b.l^=C_FLAG; cycles-=4; break; /*Register to register loads*/ case 0x40: bc.b.h=bc.b.h; cycles-=4; break; /*LD B,B*/ case 0x41: bc.b.h=bc.b.l; cycles-=4; break; /*LD B,C*/ case 0x42: bc.b.h=de.b.h; cycles-=4; break; /*LD B,D*/ case 0x43: bc.b.h=de.b.l; cycles-=4; break; /*LD B,E*/ case 0x44: bc.b.h=hl.b.h; cycles-=4; break; /*LD B,H*/ case 0x45: bc.b.h=hl.b.l; cycles-=4; break; /*LD B,L*/ case 0x46: bc.b.h=readmem(hl.w); cycles-=8; break; /*LD B,(HL)*/ // t 8 case 0x47: bc.b.h=af.b.h; cycles-=4; break; /*LD B,A*/ case 0x48: bc.b.l=bc.b.h; cycles-=4; break; /*LD C,B*/ case 0x49: bc.b.l=bc.b.l; cycles-=4; break; /*LD C,C*/ case 0x4A: bc.b.l=de.b.h; cycles-=4; break; /*LD C,D*/ case 0x4B: bc.b.l=de.b.l; cycles-=4; break; /*LD C,E*/ case 0x4C: bc.b.l=hl.b.h; cycles-=4; break; /*LD C,H*/ case 0x4D: bc.b.l=hl.b.l; cycles-=4; break; /*LD C,L*/ case 0x4E: bc.b.l=readmem(hl.w); cycles-=8; break; /*LD C,(HL)*/ // t 8 case 0x4F: bc.b.l=af.b.h; cycles-=4; break; /*LD C,A*/ case 0x50: de.b.h=bc.b.h; cycles-=4; break; /*LD D,B*/ case 0x51: de.b.h=bc.b.l; cycles-=4; break; /*LD D,C*/ case 0x52: de.b.h=de.b.h; cycles-=4; break; /*LD D,D*/ case 0x53: de.b.h=de.b.l; cycles-=4; break; /*LD D,E*/ case 0x54: de.b.h=hl.b.h; cycles-=4; break; /*LD D,H*/ case 0x55: de.b.h=hl.b.l; cycles-=4; break; /*LD D,L*/ case 0x56: de.b.h=readmem(hl.w); cycles-=8; break; /*LD D,(HL)*/ // t 8 case 0x57: de.b.h=af.b.h; cycles-=4; break; /*LD D,A*/ case 0x58: de.b.l=bc.b.h; cycles-=4; break; /*LD E,B*/ case 0x59: de.b.l=bc.b.l; cycles-=4; break; /*LD E,C*/ case 0x5A: de.b.l=de.b.h; cycles-=4; break; /*LD E,D*/ case 0x5B: de.b.l=de.b.l; cycles-=4; break; /*LD E,E*/ case 0x5C: de.b.l=hl.b.h; cycles-=4; break; /*LD E,H*/ case 0x5D: de.b.l=hl.b.l; cycles-=4; break; /*LD E,L*/ case 0x5E: de.b.l=readmem(hl.w); cycles-=8; break; /*LD E,(HL)*/ // t 8 case 0x5F: de.b.l=af.b.h; cycles-=4; break; /*LD E,A*/ case 0x60: hl.b.h=bc.b.h; cycles-=4; break; /*LD H,B*/ case 0x61: hl.b.h=bc.b.l; cycles-=4; break; /*LD H,C*/ case 0x62: hl.b.h=de.b.h; cycles-=4; break; /*LD H,D*/ case 0x63: hl.b.h=de.b.l; cycles-=4; break; /*LD H,E*/ case 0x64: hl.b.h=hl.b.h; cycles-=4; break; /*LD H,H*/ case 0x65: hl.b.h=hl.b.l; cycles-=4; break; /*LD H,L*/ case 0x66: hl.b.h=readmem(hl.w); cycles-=8; break; /*LD H,(HL)*/ // t 8 case 0x67: hl.b.h=af.b.h; cycles-=4; break; /*LD H,A*/ case 0x68: hl.b.l=bc.b.h; cycles-=4; break; /*LD L,B*/ case 0x69: hl.b.l=bc.b.l; cycles-=4; break; /*LD L,C*/ case 0x6A: hl.b.l=de.b.h; cycles-=4; break; /*LD L,D*/ case 0x6B: hl.b.l=de.b.l; cycles-=4; break; /*LD L,E*/ case 0x6C: hl.b.l=hl.b.h; cycles-=4; break; /*LD L,H*/ case 0x6D: hl.b.l=hl.b.l; cycles-=4; break; /*LD L,L*/ case 0x6E: hl.b.l=readmem(hl.w); cycles-=8; break; /*LD L,(HL)*/ // t 8 case 0x6F: hl.b.l=af.b.h; cycles-=4; break; /*LD L,A*/ case 0x70: writemem(hl.w,bc.b.h); cycles-=8; break; /*LD (HL),B*/ // t 8 case 0x71: writemem(hl.w,bc.b.l); cycles-=8; break; /*LD (HL),C*/ // t 8 case 0x72: writemem(hl.w,de.b.h); cycles-=8; break; /*LD (HL),D*/ // t 8 case 0x73: writemem(hl.w,de.b.l); cycles-=8; break; /*LD (HL),E*/ // t 8 case 0x74: writemem(hl.w,hl.b.h); cycles-=8; break; /*LD (HL),H*/ // t 8 case 0x75: writemem(hl.w,hl.b.l); cycles-=8; break; /*LD (HL),L*/ // t 8 case 0x77: writemem(hl.w,af.b.h); cycles-=8; break; /*LD (HL),A*/ // t 8 case 0x78: af.b.h=bc.b.h; cycles-=4; break; /*LD A,B*/ case 0x79: af.b.h=bc.b.l; cycles-=4; break; /*LD A,C*/ case 0x7A: af.b.h=de.b.h; cycles-=4; break; /*LD A,D*/ case 0x7B: af.b.h=de.b.l; cycles-=4; break; /*LD A,E*/ case 0x7C: af.b.h=hl.b.h; cycles-=4; break; /*LD A,H*/ case 0x7D: af.b.h=hl.b.l; cycles-=4; break; /*LD A,L*/ case 0x7E: af.b.h=readmem(hl.w); cycles-=8; break; /*LD A,(HL)*/ // t 8 case 0x7F: af.b.h=af.b.h; cycles-=4; break; /*LD A,A*/ case 0x76: /*HALT*/ if (!intreq) pc--; cycles-=4; break; /*Add group*/ case 0x80: setadd(af.b.h,bc.b.h); af.b.h+=bc.b.h; cycles-=4; break; /*ADD B*/ case 0x81: setadd(af.b.h,bc.b.l); af.b.h+=bc.b.l; cycles-=4; break; /*ADD C*/ case 0x82: setadd(af.b.h,de.b.h); af.b.h+=de.b.h; cycles-=4; break; /*ADD D*/ case 0x83: setadd(af.b.h,de.b.l); af.b.h+=de.b.l; cycles-=4; break; /*ADD E*/ case 0x84: setadd(af.b.h,hl.b.h); af.b.h+=hl.b.h; cycles-=4; break; /*ADD H*/ case 0x85: setadd(af.b.h,hl.b.l); af.b.h+=hl.b.l; cycles-=4; break; /*ADD L*/ case 0x86: temp=readmem(hl.w); setadd(af.b.h,temp); af.b.h+=temp; cycles-=8; break; /*ADD (HL)*/ // t 8 case 0x87: setadd(af.b.h,af.b.h); af.b.h+=af.b.h; cycles-=4; break; /*ADD A*/ /*ADC group*/ case 0x88: setadc(af.b.h,bc.b.h); af.b.h+=bc.b.h+tempc; cycles-=4; break; /*ADC B*/ case 0x89: setadc(af.b.h,bc.b.l); af.b.h+=bc.b.l+tempc; cycles-=4; break; /*ADC C*/ case 0x8A: setadc(af.b.h,de.b.h); af.b.h+=de.b.h+tempc; cycles-=4; break; /*ADC D*/ case 0x8B: setadc(af.b.h,de.b.l); af.b.h+=de.b.l+tempc; cycles-=4; break; /*ADC E*/ case 0x8C: setadc(af.b.h,hl.b.h); af.b.h+=hl.b.h+tempc; cycles-=4; break; /*ADC H*/ case 0x8D: setadc(af.b.h,hl.b.l); af.b.h+=hl.b.l+tempc; cycles-=4; break; /*ADC L*/ case 0x8E: temp=readmem(hl.w); setadc(af.b.h,temp); af.b.h+=temp+tempc; cycles-=8; break; /*ADC (HL)*/ // t 8 case 0x8F: setadc(af.b.h,af.b.h); af.b.h+=af.b.h+tempc; cycles-=4; break; /*ADC A*/ /*Subtract group*/ case 0x90: setsub(af.b.h,bc.b.h); af.b.h-=bc.b.h; cycles-=4; break; /*SUB B*/ case 0x91: setsub(af.b.h,bc.b.l); af.b.h-=bc.b.l; cycles-=4; break; /*SUB C*/ case 0x92: setsub(af.b.h,de.b.h); af.b.h-=de.b.h; cycles-=4; break; /*SUB D*/ case 0x93: setsub(af.b.h,de.b.l); af.b.h-=de.b.l; cycles-=4; break; /*SUB E*/ case 0x94: setsub(af.b.h,hl.b.h); af.b.h-=hl.b.h; cycles-=4; break; /*SUB H*/ case 0x95: setsub(af.b.h,hl.b.l); af.b.h-=hl.b.l; cycles-=4; break; /*SUB L*/ case 0x96: temp=readmem(hl.w); setsub(af.b.h,temp); af.b.h-=temp; cycles-=8; break; /*ADD (HL)*/ // t 8 case 0x97: setsub(af.b.h,af.b.h); af.b.h-=af.b.h; cycles-=4; break; /*SUB A*/ /*SBC group*/ case 0x98: setsbc(af.b.h,bc.b.h); af.b.h-=(bc.b.h+tempc); cycles-=4; break; /*SBC B*/ case 0x99: setsbc(af.b.h,bc.b.l); af.b.h-=(bc.b.l+tempc); cycles-=4; break; /*SBC C*/ case 0x9A: setsbc(af.b.h,de.b.h); af.b.h-=(de.b.h+tempc); cycles-=4; break; /*SBC D*/ case 0x9B: setsbc(af.b.h,de.b.l); af.b.h-=(de.b.l+tempc); cycles-=4; break; /*SBC E*/ case 0x9C: setsbc(af.b.h,hl.b.h); af.b.h-=(hl.b.h+tempc); cycles-=4; break; /*SBC H*/ case 0x9D: setsbc(af.b.h,hl.b.l); af.b.h-=(hl.b.l+tempc); cycles-=4; break; /*SBC L*/ case 0x9E: temp=readmem(hl.w); setsbc(af.b.h,temp); af.b.h-=(temp+tempc); cycles-=8; break; /*SBC (HL)*/ // t 8 case 0x9F: setsbc(af.b.h,af.b.h); af.b.h-=(af.b.h+tempc); cycles-=4; break; /*SBC A*/ /*AND group*/ case 0xA0: af.b.h&=bc.b.h; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=4; break; /*AND B*/ case 0xA1: af.b.h&=bc.b.l; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=4; break; /*AND C*/ case 0xA2: af.b.h&=de.b.h; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=4; break; /*AND D*/ case 0xA3: af.b.h&=de.b.l; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=4; break; /*AND E*/ case 0xA4: af.b.h&=hl.b.h; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=4; break; /*AND H*/ case 0xA5: af.b.h&=hl.b.l; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=4; break; /*AND L*/ case 0xA6: temp=readmem(hl.w); af.b.h&=temp; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=8; break; /*AND (HL)*/ // t 8 case 0xA7: af.b.h&=af.b.h; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=4; break; /*AND A*/ /*XOR group*/ case 0xA8: af.b.h^=bc.b.h; setzn(af.b.h); af.b.l&=~3; cycles-=4; break; /*XOR B*/ case 0xA9: af.b.h^=bc.b.l; setzn(af.b.h); af.b.l&=~3;cycles-=4; break; /*XOR C*/ case 0xAA: af.b.h^=de.b.h; setzn(af.b.h); af.b.l&=~3; cycles-=4; break; /*XOR D*/ case 0xAB: af.b.h^=de.b.l; setzn(af.b.h); af.b.l&=~3; cycles-=4; break; /*XOR E*/ case 0xAC: af.b.h^=hl.b.h; setzn(af.b.h); af.b.l&=~3; cycles-=4; break; /*XOR H*/ case 0xAD: af.b.h^=hl.b.l; setzn(af.b.h); af.b.l&=~3; cycles-=4; break; /*XOR L*/ case 0xAE: temp=readmem(hl.w); af.b.h^=temp; setzn(af.b.h); af.b.l&=~3; cycles-=8; break; /*XOR (HL)*/ // t 8 case 0xAF: af.b.h^=af.b.h; setzn(af.b.h); af.b.l&=~3; cycles-=4; break; /*XOR A*/ /*OR group*/ case 0xB0: af.b.h|=bc.b.h; setzn(af.b.h); af.b.l&=~3; cycles-=4; break; /*OR B*/ case 0xB1: af.b.h|=bc.b.l; setzn(af.b.h); af.b.l&=~3; cycles-=4; break; /*OR C*/ case 0xB2: af.b.h|=de.b.h; setzn(af.b.h); af.b.l&=~3; cycles-=4; break; /*OR D*/ case 0xB3: af.b.h|=de.b.l; setzn(af.b.h); af.b.l&=~3; cycles-=4; break; /*OR E*/ case 0xB4: af.b.h|=hl.b.h; setzn(af.b.h); af.b.l&=~3; cycles-=4; break; /*OR H*/ case 0xB5: af.b.h|=hl.b.l; setzn(af.b.h); af.b.l&=~3; cycles-=4; break; /*OR L*/ case 0xB6: temp=readmem(hl.w); af.b.h|=temp; setzn(af.b.h); af.b.l&=~3; cycles-=8; break; /*OR (HL)*/ // t 8 case 0xB7: af.b.h|=af.b.h; setzn(af.b.h); af.b.l&=~3; cycles-=4; break; /*OR A*/ /*CP group*/ case 0xB8: setcp(af.b.h,bc.b.h); cycles-=4; break; /*CP B*/ case 0xB9: setcp(af.b.h,bc.b.l); cycles-=4; break; /*CP C*/ case 0xBA: setcp(af.b.h,de.b.h); cycles-=4; break; /*CP D*/ case 0xBB: setcp(af.b.h,de.b.l); cycles-=4; break; /*CP E*/ case 0xBC: setcp(af.b.h,hl.b.h); cycles-=4; break; /*CP H*/ case 0xBD: setcp(af.b.h,hl.b.l); cycles-=4; break; /*CP L*/ case 0xBE: temp=readmem(hl.w); setcp(af.b.h,temp); /*if (output) { printf("CP %02X %02X\n",af.b.h,temp,ram[hl.w]); dumpregs(); dumpram(); exit(0); } */cycles-=8; break; /*CP (HL)*/ // t 8 case 0xBF: setcp(af.b.h,af.b.h); cycles-=4; break; /*CP A*/ //D96A is it // t 12 case 0xC0: /*RET NZ*/ if (!(af.b.l&Z_FLAG)) { pc=pull(); pc|=pull()<<8; cycles-=16; } else { cycles-=8; } break; // t 12 case 0xC1: /*POP BC*/ bc.b.l=pull(); bc.b.h=pull(); cycles-=12; break; // t 12 case 0xC2: /*JP NZ,xxxx*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (!(af.b.l&Z_FLAG)) pc=addr; cycles-=12; break; // t 12 case 0xC3: /*JP xxxx*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; pc=addr; cycles-=12; break; // t 8 12 case 0xC4: /*CALL NZ*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (!(af.b.l&Z_FLAG)) { push(pc>>8); push(pc&0xFF); pc=addr; cycles-=20; } else { cycles-=12; } break; // t 12 case 0xC5: /*PUSH BC*/ push(bc.b.h); push(bc.b.l); cycles-=16; break; // t 8 case 0xC6: /*ADD xx*/ temp=readmem(pc); pc++; setadd(af.b.h,temp); af.b.h+=temp; cycles-=8; break; // t 16 case 0xC7: /*RST 0*/ push(pc>>8); push(pc); pc=0x00; cycles-=16; break; // t 12 case 0xC8: /*RET Z*/ if (af.b.l&Z_FLAG) { pc=pull(); pc|=(pull()<<8); cycles-=16; } else { cycles-=8; } break; // t 12 case 0xC9: /*RET*/ // if (pc==0xBAA7) output=1; pc=pull(); pc|=pull()<<8; // if (output) printf("BAA7 %04X\n",pc); // output=0; cycles-=12; break; // t 12 case 0xCA: /*JP Z,xxxx*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (af.b.l&Z_FLAG) pc=addr; cycles-=12; break; case 0xCB: /*More opcodes*/ opcode=readmem(pc); pc++; ir.b.l++; switch (opcode) { case 0x00: if (bc.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.h<<=1; if (af.b.l&C_FLAG) bc.b.h|=1; setznc(bc.b.h); cycles-=8; break; /*RLC B*/ case 0x01: if (bc.b.l&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.l<<=1; if (af.b.l&C_FLAG) bc.b.l|=1; setznc(bc.b.l); cycles-=8; break; /*RLC C*/ case 0x02: if (de.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.h<<=1; if (af.b.l&C_FLAG) de.b.h|=1; setznc(de.b.h); cycles-=8; break; /*RLC D*/ case 0x03: if (de.b.l&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.l<<=1; if (af.b.l&C_FLAG) de.b.l|=1; setznc(de.b.l); cycles-=8; break; /*RLC E*/ case 0x04: if (hl.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.h<<=1; if (af.b.l&C_FLAG) hl.b.h|=1; setznc(hl.b.h); cycles-=8; break; /*RLC H*/ case 0x05: if (hl.b.l&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.l<<=1; if (af.b.l&C_FLAG) hl.b.l|=1; setznc(hl.b.l); cycles-=8; break; /*RLC L*/ case 0x06: temp=readmem(hl.w); if (temp&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp<<=1; if (af.b.l&C_FLAG) temp|=1; setznc(temp); writemem(hl.w,temp); cycles-=16; break; /*RLC L*/ // t 16 case 0x07: if (af.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; af.b.h<<=1; if (af.b.l&C_FLAG) af.b.h|=1; setznc(af.b.h); cycles-=8; break; /*RLC A*/ case 0x08: if (bc.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.h>>=1; if (af.b.l&C_FLAG) bc.b.h|=0x80; setznc(bc.b.h); cycles-=8; break; /*RRC B*/ case 0x09: if (bc.b.l&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.l>>=1; if (af.b.l&C_FLAG) bc.b.l|=0x80; setznc(bc.b.l); cycles-=8; break; /*RRC C*/ case 0x0A: if (de.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.h>>=1; if (af.b.l&C_FLAG) de.b.h|=0x80; setznc(de.b.h); cycles-=8; break; /*RRC D*/ case 0x0B: if (de.b.l&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.l>>=1; if (af.b.l&C_FLAG) de.b.l|=0x80; setznc(de.b.l); cycles-=8; break; /*RRC E*/ case 0x0C: if (hl.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.h>>=1; if (af.b.l&C_FLAG) hl.b.h|=0x80; setznc(hl.b.h); cycles-=8; break; /*RRC H*/ case 0x0D: if (hl.b.l&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.l>>=1; if (af.b.l&C_FLAG) hl.b.l|=0x80; setznc(hl.b.l); cycles-=8; break; /*RRC L*/ case 0x0E: temp=readmem(hl.w); if (temp&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp>>=1; if (af.b.l&C_FLAG) temp|=0x80; setznc(temp); writemem(hl.w,temp); cycles-=16; break; /*RRC (HL)*/// t 16 case 0x0F: if (af.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; af.b.h>>=1; if (af.b.l&C_FLAG) af.b.h|=0x80; setznc(af.b.h); cycles-=8; break; /*RRC A*/ case 0x10: if (bc.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.h<<=1; if (tempc) bc.b.h|=1; setznc(bc.b.h); cycles-=8; break; /*RL B*/ case 0x11: if (bc.b.l&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.l<<=1; if (tempc) bc.b.l|=1; setznc(bc.b.l); cycles-=8; break; /*RL C*/ case 0x12: if (de.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.h<<=1; if (tempc) de.b.h|=1; setznc(de.b.h); cycles-=8; break; /*RL D*/ case 0x13: if (de.b.l&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.l<<=1; if (tempc) de.b.l|=1; setznc(de.b.l); cycles-=8; break; /*RL E*/ case 0x14: if (hl.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.h<<=1; if (tempc) hl.b.h|=1; setznc(hl.b.h); cycles-=8; break; /*RL H*/ case 0x15: if (hl.b.l&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.l<<=1; if (tempc) hl.b.l|=1; setznc(hl.b.l); cycles-=8; break; /*RL L*/ case 0x16: temp=readmem(hl.w); if (temp&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp<<=1; if (tempc) temp|=1; setznc(temp); writemem(hl.w,temp); cycles-=16; break; /*RL (HL)*/ // t 16 case 0x17: if (af.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; af.b.h<<=1; if (tempc) af.b.h|=1; setznc(af.b.h); cycles-=8; break; /*RL A*/ case 0x18: if (bc.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.h>>=1; if (tempc) bc.b.h|=0x80; setznc(bc.b.h); cycles-=8; break; /*RR B*/ case 0x19: if (bc.b.l&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.l>>=1; if (tempc) bc.b.l|=0x80; setznc(bc.b.l); cycles-=8; break; /*RR C*/ case 0x1A: if (de.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.h>>=1; if (tempc) de.b.h|=0x80; setznc(de.b.h); cycles-=8; break; /*RR D*/ case 0x1B: if (de.b.l&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.l>>=1; if (tempc) de.b.l|=0x80; setznc(de.b.l); cycles-=8; break; /*RR E*/ case 0x1C: if (hl.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.h>>=1; if (tempc) hl.b.h|=0x80; setznc(hl.b.h); cycles-=8; break; /*RR H*/ case 0x1D: if (hl.b.l&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.l>>=1; if (tempc) hl.b.l|=0x80; setznc(hl.b.l); cycles-=8; break; /*RR L*/ case 0x1E: temp=readmem(hl.w); if (temp&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp>>=1; if (tempc) temp|=0x80; setznc(temp); writemem(hl.w,temp); cycles-=16; break; /*RR (HL)*/ // t 16 case 0x1F: if (af.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; af.b.h>>=1; if (tempc) af.b.h|=0x80; setznc(af.b.h); cycles-=8; break; /*RR A*/ case 0x20: if (bc.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.h<<=1; setznc(bc.b.h); cycles-=8; break; /*SLA B*/ case 0x21: if (bc.b.l&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.l<<=1; setznc(bc.b.l); cycles-=8; break; /*SLA C*/ case 0x22: if (de.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.h<<=1; setznc(de.b.h); cycles-=8; break; /*SLA D*/ case 0x23: if (de.b.l&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.l<<=1; setznc(de.b.l); cycles-=8; break; /*SLA E*/ case 0x24: if (hl.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.h<<=1; setznc(hl.b.h); cycles-=8; break; /*SLA H*/ case 0x25: if (hl.b.l&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.l<<=1; setznc(hl.b.l); cycles-=8; break; /*SLA L*/ case 0x26: temp=readmem(hl.w); if (temp&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp<<=1; setznc(temp); writemem(hl.w,temp); cycles-=16; break; /*SLA (HL)*/ // t 16 case 0x27: if (af.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; af.b.h<<=1; setznc(af.b.h); cycles-=8; break; /*SLA A*/ case 0x28: if (bc.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.h>>=1; if (bc.b.h&0x40) bc.b.h|=0x80; setznc(bc.b.h); cycles-=8; break; /*SRA B*/ case 0x29: if (bc.b.l&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.l>>=1; if (bc.b.l&0x40) bc.b.l|=0x80; setznc(bc.b.l); cycles-=8; break; /*SRA C*/ case 0x2A: if (de.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.h>>=1; if (de.b.h&0x40) de.b.h|=0x80; setznc(de.b.h); cycles-=8; break; /*SRA D*/ case 0x2B: if (de.b.l&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.l>>=1; if (de.b.l&0x40) de.b.l|=0x80; setznc(de.b.l); cycles-=8; break; /*SRA E*/ case 0x2C: if (hl.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.h>>=1; if (hl.b.h&0x40) hl.b.h|=0x80; setznc(hl.b.h); cycles-=8; break; /*SRA H*/ case 0x2D: if (hl.b.l&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.l>>=1; if (hl.b.l&0x40) hl.b.l|=0x80; setznc(hl.b.l); cycles-=8; break; /*SRA L*/ case 0x2E: temp=readmem(hl.w); if (temp&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp>>=1; if (temp&0x40) temp|=0x80; setznc(temp); writemem(hl.w,temp); cycles-=16; break; /*SRA (HL)*/ //t 16 case 0x2F: if (af.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; af.b.h>>=1; if (af.b.h&0x40) af.b.h|=0x80; setznc(af.b.h); cycles-=8; break; /*SRA A*/ case 0x30: if (bc.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.h<<=1; bc.b.h|=1; setznc(bc.b.h); cycles-=8; break; /*SLL B*/ case 0x31: if (bc.b.l&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.l<<=1; bc.b.l|=1; setznc(bc.b.l); cycles-=8; break; /*SLL C*/ case 0x32: if (de.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.h<<=1; de.b.h|=1; setznc(de.b.h); cycles-=8; break; /*SLL D*/ case 0x33: if (de.b.l&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.l<<=1; de.b.l|=1; setznc(de.b.l); cycles-=8; break; /*SLL E*/ case 0x34: if (hl.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.h<<=1; hl.b.h|=1; setznc(hl.b.h); cycles-=8; break; /*SLL H*/ case 0x35: if (hl.b.l&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.l<<=1; hl.b.l|=1; setznc(hl.b.l); cycles-=8; break; /*SLL L*/ case 0x36: temp=readmem(hl.w); if (temp&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp<<=1; temp|=1; setznc(temp); writemem(hl.w,temp); cycles-=16; break; /*SLL (HL)*/ // t 16 case 0x37: if (af.b.h&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; af.b.h<<=1; af.b.h|=1; setznc(af.b.h); cycles-=8; break; /*SLL A*/ case 0x38: if (bc.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.h>>=1; setznc(bc.b.h); cycles-=8; break; /*SRL B*/ case 0x39: if (bc.b.l&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; bc.b.l>>=1; setznc(bc.b.l); cycles-=8; break; /*SRL C*/ case 0x3A: if (de.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.h>>=1; setznc(de.b.h); cycles-=8; break; /*SRL D*/ case 0x3B: if (de.b.l&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; de.b.l>>=1; setznc(de.b.l); cycles-=8; break; /*SRL E*/ case 0x3C: if (hl.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.h>>=1; setznc(hl.b.h); cycles-=8; break; /*SRL H*/ case 0x3D: if (hl.b.l&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; hl.b.l>>=1; setznc(hl.b.l); cycles-=8; break; /*SRL L*/ case 0x3E: temp=readmem(hl.w); if (temp&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp>>=1; setznc(temp); writemem(hl.w,temp); cycles-=16; break; /*SRL (HL)*/ //t 16 case 0x3F: if (af.b.h&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; af.b.h>>=1; setznc(af.b.h); cycles-=8; break; /*SRL A*/ case 0x40: setznc(bc.b.h&0x01); cycles-=8; break; /*BIT 0,B*/ case 0x41: setznc(bc.b.l&0x01); cycles-=8; break; /*BIT 0,C*/ case 0x42: setznc(de.b.h&0x01); cycles-=8; break; /*BIT 0,D*/ case 0x43: setznc(de.b.l&0x01); cycles-=8; break; /*BIT 0,E*/ case 0x44: setznc(hl.b.h&0x01); cycles-=8; break; /*BIT 0,H*/ case 0x45: setznc(hl.b.l&0x01); cycles-=8; break; /*BIT 0,L*/ case 0x46: temp=readmem(hl.w); setznc(temp&0x01); cycles-=12; break; /*BIT 0,(HL)*/ case 0x47: setznc(af.b.h&0x01); cycles-=8; break; /*BIT 0,A*/ case 0x48: setznc(bc.b.h&0x02); cycles-=8; break; /*BIT 1,B*/ case 0x49: setznc(bc.b.l&0x02); cycles-=8; break; /*BIT 1,C*/ case 0x4A: setznc(de.b.h&0x02); cycles-=8; break; /*BIT 1,D*/ case 0x4B: setznc(de.b.l&0x02); cycles-=8; break; /*BIT 1,E*/ case 0x4C: setznc(hl.b.h&0x02); cycles-=8; break; /*BIT 1,H*/ case 0x4D: setznc(hl.b.l&0x02); cycles-=8; break; /*BIT 1,L*/ case 0x4E: temp=readmem(hl.w); setznc(temp&0x02); cycles-=12; break; /*BIT 1,(HL)*/ case 0x4F: setznc(af.b.h&0x02); cycles-=8; break; /*BIT 1,A*/ case 0x50: setznc(bc.b.h&0x04); cycles-=8; break; /*BIT 2,B*/ case 0x51: setznc(bc.b.l&0x04); cycles-=8; break; /*BIT 2,C*/ case 0x52: setznc(de.b.h&0x04); cycles-=8; break; /*BIT 2,D*/ case 0x53: setznc(de.b.l&0x04); cycles-=8; break; /*BIT 2,E*/ case 0x54: setznc(hl.b.h&0x04); cycles-=8; break; /*BIT 2,H*/ case 0x55: setznc(hl.b.l&0x04); cycles-=8; break; /*BIT 2,L*/ case 0x56: temp=readmem(hl.w); setznc(temp&0x04); cycles-=12; break; /*BIT 2,(HL)*/ case 0x57: setznc(af.b.h&0x04); cycles-=8; break; /*BIT 2,A*/ case 0x58: setznc(bc.b.h&0x08); cycles-=8; break; /*BIT 3,B*/ case 0x59: setznc(bc.b.l&0x08); cycles-=8; break; /*BIT 3,C*/ case 0x5A: setznc(de.b.h&0x08); cycles-=8; break; /*BIT 3,D*/ case 0x5B: setznc(de.b.l&0x08); cycles-=8; break; /*BIT 3,E*/ case 0x5C: setznc(hl.b.h&0x08); cycles-=8; break; /*BIT 3,H*/ case 0x5D: setznc(hl.b.l&0x08); cycles-=8; break; /*BIT 3,L*/ case 0x5E: temp=readmem(hl.w); setznc(temp&0x08); cycles-=12; break; /*BIT 3,(HL)*/ case 0x5F: setznc(af.b.h&0x08); cycles-=8; break; /*BIT 3,A*/ case 0x60: setznc(bc.b.h&0x10); cycles-=8; break; /*BIT 4,B*/ case 0x61: setznc(bc.b.l&0x10); cycles-=8; break; /*BIT 4,C*/ case 0x62: setznc(de.b.h&0x10); cycles-=8; break; /*BIT 4,D*/ case 0x63: setznc(de.b.l&0x10); cycles-=8; break; /*BIT 4,E*/ case 0x64: setznc(hl.b.h&0x10); cycles-=8; break; /*BIT 4,H*/ case 0x65: setznc(hl.b.l&0x10); cycles-=8; break; /*BIT 4,L*/ case 0x66: temp=readmem(hl.w); setznc(temp&0x10); cycles-=12; break; /*BIT 4,(HL)*/ case 0x67: setznc(af.b.h&0x10); cycles-=8; break; /*BIT 4,A*/ case 0x68: setznc(bc.b.h&0x20); cycles-=8; break; /*BIT 5,B*/ case 0x69: setznc(bc.b.l&0x20); cycles-=8; break; /*BIT 5,C*/ case 0x6A: setznc(de.b.h&0x20); cycles-=8; break; /*BIT 5,D*/ case 0x6B: setznc(de.b.l&0x20); cycles-=8; break; /*BIT 5,E*/ case 0x6C: setznc(hl.b.h&0x20); cycles-=8; break; /*BIT 5,H*/ case 0x6D: setznc(hl.b.l&0x20); cycles-=8; break; /*BIT 5,L*/ case 0x6E: temp=readmem(hl.w); setznc(temp&0x20); cycles-=12; break; /*BIT 5,(HL)*/ case 0x6F: setznc(af.b.h&0x20); cycles-=8; break; /*BIT 5,A*/ case 0x70: setznc(bc.b.h&0x40); cycles-=8; break; /*BIT 6,B*/ case 0x71: setznc(bc.b.l&0x40); cycles-=8; break; /*BIT 6,C*/ case 0x72: setznc(de.b.h&0x40); cycles-=8; break; /*BIT 6,D*/ case 0x73: setznc(de.b.l&0x40); cycles-=8; break; /*BIT 6,E*/ case 0x74: setznc(hl.b.h&0x40); cycles-=8; break; /*BIT 6,H*/ case 0x75: setznc(hl.b.l&0x40); cycles-=8; break; /*BIT 6,L*/ case 0x76: temp=readmem(hl.w); setznc(temp&0x40); cycles-=12; break; /*BIT 6,(HL)*/ case 0x77: setznc(af.b.h&0x40); cycles-=8; break; /*BIT 6,A*/ case 0x78: setznc(bc.b.h&0x80); cycles-=8; break; /*BIT 7,B*/ case 0x79: setznc(bc.b.l&0x80); cycles-=8; break; /*BIT 7,C*/ case 0x7A: setznc(de.b.h&0x80); cycles-=8; break; /*BIT 7,D*/ case 0x7B: setznc(de.b.l&0x80); cycles-=8; break; /*BIT 7,E*/ case 0x7C: setznc(hl.b.h&0x80); cycles-=8; break; /*BIT 7,H*/ case 0x7D: setznc(hl.b.l&0x80); cycles-=8; break; /*BIT 7,L*/ case 0x7E: temp=readmem(hl.w); setznc(temp&0x80); cycles-=12; break; /*BIT 7,(HL)*/ case 0x7F: setznc(af.b.h&0x80); cycles-=8; break; /*BIT 7,A*/ case 0x80: bc.b.h&=~1; cycles-=8; break; /*RES 0,B*/ case 0x81: bc.b.l&=~1; cycles-=8; break; /*RES 0,C*/ case 0x82: de.b.h&=~1; cycles-=8; break; /*RES 0,D*/ case 0x83: de.b.l&=~1; cycles-=8; break; /*RES 0,E*/ case 0x84: hl.b.h&=~1; cycles-=8; break; /*RES 0,H*/ case 0x85: hl.b.l&=~1; cycles-=8; break; /*RES 0,L*/ case 0x86: temp=readmem(hl.w)&~0x01; writemem(hl.w,temp); cycles-=16; break; /*RES 0,(HL)*/ // t 16 case 0x87: af.b.h&=~1; cycles-=8; break; /*RES 0,A*/ case 0x88: bc.b.h&=~2; cycles-=8; break; /*RES 1,B*/ case 0x89: bc.b.l&=~2; cycles-=8; break; /*RES 1,C*/ case 0x8A: de.b.h&=~2; cycles-=8; break; /*RES 1,D*/ case 0x8B: de.b.l&=~2; cycles-=8; break; /*RES 1,E*/ case 0x8C: hl.b.h&=~2; cycles-=8; break; /*RES 1,H*/ case 0x8D: hl.b.l&=~2; cycles-=8; break; /*RES 1,L*/ case 0x8E: temp=readmem(hl.w)&~0x02; writemem(hl.w,temp); cycles-=16; break; /*RES 1,(HL)*/ // t 16 case 0x8F: af.b.h&=~2; cycles-=8; break; /*RES 1,A*/ case 0x90: bc.b.h&=~4; cycles-=8; break; /*RES 2,B*/ case 0x91: bc.b.l&=~4; cycles-=8; break; /*RES 2,C*/ case 0x92: de.b.h&=~4; cycles-=8; break; /*RES 2,D*/ case 0x93: de.b.l&=~4; cycles-=8; break; /*RES 2,E*/ case 0x94: hl.b.h&=~4; cycles-=8; break; /*RES 2,H*/ case 0x95: hl.b.l&=~4; cycles-=8; break; /*RES 2,L*/ case 0x96: temp=readmem(hl.w)&~0x04; writemem(hl.w,temp); cycles-=16; break; /*RES 2,(HL)*/ // t 16 case 0x97: af.b.h&=~4; cycles-=8; break; /*RES 2,A*/ case 0x98: bc.b.h&=~8; cycles-=8; break; /*RES 3,B*/ case 0x99: bc.b.l&=~8; cycles-=8; break; /*RES 3,C*/ case 0x9A: de.b.h&=~8; cycles-=8; break; /*RES 3,D*/ case 0x9B: de.b.l&=~8; cycles-=8; break; /*RES 3,E*/ case 0x9C: hl.b.h&=~8; cycles-=8; break; /*RES 3,H*/ case 0x9D: hl.b.l&=~8; cycles-=8; break; /*RES 3,L*/ case 0x9E: temp=readmem(hl.w)&~0x08; writemem(hl.w,temp); cycles-=16; break; /*RES 3,(HL)*/ // t 16 case 0x9F: af.b.h&=~8; cycles-=8; break; /*RES 3,A*/ case 0xA0: bc.b.h&=~0x10; cycles-=8; break; /*RES 4,B*/ case 0xA1: bc.b.l&=~0x10; cycles-=8; break; /*RES 4,C*/ case 0xA2: de.b.h&=~0x10; cycles-=8; break; /*RES 4,D*/ case 0xA3: de.b.l&=~0x10; cycles-=8; break; /*RES 4,E*/ case 0xA4: hl.b.h&=~0x10; cycles-=8; break; /*RES 4,H*/ case 0xA5: hl.b.l&=~0x10; cycles-=8; break; /*RES 4,L*/ case 0xA6: temp=readmem(hl.w)&~0x10; writemem(hl.w,temp); cycles-=16; break; /*RES 4,(HL)*/ // t 16 case 0xA7: af.b.h&=~0x10; cycles-=8; break; /*RES 4,A*/ case 0xA8: bc.b.h&=~0x20; cycles-=8; break; /*RES 5,B*/ case 0xA9: bc.b.l&=~0x20; cycles-=8; break; /*RES 5,C*/ case 0xAA: de.b.h&=~0x20; cycles-=8; break; /*RES 5,D*/ case 0xAB: de.b.l&=~0x20; cycles-=8; break; /*RES 5,E*/ case 0xAC: hl.b.h&=~0x20; cycles-=8; break; /*RES 5,H*/ case 0xAD: hl.b.l&=~0x20; cycles-=8; break; /*RES 5,L*/ case 0xAE: temp=readmem(hl.w)&~0x20; writemem(hl.w,temp); cycles-=16; break; /*RES 5,(HL)*/ // t 16 case 0xAF: af.b.h&=~0x20; cycles-=8; break; /*RES 5,A*/ case 0xB0: bc.b.h&=~0x40; cycles-=8; break; /*RES 6,B*/ case 0xB1: bc.b.l&=~0x40; cycles-=8; break; /*RES 6,C*/ case 0xB2: de.b.h&=~0x40; cycles-=8; break; /*RES 6,D*/ case 0xB3: de.b.l&=~0x40; cycles-=8; break; /*RES 6,E*/ case 0xB4: hl.b.h&=~0x40; cycles-=8; break; /*RES 6,H*/ case 0xB5: hl.b.l&=~0x40; cycles-=8; break; /*RES 6,L*/ case 0xB6: temp=readmem(hl.w)&~0x40; writemem(hl.w,temp); cycles-=16; break; /*RES 6,(HL)*/ // t 16 case 0xB7: af.b.h&=~0x40; cycles-=8; break; /*RES 6,A*/ case 0xB8: bc.b.h&=~0x80; cycles-=8; break; /*RES 7,B*/ case 0xB9: bc.b.l&=~0x80; cycles-=8; break; /*RES 7,C*/ case 0xBA: de.b.h&=~0x80; cycles-=8; break; /*RES 7,D*/ case 0xBB: de.b.l&=~0x80; cycles-=8; break; /*RES 7,E*/ case 0xBC: hl.b.h&=~0x80; cycles-=8; break; /*RES 7,H*/ case 0xBD: hl.b.l&=~0x80; cycles-=8; break; /*RES 7,L*/ case 0xBE: temp=readmem(hl.w)&~0x80; writemem(hl.w,temp); cycles-=16; break; /*RES 7,(HL)*/ // t 16 case 0xBF: af.b.h&=~0x80; cycles-=8; break; /*RES 7,A*/ case 0xC0: bc.b.h|=0x01; cycles-=8; break; /*SET 0,B*/ case 0xC1: bc.b.l|=0x01; cycles-=8; break; /*SET 0,C*/ case 0xC2: de.b.h|=0x01; cycles-=8; break; /*SET 0,D*/ case 0xC3: de.b.l|=0x01; cycles-=8; break; /*SET 0,E*/ case 0xC4: hl.b.h|=0x01; cycles-=8; break; /*SET 0,H*/ case 0xC5: hl.b.l|=0x01; cycles-=8; break; /*SET 0,L*/ case 0xC6: temp=readmem(hl.w)|0x01; writemem(hl.w,temp); cycles-=16; break; /*SET 0,(HL)*/ // t 16 case 0xC7: af.b.h|=0x01; cycles-=8; break; /*SET 0,A*/ case 0xC8: bc.b.h|=0x02; cycles-=8; break; /*SET 1,B*/ case 0xC9: bc.b.l|=0x02; cycles-=8; break; /*SET 1,C*/ case 0xCA: de.b.h|=0x02; cycles-=8; break; /*SET 1,D*/ case 0xCB: de.b.l|=0x02; cycles-=8; break; /*SET 1,E*/ case 0xCC: hl.b.h|=0x02; cycles-=8; break; /*SET 1,H*/ case 0xCD: hl.b.l|=0x02; cycles-=8; break; /*SET 1,L*/ case 0xCE: temp=readmem(hl.w)|0x02; writemem(hl.w,temp); cycles-=16; break; /*SET 1,(HL)*/ // t 16 case 0xCF: af.b.h|=0x02; cycles-=8; break; /*SET 1,A*/ case 0xD0: bc.b.h|=0x04; cycles-=8; break; /*SET 2,B*/ case 0xD1: bc.b.l|=0x04; cycles-=8; break; /*SET 2,C*/ case 0xD2: de.b.h|=0x04; cycles-=8; break; /*SET 2,D*/ case 0xD3: de.b.l|=0x04; cycles-=8; break; /*SET 2,E*/ case 0xD4: hl.b.h|=0x04; cycles-=8; break; /*SET 2,H*/ case 0xD5: hl.b.l|=0x04; cycles-=8; break; /*SET 2,L*/ case 0xD6: temp=readmem(hl.w)|0x04; writemem(hl.w,temp); cycles-=16; break; /*SET 2,(HL)*/ // t 16 case 0xD7: af.b.h|=0x04; cycles-=8; break; /*SET 2,A*/ case 0xD8: bc.b.h|=0x08; cycles-=8; break; /*SET 3,B*/ case 0xD9: bc.b.l|=0x08; cycles-=8; break; /*SET 3,C*/ case 0xDA: de.b.h|=0x08; cycles-=8; break; /*SET 3,D*/ case 0xDB: de.b.l|=0x08; cycles-=8; break; /*SET 3,E*/ case 0xDC: hl.b.h|=0x08; cycles-=8; break; /*SET 3,H*/ case 0xDD: hl.b.l|=0x08; cycles-=8; break; /*SET 3,L*/ case 0xDE: temp=readmem(hl.w)|0x08; writemem(hl.w,temp); cycles-=16; break; /*SET 3,(HL)*/ // t 16 case 0xDF: af.b.h|=0x08; cycles-=8; break; /*SET 3,A*/ case 0xE0: bc.b.h|=0x10; cycles-=8; break; /*SET 4,B*/ case 0xE1: bc.b.l|=0x10; cycles-=8; break; /*SET 4,C*/ case 0xE2: de.b.h|=0x10; cycles-=8; break; /*SET 4,D*/ case 0xE3: de.b.l|=0x10; cycles-=8; break; /*SET 4,E*/ case 0xE4: hl.b.h|=0x10; cycles-=8; break; /*SET 4,H*/ case 0xE5: hl.b.l|=0x10; cycles-=8; break; /*SET 4,L*/ case 0xE6: temp=readmem(hl.w)|0x10; writemem(hl.w,temp); cycles-=16; break; /*SET 4,(HL)*/ // t 16 case 0xE7: af.b.h|=0x10; cycles-=8; break; /*SET 4,A*/ case 0xE8: bc.b.h|=0x20; cycles-=8; break; /*SET 5,B*/ case 0xE9: bc.b.l|=0x20; cycles-=8; break; /*SET 5,C*/ case 0xEA: de.b.h|=0x20; cycles-=8; break; /*SET 5,D*/ case 0xEB: de.b.l|=0x20; cycles-=8; break; /*SET 5,E*/ case 0xEC: hl.b.h|=0x20; cycles-=8; break; /*SET 5,H*/ case 0xED: hl.b.l|=0x20; cycles-=8; break; /*SET 5,L*/ case 0xEE: temp=readmem(hl.w)|0x20; writemem(hl.w,temp); cycles-=16; break; /*SET 5,(HL)*/ // t 16 case 0xEF: af.b.h|=0x20; cycles-=8; break; /*SET 5,A*/ case 0xF0: bc.b.h|=0x40; cycles-=8; break; /*SET 6,B*/ case 0xF1: bc.b.l|=0x40; cycles-=8; break; /*SET 6,C*/ case 0xF2: de.b.h|=0x40; cycles-=8; break; /*SET 6,D*/ case 0xF3: de.b.l|=0x40; cycles-=8; break; /*SET 6,E*/ case 0xF4: hl.b.h|=0x40; cycles-=8; break; /*SET 6,H*/ case 0xF5: hl.b.l|=0x40; cycles-=8; break; /*SET 6,L*/ case 0xF6: temp=readmem(hl.w)|0x40; writemem(hl.w,temp); cycles-=16; break; /*SET 6,(HL)*/ // t 16 case 0xF7: af.b.h|=0x40; cycles-=8; break; /*SET 6,A*/ case 0xF8: bc.b.h|=0x80; cycles-=8; break; /*SET 7,B*/ case 0xF9: bc.b.l|=0x80; cycles-=8; break; /*SET 7,C*/ case 0xFA: de.b.h|=0x80; cycles-=8; break; /*SET 7,D*/ case 0xFB: de.b.l|=0x80; cycles-=8; break; /*SET 7,E*/ case 0xFC: hl.b.h|=0x80; cycles-=8; break; /*SET 7,H*/ case 0xFD: hl.b.l|=0x80; cycles-=8; break; /*SET 7,L*/ case 0xFE: temp=readmem(hl.w)|0x80; writemem(hl.w,temp); cycles-=16; break; /*SET 7,(HL)*/ // t 16 case 0xFF: af.b.h|=0x80; cycles-=8; break; /*SET 7,A*/ default: //printf("Bad CB opcode %02X at %04X\n",opcode,--pc); dumpregs(); exit(-1); } break; // t 5 8? case 0xCC: /*CALL Z*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (af.b.l&Z_FLAG) { push(pc>>8); push(pc&0xFF); pc=addr; cycles-=20; } else { cycles-=12; } break; // t 20 case 0xCD: /*CALL*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; push(pc>>8); push(pc&0xFF); pc=addr; cycles-=20; break; // t 8 case 0xCE: /*ADC xx*/ temp=readmem(pc); pc++; setadc(af.b.h,temp); af.b.h+=(temp+tempc); cycles-=8; break; // t 16 case 0xCF: /*RST 8*/ push(pc>>8); push(pc); pc=0x08; cycles-=16; break; // t 12 -- conflict (only 5) - using Aspectrum T case 0xD0: /*RET NC*/ if (!(af.b.l&C_FLAG)) { pc=pull(); pc|=pull()<<8; cycles-=16; } else { cycles-=8; } break; // t 12 case 0xD1: /*POP DE*/ de.b.l=pull(); de.b.h=pull(); cycles-=12; break; // t 12 case 0xD2: /*JP NC,xxxx*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (!(af.b.l&C_FLAG)) pc=addr; cycles-=12; break; // t 12 case 0xD3: /*OUT (xx),A*/ temp=readmem(pc); pc++; z80out(temp|(af.b.h<<8),af.b.h); cycles-=12; break; // t 8 12 case 0xD4: /*CALL NC*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (!(af.b.l&C_FLAG)) { push(pc>>8); push(pc&0xFF); pc=addr; cycles-=20; } else { cycles-=12; } break; // t 12 case 0xD5: /*PUSH DE*/ push(de.b.h); push(de.b.l); cycles-=16; break; // t 8 case 0xD6: /*SUB xx*/ temp=readmem(pc); pc++; setsub(af.b.h,temp); af.b.h-=temp; cycles-=8; break; // t 16 case 0xD7: /*RST 10*/ push(pc>>8); push(pc); pc=0x10; cycles-=16; break; // t 12 -- CONFLICT (only 5) using ASPECTRUM T case 0xD8: /*RET C*/ if (af.b.l&C_FLAG) { pc=pull(); pc|=pull()<<8; cycles-=16; } else { cycles-=8; } break; // t 4 case 0xD9: /*EXX*/ tempw=bc.w; bc.w=sbc.w; sbc.w=tempw; tempw=de.w; de.w=sde.w; sde.w=tempw; tempw=hl.w; hl.w=shl.w; shl.w=tempw; cycles-=4; break; // t 12 case 0xDA: /*JP C,xxxx*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (af.b.l&C_FLAG) pc=addr; cycles-=12; break; // t 12 case 0xDB: /*IN A,(xx)*/ addr=readmem(pc); pc++; af.b.h=z80in((af.b.h<<8)|addr); cycles-=12; break; // t 8 12 case 0xDC: /*CALL C*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (af.b.l&C_FLAG) { push(pc>>8); push(pc&0xFF); pc=addr; cycles-=20; } else { cycles-=12; } break; case 0xDD: /*More opcodes - IX*/ ir.b.l++; opcode=readmem(pc); pc++; switch (opcode) { case 0x09: /*ADD IX,BC*/ setadd16(ix.w,bc.w); ix.w+=bc.w; cycles-=16; //t 16 break; case 0x19: /*ADD IX,DE*/ setadd16(ix.w,de.w); ix.w+=de.w; cycles-=16; //t 16 break; case 0x21: /*LD IX,xxxx*/ ix.b.l=readmem(pc); pc++; ix.b.h=readmem(pc); pc++; cycles-=16; //t 16 break; case 0x22: /*LD (xxxx),IX*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; writemem(addr,ix.b.l); writemem(addr+1,ix.b.h); cycles-=24; // t 24 break; case 0x23: /*INC IX*/ ix.w++; cycles-=12; // t 8 break; case 0x24: /*INC IXh*/ ix.b.h++; setinc(ix.b.h); cycles-=8; break; case 0x25: /*DEC IXh*/ ix.b.h--; setdec(ix.b.h); cycles-=8; break; case 0x26: /*LD IXh,xx*/ ix.b.h=readmem(pc); pc++; cycles-=12; // t 12 break; case 0x29: /*ADD IX,IX*/ setadd16(ix.w,ix.w); ix.w+=ix.w; cycles-=16; //t 16 break; case 0x2A: /*LD IX,(xxxx)*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; ix.b.l=readmem(addr); ix.b.h=readmem(addr+1); cycles-=24; // t 24 break; case 0x2B: /*DEC IX*/ ix.w--; cycles-=12; // 8 break; case 0x2C: /*INC IXl*/ ix.b.l++; setinc(ix.b.l); cycles-=8; // 8 break; case 0x2D: /*DEC IXl*/ ix.b.l--; setdec(ix.b.l); cycles-=8; // 8 break; case 0x2E: /*LD IXl,xx*/ ix.b.l=readmem(pc); pc++; cycles-=12; // t 12 break; case 0x34: /*INC (IX+d)*/ offset=(signed char)readmem(pc); pc++; temp=readmem(ix.w+offset)+1; setinc(temp); writemem(ix.w+offset,temp); cycles-=24; // t 12 break; case 0x35: /*DEC (IX+d)*/ offset=(signed char)readmem(pc); pc++; temp=readmem(ix.w+offset)-1; setdec(temp); writemem(ix.w+offset,temp); cycles-=24; // t 12 break; case 0x36: /*LD (IX+d),xx*/ offset=(signed char)readmem(pc); pc++; temp=readmem(pc); pc++; writemem(ix.w+offset,temp); cycles-=24; // t 24 break; case 0x39: /*ADD IX,SP*/ setadd16(ix.w,sp); ix.w+=sp; cycles-=16; // t 16 break; case 0x44: bc.b.h=ix.b.h; cycles-=8; break; /*LD B,IXh*/ // NEW case 0x45: bc.b.h=ix.b.l; cycles-=8; break; /*LD B,IXl*/ case 0x46: offset=(signed char)readmem(pc); pc++; bc.b.h=readmem(ix.w+offset); cycles-=20; break; /*LD B,(IX+d)*/ // t 24 case 0x4E: offset=(signed char)readmem(pc); pc++; bc.b.l=readmem(ix.w+offset); cycles-=20; break; /*LD C,(IX+d)*/ // t 24 case 0x56: offset=(signed char)readmem(pc); pc++; de.b.h=readmem(ix.w+offset); cycles-=20; break; /*LD D,(IX+d)*/ // t 24 case 0x5E: offset=(signed char)readmem(pc); pc++; de.b.l=readmem(ix.w+offset); cycles-=20; break; /*LD E,(IX+d)*/ // t 24 case 0x66: offset=(signed char)readmem(pc); pc++; hl.b.h=readmem(ix.w+offset); cycles-=20; break; /*LD H,(IX+d)*/ // t 24 case 0x6E: offset=(signed char)readmem(pc); pc++; hl.b.l=readmem(ix.w+offset); cycles-=20; break; /*LD L,(IX+d)*/ // t 24 case 0x7E: offset=(signed char)readmem(pc); pc++; af.b.h=readmem(ix.w+offset); cycles-=20; break; /*LD A,(IX+d)*/ // t 24 case 0x4C: bc.b.l=ix.b.h; cycles-=8; break; /*LD C,IXh*/ case 0x4D: bc.b.l=ix.b.l; cycles-=8; break; /*LD C,IXl*/ case 0x54: de.b.h=ix.b.h; cycles-=8; break; /*LD D,IXh*/ case 0x55: de.b.h=ix.b.l; cycles-=8; break; /*LD D,IXl*/ case 0x5C: de.b.l=ix.b.h; cycles-=8; break; /*LD E,IXh*/ case 0x5D: de.b.l=ix.b.l; cycles-=8; break; /*LD E,IXl*/ case 0x60: ix.b.h=bc.b.h; cycles-=8; break; /*LD IXh,B*/ case 0x61: ix.b.h=bc.b.l; cycles-=8; break; /*LD IXh,C*/ case 0x62: ix.b.h=de.b.h; cycles-=8; break; /*LD IXh,B*/ case 0x63: ix.b.h=de.b.l; cycles-=8; break; /*LD IXh,C*/ case 0x64: ix.b.h=hl.b.h; cycles-=8; break; /*LD IXh,B*/ case 0x65: ix.b.h=hl.b.l; cycles-=8; break; /*LD IXh,C*/ case 0x67: ix.b.h=af.b.h; cycles-=8; break; /*LD IXh,A*/ case 0x68: ix.b.l=bc.b.h; cycles-=8; break; /*LD IXl,B*/ case 0x69: ix.b.l=bc.b.l; cycles-=8; break; /*LD IXl,C*/ case 0x6A: ix.b.l=de.b.h; cycles-=8; break; /*LD IXl,B*/ case 0x6B: ix.b.l=de.b.l; cycles-=8; break; /*LD IXl,C*/ case 0x6C: ix.b.l=hl.b.h; cycles-=8; break; /*LD IXl,B*/ case 0x6D: ix.b.l=hl.b.l; cycles-=8; break; /*LD IXl,C*/ case 0x6F: ix.b.l=af.b.h; cycles-=8; break; /*LD IXl,A*/ case 0x70: offset=(signed char)readmem(pc); pc++; writemem(ix.w+offset,bc.b.h); cycles-=20; break; /*LD (IX+d),B*/ // t 24 case 0x71: offset=(signed char)readmem(pc); pc++; writemem(ix.w+offset,bc.b.l); cycles-=20; break; /*LD (IX+d),C*/ // t 24 case 0x72: offset=(signed char)readmem(pc); pc++; writemem(ix.w+offset,de.b.h); cycles-=20; break; /*LD (IX+d),D*/ // t 24 case 0x73: offset=(signed char)readmem(pc); pc++; writemem(ix.w+offset,de.b.l); cycles-=20; break; /*LD (IX+d),E*/ // t 24 case 0x74: offset=(signed char)readmem(pc); pc++; writemem(ix.w+offset,hl.b.h); cycles-=20; break; /*LD (IX+d),H*/ // t 24 case 0x75: offset=(signed char)readmem(pc); pc++; writemem(ix.w+offset,hl.b.l); cycles-=20; break; /*LD (IX+d),L*/ // t 24 case 0x77: offset=(signed char)readmem(pc); pc++; writemem(ix.w+offset,af.b.h); cycles-=20; break; /*LD (IX+d),A*/ // t 24 case 0x7C: af.b.h=ix.b.h; cycles-=8; break; /*LD A,IXh*/ case 0x7D: af.b.h=ix.b.l; cycles-=8; break; /*LD A,IXl*/ case 0x84: setadd(af.b.h,ix.b.h); af.b.h+=ix.b.h; cycles-=8; break; /*ADD IXh*/ case 0x85: setadd(af.b.h,ix.b.l); af.b.h+=ix.b.l; cycles-=8; break; /*ADD IXl*/ case 0x8C: setadc(af.b.h,ix.b.h); af.b.h+=ix.b.h+tempc; cycles-=4; break; /*ADC IXh*/ case 0x8D: setadc(af.b.h,ix.b.l); af.b.h+=ix.b.l+tempc; cycles-=4; break; /*ADC IXl*/ case 0x94: setsub(af.b.h,ix.b.h); af.b.h-=ix.b.h; cycles-=4; break; /*SUB IXh*/ case 0x95: setsub(af.b.h,ix.b.l); af.b.h-=ix.b.l; cycles-=4; break; /*SUB IXl*/ case 0x86: offset=(signed char)readmem(pc); pc++; temp=readmem(ix.w+offset); setadd(af.b.h,temp); af.b.h+=temp; cycles-=20; break; /*ADD (IX+d)*/ // t 28 case 0x8E: offset=(signed char)readmem(pc); pc++; temp=readmem(ix.w+offset); setadc(af.b.h,temp); af.b.h+=temp+tempc; cycles-=20; break; /*ADC (IX+d)*/ // t 28 case 0x96: offset=(signed char)readmem(pc); pc++; temp=readmem(ix.w+offset); setsub(af.b.h,temp); af.b.h-=temp; cycles-=20; break; /*SUB (IX+d)*/ // t 28 case 0xA6: offset=(signed char)readmem(pc); pc++; temp=readmem(ix.w+offset); af.b.h&=temp; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=20; break; /*AND (IX+d)*/ // t 28 case 0xAE: offset=(signed char)readmem(pc); pc++; temp=readmem(ix.w+offset); af.b.h^=temp; setzn(af.b.h); cycles-=20; break; /*XOR (IX+d)*/ // t 28 case 0xB6: offset=(signed char)readmem(pc); pc++; temp=readmem(ix.w+offset); af.b.h|=temp; setzn(af.b.h); cycles-=20; break; /*OR (IX+d)*/ // t 28 // NEW. case 0x9C: setsbc(af.b.h,ix.b.h); af.b.h-=(ix.b.h+tempc); cycles-=8; break; /*SBC IXh*/ case 0x9D: setsbc(af.b.h,ix.b.l); af.b.h-=(ix.b.l+tempc); cycles-=8; break; /*SBC IXl*/ case 0x9E: offset=(signed char)readmem(pc); pc++; temp=readmem(ix.w+offset); setsbc(af.b.h,temp); af.b.h-=temp; cycles-=20; break; /*SBC (IX+d)*/ // NEW // NEW. case 0xBC: setcp(af.b.h,ix.b.h); cycles-=8; break; /*CP IXh*/ // NEW case 0xBD: setcp(af.b.h,ix.b.l); cycles-=8; break; /*CP IXl*/ // NEW case 0xBE: offset=(signed char)readmem(pc); pc++; temp=readmem(ix.w+offset); setcp(af.b.h,temp); cycles-=20; break; /*CP (IX+d)*/ // t 28 // NEW. case 0xAC: af.b.h^=ix.b.h; setzn(af.b.h); af.b.l&=~3; cycles-=8; break; /*XOR IXh*/ // NEW case 0xAD: af.b.h^=ix.b.l; setzn(af.b.h); af.b.l&=~3; cycles-=8; break; /*XOR IXL*/ // NEW case 0xA4: af.b.h&=ix.b.h; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=8; break; /*AND IXh*/ case 0xA5: af.b.h&=ix.b.l; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=8; break; /*AND IXl*/ case 0xB4: af.b.h|=ix.b.h; setzn(af.b.h); cycles-=8; break; /*OR IXh*/ case 0xB5: af.b.h|=ix.b.l; setzn(af.b.h); cycles-=8; break; /*OR IXl*/ case 0xCB: /*More opcodes*/ offset=(signed char)readmem(pc); pc++; opcode=readmem(pc); pc++; ir.b.l++; switch (opcode) { case 0x06: temp=readmem(ix.w+offset); if (temp&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp<<=1; if (af.b.l&C_FLAG) temp|=1; setznc(temp); writemem(ix.w+offset,temp); cycles-=28; break; /*RLC (IX+d)*/ // t 28 case 0x0E: temp=readmem(ix.w+offset); if (temp&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp>>=1; if (af.b.l&C_FLAG) temp|=0x80; setznc(temp); writemem(ix.w+offset,temp); cycles-=28; break; /*RRC (IX+d)*/ // t 28 case 0x16: temp=readmem(ix.w+offset); if (temp&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp<<=1; if (tempc) temp|=1; setznc(temp); writemem(ix.w+offset,temp); cycles-=28; break; /*RL (IX+d)*/ // t 16 case 0x1E: temp=readmem(ix.w+offset); if (temp&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp>>=1; if (tempc) temp|=0x80; setznc(temp); writemem(ix.w+offset,temp); cycles-=28; break; /*RR (IX+d)*/ // t 28 case 0x26: temp=readmem(ix.w+offset); if (temp&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp<<=1; setznc(temp); writemem(ix.w+offset,temp); cycles-=28; break; /*SLA (IX+d)*/ //t 28 case 0x2E: temp=readmem(ix.w+offset); if (temp&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp>>=1; if (temp&0x40) temp|=0x80; setznc(temp); writemem(ix.w+offset,temp); cycles-=28; break; /*SRA (IX+d)*/ case 0x3E: temp=readmem(ix.w+offset); if (temp&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp>>=1; setznc(temp); writemem(ix.w+offset,temp); cycles-=28; break; /*SRA (IX+d)*/ // t 28 case 0x46: temp=readmem(ix.w+offset); setznc(temp&0x01); cycles-=24; break; /*BIT 0,(IX+d)*/ // t 24 case 0x4E: temp=readmem(ix.w+offset); setznc(temp&0x02); cycles-=24; break; /*BIT 1,(IX+d)*/ // t 24 case 0x56: temp=readmem(ix.w+offset); setznc(temp&0x04); cycles-=24; break; /*BIT 2,(IX+d)*/ // t 24 case 0x5E: temp=readmem(ix.w+offset); setznc(temp&0x08); cycles-=24; break; /*BIT 3,(IX+d)*/ // t 24 case 0x66: temp=readmem(ix.w+offset); setznc(temp&0x10); cycles-=24; break; /*BIT 4,(IX+d)*/ // t 24 case 0x6E: temp=readmem(ix.w+offset); setznc(temp&0x20); cycles-=24; break; /*BIT 5,(IX+d)*/ // t 24 case 0x76: temp=readmem(ix.w+offset); setznc(temp&0x40); cycles-=24; break; /*BIT 6,(IX+d)*/ // t 24 case 0x7E: temp=readmem(ix.w+offset); setznc(temp&0x80); cycles-=24; break; /*BIT 7,(IX+d)*/ // t 24 case 0x86: temp=readmem(ix.w+offset)&~0x01; writemem(ix.w+offset,temp); cycles-=28; break; /*RES 0,(IX+d)*/ // t 28 case 0x8E: temp=readmem(ix.w+offset)&~0x02; writemem(ix.w+offset,temp); cycles-=28; break; /*RES 1,(IX+d)*/ // t 28 case 0x96: temp=readmem(ix.w+offset)&~0x04; writemem(ix.w+offset,temp); cycles-=28; break; /*RES 2,(IX+d)*/ // t 28 case 0x9E: temp=readmem(ix.w+offset)&~0x08; writemem(ix.w+offset,temp); cycles-=28; break; /*RES 3,(IX+d)*/ // t 28 case 0xA6: temp=readmem(ix.w+offset)&~0x10; writemem(ix.w+offset,temp); cycles-=28; break; /*RES 4,(IX+d)*/ // t 28 case 0xAE: temp=readmem(ix.w+offset)&~0x20; writemem(ix.w+offset,temp); cycles-=28; break; /*RES 5,(IX+d)*/ // t 28 case 0xB6: temp=readmem(ix.w+offset)&~0x40; writemem(ix.w+offset,temp); cycles-=28; break; /*RES 6,(IX+d)*/ // t 28 case 0xBE: temp=readmem(ix.w+offset)&~0x80; writemem(ix.w+offset,temp); cycles-=28; break; /*RES 7,(IX+d)*/ // t 28 case 0xC6: temp=readmem(ix.w+offset)|0x01; writemem(ix.w+offset,temp); cycles-=28; break; /*SET 0,(IX+d)*/ // t 28 case 0xCE: temp=readmem(ix.w+offset)|0x02; writemem(ix.w+offset,temp); cycles-=28; break; /*SET 1,(IX+d)*/ // t 28 case 0xD6: temp=readmem(ix.w+offset)|0x04; writemem(ix.w+offset,temp); cycles-=28; break; /*SET 2,(IX+d)*/ // t 28 case 0xDE: temp=readmem(ix.w+offset)|0x08; writemem(ix.w+offset,temp); cycles-=28; break; /*SET 3,(IX+d)*/ // t 28 case 0xE6: temp=readmem(ix.w+offset)|0x10; writemem(ix.w+offset,temp); cycles-=28; break; /*SET 4,(IX+d)*/ // t 28 case 0xEE: temp=readmem(ix.w+offset)|0x20; writemem(ix.w+offset,temp); cycles-=28; break; /*SET 5,(IX+d)*/ // t 28 case 0xF6: temp=readmem(ix.w+offset)|0x40; writemem(ix.w+offset,temp); cycles-=28; break; /*SET 6,(IX+d)*/ // t 28 case 0xFE: temp=readmem(ix.w+offset)|0x80; writemem(ix.w+offset,temp); cycles-=28; break; /*SET 7,(IX+d)*/ // t 28 default: //printf("Bad DD CB opcode %02X at %04X\n, opcode: %d",opcode,--pc, opcode); dumpregs(); exit(-1); } break; case 0xCD: /*CALL*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; push(pc>>8); push(pc&0xFF); pc=addr; cycles-=20; // t 20 break; case 0xB1: /*Invalid*/ case 0xC5: case 0x02: case 0xDD: /*Another prefix*/ case 0xFD: ir.b.l--; cycles-=4; pc--; break; case 0xE1: /*POP IX*/ ix.b.l=pull(); ix.b.h=pull(); cycles-=20; // t 16 break; case 0xE3: /*EX (SP),IX*/ tempw=ix.w; ix.b.l=readmem(sp); ix.b.h=readmem(sp+1); writemem(sp,tempw&0xFF); writemem(sp+1,tempw>>8); cycles-=28; // t 28 break; case 0xE5: /*PUSH IX*/ push(ix.b.h); push(ix.b.l); cycles-=20; // t 20 break; case 0xE9: /*JP (IX)*/ pc=ix.w; cycles-=8; break; case 0xF9: /*LD SP,IX*/ sp=ix.w; cycles-=12; // t 8 break; default: //printf("Bad DD opcode %02X at %04X\n opcode: %d",opcode,--pc, opcode); dumpregs(); exit(-1); } break; case 0xDE: /*SBC xx*/ temp=readmem(pc); pc++; setsbc(af.b.h,temp); af.b.h-=(temp+tempc); cycles-=8; break; case 0xDF: /*RST 18*/ push(pc>>8); push(pc); pc=0x18; cycles-=16; // t 16 break; case 0xE0: /*RET PO*/ if (!(af.b.l&P_FLAG)) { pc=pull(); pc|=pull()<<8; cycles-=12; } else { cycles-=8; } break; case 0xE1: /*POP HL*/ hl.b.l=pull(); hl.b.h=pull(); cycles-=12; // t 12 break; case 0xE2: /*JP PO,xxxx*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (!(af.b.l&P_FLAG)) pc=addr; cycles-=16; // t 12 break; case 0xE3: /*EX (SP),HL*/ tempw=hl.w; hl.b.l=readmem(sp); hl.b.h=readmem(sp+1); writemem(sp,tempw&0xFF); writemem(sp+1,tempw>>8); cycles-=24; // t 24 break; case 0xE4: /*CALL PO*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (!(af.b.l&P_FLAG)) { push(pc>>8); push(pc&0xFF); pc=addr; cycles-=20; } else { cycles-=12; } break; case 0xE5: /*PUSH HL*/ push(hl.b.h); push(hl.b.l); cycles-=16; // t 12 break; case 0xE6: /*AND xx*/ af.b.h&=readmem(pc); pc++; af.b.l&=~3; af.b.l|=H_FLAG; setzn(af.b.h); cycles-=8; // t 8 break; case 0xE7: /*RST 20*/ push(pc>>8); push(pc); pc=0x20; cycles-=16; //t 16 break; case 0xE8: /*RET PE*/ if (af.b.l&P_FLAG) { pc=pull(); pc|=pull()<<8; cycles-=16; } else { cycles-=8; } break; case 0xE9: /*JP (HL)*/ pc=hl.w; cycles-=4; break; case 0xEA: /*JP PE,xxxx*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (af.b.l&P_FLAG) pc=addr; cycles-=12; // t 12 break; case 0xEB: /*EX DE,HL*/ tempw=de.w; de.w=hl.w; hl.w=tempw; cycles-=4; break; case 0xEC: /*CALL PE*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (af.b.l&P_FLAG) { push(pc>>8); push(pc&0xFF); pc=addr; cycles-=20; // t 8 } else { cycles-=12; // t 12 } break; case 0xED: /*More opcodes*/ opcode=readmem(pc); pc++; ir.b.l++; switch (opcode) { case 0x00: /*NOP*/ case 0x01: /*NOP*/ case 0x02: /*NOP*/ case 0x03: /*NOP*/ case 0x04: /*NOP*/ case 0x05: /*NOP*/ case 0x06: /*NOP*/ case 0x07: /*NOP*/ case 0x08: /*NOP*/ case 0x09: /*NOP*/ case 0x0A: /*NOP*/ case 0x0B: /*NOP*/ case 0x0C: /*NOP*/ case 0x0D: /*NOP*/ case 0x0E: /*NOP*/ case 0x0F: /*NOP*/ case 0x10: /*NOP*/ case 0x11: /*NOP*/ case 0x12: /*NOP*/ case 0x13: /*NOP*/ case 0x14: /*NOP*/ case 0x15: /*NOP*/ case 0x16: /*NOP*/ case 0x17: /*NOP*/ case 0x18: /*NOP*/ case 0x19: /*NOP*/ case 0x1A: /*NOP*/ case 0x1B: /*NOP*/ case 0x1C: /*NOP*/ case 0x1D: /*NOP*/ case 0x1E: /*NOP*/ case 0x1F: /*NOP*/ case 0x20: /*NOP*/ case 0x21: /*NOP*/ case 0x22: /*NOP*/ case 0x23: /*NOP*/ case 0x24: /*NOP*/ case 0x25: /*NOP*/ case 0x26: /*NOP*/ case 0x27: /*NOP*/ case 0x28: /*NOP*/ case 0x29: /*NOP*/ case 0x2A: /*NOP*/ case 0x2B: /*NOP*/ case 0x2C: /*NOP*/ case 0x2D: /*NOP*/ case 0x2E: /*NOP*/ case 0x2F: /*NOP*/ case 0x30: /*NOP*/ case 0x31: /*NOP*/ case 0x32: /*NOP*/ case 0x33: /*NOP*/ case 0x34: /*NOP*/ case 0x35: /*NOP*/ case 0x36: /*NOP*/ case 0x37: /*NOP*/ case 0x38: /*NOP*/ case 0x39: /*NOP*/ case 0x3A: /*NOP*/ case 0x3B: /*NOP*/ case 0x3C: /*NOP*/ case 0x3D: /*NOP*/ case 0x3E: /*NOP*/ case 0x3F: /*NOP*/ cycles-=8; break; case 0x40: /*IN B,(C)*/ bc.b.h=z80in(bc.w); setzn(bc.b.h); cycles-=16; break; case 0x41: /*OUT (C),B*/ z80out(bc.w,bc.b.h); cycles-=16; break; case 0x42: /*SBC HL,BC*/ setsbc16(hl.w,bc.w); hl.w-=(bc.w+tempc); cycles-=16; break; case 0x43: /*LD (xxxx),BC*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; writemem(addr,bc.b.l); writemem(addr+1,bc.b.h); cycles-=24; break; case 0x44: /*NEG*/ setsub(0,af.b.h); af.b.h=0-af.b.h; cycles-=8; break; case 0x45: /*RETN*/ iff1=iff2; pc=pull(); pc|=(pull()<<8); cycles-=16; // t 16 break; case 0x46: /*IM 0*/ im=0; cycles-=8; break; case 0x47: /*LD I,A*/ ir.b.h=af.b.h; cycles-=12; break; case 0x48: /*IN C,(C)*/ bc.b.l=z80in(bc.w); setzn(bc.b.l); cycles-=16; break; case 0x49: /*OUT (C),C*/ z80out(bc.w,bc.b.l); cycles-=16; break; case 0x4A: /*ADC HL,BC*/ setadc16(hl.w,bc.w); hl.w+=(bc.w+tempc); cycles-=16; break; case 0x4B: /*LD BC,(xxxx)*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; bc.b.l=readmem(addr); bc.b.h=readmem(addr+1); cycles-=24; break; case 0x4C: /*NEG*/ setsub(0,af.b.h); af.b.h=0-af.b.h; cycles-=8; break; case 0x4D: /*RETI*/ iff1=iff2; pc=pull(); pc|=(pull()<<8); cycles-=16; // t 16 break; case 0x4E: /*IM 0*/ im=0; cycles-=8; break; case 0x4F: /*LD R,A*/ ir.b.l=af.b.h; rhigh=af.b.h&0x80; cycles-=12; break; case 0x50: /*IN D,(C)*/ de.b.h=z80in(bc.w); setzn(de.b.h); cycles-=16; break; case 0x51: /*OUT (C),D*/ z80out(bc.w,de.b.h); cycles-=16; break; case 0x52: /*SBC HL,DE*/ setsbc16(hl.w,de.w); hl.w-=(de.w+tempc); cycles-=16; break; case 0x53: /*LD (xxxx),DE*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; writemem(addr,de.b.l); writemem(addr+1,de.b.h); cycles-=24; break; case 0x54: /*NEG*/ setsub(0,af.b.h); af.b.h=0-af.b.h; cycles-=8; break; case 0x55: /*RETN*/ iff1=iff2; pc=pull(); pc|=(pull()<<8); cycles-=16; // t 16 break; case 0x56: /*IM 1*/ im=1; cycles-=8; break; case 0x57: /*LD A,I*/ af.b.h=ir.b.h; cycles-=12; // t 8 break; case 0x58: /*IN E,(C)*/ de.b.l=z80in(bc.w); setzn(de.b.l); cycles-=16; break; case 0x59: /*OUT (C),E*/ z80out(bc.w,de.b.l); cycles-=16; break; case 0x5A: /*ADC HL,DE*/ setadc16(hl.w,de.w); hl.w+=(de.w+tempc); cycles-=16; break; case 0x5B: /*LD DE,(xxxx)*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; de.b.l=readmem(addr); de.b.h=readmem(addr+1); cycles-=24; break; case 0x5C: /*NEG*/ setsub(0,af.b.h); af.b.h=0-af.b.h; cycles-=8; break; case 0x5D: /*RETN*/ iff1=iff2; pc=pull(); pc|=(pull()<<8); cycles-=16; // t 16 break; case 0x5E: /*IM 2*/ im=2; cycles-=8; break; case 0x5F: /*LD A,R*/ af.b.h=(ir.b.l&0x7F)|rhigh; cycles-=12; break; case 0x60: /*IN H,(C)*/ hl.b.h=z80in(bc.w); setzn(hl.b.h); cycles-=16; break; case 0x61: /*OUT (C),H*/ z80out(bc.w,hl.b.h); cycles-=16; break; case 0x62: /*SBC HL,HL*/ setsbc16(hl.w,hl.w); hl.w-=(hl.w+tempc); cycles-=16; break; case 0x63: /*LD (xxxx),HL*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; writemem(addr,hl.b.l); writemem(addr+1,hl.b.h); cycles-=24; break; case 0x64: /*NEG*/ setsub(0,af.b.h); af.b.h=0-af.b.h; cycles-=8; break; case 0x65: /*RETN*/ iff1=iff2; pc=pull(); pc|=(pull()<<8); cycles-=16; // t 16 break; case 0x66: /*IM 0*/ im=0; cycles-=8; break; case 0x67: /*RRD*/ temp=readmem(hl.w); temp2=temp&0xF; temp=(temp>>4)|(af.b.h<<4); af.b.h=(af.b.h&0xF0)|temp2; writemem(hl.w,temp); setznc(af.b.h); cycles-=20; break; // NEW case 0x68: /*IN L,(C)*/ hl.b.l=z80in(bc.w); setzn(hl.b.l); cycles-=16; break; // NEW case 0x69: /*OUT (C),L*/ z80out(bc.w,hl.b.l); cycles-=16; break; case 0x6A: /*ADC HL,HL*/ setadc16(hl.w,hl.w); hl.w+=(hl.w+tempc); cycles-=16; break; case 0x6B: /*LD HL,(xxxx)*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; hl.b.l=readmem(addr); hl.b.h=readmem(addr+1); cycles-=24; break; case 0x6C: /*NEG*/ setsub(0,af.b.h); af.b.h=0-af.b.h; cycles-=8; break; case 0x6D: /*RETN*/ iff1=iff2; pc=pull(); pc|=(pull()<<8); cycles-=16; // t 16 break; case 0x6E: /*IM 0*/ im=0; cycles-=8; break; case 0x6F: /*RLD*/ temp=readmem(hl.w); temp2=temp>>4; temp=(temp<<4)|(af.b.h&0xF); af.b.h=(af.b.h&0xF0)|temp2; writemem(hl.w,temp); setznc(af.b.h); cycles-=20; break; // These seem a bit unknown! // case 0x70: /*IN L,(C)*/ // hl.b.l=z80in(bc.w); // setzn(hl.b.l); // cycles-=12; // break; // NEW case 0x71: /*OUT (C),0*/ z80out(bc.w,0); cycles-=16; break; case 0x72: /*SBC HL,SP*/ setsbc16(hl.w,sp); hl.w-=(sp+tempc); cycles-=16; break; case 0x73: /*LD (xxxx),SP*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; writemem(addr,sp&0xFF); writemem(addr+1,sp>>8); cycles-=24; break; case 0x74: /*NEG*/ setsub(0,af.b.h); af.b.h=0-af.b.h; cycles-=8; break; case 0x75: /*RETN*/ iff1=iff2; pc=pull(); pc|=(pull()<<8); cycles-=16; // t 16 break; case 0x76: /*IM 1*/ im=1; cycles-=8; break; case 0x77: /*NOP*/ cycles-=8; break; case 0x78: /*IN A,(C)*/ af.b.h=z80in(bc.w); setzn(af.b.h); cycles-=16; break; case 0x79: /*OUT (C),A*/ z80out(bc.w,af.b.h); cycles-=16; break; case 0x7A: /*ADC HL,SP*/ setadc16(hl.w,sp); hl.w+=(sp+tempc); cycles-=16; break; case 0x7B: /*LD SP,(xxxx)*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; sp=readmem(addr); sp|=(readmem(addr+1)<<8); cycles-=24; break; case 0x7C: /*NEG*/ setsub(0,af.b.h); af.b.h=0-af.b.h; cycles-=8; break; case 0x7D: /*RETN*/ iff1=iff2; pc=pull(); pc|=(pull()<<8); cycles-=16; // t 16 break; case 0x7E: /*IM 2*/ im=2; cycles-=8; break; case 0x7F: /*NOP*/ case 0x80: /*NOP*/ case 0x81: /*NOP*/ case 0x82: /*NOP*/ case 0x83: /*NOP*/ case 0x84: /*NOP*/ case 0x85: /*NOP*/ case 0x86: /*NOP*/ case 0x87: /*NOP*/ case 0x88: /*NOP*/ case 0x89: /*NOP*/ case 0x8A: /*NOP*/ case 0x8B: /*NOP*/ case 0x8C: /*NOP*/ case 0x8D: /*NOP*/ case 0x8E: /*NOP*/ case 0x8F: /*NOP*/ case 0x90: /*NOP*/ case 0x91: /*NOP*/ case 0x92: /*NOP*/ case 0x93: /*NOP*/ case 0x94: /*NOP*/ case 0x95: /*NOP*/ case 0x96: /*NOP*/ case 0x97: /*NOP*/ case 0x98: /*NOP*/ case 0x99: /*NOP*/ case 0x9A: /*NOP*/ case 0x9B: /*NOP*/ case 0x9C: /*NOP*/ case 0x9D: /*NOP*/ case 0x9E: /*NOP*/ case 0x9F: /*NOP*/ cycles-=8; break; case 0xA0: /*LDI*/ temp=readmem(hl.w); hl.w++; writemem(de.w,temp); de.w++; bc.w--; if (bc.w) af.b.l|=P_FLAG; else af.b.l&=~P_FLAG; cycles-=20; break; case 0xA1: /*CPI*/ // printf("CPI %04X %i\n",pc,curhrom); temp=readmem(hl.w); hl.w++; if (af.b.h-temp) af.b.l&=~Z_FLAG; else af.b.l|=Z_FLAG; bc.w--; if (bc.w) af.b.l|=P_FLAG; else af.b.l&=~P_FLAG; cycles-=20; break; case 0xA2: /*INI*/ temp=z80in(bc.w); writemem(hl.w,temp); hl.w++; bc.b.h--; if (bc.b.h) af.b.l|=P_FLAG; else af.b.l&=~P_FLAG; af.b.l|=S_FLAG; cycles-=20; break; case 0xA3: /*OUTI*/ temp=readmem(hl.w); hl.w++; bc.b.h--; z80out(bc.w,temp); if (bc.b.h) af.b.l|=P_FLAG; else af.b.l&=~P_FLAG; af.b.l|=S_FLAG; cycles-=20; break; case 0xA4: /*NOP*/ case 0xA5: /*NOP*/ case 0xA6: /*NOP*/ case 0xA7: /*NOP*/ cycles-=8; break; case 0xA8: /*LDD*/ temp=readmem(hl.w); hl.w--; writemem(de.w,temp); de.w--; bc.w--; if (bc.w) af.b.l|=P_FLAG; else af.b.l&=~P_FLAG; cycles-=20; //T 20 break; case 0xA9: /*CPD*/ //printf("CPD %04X %i\n",pc,curhrom); temp=readmem(hl.w); hl.w--; if (af.b.h-temp) af.b.l&=~Z_FLAG; else af.b.l|=Z_FLAG; bc.w--; if (bc.w) af.b.l|=P_FLAG; else af.b.l&=~P_FLAG; cycles-=20; break; case 0xAB: /*OUTD*/ temp=readmem(hl.w); hl.w--; bc.b.h--; z80out(bc.w,temp); if (bc.b.h) af.b.l|=P_FLAG; else af.b.l&=~P_FLAG; af.b.l|=S_FLAG; cycles-=20; break; case 0xAC: /*NOP*/ case 0xAD: /*NOP*/ case 0xAE: /*NOP*/ case 0xAF: /*NOP*/ cycles-=8; break; case 0xB0: /*LDIR*/ temp=readmem(hl.w); hl.w++; writemem(de.w,temp); de.w++; bc.w--; if (bc.w) { pc-=2; cycles-=24; } else cycles-=20; if (bc.w) af.b.l|=P_FLAG; else af.b.l&=~P_FLAG; break; case 0xB1: /*CPIR*/ temp=readmem(hl.w); hl.w++; if (af.b.h==temp) af.b.l|=Z_FLAG; else af.b.l&=~Z_FLAG; bc.w--; if (bc.w && af.b.h!=temp) { pc-=2; cycles-=4; } if (bc.w) af.b.l|=P_FLAG; else af.b.l&=~P_FLAG; cycles-=20; break; case 0xB4: /*NOP*/ case 0xB5: /*NOP*/ case 0xB6: /*NOP*/ case 0xB7: /*NOP*/ cycles-=8; break; case 0xB8: /*LDDR*/ temp=readmem(hl.w); hl.w--; writemem(de.w,temp); de.w--; bc.w--; if (bc.w) { pc-=2; cycles-=24; } else cycles-=20; if (bc.w) af.b.l|=P_FLAG; else af.b.l&=~P_FLAG; break; case 0xB9: /*CPDR*/ //printf("CPDR %04X %i\n",pc,curhrom); temp=readmem(hl.w); hl.w--; setcp(af.b.h,temp); bc.w--; if (bc.w && af.b.h!=temp) { pc-=2; cycles-=8; } if (bc.w) af.b.l|=P_FLAG; else af.b.l&=~P_FLAG; cycles-=20; break; case 0xBC: /*NOP*/ case 0xBD: /*NOP*/ case 0xBE: /*NOP*/ case 0xBF: /*NOP*/ case 0xC0: /*NOP*/ case 0xC1: /*NOP*/ case 0xC2: /*NOP*/ case 0xC3: /*NOP*/ case 0xC4: /*NOP*/ case 0xC5: /*NOP*/ case 0xC6: /*NOP*/ case 0xC7: /*NOP*/ case 0xC8: /*NOP*/ case 0xC9: /*NOP*/ case 0xCA: /*NOP*/ case 0xCB: /*NOP*/ case 0xCC: /*NOP*/ case 0xCD: /*NOP*/ case 0xCE: /*NOP*/ case 0xCF: /*NOP*/ case 0xD0: /*NOP*/ case 0xD1: /*NOP*/ case 0xD2: /*NOP*/ case 0xD3: /*NOP*/ case 0xD4: /*NOP*/ case 0xD5: /*NOP*/ case 0xD6: /*NOP*/ case 0xD7: /*NOP*/ case 0xD8: /*NOP*/ case 0xD9: /*NOP*/ case 0xDA: /*NOP*/ case 0xDB: /*NOP*/ case 0xDC: /*NOP*/ case 0xDD: /*NOP*/ case 0xDE: /*NOP*/ case 0xDF: /*NOP*/ case 0xE0: /*NOP*/ case 0xE1: /*NOP*/ case 0xE2: /*NOP*/ case 0xE3: /*NOP*/ case 0xE4: /*NOP*/ case 0xE5: /*NOP*/ case 0xE6: /*NOP*/ case 0xE7: /*NOP*/ case 0xE8: /*NOP*/ case 0xE9: /*NOP*/ case 0xEA: /*NOP*/ case 0xEB: /*NOP*/ case 0xEC: /*NOP*/ case 0xED: /*NOP*/ case 0xEE: /*NOP*/ case 0xEF: /*NOP*/ case 0xF0: /*NOP*/ case 0xF1: /*NOP*/ case 0xF2: /*NOP*/ case 0xF3: /*NOP*/ case 0xF4: /*NOP*/ case 0xF5: /*NOP*/ case 0xF6: /*NOP*/ case 0xF7: /*NOP*/ case 0xF8: /*NOP*/ case 0xF9: /*NOP*/ case 0xFA: /*NOP*/ case 0xFB: /*NOP*/ case 0xFC: /*NOP*/ case 0xFD: /*NOP*/ case 0xFE: /*NOP*/ case 0xFF: /*NOP*/ cycles-=8; break; default: //printf("Bad ED opcode %02X at %04X\n",opcode,--pc); dumpregs(); exit(-1); } break; case 0xEE: /*XOR xx*/ af.b.h^=readmem(pc); pc++; af.b.l&=~3; setzn(af.b.h); cycles-=8; break; case 0xEF: /*RST 28*/ push(pc>>8); push(pc); pc=0x28; cycles-=16; break; case 0xF0: /*RET P*/ if (!(af.b.l&N_FLAG)) { pc=pull(); pc|=pull()<<8; cycles-=8; } cycles-=8; break; case 0xF1: /*POP AF*/ af.b.l=pull(); af.b.h=pull(); cycles-=12; break; case 0xF2: /*JP P,xxxx*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (!(af.b.l&N_FLAG)) pc=addr; cycles-=12; break; case 0xF3: /*DI*/ iff1=0; cycles-=4; break; case 0xF4: /*CALL P*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (!(af.b.l&N_FLAG)) { push(pc>>8); push(pc&0xFF); pc=addr; cycles-=8; } cycles-=12; break; case 0xF5: /*PUSH AF*/ push(af.b.h); push(af.b.l); cycles-=16; break; case 0xF6: /*OR xx*/ af.b.h|=readmem(pc); pc++; af.b.l&=~3; setzn(af.b.h); cycles-=8; break; case 0xF7: /*RST 30*/ push(pc>>8); push(pc); pc=0x30; cycles-=16; break; case 0xF8: /*RET M*/ if (af.b.l&N_FLAG) { pc=pull(); pc|=pull()<<8; cycles-=8; } cycles-=8; break; case 0xF9: /*LD SP,HL*/ sp=hl.w; cycles-=4; break; case 0xFA: /*JP M,xxxx*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (af.b.l&N_FLAG) pc=addr; cycles-=12; break; case 0xFB: /*EI*/ iff1=2; if (intreq) intreq=-1; cycles-=4; break; case 0xFC: /*CALL M*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; if (af.b.l&N_FLAG) { push(pc>>8); push(pc&0xFF); pc=addr; cycles-=8; } cycles-=12; break; case 0xFD: /*More opcodes - IY*/ ir.b.l++; opcode=readmem(pc); pc++; switch (opcode) { case 0x00: case 0x4D: case 0xE0: ir.b.l--; pc--; cycles-=4; break; case 0x09: /*ADD IY,BC*/ setadd16(iy.w,bc.w); iy.w+=bc.w; cycles-=16; break; case 0x19: /*ADD IY,DE*/ setadd16(iy.w,de.w); iy.w+=de.w; cycles-=16; break; case 0x21: /*LD IY,xxxx*/ iy.b.l=readmem(pc); pc++; iy.b.h=readmem(pc); pc++; cycles-=16; break; case 0x22: /*LD (xxxx),IY*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; writemem(addr,iy.b.l); writemem(addr+1,iy.b.h); cycles-=24; break; case 0x23: /*INC IY*/ iy.w++; cycles-=12; break; // NEW case 0x24: /*INC IYh*/ iy.b.h++; setinc(iy.b.h); cycles-=8; break; case 0x25: /*DEC IYh*/ iy.b.h--; setdec(iy.b.h); cycles-=8; break; case 0x26: /*LD IYh,xx*/ iy.b.h=readmem(pc); pc++; cycles-=12; break; case 0x29: /*ADD IY,IY*/ setadd16(iy.w,iy.w); iy.w+=iy.w; cycles-=16; break; case 0x2A: /*LD IY,(xxxx)*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; iy.b.l=readmem(addr); iy.b.h=readmem(addr+1); cycles-=24; break; case 0x2B: /*DEC IY*/ iy.w--; cycles-=12; break; case 0x2C: /*INC IYl*/ iy.b.l++; setinc(iy.b.l); cycles-=8; break; case 0x2D: /*DEC IYl*/ iy.b.l--; setdec(iy.b.l); cycles-=8; break; // NEW case 0x2E: /*LD IYl,xx*/ iy.b.l=readmem(pc); pc++; cycles-=12; // t 12 break; case 0x34: /*INC (IY+d)*/ offset=(signed char)readmem(pc); pc++; temp=readmem(iy.w+offset)+1; setinc(temp); writemem(iy.w+offset,temp); cycles-=24; break; case 0x35: /*DEC (IY+d)*/ offset=(signed char)readmem(pc); pc++; temp=readmem(iy.w+offset)-1; setdec(temp); writemem(iy.w+offset,temp); cycles-=24; break; case 0x36: /*LD (IY+d),xx*/ offset=(signed char)readmem(pc); pc++; temp=readmem(pc); pc++; writemem(iy.w+offset,temp); cycles-=24; break; case 0x39: /*ADD IY,SP*/ setadd16(iy.w,sp); iy.w+=sp; cycles-=16; break; case 0x3A: /*LD A,(xxxx)*/ addr=readmem(pc)|(readmem(pc+1)<<8); pc+=2; af.b.h=readmem(addr); cycles-=20; break; // t 4 case 0x3B: /*DEC SP*/ sp--; cycles-=12; break; // t 4 case 0x3C: /*INC A*/ af.b.h++; setinc(af.b.h); cycles-=4; break; // t 4 case 0x3D: /*DEC A*/ af.b.h--; setdec(af.b.h); cycles-=4; break; // t 8 case 0x3E: /*LD A,xx*/ af.b.h=readmem(pc); pc++; cycles-=8; break; // t 4 case 0x3F: /*CCF*/ if (af.b.l&C_FLAG) af.b.l|=H_FLAG; else af.b.l&=~H_FLAG; af.b.l^=C_FLAG; cycles-=4; break; case 0x40: bc.b.h=bc.b.h; cycles-=8; break; /*LD B,B*/ case 0x41: bc.b.h=bc.b.l; cycles-=8; break; /*LD B,C*/ case 0x42: bc.b.h=de.b.h; cycles-=8; break; /*LD B,D*/ case 0x43: bc.b.h=de.b.l; cycles-=8; break; /*LD B,E*/ case 0x44: bc.b.h=iy.b.h; cycles-=8; break; /*LD B,IYh*/ // NEW case 0x45: bc.b.h=iy.b.l; cycles-=8; break; /*LD B,IYl*/ case 0x46: offset=(signed char)readmem(pc); pc++; bc.b.h=readmem(iy.w+offset); cycles-=20; break; /*LD B,(IY+d)*/ case 0x4E: offset=(signed char)readmem(pc); pc++; bc.b.l=readmem(iy.w+offset); cycles-=20; break; /*LD C,(IY+d)*/ case 0x4F: bc.b.l=af.b.h; cycles-=8; break; /*LD C,A*/ case 0x50: de.b.h=bc.b.h; cycles-=8; break; /*LD D,B*/ case 0x51: de.b.h=bc.b.l; cycles-=8; break; /*LD D,C*/ case 0x52: de.b.h=de.b.h; cycles-=8; break; /*LD D,D*/ case 0x53: de.b.h=de.b.l; cycles-=8; break; /*LD D,E*/ case 0x54: de.b.h=iy.b.h; cycles-=8; break; /*LD D,IYh*/ case 0x55: de.b.h=iy.b.l; cycles-=8; break; /*LD D,IYl*/ case 0x56: offset=(signed char)readmem(pc); pc++; de.b.h=readmem(iy.w+offset); cycles-=20; break; /*LD D,(IY+d)*/ case 0x57: de.b.h=af.b.h; cycles-=8; break; /*LD D,A*/ case 0x58: de.b.l=bc.b.h; cycles-=8; break; /*LD E,B*/ case 0x59: de.b.l=bc.b.l; cycles-=8; break; /*LD E,C*/ case 0x5A: de.b.l=de.b.h; cycles-=8; break; /*LD E,D*/ case 0x5B: de.b.l=de.b.l; cycles-=8; break; /*LD E,E*/ case 0x5C: de.b.l=iy.b.h; cycles-=8; break; /*LD E,IYh*/ case 0x5D: de.b.l=iy.b.l; cycles-=8; break; /*LD E,IYl*/ case 0x5E: offset=(signed char)readmem(pc); pc++; de.b.l=readmem(iy.w+offset); cycles-=20; break; /*LD E,(IY+d)*/ case 0x5F: de.b.l=af.b.h; cycles-=8; break; /*LD E,A*/ case 0x60: iy.b.h=bc.b.h; cycles-=8; break; /*LD IYh,B*/ case 0x61: iy.b.h=bc.b.l; cycles-=8; break; /*LD IYh,C*/ case 0x62: iy.b.h=de.b.h; cycles-=8; break; /*LD IYh,B*/ case 0x63: iy.b.h=de.b.l; cycles-=8; break; /*LD IYh,C*/ case 0x64: iy.b.h=hl.b.h; cycles-=8; break; /*LD IYh,B*/ case 0x65: iy.b.h=hl.b.l; cycles-=8; break; /*LD IYh,C*/ case 0x66: offset=(signed char)readmem(pc); pc++; hl.b.h=readmem(iy.w+offset); cycles-=20; break; /*LD H,(IY+d)*/ case 0x67: iy.b.h=af.b.h; cycles-=8; break; /*LD IYh,A*/ case 0x68: iy.b.l=bc.b.h; cycles-=8; break; /*LD IYl,B*/ case 0x69: iy.b.l=bc.b.l; cycles-=8; break; /*LD IYl,C*/ case 0x6A: iy.b.l=de.b.h; cycles-=8; break; /*LD IYl,B*/ case 0x6B: iy.b.l=de.b.l; cycles-=8; break; /*LD IYl,C*/ case 0x6C: iy.b.l=hl.b.h; cycles-=8; break; /*LD IYl,B*/ case 0x6D: iy.b.l=hl.b.l; cycles-=8; break; /*LD IYl,C*/ case 0x6E: offset=(signed char)readmem(pc); pc++; hl.b.l=readmem(iy.w+offset); cycles-=20; break; /*LD L,(IY+d)*/ case 0x6F: iy.b.l=af.b.h; cycles-=8; break; /*LD IYl,A*/ case 0x70: offset=(signed char)readmem(pc); pc++; writemem(iy.w+offset,bc.b.h); cycles-=20; break; /*LD (IY+d),B*/ case 0x71: offset=(signed char)readmem(pc); pc++; writemem(iy.w+offset,bc.b.l); cycles-=20; break; /*LD (IY+d),C*/ case 0x72: offset=(signed char)readmem(pc); pc++; writemem(iy.w+offset,de.b.h); cycles-=20; break; /*LD (IY+d),D*/ case 0x73: offset=(signed char)readmem(pc); pc++; writemem(iy.w+offset,de.b.l); cycles-=20; break; /*LD (IY+d),E*/ case 0x74: offset=(signed char)readmem(pc); pc++; writemem(iy.w+offset,hl.b.h); cycles-=20; break; /*LD (IY+d),H*/ case 0x75: offset=(signed char)readmem(pc); pc++; writemem(iy.w+offset,hl.b.l); cycles-=20; break; /*LD (IY+d),L*/ case 0x76: /*HALT*/ if (!intreq) pc--; cycles-=8; break; case 0x77: offset=(signed char)readmem(pc); pc++; writemem(iy.w+offset,af.b.h); cycles-=20; break; /*LD (IY+d),A*/ case 0x78: af.b.h=bc.b.h; cycles-=8; break; /*LD A,B*/ case 0x79: af.b.h=bc.b.l; cycles-=8; break; /*LD A,C*/ case 0x7A: af.b.h=de.b.h; cycles-=8; break; /*LD A,D*/ case 0x7B: af.b.h=de.b.l; cycles-=8; break; /*LD A,E*/ case 0x7C: af.b.h=iy.b.h; cycles-=8; break; /*LD A,IYh*/ case 0x7D: af.b.h=iy.b.l; cycles-=8; break; /*LD A,IYl*/ case 0x7E: offset=(signed char)readmem(pc); pc++; af.b.h=readmem(iy.w+offset); cycles-=20; break; /*LD A,(IY+d)*/ case 0x7F: af.b.h=af.b.h; cycles-=8; break; /*LD A,A*/ case 0x80: setadd(af.b.h,bc.b.h); af.b.h+=bc.b.h; cycles-=8; break; /*ADD B*/ case 0x81: setadd(af.b.h,bc.b.l); af.b.h+=bc.b.l; cycles-=8; break; /*ADD C*/ case 0x82: setadd(af.b.h,de.b.h); af.b.h+=de.b.h; cycles-=8; break; /*ADD D*/ case 0x83: setadd(af.b.h,de.b.l); af.b.h+=de.b.l; cycles-=8; break; /*ADD E*/ case 0x84: setadd(af.b.h,iy.b.h); af.b.h+=iy.b.h; cycles-=8; break; /*ADD IYh*/ case 0x85: setadd(af.b.h,iy.b.l); af.b.h+=iy.b.l; cycles-=8; break; /*ADD IYl*/ case 0x86: offset=(signed char)readmem(pc); pc++; temp=readmem(iy.w+offset); setadd(af.b.h,temp); af.b.h+=temp; cycles-=20; break; /*ADD (IY+d)*/ case 0x87: setadd(af.b.h,af.b.h); af.b.h+=af.b.h; cycles-=8; break; /*ADD A*/ case 0x88: setadc(af.b.h,bc.b.h); af.b.h+=bc.b.h+tempc; cycles-=8; break; /*ADC B*/ case 0x89: setadc(af.b.h,bc.b.l); af.b.h+=bc.b.l+tempc; cycles-=8; break; /*ADC C*/ case 0x8A: setadc(af.b.h,de.b.h); af.b.h+=de.b.h+tempc; cycles-=8; break; /*ADC D*/ case 0x8B: setadc(af.b.h,de.b.l); af.b.h+=de.b.l+tempc; cycles-=8; break; /*ADC E*/ case 0x8E: offset=(signed char)readmem(pc); pc++; temp=readmem(iy.w+offset); setadc(af.b.h,temp); af.b.h+=temp+tempc; cycles-=20; break; /*ADC (IY+d)*/ // t 28 case 0x8C: setadc(af.b.h,iy.b.h); af.b.h+=iy.b.h+tempc; cycles-=8; break; /*ADC IYh*/ case 0x8D: setadc(af.b.h,iy.b.l); af.b.h+=iy.b.l+tempc; cycles-=8; break; /*ADC IYl*/ case 0x94: setsub(af.b.h,iy.b.h); af.b.h-=iy.b.h; cycles-=8; break; /*SUB IYh*/ case 0x95: setsub(af.b.h,iy.b.l); af.b.h-=iy.b.l; cycles-=8; break; /*SUB IYl*/ case 0x96: offset=(signed char)readmem(pc); pc++; temp=readmem(iy.w+offset); setsub(af.b.h,temp); af.b.h-=temp; cycles-=20; break; /*SUB (IY+d)*/ case 0x9C: setsbc(af.b.h,iy.b.h); af.b.h-=(iy.b.h+tempc); cycles-=8; break; /*SBC IYh*/ case 0x9D: setsbc(af.b.h,iy.b.l); af.b.h-=(iy.b.l+tempc); cycles-=8; break; /*SBC IYl*/ case 0x9E: offset=(signed char)readmem(pc); pc++; temp=readmem(iy.w+offset); setsbc(af.b.h,temp); af.b.h-=(temp+tempc); cycles-=20; break; /*SBC (IY+d)*/ case 0xA6: offset=(signed char)readmem(pc); pc++; temp=readmem(iy.w+offset); af.b.h&=temp; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=20; break; /*AND (IY+d)*/ case 0xAE: offset=(signed char)readmem(pc); pc++; temp=readmem(iy.w+offset); af.b.h^=temp; setzn(af.b.h); cycles-=20; break; /*XOR (IY+d)*/ case 0xB6: offset=(signed char)readmem(pc); pc++; temp=readmem(iy.w+offset); af.b.h|=temp; setzn(af.b.h); cycles-=20; break; /*OR (IY+d)*/ case 0xBE: offset=(signed char)readmem(pc); pc++; temp=readmem(iy.w+offset); setcp(af.b.h,temp); cycles-=20; break; /*CP (IY+d)*/ case 0xA4: af.b.h&=iy.b.h; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=8; break; /*AND IYh*/ case 0xA5: af.b.h&=iy.b.l; setzn(af.b.h); af.b.l&=~3; af.b.l|=H_FLAG; cycles-=8; break; /*AND IYl*/ case 0xB4: af.b.h|=iy.b.h; setzn(af.b.h); cycles-=8; break; /*OR IYh*/ case 0xB5: af.b.h|=iy.b.l; setzn(af.b.h); cycles-=8; break; /*OR IYl*/ // NEW. case 0xAC: af.b.h^=iy.b.h; setzn(af.b.h); af.b.l&=~3; cycles-=8; break; /*XOR IYh*/ // NEW case 0xAD: af.b.h^=iy.b.l; setzn(af.b.h); af.b.l&=~3; cycles-=8; break; /*XOR IYL*/ // NEW // NEW. case 0xBC: setcp(af.b.h,iy.b.h); cycles-=8; break; /*CP IYh*/ // NEW case 0xBD: setcp(af.b.h,iy.b.l); cycles-=8; break; /*CP IYl*/ // NEW case 0xCB: /*More opcodes*/ offset=(signed char)readmem(pc); pc++; opcode=readmem(pc); pc++; ir.b.l++; switch (opcode) { case 0x06: temp=readmem(iy.w+offset); if (temp&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp<<=1; if (af.b.l&C_FLAG) temp|=1; setznc(temp); writemem(iy.w+offset,temp); cycles-=28; break; /*RLC (IY+d)*/ case 0x0E: temp=readmem(iy.w+offset); if (temp&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp>>=1; if (af.b.l&C_FLAG) temp|=0x80; setznc(temp); writemem(iy.w+offset,temp); cycles-=28; break; /*RRC (IY+d)*/ case 0x16: temp=readmem(iy.w+offset); if (temp&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp<<=1; if (tempc) temp|=1; setznc(temp); writemem(iy.w+offset,temp); cycles-=28; break; /*RL (IY+d)*/ case 0x1E: temp=readmem(iy.w+offset); if (temp&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp>>=1; if (tempc) temp|=0x80; setznc(temp); writemem(iy.w+offset,temp); cycles-=28; break; /*RR (IY+d)*/ case 0x26: temp=readmem(iy.w+offset); if (temp&0x80) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp<<=1; setznc(temp); writemem(iy.w+offset,temp); cycles-=28; break; /*SLA (IY+d)*/ case 0x2E: temp=readmem(iy.w+offset); if (temp&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp>>=1; if (temp&0x40) temp|=0x80; setznc(temp); writemem(iy.w+offset,temp); cycles-=28; break; /*SRA (IY+d)*/ case 0x3E: temp=readmem(iy.w+offset); if (temp&1) af.b.l|=C_FLAG; else af.b.l&=~C_FLAG; temp>>=1; setznc(temp); writemem(iy.w+offset,temp); cycles-=28; break; /*SRL (IY+d)*/ case 0x46: temp=readmem(iy.w+offset); setznc(temp&0x01); cycles-=24; break; /*BIT 0,(IY+d)*/ case 0x4E: temp=readmem(iy.w+offset); setznc(temp&0x02); cycles-=24; break; /*BIT 1,(IY+d)*/ case 0x56: temp=readmem(iy.w+offset); setznc(temp&0x04); cycles-=24; break; /*BIT 2,(IY+d)*/ case 0x5E: temp=readmem(iy.w+offset); setznc(temp&0x08); cycles-=24; break; /*BIT 3,(IY+d)*/ case 0x66: temp=readmem(iy.w+offset); setznc(temp&0x10); cycles-=24; break; /*BIT 4,(IY+d)*/ case 0x6E: temp=readmem(iy.w+offset); setznc(temp&0x20); cycles-=24; break; /*BIT 5,(IY+d)*/ case 0x76: temp=readmem(iy.w+offset); setznc(temp&0x40); cycles-=24; break; /*BIT 6,(IY+d)*/ case 0x7E: temp=readmem(iy.w+offset); setznc(temp&0x80); cycles-=24; break; /*BIT 7,(IY+d)*/ case 0x86: temp=readmem(iy.w+offset)&~0x01; writemem(iy.w+offset,temp); cycles-=28; break; /*RES 0,(IY+d)*/ case 0x8E: temp=readmem(iy.w+offset)&~0x02; writemem(iy.w+offset,temp); cycles-=28; break; /*RES 1,(IY+d)*/ case 0x96: temp=readmem(iy.w+offset)&~0x04; writemem(iy.w+offset,temp); cycles-=28; break; /*RES 2,(IY+d)*/ case 0x9E: temp=readmem(iy.w+offset)&~0x08; writemem(iy.w+offset,temp); cycles-=28; break; /*RES 3,(IY+d)*/ case 0xA6: temp=readmem(iy.w+offset)&~0x10; writemem(iy.w+offset,temp); cycles-=28; break; /*RES 4,(IY+d)*/ case 0xAE: temp=readmem(iy.w+offset)&~0x20; writemem(iy.w+offset,temp); cycles-=28; break; /*RES 5,(IY+d)*/ case 0xB6: temp=readmem(iy.w+offset)&~0x40; writemem(iy.w+offset,temp); cycles-=28; break; /*RES 6,(IY+d)*/ case 0xBE: temp=readmem(iy.w+offset)&~0x80; writemem(iy.w+offset,temp); cycles-=28; break; /*RES 7,(IY+d)*/ case 0xC6: temp=readmem(iy.w+offset)|0x01; writemem(iy.w+offset,temp); cycles-=28; break; /*SET 0,(IY+d)*/ case 0xCE: temp=readmem(iy.w+offset)|0x02; writemem(iy.w+offset,temp); cycles-=28; break; /*SET 1,(IY+d)*/ case 0xD6: temp=readmem(iy.w+offset)|0x04; writemem(iy.w+offset,temp); cycles-=28; break; /*SET 2,(IY+d)*/ case 0xDE: temp=readmem(iy.w+offset)|0x08; writemem(iy.w+offset,temp); cycles-=28; break; /*SET 3,(IY+d)*/ case 0xE6: temp=readmem(iy.w+offset)|0x10; writemem(iy.w+offset,temp); cycles-=28; break; /*SET 4,(IY+d)*/ case 0xEE: temp=readmem(iy.w+offset)|0x20; writemem(iy.w+offset,temp); cycles-=28; break; /*SET 5,(IY+d)*/ case 0xF6: temp=readmem(iy.w+offset)|0x40; writemem(iy.w+offset,temp); cycles-=28; break; /*SET 6,(IY+d)*/ case 0xFE: temp=readmem(iy.w+offset)|0x80; writemem(iy.w+offset,temp); cycles-=28; break; /*SET 7,(IY+d)*/ default: //printf("Bad FD CB opcode %02X at %04X\n",opcode,--pc); dumpregs(); exit(-1); } break; case 0xE1: /*POP IY*/ iy.b.l=pull(); iy.b.h=pull(); cycles-=20; break; case 0xE3: /*EX (SP),Iy*/ tempw=ix.w; iy.b.l=readmem(sp); iy.b.h=readmem(sp+1); writemem(sp,tempw&0xFF); writemem(sp+1,tempw>>8); cycles-=28; // t 28 break; case 0xE5: /*PUSH IY*/ push(iy.b.h); push(iy.b.l); cycles-=20; break; case 0xE9: /*JP (IY)*/ pc=iy.w; cycles-=8; break; case 0xF9: /*LD SP,IY*/ sp=iy.w; cycles-=12; break; case 0xDD: /*Another prefix*/ case 0xFD: ir.b.l--; cycles-=4; pc--; break; default: //printf("Bad FD opcode %02X at %04X\n",opcode,--pc); dumpregs(); exit(-1); } break; case 0xFE: /*CP xx*/ temp=readmem(pc); pc++; setcp(af.b.h,temp); cycles-=8; break; case 0xFF: /*RST 38*/ push(pc>>8); push(pc); pc=0x38; cycles-=16; break; default: //printf("Bad opcode %02X at %04X\n",opcode,--pc); dumpregs(); exit(-1); } ir.b.l++; if (intreq==1 && iff1==1) { cleargacount(); intreq=0; iff2=iff1; iff1=0; push(pc>>8); push(pc&0xFF); switch (im) { case 0: pc=0x38; cycles-=20; break; case 1: pc=0x38; cycles-=20; break; case 2: addr=(ir.b.h<<8)|0xFF; pc=readmem(addr)|(readmem(addr+1)<<8); cycles-=76; break; default: //printf("Bad IM %i\n",im); dumpregs(); exit(-1); } } if (intreq==-1) intreq=1; if (iff1==3) iff1=iff2=1; if (iff1==2) iff1=3; } } }
70.925673
261
0.604099
rpsubc8
cb4228247489e8a081d561cea3ee795112a74380
3,843
cpp
C++
src/sudoku/solution_queue.cpp
samwarring/sudoku
0dee535363358e3124c869cd91f2b02a124e4c20
[ "MIT" ]
null
null
null
src/sudoku/solution_queue.cpp
samwarring/sudoku
0dee535363358e3124c869cd91f2b02a124e4c20
[ "MIT" ]
16
2020-04-25T19:53:04.000Z
2020-07-13T00:06:56.000Z
src/sudoku/solution_queue.cpp
samwarring/sudoku
0dee535363358e3124c869cd91f2b02a124e4c20
[ "MIT" ]
null
null
null
#include <sudoku/solution_queue.h> namespace sudoku { SolutionQueue::SolutionQueue(size_t maxSize) : maxSize_(maxSize) { } SolutionQueue::Producer::Producer(SolutionQueue& queue) : queue_(queue) { std::lock_guard<std::mutex> lock(queue_.mutex_); queue_.numProducers_++; } SolutionQueue::Producer::Producer(const Producer& other) : queue_(other.queue_) { std::lock_guard<std::mutex> lock(queue_.mutex_); queue_.numProducers_++; } SolutionQueue::Producer::Producer(Producer&& other) : queue_(other.queue_) { other.moved_ = true; } SolutionQueue::Producer::~Producer() { if (!moved_) { std::lock_guard<std::mutex> lock(queue_.mutex_); queue_.numProducers_--; // If this is the last producer, notify remaining consumers. if (queue_.numProducers_ == 0) { queue_.condVar_.notify_all(); } } } bool SolutionQueue::Producer::push(std::vector<CellValue> solution, Metrics metrics) { // Wait until the queue has free capacity, or until there are // no more consumers. std::unique_lock<std::mutex> lock(queue_.mutex_); queue_.condVar_.wait(lock, [&](){ return (queue_.valuesQueue_.size() < queue_.maxSize_) || (queue_.numConsumers_ == 0); }); // If there are no consumers, then return false now. if (queue_.numConsumers_ == 0) { return false; } // There must be free capacity in the queue. Add the solution to the // queue, and notify a consumer thread which may be waiting. queue_.valuesQueue_.emplace(std::move(solution)); queue_.metricsQueue_.push(metrics); queue_.condVar_.notify_one(); return true; } SolutionQueue::Consumer::Consumer(SolutionQueue& queue) : queue_(queue) { std::lock_guard<std::mutex> lock(queue_.mutex_); queue_.numConsumers_++; } SolutionQueue::Consumer::Consumer(const Consumer& other) : queue_(other.queue_) { std::lock_guard<std::mutex> lock(queue_.mutex_); queue_.numConsumers_++; } SolutionQueue::Consumer::Consumer(Consumer&& other) : queue_(other.queue_) { other.moved_ = true; } SolutionQueue::Consumer::~Consumer() { if (!moved_) { std::lock_guard<std::mutex> lock(queue_.mutex_); queue_.numConsumers_--; // If this is the last consumer, notify remaining producers. if (queue_.numConsumers_ == 0) { queue_.condVar_.notify_all(); } } } bool SolutionQueue::Consumer::pop(std::vector<CellValue>& solution, Metrics& metrics) { // Wait until the queue contains at least one element, or until // there are no more producers. std::unique_lock<std::mutex> lock(queue_.mutex_); queue_.condVar_.wait(lock, [&](){ return (queue_.valuesQueue_.size() > 0) || (queue_.numProducers_ == 0); }); // If there are no more producers, there still may be solutions left // to proces in the queue. We only quit if there are no more producers // AND the queue is empty. if (queue_.numProducers_ == 0 && queue_.valuesQueue_.size() == 0) { return false; } // We know there is at least one producer, and the queue is not empty. // Retrieve the front of the queue. Notify a consumer which may be // waiting to write the the queue. solution = std::move(queue_.valuesQueue_.front()); metrics = queue_.metricsQueue_.front(); queue_.valuesQueue_.pop(); queue_.metricsQueue_.pop(); queue_.condVar_.notify_one(); return true; } }
32.567797
97
0.602394
samwarring
cb45098d43af681ef458b5381157a9694310b2cf
6,040
cpp
C++
src/error.cpp
BlubBlab/micromacro-with-OpenCV
c1a17d5faef38fc8532fb1a52ae1c41e7d2d3a34
[ "BSD-3-Clause" ]
null
null
null
src/error.cpp
BlubBlab/micromacro-with-OpenCV
c1a17d5faef38fc8532fb1a52ae1c41e7d2d3a34
[ "BSD-3-Clause" ]
null
null
null
src/error.cpp
BlubBlab/micromacro-with-OpenCV
c1a17d5faef38fc8532fb1a52ae1c41e7d2d3a34
[ "BSD-3-Clause" ]
null
null
null
/****************************************************************************** Project: MicroMacro Author: SolarStrike Software URL: www.solarstrike.net License: Modified BSD (see license.txt) ******************************************************************************/ #include "error.h" #include "strl.h" #include "logger.h" #include "macro.h" #include "ncurses_lua.h" #include <vector> #include <string> #include <string.h> extern "C" { #include <lua.h> #include <lauxlib.h> #include <lualib.h> } const char *getErrorString(int errcode) { switch(errcode) { case MicroMacro::ERR_OK: return "Everything is OK"; break; case MicroMacro::ERR_CLOSE: return "Close request signal sent"; break; case MicroMacro::ERR_DOUBLE_INIT: return "Double initialization not allowed"; break; case MicroMacro::ERR_INIT_FAIL: return "Initialization failure"; break; case MicroMacro::ERR_CLEANUP_FAIL: return "Failure to properly cleanup"; break; case MicroMacro::ERR_NO_STATE: return "Attempt to use Lua state when no state has been created"; break; case MicroMacro::ERR_RUN: return "Runtime error"; break; case MicroMacro::ERR_MEM: return "Memory error"; break; case MicroMacro::ERR_SYNTAX: return "Syntax error"; break; case MicroMacro::ERR_FILE: return "File error"; break; case MicroMacro::ERR_ERR: return "Error inside of an error: Errorception. I don\'t even know what\'s right anymore."; break; case MicroMacro::ERR_NOFUNCTION: return "Function does not exist or could not be found"; break; case MicroMacro::ERR_UNKNOWN: default: return "Unknown or undefined error"; break; } } std::string getWindowsErrorString(int errCode) { char *tmp = NULL; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, errCode, 0, (CHAR*)&tmp, 0, NULL); if( tmp == NULL ) return ""; std::string retval = tmp; LocalFree(tmp); retval.erase( retval.size()-2 ); // chop off trailing \r\n return retval; } void wrongArgsReal(lua_State *s, const char *name) { luaL_error(s, "Wrong number of parameters supplied to %s().\n", name); } void badAllocationReal(const char *file, const char *func, int line) { // Log the error char buffer[1024]; #ifdef DISPLAY_DEBUG_MESSAGES sprintf(buffer, "Bad allocation, %s:%d in function %s\n", file, line, func); #else sprintf(buffer, "Bad allocation in function %s, line %d\n", func, line); #endif fprintf(stderr, buffer); Logger::instance()->add("%s", buffer); // Shut down Ncurses (if needed) if( Ncurses_lua::is_initialized() ) { Ncurses_lua::cleanup(Macro::instance()->getEngine()->getLuaState()); } // Let the user know something bad happened, give them time to see the error printf("\a\a\a"); // Ding! system("pause"); // Time to go home exit(MicroMacro::ERR_MEM); } int checkType(lua_State *L, int acceptableTypes, int arg) { int ok = false; std::vector<short> acceptableTypeIDs; acceptableTypeIDs.reserve(10); // Check each type if( acceptableTypes & LT_NIL ) { acceptableTypeIDs.push_back(LUA_TNIL); if( lua_isnil(L, arg) ) ok = true; } if( acceptableTypes & LT_NUMBER ) { acceptableTypeIDs.push_back(LUA_TNUMBER); if( lua_isnumber(L, arg) ) ok = true; } if( acceptableTypes & LT_STRING ) { acceptableTypeIDs.push_back(LUA_TSTRING); if( lua_isstring(L, arg) ) ok = true; } if( acceptableTypes & LT_BOOLEAN ) { acceptableTypeIDs.push_back(LUA_TBOOLEAN); if( lua_isboolean(L, arg) ) ok = true; } if( acceptableTypes & LT_TABLE ) { acceptableTypeIDs.push_back(LUA_TTABLE); if( lua_istable(L, arg) ) ok = true; } if( acceptableTypes & LT_FUNCTION ) { acceptableTypeIDs.push_back(LUA_TFUNCTION); if( lua_isfunction(L, arg) ) ok = true; } if( acceptableTypes & LT_THREAD ) { acceptableTypeIDs.push_back(LUA_TTHREAD); if( lua_isthread(L, arg) ) ok = true; } if( acceptableTypes & LT_USERDATA ) { acceptableTypeIDs.push_back(LUA_TUSERDATA); if( lua_isuserdata(L, arg) ) ok = true; } if( !ok ) { char expected[256]; strlcpy((char*)&expected, "unknown", 8); size_t buff_left = sizeof(expected)-1; // What's left to use (below) for(size_t i = 0; i < acceptableTypeIDs.size(); i++) { if( i == 0 ) { size_t buff_used = 0; buff_used = strlcpy((char*)&expected, lua_typename(L, acceptableTypeIDs.at(i)), buff_left); buff_left = sizeof(expected) - 1 - buff_used; } else if( i == acceptableTypeIDs.size() - 1 ) { const char *or_txt = " or "; strlcat((char*)&expected, or_txt, buff_left); buff_left -= strlen(or_txt); strlcat((char*)&expected, lua_typename(L, acceptableTypeIDs.at(i)), buff_left); buff_left = sizeof(expected) - 1 - strlen((char*)&expected); } else { const char *comma_txt = ", "; strlcat((char*)&expected, comma_txt, buff_left); buff_left -= strlen(comma_txt); strlcat((char*)&expected, lua_typename(L, acceptableTypeIDs.at(i)), buff_left); buff_left -= sizeof(expected) - 1 - strlen((char*)&expected); } } luaL_typerror(L, arg, expected); } return 0; } int luaL_typerror(lua_State *L, int narg, const char *tname) { const char *msg = lua_pushfstring(L, "%s expected, got %s", tname, luaL_typename(L, narg)); return luaL_argerror(L, narg, msg); } void pushLuaErrorEvent(lua_State *L, const char *fmt, ...) { // Get Lua state info lua_Debug ar; lua_getstack(L, 1, &ar); lua_getinfo(L, "nSl", &ar); // Prep a string that tells us where the error originated char scriptinfo[256]; slprintf(scriptinfo, sizeof(scriptinfo)-1, " %s:%d", ar.short_src, ar.currentline); // Actually format the error we were given char buffer[2048]; va_list va_alist; va_start(va_alist, fmt); _vsnprintf_s(buffer, sizeof(buffer), fmt, va_alist); va_end(va_alist); // Queue it MicroMacro::Event e; e.type = MicroMacro::EVENT_ERROR; e.msg = buffer; e.msg += scriptinfo; //Macro::instance()->getEventQueue()->push(e); Macro::instance()->pushEvent(e); }
23.501946
95
0.665232
BlubBlab
cb4608985ca07706758e1f4c511dc8a060def709
1,699
cpp
C++
stimulus.cpp
dcblack/ModernSystemC
953740c6d796cd3a2f60108c5093f0366d6ee3bd
[ "Apache-2.0" ]
29
2019-06-17T20:46:21.000Z
2022-03-21T13:13:42.000Z
stimulus.cpp
dcblack/ModernSystemC
953740c6d796cd3a2f60108c5093f0366d6ee3bd
[ "Apache-2.0" ]
4
2019-11-07T18:42:32.000Z
2021-09-16T19:03:21.000Z
stimulus.cpp
dcblack/ModernSystemC
953740c6d796cd3a2f60108c5093f0366d6ee3bd
[ "Apache-2.0" ]
7
2020-02-04T17:17:28.000Z
2021-11-05T23:16:23.000Z
/** * @file stimulus.cpp */ #include "stimulus.hpp" #include "objection.hpp" #include "report.hpp" #include <random> using namespace sc_core; namespace { char const * const MSGID{ "/Doulos/Example/Modern/Stimulus_module" }; } //.............................................................................. Stimulus_module::Stimulus_module( sc_module_name instance ) //< Constructor : sc_module( instance ) { SC_HAS_PROCESS( Stimulus_module ); SC_THREAD( stimulus_thread ); } //.............................................................................. Stimulus_module::~Stimulus_module( void ) = default; //.............................................................................. void Stimulus_module::stimulus_thread( void ) { Objection generating_data( name() ); unsigned int seed = 1; std::default_random_engine generator(seed); std::uniform_real_distribution<double> distribution (-128.0,128.0); std::vector<double> directed = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }; size_t samples = directed.size()*directed.size()*directed.size(); REPORT( INFO, "Sending " << samples << " directed samples" ); for( auto const& x : directed ) { for( auto const& y : directed ) { for( auto const& z : directed ) { Coordinate xyz{ x, y, z }; rawout_port->write( xyz ); INFO( DEBUG, "Sent " << xyz ); } } } samples = 1000; REPORT( INFO, "Sending " << samples << " random samples" ); for( size_t n=0; n<samples; ++n ) { Coordinate xyz = { distribution(generator), distribution(generator), distribution(generator) }; rawout_port->write( xyz ); INFO( DEBUG, "Sent " << xyz ); } REPORT( INFO, "Stimulus complete" ); }
32.673077
99
0.560918
dcblack
cb4a4d1e1c306ca1bcdef8945b3e789bf8773c8a
5,461
cpp
C++
openstudiocore/src/openstudio_lib/ConstructionsController.cpp
colemat/OpenStudio
46680e95efa5ef51c7199176f366dfdede5ab706
[ "blessing" ]
null
null
null
openstudiocore/src/openstudio_lib/ConstructionsController.cpp
colemat/OpenStudio
46680e95efa5ef51c7199176f366dfdede5ab706
[ "blessing" ]
1
2019-02-04T23:30:45.000Z
2019-02-04T23:30:45.000Z
openstudiocore/src/openstudio_lib/ConstructionsController.cpp
colemat/OpenStudio
46680e95efa5ef51c7199176f366dfdede5ab706
[ "blessing" ]
null
null
null
/*********************************************************************************************************************** * OpenStudio(R), Copyright (c) 2008-2019, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the * following conditions are met: * * (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following * disclaimer. * * (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided with the distribution. * * (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products * derived from this software without specific prior written permission from the respective party. * * (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works * may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior * written permission from Alliance for Sustainable Energy, LLC. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED * STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************************************************************/ #include "ConstructionsController.hpp" #include "ConstructionsView.hpp" #include "../model/CFactorUndergroundWallConstruction.hpp" #include "../model/Component.hpp" #include "../model/Component_Impl.hpp" #include "../model/ComponentData.hpp" #include "../model/ComponentData_Impl.hpp" #include "../model/Construction.hpp" #include "../model/ConstructionBase.hpp" #include "../model/ConstructionBase_Impl.hpp" #include "../model/ConstructionWithInternalSource.hpp" #include "../model/DefaultConstructionSet.hpp" #include "../model/DefaultConstructionSet_Impl.hpp" #include "../model/FFactorGroundFloorConstruction.hpp" #include "../model/WindowDataFile.hpp" #include "../utilities/core/Logger.hpp" #include <utilities/idd/IddEnums.hxx> namespace openstudio { ConstructionsController::ConstructionsController(bool isIP, const model::Model& model) : ModelSubTabController(new ConstructionsView(isIP,model), model) { } ConstructionsController::~ConstructionsController() { } void ConstructionsController::onAddObject(const openstudio::IddObjectType& iddObjectType) { switch(iddObjectType.value()){ case IddObjectType::OS_Construction: openstudio::model::Construction(this->model()); break; case IddObjectType::OS_Construction_InternalSource: openstudio::model::ConstructionWithInternalSource(this->model()); break; case IddObjectType::OS_Construction_CfactorUndergroundWall: openstudio::model::CFactorUndergroundWallConstruction(this->model()); break; case IddObjectType::OS_Construction_FfactorGroundFloor: openstudio::model::FFactorGroundFloorConstruction(this->model()); break; case IddObjectType::OS_Construction_WindowDataFile: openstudio::model::WindowDataFile(this->model()); break; default: LOG_FREE_AND_THROW("ConstructionsController", "Unknown IddObjectType '" << iddObjectType.valueName() << "'"); } } void ConstructionsController::onCopyObject(const openstudio::model::ModelObject& modelObject) { modelObject.clone(this->model()); } void ConstructionsController::onRemoveObject(openstudio::model::ModelObject modelObject) { modelObject.remove(); } void ConstructionsController::onReplaceObject(openstudio::model::ModelObject modelObject, const OSItemId& replacementItemId) { // not yet implemented } void ConstructionsController::onPurgeObjects(const openstudio::IddObjectType& iddObjectType) { this->model().purgeUnusedResourceObjects(iddObjectType); } void ConstructionsController::onDrop(const OSItemId& itemId) { boost::optional<model::ModelObject> modelObject = this->getModelObject(itemId); if (modelObject){ if(modelObject->optionalCast<model::ConstructionBase>()){ if (this->fromComponentLibrary(itemId)){ modelObject = modelObject->clone(this->model()); } } }else{ boost::optional<model::Component> component = this->getComponent(itemId); if (component){ if (component->primaryObject().optionalCast<model::ModelObject>()){ this->model().insertComponent(*component); } } } } void ConstructionsController::onInspectItem(OSItem* item) { } } // openstudio
42.333333
125
0.730819
colemat
cb4ba2cb949e2aaaf6e6c36f773ed35c82df9e73
7,632
cpp
C++
sim/decoder_tb.cpp
nmoroze/lemoncore
8223f6f6fd9b3bb6dfeeae3025d1d63aceced324
[ "MIT" ]
11
2020-08-29T19:49:48.000Z
2021-05-29T17:52:12.000Z
sim/decoder_tb.cpp
nmoroze/lemoncore
8223f6f6fd9b3bb6dfeeae3025d1d63aceced324
[ "MIT" ]
null
null
null
sim/decoder_tb.cpp
nmoroze/lemoncore
8223f6f6fd9b3bb6dfeeae3025d1d63aceced324
[ "MIT" ]
null
null
null
#include <stdint.h> #include <stdlib.h> #include <gtest/gtest.h> #include "Vdecoder.h" #include "verilated.h" #include "riscv.h" #include "decoder_tb.h" const static int NUM_INSTRUCTIONS = 37; struct control_signals_t { std::string instr; uint32_t (*gen_instr)(); int alu_op; int a_src; int b_src; int b_neg; int mem_w; int reg_w; int next_pc; int wb_src; int shift_type; }; struct control_signals_t CONTROL_SIGNAL_TABLE[NUM_INSTRUCTIONS] = { // Instr ALUop Asrc Bsrc Bneg MemW RegW NextPc WBsrc ShiftType {"LUI", rv_lui, ALU_OP_ADD, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"AUIPC", rv_auipc, ALU_OP_ADD, A_SRC_PC, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"JAL", rv_jal, ALU_OP_AND, A_SRC_RS1, -1, -1, 0, 1, NEXT_PC_BR0, WB_SRC_PC, -1}, {"JALR", rv_jalr, ALU_OP_ADD, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_ALU, WB_SRC_PC, -1}, {"BEQ", rv_beq, ALU_OP_XOR, A_SRC_RS1, B_SRC_RS2, 0, 0, 0, NEXT_PC_BR0, -1, -1}, {"BNE", rv_bne, ALU_OP_XOR, A_SRC_RS1, B_SRC_RS2, 0, 0, 0, NEXT_PC_BR1, -1, -1}, {"BLT", rv_blt, ALU_OP_CMP, A_SRC_RS1, B_SRC_RS2, 0, 0, 0, NEXT_PC_BR1, -1, -1}, {"BGE", rv_bge, ALU_OP_CMP, A_SRC_RS1, B_SRC_RS2, 0, 0, 0, NEXT_PC_BR0, -1, -1}, {"BLTU", rv_bltu, ALU_OP_CMPU, A_SRC_RS1, B_SRC_RS2, 0, 0, 0, NEXT_PC_BR1, -1, -1}, {"BGEU", rv_bgeu, ALU_OP_CMPU, A_SRC_RS1, B_SRC_RS2, 0, 0, 0, NEXT_PC_BR0, -1, -1}, {"LB", rv_lb, ALU_OP_ADD, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_MEM, -1}, {"LH", rv_lh, ALU_OP_ADD, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_MEM, -1}, {"LW", rv_lw, ALU_OP_ADD, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_MEM, -1}, {"LBU", rv_lbu, ALU_OP_ADD, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_MEM, -1}, {"LHU", rv_lhu, ALU_OP_ADD, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_MEM, -1}, {"SB", rv_sb, ALU_OP_ADD, A_SRC_RS1, B_SRC_IMM, 0, 1, 0, NEXT_PC_INC, -1, -1}, {"SH", rv_sh, ALU_OP_ADD, A_SRC_RS1, B_SRC_IMM, 0, 1, 0, NEXT_PC_INC, -1, -1}, {"SW", rv_sw, ALU_OP_ADD, A_SRC_RS1, B_SRC_IMM, 0, 1, 0, NEXT_PC_INC, -1, -1}, {"ADDI", rv_addi, ALU_OP_ADD, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"SLTI", rv_slti, ALU_OP_CMP, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"SLTIU", rv_sltiu, ALU_OP_CMPU, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"XORI", rv_xori, ALU_OP_XOR, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"ORI", rv_ori, ALU_OP_OR, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"ANDI", rv_andi, ALU_OP_AND, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"SLLI", rv_slli, ALU_OP_SHL, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"SRLI", rv_srli, ALU_OP_SHR, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, 1}, {"SRAI", rv_srai, ALU_OP_SHR, A_SRC_RS1, B_SRC_IMM, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, 0}, {"ADD", rv_add, ALU_OP_ADD, A_SRC_RS1, B_SRC_RS2, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"SUB", rv_sub, ALU_OP_ADD, A_SRC_RS1, B_SRC_RS2, 1, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"SLL", rv_sll, ALU_OP_SHL, A_SRC_RS1, B_SRC_RS2, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"SLT", rv_slt, ALU_OP_CMP, A_SRC_RS1, B_SRC_RS2, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"SLTU", rv_sltu, ALU_OP_CMPU, A_SRC_RS1, B_SRC_RS2, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"XOR", rv_xor, ALU_OP_XOR, A_SRC_RS1, B_SRC_RS2, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"SRL", rv_srl, ALU_OP_SHR, A_SRC_RS1, B_SRC_RS2, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, 1}, {"SRA", rv_sra, ALU_OP_SHR, A_SRC_RS1, B_SRC_RS2, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, 0}, {"OR", rv_or, ALU_OP_OR, A_SRC_RS1, B_SRC_RS2, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, {"AND", rv_and, ALU_OP_AND, A_SRC_RS1, B_SRC_RS2, 0, 0, 1, NEXT_PC_INC, WB_SRC_ALU, -1}, }; class DecoderTest : public ::testing::Test { protected: void SetUp() override { tb = new Vdecoder; } void TearDown() override { delete tb; } Vdecoder *tb; }; TEST_F(DecoderTest, ControlSignals) { for (int i = 0; i < NUM_INSTRUCTIONS; i++) { auto ctrlsigs = CONTROL_SIGNAL_TABLE[i]; uint32_t instr = ctrlsigs.gen_instr(); auto name = ctrlsigs.instr; tb->instr_i = instr; tb->eval(); EXPECT_EQ(tb->illegal_instr_o, 0); if (ctrlsigs.alu_op != -1) EXPECT_EQ(tb->alu_op_o, ctrlsigs.alu_op) << "ALUOp incorrect for instruction " << name; if (ctrlsigs.a_src != -1) EXPECT_EQ(tb->a_src_o, ctrlsigs.a_src) << "Asrc incorrect for instruction " << name; if (ctrlsigs.b_src != -1) EXPECT_EQ(tb->b_src_o, ctrlsigs.b_src) << "Bsrc incorrect for instruction " << name; if (ctrlsigs.b_neg != -1) EXPECT_EQ(tb->negate_b_o, ctrlsigs.b_neg) << "NegateB incorrect for instruction " << name; if (ctrlsigs.mem_w != -1) EXPECT_EQ(tb->mem_w_o, ctrlsigs.mem_w) << "MemW incorrect for instruction " << name; if (ctrlsigs.reg_w != -1) EXPECT_EQ(tb->reg_w_o, ctrlsigs.reg_w) << "RegW incorrect for instruction " << name; if (ctrlsigs.next_pc != -1) EXPECT_EQ(tb->next_pc_o, ctrlsigs.next_pc) << "NextPC incorrect for instruction " << name; if (ctrlsigs.wb_src != -1) EXPECT_EQ(tb->wb_src_o, ctrlsigs.wb_src) << "WBsrc incorrect for instruction " << name; } } TEST_F(DecoderTest, IllegalInstruction) { tb->instr_i = 0x0; tb->eval(); EXPECT_EQ(tb->illegal_instr_o, 1); tb->instr_i = rv_and() | (1 << 30); // AND w/ a twist tb->eval(); EXPECT_EQ(tb->illegal_instr_o, 1); } TEST_F(DecoderTest, ExtractRs1) { // Regression test for silly bug where I mixed up jal and jalr when refactoring // decoder. Would be nice to include rs1 gating in main control signals test, // but not sure of super clean way to do it. tb->instr_i = rv_jalr(0, 1, 0); // jalr w/ rs1 = 1 tb->eval(); EXPECT_EQ(tb->rs1_o, 1); tb->instr_i = rv_jal() | (1 << 15); tb->eval(); EXPECT_EQ(tb->rs1_o, 0); } TEST_F(DecoderTest, System) { // System instructions don't really take advantage of the same control signals, // so cleanest to test them individually. tb->instr_i = rv_fence(); tb->eval(); EXPECT_EQ(tb->nop_o, 1); EXPECT_EQ(tb->ebreak_o, 0); EXPECT_EQ(tb->ecall_o, 0); EXPECT_EQ(tb->mret_o, 0); tb->instr_i = rv_fence_i(); tb->eval(); EXPECT_EQ(tb->nop_o, 1); EXPECT_EQ(tb->ebreak_o, 0); EXPECT_EQ(tb->ecall_o, 0); EXPECT_EQ(tb->mret_o, 0); tb->instr_i = rv_wfi(); tb->eval(); EXPECT_EQ(tb->nop_o, 1); EXPECT_EQ(tb->ebreak_o, 0); EXPECT_EQ(tb->ecall_o, 0); EXPECT_EQ(tb->mret_o, 0); tb->instr_i = rv_ecall(); tb->eval(); EXPECT_EQ(tb->ecall_o, 1); EXPECT_EQ(tb->ebreak_o, 0); EXPECT_EQ(tb->mret_o, 0); EXPECT_EQ(tb->nop_o, 0); tb->instr_i = rv_ebreak(); tb->eval(); EXPECT_EQ(tb->ebreak_o, 1); EXPECT_EQ(tb->ecall_o, 0); EXPECT_EQ(tb->mret_o, 0); EXPECT_EQ(tb->nop_o, 0); tb->instr_i = rv_mret(); tb->eval(); EXPECT_EQ(tb->mret_o, 1); EXPECT_EQ(tb->ecall_o, 0); EXPECT_EQ(tb->ebreak_o, 0); EXPECT_EQ(tb->nop_o, 0); }
43.363636
108
0.611242
nmoroze