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
listlengths 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
listlengths 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
listlengths 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7ed02d68dd213deeafc9942003012d4865f18e14
| 10,429
|
hh
|
C++
|
extern/glow/src/glow/objects/Program.hh
|
huzjkevin/portal_maze_zgl
|
efb32b1c3430f20638c1401095999ecb4d0af5aa
|
[
"MIT"
] | null | null | null |
extern/glow/src/glow/objects/Program.hh
|
huzjkevin/portal_maze_zgl
|
efb32b1c3430f20638c1401095999ecb4d0af5aa
|
[
"MIT"
] | null | null | null |
extern/glow/src/glow/objects/Program.hh
|
huzjkevin/portal_maze_zgl
|
efb32b1c3430f20638c1401095999ecb4d0af5aa
|
[
"MIT"
] | null | null | null |
#pragma once
#include <glow/common/gltypeinfo.hh>
#include <glow/common/macro_join.hh>
#include <glow/common/nodiscard.hh>
#include <glow/common/non_copyable.hh>
#include <glow/common/property.hh>
#include <glow/common/shared.hh>
#include <glow/gl.hh>
#include <glow/util/LocationMapping.hh>
#include "NamedObject.hh"
#include "raii/UsedProgram.hh"
#include <map>
#include <string>
#include <vector>
// only vec/mat types
#include <glm/matrix.hpp>
namespace glow
{
GLOW_SHARED(class, Sampler);
GLOW_SHARED(class, Shader);
GLOW_SHARED(class, Program);
GLOW_SHARED(class, LocationMapping);
GLOW_SHARED(class, UniformState);
GLOW_SHARED(class, Texture);
GLOW_SHARED(class, Texture2D);
GLOW_SHARED(class, UniformBuffer);
GLOW_SHARED(class, ShaderStorageBuffer);
GLOW_SHARED(class, AtomicCounterBuffer);
GLOW_SHARED(class, Buffer);
class Program final : public NamedObject<Program, GL_PROGRAM>
{
public:
struct UniformInfo
{
std::string name;
GLint location = -1;
GLint size = -1;
GLenum type = GL_INVALID_ENUM;
bool wasSet = false;
};
private:
/// If true, shader check for shader reloading periodically
static bool sCheckShaderReloading;
/// OpenGL object name
GLuint mObjectName;
/// List of attached shader
std::vector<SharedShader> mShader;
/// Last time of reload checking
int64_t mLastReloadCheck = 0;
/// Last time this shader was linked
int64_t mLastTimeLinked = 0;
/// Uniform lookup cache
/// Invalidates after link
mutable std::vector<UniformInfo> mUniformCache;
/// Texture unit mapping
LocationMapping mTextureUnitMapping;
/// Bounds texture (idx = unit)
std::vector<SharedTexture> mTextures;
/// Bounds texture sampler (idx = unit)
std::vector<SharedSampler> mSamplers;
/// Locations for in-VS-attributes
/// At any point, the mapping saved here must be consistent (i.e. a superset) of the GPU mapping
SharedLocationMapping mAttributeMapping;
/// Locations for out-FS-attributes
/// At any point, the mapping saved here must be consistent (i.e. a superset) of the GPU mapping
SharedLocationMapping mFragmentMapping;
/// Friend for negotiating mAttributeMapping
friend class VertexArray;
friend struct BoundVertexArray;
/// Friend for negotiating mFragmentMapping
friend class Framebuffer;
friend struct BoundFramebuffer;
/// Mapping for uniform buffers
LocationMapping mUniformBufferMapping;
/// Bound uniform buffer
std::map<std::string, SharedUniformBuffer> mUniformBuffers;
/// Mapping for shaderStorage buffers
LocationMapping mShaderStorageBufferMapping;
/// Bound shaderStorage buffer
std::map<std::string, SharedShaderStorageBuffer> mShaderStorageBuffers;
/// Bound AtomicCounter buffer
std::map<int, SharedAtomicCounterBuffer> mAtomicCounterBuffers;
/// List of varyings for transform feedback
std::vector<std::string> mTransformFeedbackVaryings;
/// Buffer mode for transform feedback
GLenum mTransformFeedbackMode;
/// if true, this program is linked properly for transform feedback
bool mIsLinkedForTransformFeedback = false;
/// true if already checked for layout(loc)
bool mCheckedForAttributeLocationLayout = false;
/// true if already checked for layout(loc)
bool mCheckedForFragmentLocationLayout = false;
/// disables unchanged uniform warning
bool mWarnOnUnchangedUniforms = true;
/// true if already checked for unchanged uniforms
bool mCheckedUnchangedUniforms = false;
private:
/// Internal linking
/// returns false on errors
bool linkAndCheckErrors();
/// Restores additional "program state", like textures and shader buffers
void restoreExtendedState();
/// Reset frag location check
/// Necessary because frags cannot be queried ...
void resetFragmentLocationCheck() { mCheckedForFragmentLocationLayout = false; }
/// see public: version
UniformInfo* getUniformInfo(std::string const& name);
/// returns uniform location and sets "wasSet" to true
/// Also verifies that the uniform types match
GLint useUniformLocationAndVerify(std::string const& name, GLint size, GLenum type);
public: // properties
GLuint getObjectName() const { return mObjectName; }
std::vector<SharedShader> const& getShader() const { return mShader; }
SharedLocationMapping const& getAttributeMapping() const { return mAttributeMapping; }
SharedLocationMapping const& getFragmentMapping() const { return mFragmentMapping; }
LocationMapping const& getTextureUnitMapping() const { return mTextureUnitMapping; }
GLOW_GETTER(LastTimeLinked);
GLOW_PROPERTY(WarnOnUnchangedUniforms);
/// returns true iff a shader with this type is attached
bool hasShaderType(GLenum type) const;
/// Gets the currently used program (nullptr if none)
static UsedProgram* getCurrentProgram();
/// Modifies shader reloading state
static void setShaderReloading(bool enabled);
public:
/// Checks if all bound textures have valid mipmaps
void validateTextureMipmaps() const;
/// if not already done so:
/// checks if any uniform is used but not set
void checkUnchangedUniforms();
public: // gl functions without use
/// Returns the in-shader location of the given uniform name
/// Is -1 if not found or optimized out (!)
/// Uses an internal cache to speedup the call
GLint getUniformLocation(std::string const& name) const;
/// Returns information about a uniform
/// If location is -1, information is nullptr
/// (Returned pointer is invalidated if shader is relinked)
UniformInfo const* getUniformInfo(std::string const& name) const;
/// Returns the index of a uniform block
GLuint getUniformBlockIndex(std::string const& name) const;
/// ========================================= UNIFORMS - START =========================================
/// Getter for uniforms
/// If you get linker errors, the type is not supported
/// Returns default-constructed values for optimized uniforms
/// Usage:
/// auto pos = prog->getUniform<glm::vec3>("uPosition");
///
/// LIMITATIONS:
/// currently doesn't work for arrays/structs
///
/// Supported types:
/// * bool
/// * float
/// * int
/// * unsigned int
/// * [ uib]vec[234]
/// * mat[234]
/// * mat[234]x[234]
template <typename DataT>
DataT getUniform(std::string const& name) const
{
DataT value;
auto loc = getUniformLocation(name);
if (loc >= 0)
implGetUniform(glTypeOf<DataT>::basetype, loc, (void*)&value);
else
value = DataT{};
return value;
}
/// ========================================== UNIFORMS - END ==========================================
private:
/// Internal generic getter for uniforms
void implGetUniform(detail::glBaseType type, GLint loc, void* data) const;
public:
Program();
~Program();
/// Returns true iff program is linked properly
bool isLinked() const;
/// Returns a list of all attribute locations
/// Depending on driver, this only returns "used" attributes
std::vector<std::pair<std::string, int>> extractAttributeLocations();
/// Attaches the given shader to this program
/// Requires re-linking!
void attachShader(SharedShader const& shader);
/// Links all attached shader into the program.
/// Has to be done each time shader and/or IO locations are changed
/// CAUTION: linking deletes all currently set uniform values!
void link(bool saveUniformState = true);
/// Configures this shader for use with transform feedback
/// NOTE: cannot be done while shader is in use
void configureTransformFeedback(std::vector<std::string> const& varyings, GLenum bufferMode = GL_INTERLEAVED_ATTRIBS);
/// Returns true if transform feedback can be used
bool isConfiguredForTransformFeedback() const { return mTransformFeedbackVaryings.size() > 0; }
/// Extracts all active uniforms and saves them into a UniformState object
/// This function should not be used very frequently
SharedUniformState getUniforms() const;
/// Binds a uniform buffer to a given block name
/// DOES NOT REQUIRE PROGRAM USE
void setUniformBuffer(std::string const& bufferName, SharedUniformBuffer const& buffer);
/// Binds a shader storage buffer to a given block name
/// DOES NOT REQUIRE PROGRAM USE
void setShaderStorageBuffer(std::string const& bufferName, SharedShaderStorageBuffer const& buffer);
/// Binds an atomic counter buffer to a binding point
/// DOES NOT REQUIRE PROGRAM USE
void setAtomicCounterBuffer(int bindingPoint, SharedAtomicCounterBuffer const& buffer);
/// Verifies registered offsets in the uniform buffer and emits errors if they don't match
/// Return false if verification failed
bool verifyUniformBuffer(std::string const& bufferName, SharedUniformBuffer const& buffer);
/// Activates this shader program.
/// Deactivation is done when the returned object runs out of scope.
GLOW_NODISCARD UsedProgram use() { return {this}; }
friend UsedProgram;
public: // static construction
/// Creates a shader program from a list of shaders
/// Attaches shader and links the program
/// Program can be used directly after this
static SharedProgram create(std::vector<SharedShader> const& shader);
static SharedProgram create(SharedShader const& shader) { return create(std::vector<SharedShader>({shader})); }
/// Creates a program from either a single file or auto-discovered shader files
/// E.g. createFromFile("mesh");
/// will use mesh.vsh as vertex shader and mesh.fsh as fragment shader if available
/// See common/shader_endings.cc for a list of available endings
/// Will also traverse "dots" if file not found to check for base versions
/// E.g. createFromFile("mesh.opaque");
/// might find mesh.opaque.fsh and mesh.vsh
static SharedProgram createFromFile(std::string const& fileOrBaseName);
/// Creates a program from a list of explicitly named files
/// Shader type is determined by common/shader_endings.cc
static SharedProgram createFromFiles(std::vector<std::string> const& filenames);
};
}
| 36.592982
| 122
| 0.698149
|
huzjkevin
|
7ed08d18a4a54352dac118c13d60f2c6715f9bb7
| 1,092
|
cc
|
C++
|
leetcode/p6.cc
|
lhyqie/lhyqie.github.io
|
d986ac4afddf169a07d4f1de95bcc737368e212b
|
[
"MIT"
] | null | null | null |
leetcode/p6.cc
|
lhyqie/lhyqie.github.io
|
d986ac4afddf169a07d4f1de95bcc737368e212b
|
[
"MIT"
] | null | null | null |
leetcode/p6.cc
|
lhyqie/lhyqie.github.io
|
d986ac4afddf169a07d4f1de95bcc737368e212b
|
[
"MIT"
] | null | null | null |
#include "common.h"
class Solution {
public:
string longestPalindrome(string s) {
int start = 0, max_len = 1;
for(int i = 0; i < s.size(); i++){
int len1 = expandAroundCenter(s, i, i);
int len2 = expandAroundCenter(s, i, i+1);
int len = std::max(len1, len2);
if(std::max(len1, len2) > max_len){
// when len is odd e.g. ...abcba... len = 5 center is i => start = i - (len-1)/2 = i - 2
// when len is even e.g. ...abba... len = 4 center is i => start = i - (len-1)/2 = i - 1
start = i - (len-1)/2;
max_len = len;
}
// std::cout << "i=" << i << " len1=" << len1 << " len2=" << len2 << " start=" << start << "\n" ;
}
return s.substr(start, max_len);
}
private:
int expandAroundCenter(const string& s, int left, int right){
while(left >= 0 && right< s.size() && s[left] == s[right]){
left --; right ++;
}
return right - left - 1; // right - left + 1 - 2
}
};
int main()
{
std::cout << Solution().longestPalindrome("babbc");
return 0;
}
| 30.333333
| 112
| 0.494505
|
lhyqie
|
7ed9e9e405f5aad41a90800b91beedbb009328e9
| 769
|
hpp
|
C++
|
include/Version.hpp
|
marcosivni/dicomlib
|
dd268d07368ff4f1ffd1f94cdaa1e2dbf30bc5c7
|
[
"BSD-3-Clause"
] | null | null | null |
include/Version.hpp
|
marcosivni/dicomlib
|
dd268d07368ff4f1ffd1f94cdaa1e2dbf30bc5c7
|
[
"BSD-3-Clause"
] | null | null | null |
include/Version.hpp
|
marcosivni/dicomlib
|
dd268d07368ff4f1ffd1f94cdaa1e2dbf30bc5c7
|
[
"BSD-3-Clause"
] | null | null | null |
/************************************************************************
* DICOMLIB
* Copyright 2003 Sunnybrook and Women's College Health Science Center
* Implemented by Trevor Morgan (morgan@sten.sunnybrook.utoronto.ca)
*
* See LICENSE.txt for copyright and licensing info.
*************************************************************************/
#ifndef VERSION_HPP_INCLUDE_GUARD_U62KI43SNTDB4
#define VERSION_HPP_INCLUDE_GUARD_U62KI43SNTDB4
namespace dicom
{
//!library meta-information, such as version.
namespace library
{
extern const char* name;
extern const char* version;
extern const int major_version;
extern const int minor_version;
extern const int revision;
}//namespace library
}
#endif //VERSION_HPP_INCLUDE_GUARD_U62KI43SNTDB4
| 26.517241
| 74
| 0.642393
|
marcosivni
|
7edaec75b0cf2648a7cee0b07f42f61f99fa1368
| 389
|
cpp
|
C++
|
cppcode/201710_12/reference.cpp
|
jiedou/study
|
606676ebc3d1fb1a87de26b6609307d71dafec22
|
[
"Apache-2.0"
] | null | null | null |
cppcode/201710_12/reference.cpp
|
jiedou/study
|
606676ebc3d1fb1a87de26b6609307d71dafec22
|
[
"Apache-2.0"
] | null | null | null |
cppcode/201710_12/reference.cpp
|
jiedou/study
|
606676ebc3d1fb1a87de26b6609307d71dafec22
|
[
"Apache-2.0"
] | null | null | null |
#include <iostream>
using namespace std;
int main()
{
int a=1;
int &b=a;
int c=b;
b=2;
cout<<"a="<<a<<",b="<<b<<",c="<<c<<endl;
int d[]={1,2,3,4,5};
int(&e)[5]=d;
for(int i=0;i<sizeof(d)/sizeof(d[0]);i++)
{
e[i]=e[i]*10+e[i];
}
for(int i=0;i<sizeof(d)/sizeof(d[0]);i++)
{
cout<<d[i]<<endl;
}
return 0;
}
| 16.913043
| 45
| 0.411311
|
jiedou
|
7edf5e50fc97e2e4a115438d0fe06804eb043f50
| 1,648
|
hpp
|
C++
|
graph_tree/reroot.hpp
|
hotman78/cpplib
|
c2f85c8741cdd0b731a5aa828b28b38c70c8d699
|
[
"CC0-1.0"
] | null | null | null |
graph_tree/reroot.hpp
|
hotman78/cpplib
|
c2f85c8741cdd0b731a5aa828b28b38c70c8d699
|
[
"CC0-1.0"
] | null | null | null |
graph_tree/reroot.hpp
|
hotman78/cpplib
|
c2f85c8741cdd0b731a5aa828b28b38c70c8d699
|
[
"CC0-1.0"
] | null | null | null |
#pragma once
#include<vector>
/**
* @brief 全方位木DP
*/
template<typename T,typename F,typename Fix>
struct reroot{
std::vector<std::vector<long long>>g;
std::vector<int>p_list;
std::vector<T>p_table;
std::vector<bool>p_checked;
std::vector<map<int,T>>table;
std::vector<T>ans;
T e;
F f;
Fix fix;
reroot(const std::vector<std::vector<long long>>& g,T e,F f=F(),Fix fix=Fix()):g(g),e(e),f(f),fix(fix){
int n=g.size();
p_list.resize(n,-1);
p_checked.resize(n,0);
table.resize(n);
p_table.resize(n,e);
ans.resize(n,e);
dfs1(0,-1);
for(int i=0;i<n;++i)ans[i]=dfs2(i,-1);
}
T dfs1(int n,int p){
p_list[n]=p;
T tmp1=e,tmp2=e;
std::vector<T>tmp(g[n].size());
rep(i,g[n].size()){
int t=g[n][i];
if(t==p)continue;
table[n][t]=tmp1;
tmp1=f(tmp1,tmp[i]=dfs1(t,n));
}
for(int i=g[n].size()-1;i>=0;--i){
int t=g[n][i];
if(t==p)continue;
table[n][t]=f(table[n][t],tmp2);
tmp2=f(tmp[i],tmp2);
}
return fix(table[n][p]=tmp1,n,p);
}
T dfs2(int n,int p){
if(n==-1){
return e;
}
if(!p_checked[n]){
p_checked[n]=1;
p_table[n]=dfs2(p_list[n],n);
}
if(p==-1){
return f(table[n][p_list[n]],p_table[n]);
}else{
if(p_list[n]==-1)return fix(table[n][p],n,p);
else return fix(f(table[n][p],p_table[n]),n,p);
}
}
vector<T>query(){
return ans;
}
};
| 25.353846
| 107
| 0.462985
|
hotman78
|
7ee4b87260e8806d0a41f06e5a6ee005bf9bf864
| 1,963
|
cpp
|
C++
|
apps/opencs/view/doc/operations.cpp
|
Bodillium/openmw
|
5fdd264d0704e33b44b1ccf17ab4fb721f362e34
|
[
"Unlicense"
] | null | null | null |
apps/opencs/view/doc/operations.cpp
|
Bodillium/openmw
|
5fdd264d0704e33b44b1ccf17ab4fb721f362e34
|
[
"Unlicense"
] | null | null | null |
apps/opencs/view/doc/operations.cpp
|
Bodillium/openmw
|
5fdd264d0704e33b44b1ccf17ab4fb721f362e34
|
[
"Unlicense"
] | null | null | null |
#include "operations.hpp"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include "operation.hpp"
CSVDoc::Operations::Operations()
{
/// \todo make widget height fixed (exactly the height required to display all operations)
setFeatures (QDockWidget::NoDockWidgetFeatures);
QWidget *widgetContainer = new QWidget (this);
mLayout = new QVBoxLayout;
widgetContainer->setLayout (mLayout);
setWidget (widgetContainer);
setVisible (false);
setFixedHeight (widgetContainer->height());
setTitleBarWidget (new QWidget (this));
}
void CSVDoc::Operations::setProgress (int current, int max, int type, int threads)
{
for (std::vector<Operation *>::iterator iter (mOperations.begin()); iter!=mOperations.end(); ++iter)
if ((*iter)->getType()==type)
{
(*iter)->setProgress (current, max, threads);
return;
}
int oldCount = mOperations.size();
int newCount = oldCount + 1;
Operation *operation = new Operation (type, this);
connect (operation, SIGNAL (abortOperation (int)), this, SIGNAL (abortOperation (int)));
mLayout->addLayout (operation->getLayout());
mOperations.push_back (operation);
operation->setProgress (current, max, threads);
if ( oldCount > 0)
setFixedHeight (height()/oldCount * newCount);
setVisible (true);
}
void CSVDoc::Operations::quitOperation (int type)
{
for (std::vector<Operation *>::iterator iter (mOperations.begin()); iter!=mOperations.end(); ++iter)
if ((*iter)->getType()==type)
{
int oldCount = mOperations.size();
int newCount = oldCount - 1;
mLayout->removeItem ((*iter)->getLayout());
(*iter)->deleteLater();
mOperations.erase (iter);
if (oldCount > 1)
setFixedHeight (height() / oldCount * newCount);
else
setVisible (false);
break;
}
}
| 28.042857
| 104
| 0.620479
|
Bodillium
|
7ee4c63995bffaf76d26ee7753c7496bf6dd7647
| 10,720
|
cpp
|
C++
|
evs/src/v2/model/ListSnapshotsRequest.cpp
|
yangzhaofeng/huaweicloud-sdk-cpp-v3
|
4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23
|
[
"Apache-2.0"
] | 5
|
2021-03-03T08:23:43.000Z
|
2022-02-16T02:16:39.000Z
|
evs/src/v2/model/ListSnapshotsRequest.cpp
|
yangzhaofeng/huaweicloud-sdk-cpp-v3
|
4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23
|
[
"Apache-2.0"
] | null | null | null |
evs/src/v2/model/ListSnapshotsRequest.cpp
|
yangzhaofeng/huaweicloud-sdk-cpp-v3
|
4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23
|
[
"Apache-2.0"
] | 7
|
2021-02-26T13:53:35.000Z
|
2022-03-18T02:36:43.000Z
|
#include "huaweicloud/evs/v2/model/ListSnapshotsRequest.h"
namespace HuaweiCloud {
namespace Sdk {
namespace Evs {
namespace V2 {
namespace Model {
ListSnapshotsRequest::ListSnapshotsRequest()
{
offset_ = 0;
offsetIsSet_ = false;
limit_ = 0;
limitIsSet_ = false;
name_ = "";
nameIsSet_ = false;
status_ = "";
statusIsSet_ = false;
volumeId_ = "";
volumeIdIsSet_ = false;
availabilityZone_ = "";
availabilityZoneIsSet_ = false;
id_ = "";
idIsSet_ = false;
dedicatedStorageName_ = "";
dedicatedStorageNameIsSet_ = false;
dedicatedStorageId_ = "";
dedicatedStorageIdIsSet_ = false;
serviceType_ = "";
serviceTypeIsSet_ = false;
enterpriseProjectId_ = "";
enterpriseProjectIdIsSet_ = false;
}
ListSnapshotsRequest::~ListSnapshotsRequest() = default;
void ListSnapshotsRequest::validate()
{
}
web::json::value ListSnapshotsRequest::toJson() const
{
web::json::value val = web::json::value::object();
if(offsetIsSet_) {
val[utility::conversions::to_string_t("offset")] = ModelBase::toJson(offset_);
}
if(limitIsSet_) {
val[utility::conversions::to_string_t("limit")] = ModelBase::toJson(limit_);
}
if(nameIsSet_) {
val[utility::conversions::to_string_t("name")] = ModelBase::toJson(name_);
}
if(statusIsSet_) {
val[utility::conversions::to_string_t("status")] = ModelBase::toJson(status_);
}
if(volumeIdIsSet_) {
val[utility::conversions::to_string_t("volume_id")] = ModelBase::toJson(volumeId_);
}
if(availabilityZoneIsSet_) {
val[utility::conversions::to_string_t("availability_zone")] = ModelBase::toJson(availabilityZone_);
}
if(idIsSet_) {
val[utility::conversions::to_string_t("id")] = ModelBase::toJson(id_);
}
if(dedicatedStorageNameIsSet_) {
val[utility::conversions::to_string_t("dedicated_storage_name")] = ModelBase::toJson(dedicatedStorageName_);
}
if(dedicatedStorageIdIsSet_) {
val[utility::conversions::to_string_t("dedicated_storage_id")] = ModelBase::toJson(dedicatedStorageId_);
}
if(serviceTypeIsSet_) {
val[utility::conversions::to_string_t("service_type")] = ModelBase::toJson(serviceType_);
}
if(enterpriseProjectIdIsSet_) {
val[utility::conversions::to_string_t("enterprise_project_id")] = ModelBase::toJson(enterpriseProjectId_);
}
return val;
}
bool ListSnapshotsRequest::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t("offset"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("offset"));
if(!fieldValue.is_null())
{
int32_t refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setOffset(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("limit"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("limit"));
if(!fieldValue.is_null())
{
int32_t refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setLimit(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("name"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("name"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setName(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("status"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("status"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setStatus(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("volume_id"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("volume_id"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setVolumeId(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("availability_zone"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("availability_zone"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setAvailabilityZone(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("id"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("id"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setId(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("dedicated_storage_name"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("dedicated_storage_name"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setDedicatedStorageName(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("dedicated_storage_id"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("dedicated_storage_id"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setDedicatedStorageId(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("service_type"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("service_type"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setServiceType(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("enterprise_project_id"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("enterprise_project_id"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setEnterpriseProjectId(refVal);
}
}
return ok;
}
int32_t ListSnapshotsRequest::getOffset() const
{
return offset_;
}
void ListSnapshotsRequest::setOffset(int32_t value)
{
offset_ = value;
offsetIsSet_ = true;
}
bool ListSnapshotsRequest::offsetIsSet() const
{
return offsetIsSet_;
}
void ListSnapshotsRequest::unsetoffset()
{
offsetIsSet_ = false;
}
int32_t ListSnapshotsRequest::getLimit() const
{
return limit_;
}
void ListSnapshotsRequest::setLimit(int32_t value)
{
limit_ = value;
limitIsSet_ = true;
}
bool ListSnapshotsRequest::limitIsSet() const
{
return limitIsSet_;
}
void ListSnapshotsRequest::unsetlimit()
{
limitIsSet_ = false;
}
std::string ListSnapshotsRequest::getName() const
{
return name_;
}
void ListSnapshotsRequest::setName(const std::string& value)
{
name_ = value;
nameIsSet_ = true;
}
bool ListSnapshotsRequest::nameIsSet() const
{
return nameIsSet_;
}
void ListSnapshotsRequest::unsetname()
{
nameIsSet_ = false;
}
std::string ListSnapshotsRequest::getStatus() const
{
return status_;
}
void ListSnapshotsRequest::setStatus(const std::string& value)
{
status_ = value;
statusIsSet_ = true;
}
bool ListSnapshotsRequest::statusIsSet() const
{
return statusIsSet_;
}
void ListSnapshotsRequest::unsetstatus()
{
statusIsSet_ = false;
}
std::string ListSnapshotsRequest::getVolumeId() const
{
return volumeId_;
}
void ListSnapshotsRequest::setVolumeId(const std::string& value)
{
volumeId_ = value;
volumeIdIsSet_ = true;
}
bool ListSnapshotsRequest::volumeIdIsSet() const
{
return volumeIdIsSet_;
}
void ListSnapshotsRequest::unsetvolumeId()
{
volumeIdIsSet_ = false;
}
std::string ListSnapshotsRequest::getAvailabilityZone() const
{
return availabilityZone_;
}
void ListSnapshotsRequest::setAvailabilityZone(const std::string& value)
{
availabilityZone_ = value;
availabilityZoneIsSet_ = true;
}
bool ListSnapshotsRequest::availabilityZoneIsSet() const
{
return availabilityZoneIsSet_;
}
void ListSnapshotsRequest::unsetavailabilityZone()
{
availabilityZoneIsSet_ = false;
}
std::string ListSnapshotsRequest::getId() const
{
return id_;
}
void ListSnapshotsRequest::setId(const std::string& value)
{
id_ = value;
idIsSet_ = true;
}
bool ListSnapshotsRequest::idIsSet() const
{
return idIsSet_;
}
void ListSnapshotsRequest::unsetid()
{
idIsSet_ = false;
}
std::string ListSnapshotsRequest::getDedicatedStorageName() const
{
return dedicatedStorageName_;
}
void ListSnapshotsRequest::setDedicatedStorageName(const std::string& value)
{
dedicatedStorageName_ = value;
dedicatedStorageNameIsSet_ = true;
}
bool ListSnapshotsRequest::dedicatedStorageNameIsSet() const
{
return dedicatedStorageNameIsSet_;
}
void ListSnapshotsRequest::unsetdedicatedStorageName()
{
dedicatedStorageNameIsSet_ = false;
}
std::string ListSnapshotsRequest::getDedicatedStorageId() const
{
return dedicatedStorageId_;
}
void ListSnapshotsRequest::setDedicatedStorageId(const std::string& value)
{
dedicatedStorageId_ = value;
dedicatedStorageIdIsSet_ = true;
}
bool ListSnapshotsRequest::dedicatedStorageIdIsSet() const
{
return dedicatedStorageIdIsSet_;
}
void ListSnapshotsRequest::unsetdedicatedStorageId()
{
dedicatedStorageIdIsSet_ = false;
}
std::string ListSnapshotsRequest::getServiceType() const
{
return serviceType_;
}
void ListSnapshotsRequest::setServiceType(const std::string& value)
{
serviceType_ = value;
serviceTypeIsSet_ = true;
}
bool ListSnapshotsRequest::serviceTypeIsSet() const
{
return serviceTypeIsSet_;
}
void ListSnapshotsRequest::unsetserviceType()
{
serviceTypeIsSet_ = false;
}
std::string ListSnapshotsRequest::getEnterpriseProjectId() const
{
return enterpriseProjectId_;
}
void ListSnapshotsRequest::setEnterpriseProjectId(const std::string& value)
{
enterpriseProjectId_ = value;
enterpriseProjectIdIsSet_ = true;
}
bool ListSnapshotsRequest::enterpriseProjectIdIsSet() const
{
return enterpriseProjectIdIsSet_;
}
void ListSnapshotsRequest::unsetenterpriseProjectId()
{
enterpriseProjectIdIsSet_ = false;
}
}
}
}
}
}
| 24.814815
| 116
| 0.673134
|
yangzhaofeng
|
7ee5dd311a7c3ec42cf4eae373c6b0f129fb3ffa
| 2,332
|
cpp
|
C++
|
School Olympiads/Kazakhstan IOI Team Selection Camp 2018/Day 4/c.cpp
|
SuperPuperMegaUltraEpicGoldenHacker/Competetive-Programming
|
ab1ca0d0d2187b561750d547e155e768951d29a0
|
[
"MIT"
] | null | null | null |
School Olympiads/Kazakhstan IOI Team Selection Camp 2018/Day 4/c.cpp
|
SuperPuperMegaUltraEpicGoldenHacker/Competetive-Programming
|
ab1ca0d0d2187b561750d547e155e768951d29a0
|
[
"MIT"
] | null | null | null |
School Olympiads/Kazakhstan IOI Team Selection Camp 2018/Day 4/c.cpp
|
SuperPuperMegaUltraEpicGoldenHacker/Competetive-Programming
|
ab1ca0d0d2187b561750d547e155e768951d29a0
|
[
"MIT"
] | null | null | null |
# include <bits/stdc++.h>
# define F first
# define S second
# define mp make_pair
// everything go according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1 Y_U_NO_y1
# define left Y_U_NO_left
# define right Y_U_NO_right
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;
const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
ios_base :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
unsigned int seed;
asm ("rdtsc" : "=A"(seed));
srand (seed);
}
void files (string problem) {
if (fopen ((problem + ".in").c_str(),"r")) {
freopen ((problem + ".in").c_str(),"r",stdin);
freopen ((problem + ".out").c_str(),"w",stdout);
}
}
void localInput(const char in[] = "s") {
if (fopen (in, "r"))
freopen (in, "r", stdin);
else
cerr << "Warning: Input file not found" << endl;
}
ll n, k, a, b;
ll x, y;
ll binpow (ll a, ll b) {
int res = 1;
while (b) {
if (b & 1)
res = (res * a) % Mod;
b >>= 1;
a = (a * a) % Mod;
}
return res;
}
ll dp[Sz];
ll calc (int n) {
if (n < k)
return binpow (a + b, n);
if (~dp[n])
return dp[n];
dp[n] = 0;
for (int j = 0; j < k; j++)
dp[n] = (dp[n] + (calc (n - j - 1) * b) % Mod * binpow (a, j)) % Mod;
return dp[n];
}
int main()
{
# ifdef Local
//localInput();
# endif
Read_rap();
cin >> n >> k >> a >> b;
/*
memset (dp, -1, sizeof dp);
x = binpow (a + b, k-1);
y = (binpow (a, k-1) * b) % Mod;
ll res1 = binpow (a + b, n) - calc(n);
*/
for (int i = 0; i < k; i++)
dp[i] = binpow (a + b, i);
ll sum = 0;
for (int i = 0; i < k; i++)
sum = (sum + (dp[k - 1 - i] * b) % Mod * binpow (a, i)) % Mod;
dp[k] = sum;
for (int i = k + 1; i <= n; i++) {
sum = (sum * a + b * dp[i - 1]) % Mod;
sum = (sum - ((dp[i - k - 1] * b) % Mod * binpow (a, k))) % Mod;
if (sum < 0)
sum += Mod;
dp[i] = sum;
}
ll res = binpow (a + b, n) - dp[n];
if (res < 0)
res += Mod;
cout << res;
return 0;
}
// Coded by Z..
| 19.433333
| 73
| 0.496998
|
SuperPuperMegaUltraEpicGoldenHacker
|
7ee62dc712cbf004e7453a3de916c97755ceec2b
| 2,417
|
cpp
|
C++
|
src/zone/call-task.cpp
|
localh0rzd/napajs
|
b3f5e67dd20caef5d96ea8c3e3d4c542fcb9a431
|
[
"MIT"
] | 9,088
|
2017-08-08T22:28:16.000Z
|
2019-05-05T14:57:12.000Z
|
src/zone/call-task.cpp
|
localh0rzd/napajs
|
b3f5e67dd20caef5d96ea8c3e3d4c542fcb9a431
|
[
"MIT"
] | 172
|
2017-08-09T21:32:15.000Z
|
2019-05-03T21:21:05.000Z
|
src/zone/call-task.cpp
|
localh0rzd/napajs
|
b3f5e67dd20caef5d96ea8c3e3d4c542fcb9a431
|
[
"MIT"
] | 370
|
2017-08-09T04:58:14.000Z
|
2019-04-13T18:59:29.000Z
|
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
// See: https://groups.google.com/forum/#!topic/nodejs/onA0S01INtw
#ifdef BUILDING_NODE_EXTENSION
#include <node.h>
#endif
#include "call-task.h"
#include <module/core-modules/napa/call-context-wrap.h>
#include <napa/log.h>
using namespace napa::zone;
using namespace napa::v8_helpers;
napa::zone::CallTask::CallTask(std::shared_ptr<CallContext> context) :
_context(std::move(context)) {
}
void CallTask::Execute() {
NAPA_DEBUG("CallTask", "Begin executing function (%s.%s).", _context->GetModule().c_str(), _context->GetFunction().c_str());
auto isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
auto context = isolate->GetCurrentContext();
// Get the module based main function from global scope.
auto executeFunction = context->Global()->Get(MakeExternalV8String(isolate, "__napa_zone_call__"));
JS_ENSURE(isolate, executeFunction->IsFunction(), "__napa_zone_call__ function must exist in global scope");
// Create task wrap.
auto contextWrap = napa::module::CallContextWrap::NewInstance(_context);
v8::Local<v8::Value> argv[] = { contextWrap };
// Execute the function.
v8::TryCatch tryCatch(isolate);
auto res = v8::Local<v8::Function>::Cast(executeFunction)->Call(
isolate->GetCurrentContext(),
context->Global(),
1,
argv);
// Terminating an isolate may occur from a different thread, i.e. from timeout service.
// If the function call already finished successfully when the isolate is terminated it may lead
// to one the following:
// 1. Terminate was called before tryCatch.HasTerminated(), the user gets an error code.
// 2. Terminate was called after tryCatch.HasTerminated(), the user gets a success code.
//
// In both cases the isolate is being restored since this happens before each task executes.
if (tryCatch.HasTerminated()) {
if (_terminationReason == TerminationReason::TIMEOUT) {
(void)_context->Reject(NAPA_RESULT_TIMEOUT, "Terminated due to timeout");
} else {
(void)_context->Reject(NAPA_RESULT_INTERNAL_ERROR, "Terminated with unknown reason");
}
return;
}
NAPA_ASSERT(!tryCatch.HasCaught(), "__napa_zone_call__ should catch all user exceptions and reject task.");
}
| 38.365079
| 128
| 0.695904
|
localh0rzd
|
7ee9248ee9f8bd45268bfd3793b758401e95d653
| 1,892
|
cpp
|
C++
|
SimuVar/Is_Number.cpp
|
TheArquitect/SimuVar
|
b6f4965af938706f6de1497494362c4b5c87d01e
|
[
"BSD-2-Clause"
] | null | null | null |
SimuVar/Is_Number.cpp
|
TheArquitect/SimuVar
|
b6f4965af938706f6de1497494362c4b5c87d01e
|
[
"BSD-2-Clause"
] | null | null | null |
SimuVar/Is_Number.cpp
|
TheArquitect/SimuVar
|
b6f4965af938706f6de1497494362c4b5c87d01e
|
[
"BSD-2-Clause"
] | null | null | null |
/**
File : Is_Number.cpp
Author : Menashe Rosemberg
Created : 2019.02.19 Version: 20190219.1
Check if a string is a number
Copyright (c) 2019 TheArquitect (Menashe Rosemberg) rosemberg@ymail.com
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 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.
**/
#include "Is_Number.h"
bool is_number(const std::string& TxT) {
bool OnePoint = true;
for (auto Letter = TxT.cbegin() + (TxT[0] == '-'? 1 : 0); Letter != TxT.cend(); ++Letter)
if (*Letter =='.' && OnePoint)
OnePoint = false;
else if (!isdigit(*Letter))
return false;
return true;
}
| 44
| 94
| 0.708774
|
TheArquitect
|
7ef3b326accd80455c869d530b44fecb228876a2
| 1,124
|
hpp
|
C++
|
src/Message.hpp
|
relaxtakenotes/xenos
|
24d19b683e85df54f56cd9a5b2c6416b86e1325d
|
[
"MIT"
] | 4
|
2021-12-14T13:32:10.000Z
|
2022-03-08T23:14:58.000Z
|
src/Message.hpp
|
relaxtakenotes/xenos
|
24d19b683e85df54f56cd9a5b2c6416b86e1325d
|
[
"MIT"
] | 1
|
2021-10-20T14:09:51.000Z
|
2021-10-20T14:09:51.000Z
|
src/Message.hpp
|
relaxtakenotes/xenos
|
24d19b683e85df54f56cd9a5b2c6416b86e1325d
|
[
"MIT"
] | null | null | null |
#pragma once
#include "stdafx.h"
#include "Log.h"
class Message
{
enum MsgType
{
Error,
Warning,
Info,
Question,
};
public:
static void ShowError( HWND parent, const std::wstring& msg, const std::wstring& title = L"Error" )
{
Show( msg, title, Error, parent );
}
static void ShowWarning( HWND parent, const std::wstring& msg, const std::wstring& title = L"Warning" )
{
Show( msg, title, Warning, parent );
}
static void ShowInfo( HWND parent, const std::wstring& msg, const std::wstring& title = L"Info" )
{
Show( msg, title, Info, parent );
}
static bool ShowQuestion( HWND parent, const std::wstring& msg, const std::wstring& title = L"Question" )
{
return Show( msg, title, Question, parent ) == IDYES;
}
private:
static int Show(
const std::wstring& msg,
const std::wstring& title,
MsgType type,
HWND parent = NULL
)
{
UINT uType = MB_ICONERROR;
return MessageBoxW( parent, msg.c_str(), title.c_str(), uType );
}
};
| 22.938776
| 109
| 0.573843
|
relaxtakenotes
|
7d0aa05c46f1372bd499f5ec56029f30c8b6d2df
| 1,072
|
cpp
|
C++
|
Source/UModEditor/SUModPalette.cpp
|
StoneLineDevTeam/UMod
|
e57e41b95d8cdcc4479965453ac86e5116178795
|
[
"BSD-4-Clause"
] | 21
|
2015-09-03T13:17:55.000Z
|
2022-03-28T15:55:42.000Z
|
Source/UModEditor/SUModPalette.cpp
|
StoneLineDevTeam/UMod
|
e57e41b95d8cdcc4479965453ac86e5116178795
|
[
"BSD-4-Clause"
] | 24
|
2015-09-19T18:03:30.000Z
|
2018-12-21T10:53:01.000Z
|
Source/UModEditor/SUModPalette.cpp
|
StoneLineDevTeam/UMod
|
e57e41b95d8cdcc4479965453ac86e5116178795
|
[
"BSD-4-Clause"
] | 17
|
2015-09-03T13:18:04.000Z
|
2021-11-24T02:14:11.000Z
|
#include "UModEditor.h"
#include "SUModPalette.h"
void SUModPalette::Construct(const FArguments& Args)
{
/*ChildSlot
[
//Creating the button that adds a new item on the list when pressed
SNew(SScrollBox)
+ SScrollBox::Slot()
[
//The actual list view creation
+ SScrollBox::Slot()
[
SAssignNew(ListViewWidget, SListView<TSharedPtr<FString>>)
.ItemHeight(24)
.ListItemsSource(&Items) //The Items array is the source of this listview
.OnGenerateRow(this, &SUModPalette::OnGenerateRowForList)
]
];*/
}
FReply SUModPalette::ButtonPressed()
{
//Adds a new item to the array (do whatever you want with this)
Items.Add(MakeShareable(new FString("Hello 1")));
//Update the listview
ListViewWidget->RequestListRefresh();
return FReply::Handled();
}
TSharedRef<ITableRow> SUModPalette::OnGenerateRowForList(TSharedPtr<FString> Item, const TSharedRef<STableViewBase>& OwnerTable)
{
//Create the row
return
SNew(STableRow<TSharedPtr<FString>>, OwnerTable)
.Padding(2.0f)
[
SNew(SButton).Text(FText::FromString(*Item.Get()))
];
}
| 23.822222
| 128
| 0.726679
|
StoneLineDevTeam
|
7d0c6614694712d3b9099d1ddf3df2b30ef9d34d
| 11,175
|
cpp
|
C++
|
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
|
dalihub/dali-toolk
|
980728a7e35b8ddd28f70c090243e8076e21536e
|
[
"Apache-2.0",
"BSD-3-Clause"
] | 7
|
2016-11-18T10:26:51.000Z
|
2021-01-28T13:51:59.000Z
|
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
|
dalihub/dali-toolk
|
980728a7e35b8ddd28f70c090243e8076e21536e
|
[
"Apache-2.0",
"BSD-3-Clause"
] | 13
|
2020-07-15T11:33:03.000Z
|
2021-04-09T21:29:23.000Z
|
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
|
dalihub/dali-toolk
|
980728a7e35b8ddd28f70c090243e8076e21536e
|
[
"Apache-2.0",
"BSD-3-Clause"
] | 10
|
2019-05-17T07:15:09.000Z
|
2021-05-24T07:28:08.000Z
|
/*
* Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* 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 "dummy-control.h"
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
namespace Dali
{
namespace Toolkit
{
DummyControl::DummyControl()
{
}
DummyControl::DummyControl(const DummyControl& control)
: Control( control )
{
}
DummyControl::~DummyControl()
{
}
DummyControl DummyControl::DownCast( BaseHandle handle )
{
return Control::DownCast<DummyControl, DummyControlImpl>(handle);
}
DummyControl& DummyControl::operator=(const DummyControl& control)
{
Control::operator=( control );
return *this;
}
// Used to test signal connections
void DummyControlImpl::CustomSlot1( Actor actor )
{
mCustomSlot1Called = true;
}
namespace {
BaseHandle Create()
{
return DummyControlImpl::New();
}
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::DummyControl, Toolkit::Control, Create );
DALI_TYPE_REGISTRATION_END()
Dali::PropertyRegistration dummyControlVisualProperty01(
typeRegistration, "testVisual", Dali::Toolkit::DummyControl::Property::TEST_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
Dali::PropertyRegistration dummyControlVisualProperty02(
typeRegistration, "testVisual2", Dali::Toolkit::DummyControl::Property::TEST_VISUAL2, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
Dali::PropertyRegistration dummyControlVisualProperty03(
typeRegistration, "foregroundVisual", Dali::Toolkit::DummyControl::Property::FOREGROUND_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
Dali::PropertyRegistration dummyControlVisualProperty04(
typeRegistration, "focusVisual", Dali::Toolkit::DummyControl::Property::FOCUS_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
Dali::PropertyRegistration dummyControlVisualProperty05(
typeRegistration, "labelVisual", Dali::Toolkit::DummyControl::Property::LABEL_VISUAL, Dali::Property::MAP, &Dali::Toolkit::DummyControlImpl::SetProperty, &Dali::Toolkit::DummyControlImpl::GetProperty );
}
DummyControl DummyControlImpl::New()
{
IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
DummyControl control( *impl );
impl->Initialize();
return control;
}
DummyControlImpl::DummyControlImpl()
: Control( ControlBehaviour() ),
mCustomSlot1Called(false)
{
}
DummyControlImpl::~DummyControlImpl()
{
}
void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual )
{
DevelControl::RegisterVisual( *this, index, visual );
VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
if( iter == mRegisteredVisualIndices.end() )
{
mRegisteredVisualIndices.push_back(index);
}
}
void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled )
{
DevelControl::RegisterVisual( *this, index, visual, enabled );
VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
if( iter == mRegisteredVisualIndices.end() )
{
mRegisteredVisualIndices.push_back(index);
}
}
void DummyControlImpl::UnregisterVisual( Property::Index index )
{
DevelControl::UnregisterVisual( *this, index );
VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
if( iter != mRegisteredVisualIndices.end() )
{
mRegisteredVisualIndices.erase(iter);
}
}
Toolkit::Visual::Base DummyControlImpl::GetVisual( Property::Index index )
{
return DevelControl::GetVisual( *this, index );
}
void DummyControlImpl::EnableVisual( Property::Index index, bool enabled )
{
DevelControl::EnableVisual( *this, index, enabled );
}
bool DummyControlImpl::IsVisualEnabled( Property::Index index )
{
return DevelControl::IsVisualEnabled( *this, index );
}
Animation DummyControlImpl::CreateTransition( const Toolkit::TransitionData& transition )
{
return DevelControl::CreateTransition( *this, transition );
}
void DummyControlImpl::DoAction( Dali::Property::Index index, Dali::Property::Index action, const Dali::Property::Value attributes )
{
DummyControl control( *this );
DevelControl::DoAction( control, index, action, attributes);
}
void DummyControlImpl::SetProperty( BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value )
{
Toolkit::DummyControl control = Toolkit::DummyControl::DownCast( Dali::BaseHandle( object ) );
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(control.GetImplementation());
switch(index)
{
case Toolkit::DummyControl::Property::TEST_VISUAL:
case Toolkit::DummyControl::Property::TEST_VISUAL2:
case Toolkit::DummyControl::Property::FOREGROUND_VISUAL:
case Toolkit::DummyControl::Property::FOCUS_VISUAL:
case Toolkit::DummyControl::Property::LABEL_VISUAL:
{
const Property::Map* map = value.GetMap();
if( map != NULL )
{
VisualFactory visualFactory = VisualFactory::Get();
Visual::Base visual = visualFactory.CreateVisual(*map);
dummyImpl.RegisterVisual(index, visual);
}
break;
}
}
}
Property::Value DummyControlImpl::GetProperty( BaseObject* object, Dali::Property::Index propertyIndex )
{
Toolkit::DummyControl control = Toolkit::DummyControl::DownCast( Dali::BaseHandle( object ) );
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>( control.GetImplementation() );
Visual::Base visual = dummyImpl.GetVisual( propertyIndex );
Property::Map map;
if( visual )
{
visual.CreatePropertyMap( map );
}
Dali::Property::Value value = map;
return value;
}
Toolkit::DummyControl Impl::DummyControl::New()
{
IntrusivePtr< Toolkit::Impl::DummyControl > impl = new Toolkit::Impl::DummyControl;
Toolkit::DummyControl control( *impl );
impl->Initialize();
return control;
}
int Impl::DummyControl::constructorCount;
int Impl::DummyControl::destructorCount;
Impl::DummyControl::DummyControl()
: DummyControlImpl(),
initializeCalled(false),
activatedCalled(false),
onAccValueChangeCalled(false),
themeChangeCalled(false),
fontChangeCalled(false),
pinchCalled(false),
panCalled(false),
tapCalled(false),
longPressCalled(false),
stageConnectionCalled(false),
stageDisconnectionCalled(false),
childAddCalled(false),
childRemoveCalled(false),
sizeSetCalled(false),
sizeAnimationCalled(false),
hoverEventCalled(false),
wheelEventCalled(false),
keyEventCalled(false),
keyInputFocusGained(false),
keyInputFocusLost(false)
{
++constructorCount;
}
Impl::DummyControl::~DummyControl()
{
++destructorCount;
}
void Impl::DummyControl::OnInitialize() { initializeCalled = true; }
bool Impl::DummyControl::OnAccessibilityActivated() { activatedCalled = true; return true; }
bool Impl::DummyControl::OnAccessibilityValueChange( bool isIncrease )
{
onAccValueChangeCalled = true; return true;
}
void Impl::DummyControl::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
{
themeChangeCalled = change == StyleChange::THEME_CHANGE;
fontChangeCalled = change == StyleChange::DEFAULT_FONT_SIZE_CHANGE;
}
void Impl::DummyControl::OnPinch(const PinchGesture& pinch) { pinchCalled = true; }
void Impl::DummyControl::OnPan(const PanGesture& pan) { panCalled = true; }
void Impl::DummyControl::OnTap(const TapGesture& tap) { tapCalled = true; }
void Impl::DummyControl::OnLongPress(const LongPressGesture& longPress) { longPressCalled = true; }
void Impl::DummyControl::OnSceneConnection( int depth ) { Control::OnSceneConnection( depth ); stageConnectionCalled = true; }
void Impl::DummyControl::OnSceneDisconnection() { stageDisconnectionCalled = true; Control::OnSceneDisconnection(); }
void Impl::DummyControl::OnChildAdd(Actor& child) { childAddCalled = true; }
void Impl::DummyControl::OnChildRemove(Actor& child) { childRemoveCalled = true; }
void Impl::DummyControl::OnSizeSet(const Vector3& targetSize) { Control::OnSizeSet( targetSize ); sizeSetCalled = true; }
void Impl::DummyControl::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { Control::OnSizeAnimation( animation, targetSize ); sizeAnimationCalled = true; }
bool Impl::DummyControl::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
void Impl::DummyControl::OnKeyInputFocusGained() { keyInputFocusGained = true; }
void Impl::DummyControl::OnKeyInputFocusLost() { keyInputFocusLost = true; }
void Impl::DummyControl::SetLayout( Property::Index visualIndex, Property::Map& map )
{
Property::Value value( map );
mLayouts[visualIndex] = value;
}
void Impl::DummyControl::OnRelayout( const Vector2& size, RelayoutContainer& container )
{
if ( mRelayoutCallback )
{
mRelayoutCallback( size ); // Execute callback if set
}
Property::Map emptyMap;
for( VisualIndices::iterator iter = mRegisteredVisualIndices.begin(); iter != mRegisteredVisualIndices.end() ; ++iter )
{
Visual::Base visual = GetVisual(*iter);
Property::Value value = mLayouts[*iter];
Property::Map* map = NULL;
if( value.GetType() != Property::NONE )
{
map = value.GetMap();
}
if( map == NULL )
{
map = &emptyMap;
}
visual.SetTransformAndSize( *map, size );
}
}
void Impl::DummyControl::SetRelayoutCallback( RelayoutCallbackFunc callback )
{
mRelayoutCallback = callback;
}
Vector3 Impl::DummyControl::GetNaturalSize()
{
Vector2 currentSize;
for( auto elem : mRegisteredVisualIndices )
{
Vector2 naturalSize;
Visual::Base visual = GetVisual(elem);
visual.GetNaturalSize( naturalSize );
currentSize.width = std::max( naturalSize.width, currentSize.width );
currentSize.height = std::max( naturalSize.height, currentSize.height );
}
return Vector3( currentSize );
}
DummyControl DummyControl::New( bool override )
{
DummyControl control;
if (override)
{
control = Impl::DummyControl::New();
}
else
{
control = DummyControlImpl::New();
}
return control;
}
DummyControl::DummyControl( DummyControlImpl& implementation )
: Control( implementation )
{
}
DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
: Control( internal )
{
VerifyCustomActorPointer<DummyControlImpl>(internal);
}
} // namespace Toolkit
} // namespace Dali
| 30.955679
| 214
| 0.747383
|
dalihub
|
7d10dd6416879b3113cbbcf6fc45aee5d1edc9f8
| 2,847
|
cpp
|
C++
|
example/tutorial.cpp
|
anarthal/mysql-asio
|
13d3615464f41222052d9ad8fa0c86bcdddee537
|
[
"BSL-1.0"
] | 47
|
2019-10-21T14:54:39.000Z
|
2020-07-06T19:36:58.000Z
|
example/tutorial.cpp
|
anarthal/mysql-asio
|
13d3615464f41222052d9ad8fa0c86bcdddee537
|
[
"BSL-1.0"
] | 5
|
2020-03-05T12:03:02.000Z
|
2020-07-06T18:18:35.000Z
|
example/tutorial.cpp
|
anarthal/mysql-asio
|
13d3615464f41222052d9ad8fa0c86bcdddee537
|
[
"BSL-1.0"
] | 4
|
2020-03-05T11:28:55.000Z
|
2020-05-20T09:06:21.000Z
|
//
// Copyright (c) 2019-2022 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
//
// 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)
//
#include "boost/mysql/connection.hpp"
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl/context.hpp>
#include <boost/mysql.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/system/system_error.hpp>
#include <iostream>
#include <string>
/**
* For this example, we will be using the 'boost_mysql_examples' database.
* You can get this database by running db_setup.sql.
* This example assumes you are connecting to a localhost MySQL server.
*
* This example uses synchronous functions and handles errors using exceptions.
*/
void main_impl(int argc, char** argv)
{
if (argc != 4)
{
std::cerr << "Usage: " << argv[0] << " <username> <password> <server-hostname>\n";
exit(1);
}
//[tutorial_connection
// The execution context, required to run I/O operations
boost::asio::io_context ctx;
// The SSL context, required to establish TLS connections.
// The default SSL options are good enough for us at this point.
boost::asio::ssl::context ssl_ctx (boost::asio::ssl::context::tls_client);
// The object defining the connection to the MySQL server.
boost::mysql::tcp_ssl_connection conn (ctx.get_executor(), ssl_ctx);
//]
//[tutorial_connect
// Resolve the hostname to get a collection of endpoints
boost::asio::ip::tcp::resolver resolver (ctx.get_executor());
auto endpoints = resolver.resolve(argv[3], boost::mysql::default_port_string);
// The username and password to use
boost::mysql::connection_params params (
argv[1], // username
argv[2] // password
);
// Connect to the server using the first endpoint returned by the resolver
conn.connect(*endpoints.begin(), params);
//]
//[tutorial_query
const char* sql = "SELECT \"Hello world!\"";
boost::mysql::tcp_ssl_resultset result = conn.query(sql);
//]
//[tutorial_read
std::vector<boost::mysql::row> employees = result.read_all();
//]
//[tutorial_values
const boost::mysql::row& first_row = employees.at(0);
boost::mysql::value first_value = first_row.values().at(0);
std::cout << first_value << std::endl;
//]
//[tutorial_close
conn.close();
//]
}
int main(int argc, char** argv)
{
try
{
main_impl(argc, argv);
}
catch (const boost::system::system_error& err)
{
std::cerr << "Error: " << err.what() << ", error code: " << err.code() << std::endl;
return 1;
}
catch (const std::exception& err)
{
std::cerr << "Error: " << err.what() << std::endl;
return 1;
}
}
| 29.05102
| 92
| 0.645592
|
anarthal
|
7d1125330c9522ef1fd250f11ab7a4f8dbb1bc06
| 3,497
|
cpp
|
C++
|
CNN/activation_test.cpp
|
suiyili/projects
|
29b4ab0435c8994809113c444b3dea4fff60b75c
|
[
"MIT"
] | null | null | null |
CNN/activation_test.cpp
|
suiyili/projects
|
29b4ab0435c8994809113c444b3dea4fff60b75c
|
[
"MIT"
] | null | null | null |
CNN/activation_test.cpp
|
suiyili/projects
|
29b4ab0435c8994809113c444b3dea4fff60b75c
|
[
"MIT"
] | null | null | null |
#ifdef TEST
#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp>
#include "activation_mock.hpp"
#include "layer_mock.hpp"
#include "test_value.hpp"
#include "value_factory_mock.hpp"
#include <array>
#include <forward_list>
#include <future>
#include <numeric>
using namespace Catch;
namespace cnn::neuron {
SCENARIO("activation test", "[activation]") {
GIVEN("a previous layer") {
value_array prev_layer_values{.40f, .25f, .13f, .61f, 1.0f};
constexpr unsigned short prev_size = 4U;
auto prev_layer = std::make_unique<layer_mock>(prev_size);
auto &prev = *prev_layer;
for (size_t i = 0U; i < prev_size; ++i)
prev[i].set_output(prev_layer_values[i]);
AND_GIVEN("a series of W values") {
value_array init_weights{.20f, .31f, .22f, .85f, .58f};
value_factory_mock factory(init_weights);
activation_mock n(std::move(prev_layer), factory);
WHEN("activation forward") {
n.forward();
THEN("it should get argument from linear product") {
auto expected = factory[prev.size()];
for (size_t i = 0; i < prev.size(); ++i)
expected += prev[i].output() * factory[i];
REQUIRE(n.get_argument() == Approx(expected).margin(test_precision));
}
}
AND_GIVEN("a series of error gredients") {
std::array<float, 4> error_gradient{.25f, .22f, .38f, .18f};
WHEN("activation propagates back") {
n.propagate_back(error_gradient[0]);
n.train();
THEN("it should call previous layer with curated value") {
for (size_t i = 0; i < prev.size(); ++i) {
auto expected = error_gradient[0] * factory[i];
REQUIRE(prev[i].propagate_back_called_with() ==
Approx(expected).margin(test_precision));
}
AND_WHEN("learn from more back propagation") {
for (size_t i = 1U; i < error_gradient.size(); ++i) {
n.propagate_back(error_gradient[i]);
n.train();
}
const float learning_rate = .2f;
n.learn(learning_rate);
auto gradient_sum = std::accumulate(error_gradient.begin(),
error_gradient.end(), 0.0f);
value_array delta = prev_layer_values * gradient_sum;
delta /= (float)error_gradient.size();
delta *= learning_rate;
auto weights = init_weights - delta;
for (size_t i = 0; i < prev.size(); ++i)
prev[i].set_output(1.0f);
n.forward();
REQUIRE(n.get_argument() ==
Approx(weights.sum()).margin(test_precision));
}
}
}
WHEN("propagate back with multi-threads") {
std::forward_list<std::future<void>> tasks;
float total_error = 0.0f;
for (auto e : error_gradient) {
tasks.emplace_front(std::async(std::launch::async,
[&n, e] { n.propagate_back(e); }));
total_error += e;
}
for (auto &t : tasks)
t.wait();
n.train();
THEN("it should sum all propagation currectly") {
REQUIRE(n.get_back_prop() ==
Approx(total_error).margin(test_precision));
}
}
}
}
}
}
} // namespace cnn::neuron
#endif // TEST
| 32.37963
| 79
| 0.547612
|
suiyili
|
7d12722e884fe5221263bcfc371a702b1c0ca7bf
| 1,832
|
cpp
|
C++
|
tests/depthai_pybind11_tests.cpp
|
4ndr3aR/depthai-python
|
b4fe1211d19280b2f2be8a43912ea818f6f4b5b3
|
[
"MIT"
] | 182
|
2020-06-25T00:27:12.000Z
|
2022-03-31T05:06:04.000Z
|
tests/depthai_pybind11_tests.cpp
|
4ndr3aR/depthai-python
|
b4fe1211d19280b2f2be8a43912ea818f6f4b5b3
|
[
"MIT"
] | 206
|
2020-07-28T22:32:14.000Z
|
2022-03-31T13:57:59.000Z
|
tests/depthai_pybind11_tests.cpp
|
4ndr3aR/depthai-python
|
b4fe1211d19280b2f2be8a43912ea818f6f4b5b3
|
[
"MIT"
] | 102
|
2020-08-06T23:02:35.000Z
|
2022-03-24T19:43:30.000Z
|
/*
tests/pybind11_tests.cpp -- pybind example plugin
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
All rights reserved. Use of this source code is governed by a
BSD-style license that can be found in the LICENSE file.
*/
#include "depthai_pybind11_tests.hpp"
#include <functional>
#include <list>
/*
For testing purposes, we define a static global variable here in a function that each individual
test .cpp calls with its initialization lambda. It's convenient here because we can just not
compile some test files to disable/ignore some of the test code.
It is NOT recommended as a way to use pybind11 in practice, however: the initialization order will
be essentially random, which is okay for our test scripts (there are no dependencies between the
individual pybind11 test .cpp files), but most likely not what you want when using pybind11
productively.
Instead, see the "How can I reduce the build time?" question in the "Frequently asked questions"
section of the documentation for good practice on splitting binding code over multiple files.
*/
std::list<std::function<void(py::module_ &)>> &initializers() {
static std::list<std::function<void(py::module_ &)>> inits;
return inits;
}
test_initializer::test_initializer(Initializer init) {
initializers().emplace_back(init);
}
test_initializer::test_initializer(const char *submodule_name, Initializer init) {
initializers().emplace_back([=](py::module_ &parent) {
auto m = parent.def_submodule(submodule_name);
init(m);
});
}
PYBIND11_MODULE(depthai_pybind11_tests, m) {
m.doc() = "depthai pybind11 test module";
#if !defined(NDEBUG)
m.attr("debug_enabled") = true;
#else
m.attr("debug_enabled") = false;
#endif
for (const auto &initializer : initializers())
initializer(m);
}
| 32.714286
| 98
| 0.736354
|
4ndr3aR
|
7d16eb73ad5ad9f95d96c26644eecb823e05d550
| 26,472
|
cc
|
C++
|
Ghidra/rulecompile.cc
|
fjqisba/E-Decompiler
|
f598c4205d8b9e4d29172dab0bb2672c75e48af9
|
[
"MIT"
] | 74
|
2021-03-04T08:12:43.000Z
|
2022-03-14T13:50:20.000Z
|
Ghidra/rulecompile.cc
|
fjqisba/E-Decompiler
|
f598c4205d8b9e4d29172dab0bb2672c75e48af9
|
[
"MIT"
] | 10
|
2021-03-05T09:52:10.000Z
|
2021-07-05T13:48:33.000Z
|
Ghidra/rulecompile.cc
|
fjqisba/E-Decompiler
|
f598c4205d8b9e4d29172dab0bb2672c75e48af9
|
[
"MIT"
] | 15
|
2021-04-06T14:22:39.000Z
|
2022-03-29T13:14:47.000Z
|
/* ###
* IP: GHIDRA
*
* 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.
*/
#ifdef CPUI_RULECOMPILE
#include "rulecompile.hh"
#include "ruleparse.hh"
RuleCompile *rulecompile;
extern int4 ruleparsedebug;
extern int4 ruleparseparse(void);
class MyLoadImage : public LoadImage { // Dummy loadimage
public:
MyLoadImage(void) : LoadImage("nofile") {}
virtual void loadFill(uint1 *ptr,int4 size,const Address &addr) { for(int4 i=0;i<size;++i) ptr[i] = 0; }
virtual string getArchType(void) const { return "myload"; }
virtual void adjustVma(long adjust) { }
};
int4 RuleLexer::identlist[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0,
0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 5,
0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
int4 RuleLexer::scanIdentifier(void)
{
int4 i=0;
identifier[i] = (char)getNextChar(); // Scan at least the first character
i += 1;
do {
if ((identlist[next(0)]&1) != 0) {
identifier[i] = (char) getNextChar();
i += 1;
}
else
break;
} while(i<255);
if ((i==255)||(i==0))
return -1; // Identifier is too long
identifier[i] = '\0';
identlength = i;
if ((identlist[(int4)identifier[0]]&2) != 0) // First number is digit
return scanNumber();
switch(identifier[0]) {
case 'o':
return buildString(OP_IDENTIFIER);
case 'v':
return buildString(VAR_IDENTIFIER);
case '#':
return buildString(CONST_IDENTIFIER);
case 'O':
return buildString(OP_NEW_IDENTIFIER);
case 'V':
return buildString(VAR_NEW_IDENTIFIER);
case '.':
return buildString(DOT_IDENTIFIER);
default:
return otherIdentifiers();
}
}
int4 RuleLexer::scanNumber(void)
{
istringstream s(identifier);
s.unsetf(ios::dec | ios::hex | ios::oct);
uint8 val;
s >> val;
if (!s)
return BADINTEGER;
ruleparselval.big = new int8(val);
return INTB;
}
int4 RuleLexer::buildString(int4 tokentype)
{
if (identlength <= 1) return -1;
for(int4 i=1;i<identlength;++i) {
if ((identlist[(int4)identifier[i]]&4)==0) return -1;
}
if (identifier[0] == '.') {
ruleparselval.str = new string(identifier+1);
return tokentype;
}
if (identifier[0] == '#')
identifier[0] = 'c';
ruleparselval.str = new string(identifier);
return tokentype;
}
int4 RuleLexer::otherIdentifiers(void)
{
map<string,int4>::const_iterator iter;
iter = keywordmap.find(string(identifier));
if (iter != keywordmap.end())
return (*iter).second;
return -1;
}
void RuleLexer::initKeywords(void)
{
keywordmap["COPY"] = OP_COPY;
keywordmap["ZEXT"] = OP_INT_ZEXT;
keywordmap["CARRY"] = OP_INT_CARRY;
keywordmap["SCARRY"] = OP_INT_SCARRY;
keywordmap["SEXT"] = OP_INT_SEXT;
keywordmap["SBORROW"] = OP_INT_SBORROW;
keywordmap["NAN"] = OP_FLOAT_NAN;
keywordmap["ABS"] = OP_FLOAT_ABS;
keywordmap["SQRT"] = OP_FLOAT_SQRT;
keywordmap["CEIL"] = OP_FLOAT_CEIL;
keywordmap["FLOOR"] = OP_FLOAT_FLOOR;
keywordmap["ROUND"] = OP_FLOAT_ROUND;
keywordmap["INT2FLOAT"] = OP_FLOAT_INT2FLOAT;
keywordmap["FLOAT2FLOAT"] = OP_FLOAT_FLOAT2FLOAT;
keywordmap["TRUNC"] = OP_FLOAT_TRUNC;
keywordmap["GOTO"] = OP_BRANCH;
keywordmap["GOTOIND"] = OP_BRANCHIND;
keywordmap["CALL"] = OP_CALL;
keywordmap["CALLIND"] = OP_CALLIND;
keywordmap["RETURN"] = OP_RETURN;
keywordmap["CBRANCH"] = OP_CBRANCH;
keywordmap["USEROP"] = OP_CALLOTHER;
keywordmap["LOAD"] = OP_LOAD;
keywordmap["STORE"] = OP_STORE;
keywordmap["CONCAT"] = OP_PIECE;
keywordmap["SUBPIECE"] = OP_SUBPIECE;
keywordmap["before"] = BEFORE_KEYWORD;
keywordmap["after"] = AFTER_KEYWORD;
keywordmap["remove"] = REMOVE_KEYWORD;
keywordmap["set"] = SET_KEYWORD;
keywordmap["istrue"] = ISTRUE_KEYWORD;
keywordmap["isfalse"] = ISFALSE_KEYWORD;
}
int4 RuleLexer::nextToken(void)
{
for(;;) {
int4 mychar = next(0);
switch(mychar) {
case '(':
case ')':
case ',':
case '[':
case ']':
case ';':
case '{':
case '}':
case ':':
getNextChar();
ruleparselval.ch = (char)mychar;
return mychar;
case '\r':
case ' ':
case '\t':
case '\v':
getNextChar();
break;
case '\n':
getNextChar();
lineno += 1;
break;
case '-':
getNextChar();
if (next(0) == '>') {
getNextChar();
return RIGHT_ARROW;
}
else if (next(0) == '-') {
getNextChar();
if (next(0) == '>') {
getNextChar();
return DOUBLE_RIGHT_ARROW;
}
return ACTION_TICK;
}
return OP_INT_SUB;
case '<':
getNextChar();
if (next(0) == '-') {
getNextChar();
if (next(0) == '-') {
getNextChar();
return DOUBLE_LEFT_ARROW;
}
return LEFT_ARROW;
}
else if (next(0) == '<') {
getNextChar();
return OP_INT_LEFT;
}
else if (next(0) == '=') {
getNextChar();
return OP_INT_LESSEQUAL;
}
return OP_INT_LESS;
case '|':
getNextChar();
if (next(0) == '|') {
getNextChar();
return OP_BOOL_OR;
}
return OP_INT_OR;
case '&':
getNextChar();
if (next(0) == '&') {
getNextChar();
return OP_BOOL_AND;
}
return OP_INT_AND;
case '^':
getNextChar();
if (next(0) == '^') {
getNextChar();
return OP_BOOL_XOR;
}
return OP_INT_XOR;
case '>':
if (next(1) == '>') {
getNextChar();
getNextChar();
return OP_INT_RIGHT;
}
return -1;
case '=':
getNextChar();
if (next(0) == '=') {
getNextChar();
return OP_INT_EQUAL;
}
ruleparselval.ch = (char)mychar;
return mychar;
case '!':
getNextChar();
if (next(0) == '=') {
getNextChar();
return OP_INT_NOTEQUAL;
}
return OP_BOOL_NEGATE;
case 's':
if (next(1) == '/') {
getNextChar();
getNextChar();
return OP_INT_SDIV;
}
else if (next(1) == '%') {
getNextChar();
getNextChar();
return OP_INT_SREM;
}
else if ((next(1)=='>')&&(next(2)=='>')) {
getNextChar();
getNextChar();
getNextChar();
return OP_INT_SRIGHT;
}
else if (next(1)=='<') {
getNextChar();
getNextChar();
if (next(0) == '=') {
getNextChar();
return OP_INT_SLESSEQUAL;
}
return OP_INT_SLESS;
}
return scanIdentifier();
case 'f':
if (next(1) == '+') {
getNextChar();
getNextChar();
return OP_FLOAT_ADD;
}
else if (next(1) == '-') {
getNextChar();
getNextChar();
return OP_FLOAT_SUB;
}
else if (next(1) == '*') {
getNextChar();
getNextChar();
return OP_FLOAT_MULT;
}
else if (next(1) == '/') {
getNextChar();
getNextChar();
return OP_FLOAT_DIV;
}
else if ((next(1) == '=')&&(next(2) == '=')) {
getNextChar();
getNextChar();
getNextChar();
return OP_FLOAT_EQUAL;
}
else if ((next(1) == '!')&&(next(2) == '=')) {
getNextChar();
getNextChar();
getNextChar();
return OP_FLOAT_NOTEQUAL;
}
else if (next(1) == '<') {
getNextChar();
getNextChar();
if (next(0) == '=') {
getNextChar();
return OP_FLOAT_LESSEQUAL;
}
return OP_FLOAT_LESS;
}
return -1;
case '+':
getNextChar();
return OP_INT_ADD;
case '*':
getNextChar();
return OP_INT_MULT;
case '/':
getNextChar();
return OP_INT_DIV;
case '%':
getNextChar();
return OP_INT_REM;
case '~':
getNextChar();
return OP_INT_NEGATE;
case '#':
if ((identlist[next(1)]&6)==4)
return scanIdentifier();
getNextChar();
ruleparselval.ch = (char)mychar; // Return '#' as single token
return mychar;
default:
return scanIdentifier();
}
}
return -1;
}
RuleLexer::RuleLexer(void)
{
initKeywords();
}
void RuleLexer::initialize(istream &t)
{
s = &t;
pos = 0;
endofstream = false;
lineno = 1;
getNextChar();
getNextChar();
getNextChar();
getNextChar(); // Fill lookahead buffer
}
RuleCompile::RuleCompile(void)
{
DummyTranslate dummy;
error_stream = (ostream *)0;
errors = 0;
finalrule = (ConstraintGroup *)0;
OpBehavior::registerInstructions(inst,&dummy);
}
RuleCompile::~RuleCompile(void)
{
if (finalrule != (ConstraintGroup *)0)
delete finalrule;
for(int4 i=0;i<inst.size();++i) {
OpBehavior *t_op = inst[i];
if (t_op != (OpBehavior *)0)
delete t_op;
}
}
void RuleCompile::ruleError(const char *s)
{
if (error_stream != (ostream *)0) {
*error_stream << "Error at line " << dec << lexer.getLineNo() << endl;
*error_stream << " " << s << endl;
}
errors += 1;
}
int4 RuleCompile::findIdentifier(string *nm)
{
int4 resid;
map<string,int4>::const_iterator iter;
iter = namemap.find(*nm);
if (iter == namemap.end()) {
resid = namemap.size();
namemap[*nm] = resid;
}
else
resid = (*iter).second;
delete nm;
return resid;
}
ConstraintGroup *RuleCompile::newOp(int4 id)
{
ConstraintGroup *res = new ConstraintGroup();
res->addConstraint(new DummyOpConstraint(id));
return res;
}
ConstraintGroup *RuleCompile::newVarnode(int4 id)
{
ConstraintGroup *res = new ConstraintGroup();
res->addConstraint(new DummyVarnodeConstraint(id));
return res;
}
ConstraintGroup *RuleCompile::newConst(int4 id)
{
ConstraintGroup *res = new ConstraintGroup();
res->addConstraint(new DummyConstConstraint(id));
return res;
}
ConstraintGroup *RuleCompile::opCopy(ConstraintGroup *base,int4 opid)
{
int4 opindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintOpCopy(opindex,opid);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::opInput(ConstraintGroup *base,int8 *slot,int4 varid)
{
int4 ourslot = (int4) *slot;
delete slot;
int4 opindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintOpInput(opindex,varid,ourslot);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::opInputAny(ConstraintGroup *base,int4 varid)
{
int4 opindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintOpInputAny(opindex,varid);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::opInputConstVal(ConstraintGroup *base,int8 *slot,RHSConstant *val)
{
int4 ourslot = (int4) *slot;
delete slot;
int4 opindex = base->getBaseIndex();
UnifyConstraint *newconstraint;
ConstantAbsolute *myconst = dynamic_cast<ConstantAbsolute *>(val);
if (myconst != (ConstantAbsolute *)0) {
newconstraint = new ConstraintParamConstVal(opindex,ourslot,myconst->getVal());
}
else {
ConstantNamed *mynamed = dynamic_cast<ConstantNamed *>(val);
if (mynamed != (ConstantNamed *)0) {
newconstraint = new ConstraintParamConst(opindex,ourslot,mynamed->getId());
}
else {
ruleError("Can only use absolute constant here");
newconstraint = new ConstraintParamConstVal(opindex,ourslot,0);
}
}
delete val;
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::opOutput(ConstraintGroup *base,int4 varid)
{
int4 opindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintOpOutput(opindex,varid);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::varCopy(ConstraintGroup *base,int4 varid)
{
int4 varindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintVarnodeCopy(varid,varindex);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::varConst(ConstraintGroup *base,RHSConstant *ex,RHSConstant *sz)
{
int4 varindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintVarConst(varindex,ex,sz);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::varDef(ConstraintGroup *base,int4 opid)
{
int4 varindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintDef(opid,varindex);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::varDescend(ConstraintGroup *base,int4 opid)
{
int4 varindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintDescend(opid,varindex);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::varUniqueDescend(ConstraintGroup *base,int4 opid)
{
int4 varindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintLoneDescend(opid,varindex);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::opCodeConstraint(ConstraintGroup *base,vector<OpCode> *oplist)
{
if (oplist->size() != 1)
throw LowlevelError("Not currently supporting multiple opcode constraints");
int4 opindex = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintOpcode(opindex,*oplist);
delete oplist;
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::opCompareConstraint(ConstraintGroup *base,int4 opid,OpCode opc)
{
int4 op1index = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintOpCompare(op1index,opid,(opc==CPUI_INT_EQUAL));
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::varCompareConstraint(ConstraintGroup *base,int4 varid,OpCode opc)
{
int4 var1index = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintVarCompare(var1index,varid,(opc==CPUI_INT_EQUAL));
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::constCompareConstraint(ConstraintGroup *base,int4 constid,OpCode opc)
{
int4 const1index = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintConstCompare(const1index,constid,opc);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::constNamedExpression(int4 id,RHSConstant *expr)
{
ConstraintGroup *res = new ConstraintGroup();
res->addConstraint(new ConstraintNamedExpression(id,expr));
return res;
}
ConstraintGroup *RuleCompile::emptyGroup(void)
{
return new ConstraintGroup();
}
ConstraintGroup *RuleCompile::emptyOrGroup(void)
{
return new ConstraintOr();
}
ConstraintGroup *RuleCompile::mergeGroups(ConstraintGroup *a,ConstraintGroup *b)
{
a->mergeIn(b);
return a;
}
ConstraintGroup *RuleCompile::addOr(ConstraintGroup *base,ConstraintGroup *newor)
{
base->addConstraint(newor);
return base;
}
ConstraintGroup *RuleCompile::opCreation(int4 newid,OpCode oc,bool iafter,int4 oldid)
{
OpBehavior *behave = inst[oc];
int4 numparms = behave->isUnary() ? 1 : 2;
UnifyConstraint *newconstraint = new ConstraintNewOp(newid,oldid,oc,iafter,numparms);
ConstraintGroup *res = new ConstraintGroup();
res->addConstraint(newconstraint);
return res;
}
ConstraintGroup *RuleCompile::newUniqueOut(ConstraintGroup *base,int4 varid,int4 sz)
{
UnifyConstraint *newconstraint = new ConstraintNewUniqueOut(base->getBaseIndex(),varid,sz);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::newSetInput(ConstraintGroup *base,RHSConstant *slot,int4 varid)
{
UnifyConstraint *newconstraint = new ConstraintSetInput(base->getBaseIndex(),slot,varid);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::newSetInputConstVal(ConstraintGroup *base,RHSConstant *slot,RHSConstant *val,RHSConstant *sz)
{
UnifyConstraint *newconstraint = new ConstraintSetInputConstVal(base->getBaseIndex(),slot,val,sz);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::removeInput(ConstraintGroup *base,RHSConstant *slot)
{
UnifyConstraint *newconstraint = new ConstraintRemoveInput(base->getBaseIndex(),slot);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::newSetOpcode(ConstraintGroup *base,OpCode opc)
{
int4 opid = base->getBaseIndex();
UnifyConstraint *newconstraint = new ConstraintSetOpcode(opid,opc);
base->addConstraint(newconstraint);
return base;
}
ConstraintGroup *RuleCompile::booleanConstraint(bool ist,RHSConstant *expr)
{
ConstraintGroup *base = new ConstraintGroup();
UnifyConstraint *newconstraint = new ConstraintBoolean(ist,expr);
base->addConstraint(newconstraint);
return base;
}
RHSConstant *RuleCompile::constNamed(int4 id)
{
RHSConstant *res = new ConstantNamed(id);
return res;
}
RHSConstant *RuleCompile::constAbsolute(int8 *val)
{
RHSConstant *res = new ConstantAbsolute(*val);
delete val;
return res;
}
RHSConstant *RuleCompile::constBinaryExpression(RHSConstant *ex1,OpCode opc,RHSConstant *ex2)
{
RHSConstant *res = new ConstantExpression( ex1, ex2, opc );
return res;
}
RHSConstant *RuleCompile::constVarnodeSize(int4 varindex)
{
RHSConstant *res = new ConstantVarnodeSize(varindex);
return res;
}
RHSConstant *RuleCompile::dotIdentifier(int4 id,string *str)
{
RHSConstant *res;
if ((*str) == "offset")
res = new ConstantOffset(id);
else if ((*str) == "size")
res = new ConstantVarnodeSize(id);
else if ((*str) == "isconstant")
res = new ConstantIsConstant(id);
else if ((*str) == "heritageknown")
res = new ConstantHeritageKnown(id);
else if ((*str) == "consume")
res = new ConstantConsumed(id);
else if ((*str) == "nzmask")
res = new ConstantNZMask(id);
else {
string errmsg = "Unknown variable attribute: " + *str;
ruleError(errmsg.c_str());
res = new ConstantAbsolute(0);
}
delete str;
return res;
}
void RuleCompile::run(istream &s,bool debug)
{
#ifdef YYDEBUG
ruleparsedebug = debug ? 1 : 0;
#endif
if (!s) {
if (error_stream != (ostream *)0)
*error_stream << "Bad input stream to rule compiler" << endl;
return;
}
errors = 0;
if (finalrule != (ConstraintGroup *)0) {
delete finalrule;
finalrule = (ConstraintGroup *)0;
}
lexer.initialize(s);
rulecompile = this; // Setup the global pointer
int4 parseres = ruleparseparse(); // Try to parse
if (parseres!=0) {
errors += 1;
if (error_stream != (ostream *)0)
*error_stream << "Parsing error" << endl;
}
if (errors!=0) {
if (error_stream != (ostream *)0)
*error_stream << "Parsing incomplete" << endl;
}
}
void RuleCompile::postProcess(void)
{
int4 id = 0;
finalrule->removeDummy();
finalrule->setId(id); // Set id for everybody
}
int4 RuleCompile::postProcessRule(vector<OpCode> &opcodelist)
{ // Do normal post processing but also remove initial opcode check
finalrule->removeDummy();
if (finalrule->numConstraints() == 0)
throw LowlevelError("Cannot postprocess empty rule");
ConstraintOpcode *subconst = dynamic_cast<ConstraintOpcode *>(finalrule->getConstraint(0));
if (subconst == (ConstraintOpcode *)0)
throw LowlevelError("Rule does not start with opcode constraint");
opcodelist = subconst->getOpCodes();
int4 opinit = subconst->getMaxNum();
finalrule->deleteConstraint(0);
int4 id = 0;
finalrule->setId(id);
return opinit;
}
ConstraintGroup *RuleCompile::buildUnifyer(const string &rule,const vector<string> &idlist,
vector<int4> &res)
{
RuleCompile ruler;
istringstream s(rule);
ruler.run(s,false);
if (ruler.numErrors() != 0)
throw LowlevelError("Could not build rule");
ConstraintGroup *resconst = ruler.releaseRule();
for(int4 i=0;i<idlist.size();++i) {
char initc;
int4 id = -1;
map<string,int4>::const_iterator iter;
if (idlist[i].size() != 0) {
initc = idlist[i][0];
if ((initc == 'o')||(initc == 'O')||(initc == 'v')||(initc == 'V')||(initc == '#')) {
iter = ruler.namemap.find(idlist[i]);
if (iter != ruler.namemap.end())
id = (*iter).second;
}
}
if (id == -1)
throw LowlevelError("Bad initializer name: "+idlist[i]);
res.push_back(id);
}
return resconst;
}
RuleGeneric::RuleGeneric(const string &g,const string &nm,const vector<OpCode> &sops,int4 opi,ConstraintGroup *c)
: Rule(g,0,nm), state(c)
{
starterops = sops;
opinit = opi;
constraint = c;
}
void RuleGeneric::getOpList(vector<uint4> &oplist) const
{
for(int4 i=0;i<starterops.size();++i)
oplist.push_back((uint4)starterops[i]);
}
int4 RuleGeneric::applyOp(PcodeOp *op,Funcdata &data)
{
state.setFunction(&data);
state.initialize(opinit,op);
constraint->initialize(state);
return constraint->step(state);
}
RuleGeneric *RuleGeneric::build(const string &nm,const string &gp,const string &content)
{
RuleCompile compiler;
istringstream s(content);
compiler.run(s,false);
if (compiler.numErrors() != 0)
throw LowlevelError("Unable to parse dynamic rule: "+nm);
vector<OpCode> opcodelist;
int4 opinit = compiler.postProcessRule(opcodelist);
RuleGeneric *res = new RuleGeneric(gp,nm,opcodelist,opinit,compiler.releaseRule());
return res;
}
#endif
/*
Here is the original flex parser
%{
#include "rulecompile.hh"
#include "ruleparse.hh"
#define ruleparsewrap() 1
#define YY_SKIP_YYWRAP
extern RuleCompile *rulecompile;
int4 scan_number(char *numtext,YYSTYPE *lval)
{
istringstream s(numtext);
s.unsetf(ios::dec | ios::hex | ios::oct);
uintb val;
s >> val;
if (!s)
return BADINTEGER;
lval->big = new intb(val);
return INTB;
}
int4 find_op_identifier(void)
{
string ident(yytext);
ruleparselval.id = rulecompile->findOpIdentifier(ident);
return OP_IDENTIFIER;
}
int4 find_var_identifier(void)
{
string ident(yytext);
ruleparselval.id = rulecompile->findVarIdentifier(ident);
return VAR_IDENTIFIER;
}
int4 find_const_identifier(void)
{
string ident(yytext);
ruleparselval.id = rulecompile->findConstIdentifier(ident);
return CONST_IDENTIFIER;
}
%}
%%
[(),\[\];\{\}\#] { ruleparselval.ch = yytext[0]; return yytext[0]; }
[0-9]+ { return scan_number(yytext,&ruleparselval); }
0x[0-9a-fA-F]+ { return scan_number(yytext,&ruleparselval); }
[\r\ \t\v]+
\n { rulecompile->nextLine(); }
\-\> { return RIGHT_ARROW; }
\<\- { return LEFT_ARROW; }
\|\| { return OP_BOOL_OR; }
\&\& { return OP_BOOL_AND; }
\^\^ { return OP_BOOL_XOR; }
\>\> { return OP_INT_RIGHT; }
\<\< { return OP_INT_LEFT; }
\=\= { return OP_INT_EQUAL; }
\!\= { return OP_INT_NOTEQUAL; }
\<\= { return OP_INT_LESSEQUAL; }
s\/ { return OP_INT_SDIV; }
s\% { return OP_INT_SREM; }
s\>\> { return OP_INT_SRIGHT; }
s\< { return OP_INT_SLESS; }
s\<\= { return OP_INT_SLESSEQUAL; }
f\+ { return OP_FLOAT_ADD; }
f\- { return OP_FLOAT_SUB; }
f\* { return OP_FLOAT_MULT; }
f\/ { return OP_FLOAT_DIV; }
f\=\= { return OP_FLOAT_EQUAL; }
f\!\= { return OP_FLOAT_NOTEQUAL; }
f\< { return OP_FLOAT_LESS; }
f\<\= { return OP_FLOAT_LESSEQUAL; }
ZEXT { return OP_INT_ZEXT; }
CARRY { return OP_INT_CARRY; }
SEXT { return OP_INT_SEXT; }
SCARRY { return OP_INT_SCARRY; }
SBORROW { return OP_INT_SBORROW; }
NAN { return OP_FLOAT_NAN; }
ABS { return OP_FLOAT_ABS; }
SQRT { return OP_FLOAT_SQRT; }
CEIL { return OP_FLOAT_CEIL; }
FLOOR { return OP_FLOAT_FLOOR; }
ROUND { return OP_FLOAT_ROUND; }
INT2FLOAT { return OP_FLOAT_INT2FLOAT; }
FLOAT2FLOAT { return OP_FLOAT_FLOAT2FLOAT; }
TRUNC { return OP_FLOAT_TRUNC; }
GOTO { return OP_BRANCH; }
GOTOIND { return OP_BRANCHIND; }
CALL { return OP_CALL; }
CALLIND { return OP_CALLIND; }
RETURN { return OP_RETURN; }
CBRRANCH { return OP_CBRANCH; }
USEROP { return OP_CALLOTHER; }
LOAD { return OP_LOAD; }
STORE { return OP_STORE; }
CONCAT { return OP_PIECE; }
SUBPIECE { return OP_SUBPIECE; }
\+ { return OP_INT_ADD; }
\- { return OP_INT_SUB; }
\! { return OP_BOOL_NEGATE; }
\& { return OP_INT_AND; }
\| { return OP_INT_OR; }
\^ { return OP_INT_XOR; }
\* { return OP_INT_MULT; }
\/ { return OP_INT_DIV; }
\% { return OP_INT_REM; }
\~ { return OP_INT_NEGATE; }
\< { return OP_INT_LESS; }
o[a-zA-Z0-9_]+ { return find_op_identifier(); }
v[a-zA-Z0-9_]+ { return find_var_identifier(); }
#[a-zA-Z0-9_]+ { return find_const_identifier(); }
*/
| 26.183976
| 124
| 0.624169
|
fjqisba
|
7d1b701c9c52c0c08dbe982a77322b9a4b100356
| 263
|
cpp
|
C++
|
include-engine/utility.cpp
|
sgorsten/include-engine
|
67af882e24beba73ad44621397993e1b6818cf5b
|
[
"Unlicense"
] | 47
|
2017-03-27T12:37:02.000Z
|
2021-05-31T12:34:01.000Z
|
include-engine/utility.cpp
|
sgorsten/include-engine
|
67af882e24beba73ad44621397993e1b6818cf5b
|
[
"Unlicense"
] | 3
|
2017-03-27T12:46:28.000Z
|
2018-03-24T16:05:05.000Z
|
include-engine/utility.cpp
|
sgorsten/include-engine
|
67af882e24beba73ad44621397993e1b6818cf5b
|
[
"Unlicense"
] | 4
|
2017-09-05T11:22:40.000Z
|
2020-05-07T13:17:31.000Z
|
#include "utility.h"
/////////////////
// fail_fast() //
/////////////////
#include <Windows.h>
#include <iostream>
void fail_fast()
{
if(IsDebuggerPresent()) DebugBreak();
std::cerr << "fail_fast() called." << std::endl;
std::exit(EXIT_FAILURE);
}
| 17.533333
| 52
| 0.547529
|
sgorsten
|
7d20aaa9218edb194a674a4700ca96d0bde3c7d5
| 1,120
|
cpp
|
C++
|
source/problem0003.cpp
|
quisseh/project-euler-solutions
|
68a7d0c1c6cff7a80d6afca7f3542715ee4339eb
|
[
"MIT"
] | 1
|
2015-12-19T03:48:46.000Z
|
2015-12-19T03:48:46.000Z
|
source/problem0003.cpp
|
quisseh/project-euler-solutions
|
68a7d0c1c6cff7a80d6afca7f3542715ee4339eb
|
[
"MIT"
] | null | null | null |
source/problem0003.cpp
|
quisseh/project-euler-solutions
|
68a7d0c1c6cff7a80d6afca7f3542715ee4339eb
|
[
"MIT"
] | null | null | null |
/*
* Largest prime factor
*
* Problem 3
*
* Created by quisseh on 11/2/15.
*/
#include "problem0003.h"
/*
* A number will have at most one prime factor
* greater than its square root. So loop through
* potential prime factors of [target], and
* if one is found, reduce [target] by the current
* [factor]. If [factor] exceeds the square root of
* [target], then it is the largest prime factor.
*/
void problem0003::run() {
long target = m_target;
long factor = 2; /* Start with the smallest prime numbers. */
long lastFactor = 1;
long topFactor = (long) sqrt(target);
while (target > 0 && factor <= topFactor) {
while (target % factor == 0) { /* If [factor] is a factor of [target], */
target /= factor; /* reduce [target] by [factor]. */
lastFactor = factor;
topFactor = (long) sqrt(target); /* Get the new square root of the updated [target]. */
}
factor += factor == 2 ? 1 : 2; /* Increment [factor] by 2 once it reaches 3 so only odd numbers are checked. */
}
std::cout << ((target == 1) ? lastFactor : target);
}
| 32.941176
| 119
| 0.608036
|
quisseh
|
7d277e232f3c927894e50b38bf10455e88f25aac
| 14
|
hpp
|
C++
|
src/arrays.hpp
|
radio-rogal/c-pointers
|
a4036d0b8ee982f924463dd2fa79afcca7da9d72
|
[
"Apache-2.0"
] | null | null | null |
src/arrays.hpp
|
radio-rogal/c-pointers
|
a4036d0b8ee982f924463dd2fa79afcca7da9d72
|
[
"Apache-2.0"
] | null | null | null |
src/arrays.hpp
|
radio-rogal/c-pointers
|
a4036d0b8ee982f924463dd2fa79afcca7da9d72
|
[
"Apache-2.0"
] | null | null | null |
void arrays();
| 14
| 14
| 0.714286
|
radio-rogal
|
7d3060c0d0ec2fa7ab587beb1e24987212f8d78a
| 2,625
|
cpp
|
C++
|
Chapter10/testBSPDE1.cpp
|
alamlam1982/fincpp
|
470469d35d90fc0fde96f119e329aedbc5f68f89
|
[
"CECILL-B"
] | null | null | null |
Chapter10/testBSPDE1.cpp
|
alamlam1982/fincpp
|
470469d35d90fc0fde96f119e329aedbc5f68f89
|
[
"CECILL-B"
] | null | null | null |
Chapter10/testBSPDE1.cpp
|
alamlam1982/fincpp
|
470469d35d90fc0fde96f119e329aedbc5f68f89
|
[
"CECILL-B"
] | null | null | null |
// testBSPDE1.cpp
//
// Testing 1 factor BS model.
//
// (C) Datasim Education BV 2005
//
#include "fdmdirector.cpp"
#include "arraymechanisms.cpp"
#include <iostream>
#include <string>
using namespace std;
#include "exceldriver.cpp"
void printOneExcel(Vector<double, long> & x,
Vector<double, long>& functionResult,
string& title)
{
// N.B. Excel has a limit of 8 charts; after that you get a run-time error
cout << "Starting Excel\n";
ExcelDriver & excel = ExcelDriver::Instance();
excel.MakeVisible(true); // Default is INVISIBLE!
excel.CreateChart(x, functionResult, title, "X", "Y");
}
// Excel output as well
void printInExcel(const Vector<double, long>& x, // X array
const list<string>& labels, // Names of each vector
const list<Vector<double, long> >& functionResult) // The list of Y values
{ // Print a list of Vectors in Excel. Each vector is the output of
// a finite difference scheme for a scalar IVP
cout << "Starting Excel\n";
ExcelDriver & excel = ExcelDriver::Instance();
excel.MakeVisible(true); // Default is INVISIBLE!
// Don't make the string names too long!!
excel.CreateChart(x, labels, functionResult, string("FDM Scalar IVP"),
string("Time Axis"), string ("Value"));
}
double mySigma (double x, double t)
{
double sigmaS = 0.30 * 0.30;
return 0.5 * sigmaS * x * x;
}
double myMu (double x, double t)
{
double r = 0.06;
double D = 0.00;
return (r - D) * x;
}
double myB (double x, double t)
{
double r = 0.06;
return -r;
}
double myF (double x, double t)
{
return 0.0;
}
double myBCL (double t)
{
//return 0.0; // C
double K = 10;
double r = 0.06;
double T = 1.0;
return K * ::exp(-r * (T - t));
}
double myBCR (double t)
{
double Smax = 100;
// return Smax;
return 0.0; // P
}
double myIC (double x)
{
double K = 10;
if (x < K)
return -(x - K);
return 0.0;
}
int main()
{
using namespace BlackScholesOneFactorIBVP;
// Assignment of functions
sigma = mySigma;
mu = myMu;
b = myB;
f = myF;
BCL = myBCL;
BCR = myBCR;
IC = myIC;
double T = 1.0; int J= 200; int N = 4000-1;
double Smax = 100.0;
FDMDirector fdir(Smax, T, J, N);
fdir.Start();
L1:
fdir.doit();
// print(fdir.current());
if (fdir.isDone() == false)
goto L1;
Vector<double, long> xresult(J+1, 1);
xresult[xresult.MinIndex()] = 0.0;
double h = Smax / (double) (J);
for (long j = xresult.MinIndex()+1; j <= xresult.MaxIndex(); j++)
{
xresult[j] = xresult[j-1] + h;
}
print (xresult);
//print(fdir.current());
printOneExcel(xresult, fdir.current(), string("Value"));
return 0;
}
| 16.719745
| 79
| 0.629333
|
alamlam1982
|
7d3e7c50c315d62a9e01aa1befec07345b2ea650
| 140
|
cpp
|
C++
|
module8/quiz.cpp
|
canmenzo/CppExamples
|
e569edbedeb9ac1afec7b33602ce32014cbe2b05
|
[
"MIT"
] | null | null | null |
module8/quiz.cpp
|
canmenzo/CppExamples
|
e569edbedeb9ac1afec7b33602ce32014cbe2b05
|
[
"MIT"
] | null | null | null |
module8/quiz.cpp
|
canmenzo/CppExamples
|
e569edbedeb9ac1afec7b33602ce32014cbe2b05
|
[
"MIT"
] | null | null | null |
//quiz.cpp
#include <iostream>
using namespace std;
int main()
{
char c = 'x';
char *pC = &c;
cout << ++(*pC) << endl;
}
| 11.666667
| 26
| 0.492857
|
canmenzo
|
7d44240b68e343d7452b77f8ac30aafaa0bddca4
| 494
|
cpp
|
C++
|
flame/toSystem.cpp
|
ChaosKit/ChaosKit
|
e7cba03db1ae34160868656ea357c7166ae1d84a
|
[
"Apache-2.0"
] | 3
|
2021-01-09T17:25:18.000Z
|
2021-07-11T00:04:22.000Z
|
flame/toSystem.cpp
|
ChaosKit/ChaosKit
|
e7cba03db1ae34160868656ea357c7166ae1d84a
|
[
"Apache-2.0"
] | 1
|
2021-03-21T13:17:04.000Z
|
2021-03-21T14:03:46.000Z
|
flame/toSystem.cpp
|
ChaosKit/ChaosKit
|
e7cba03db1ae34160868656ea357c7166ae1d84a
|
[
"Apache-2.0"
] | 1
|
2020-04-03T16:32:53.000Z
|
2020-04-03T16:32:53.000Z
|
#include "toSystem.h"
namespace chaoskit::flame {
core::TransformSystem toTransformSystem(const System& system) {
return {toTransform(system), toParams(system)};
}
core::CameraSystem toCameraSystem(const System& system) {
core::CameraSystem result{toTransformSystem(system)};
auto cameraTransform = toCameraTransform(system);
if (cameraTransform) {
result.camera = {*std::move(cameraTransform), *toCameraParams(system)};
}
return result;
}
} // namespace chaoskit::flame
| 23.52381
| 75
| 0.742915
|
ChaosKit
|
7d472d0cf518b331645510c063203095f8a14064
| 1,544
|
cpp
|
C++
|
TP1/ex7.cpp
|
biromiro/feup-cal
|
d0fe01603e13729a5b91ca2758d8db5aafd2a13c
|
[
"MIT"
] | null | null | null |
TP1/ex7.cpp
|
biromiro/feup-cal
|
d0fe01603e13729a5b91ca2758d8db5aafd2a13c
|
[
"MIT"
] | null | null | null |
TP1/ex7.cpp
|
biromiro/feup-cal
|
d0fe01603e13729a5b91ca2758d8db5aafd2a13c
|
[
"MIT"
] | 2
|
2021-04-11T17:31:16.000Z
|
2021-04-27T14:04:44.000Z
|
#include "exercises.h"
#include <algorithm>
#include <vector>
#include <numeric>
double minimumAverageCompletionTime(std::vector<unsigned int> tasks, std::vector<unsigned int> &orderedTasks) {
sort(tasks.begin(), tasks.end());
/* What they want you to do
do {
permutations.push_back(tasks);
} while (std::next_permutation(tasks.begin(), tasks.end()));
double bestAverage = 99999;
for (const auto &elem: permutations) {
double average = 0;
for (size_t i = 1; i <= elem.size(); i++) {
average += std::accumulate(elem.begin(), elem.begin() + i, 0);
}
average /= elem.size();
if (bestAverage > average) {
bestAverage = average;
orderedTasks = elem;
}
}
*/
//What you can do (the exercise is just stupid, the best solution will always be the sorted vector)
double bestAverage = 0.0;
orderedTasks = tasks;
for (size_t i = 1; i <= tasks.size(); i++) {
bestAverage += std::accumulate(tasks.begin(), tasks.begin() + i, 0);
}
return bestAverage / tasks.size();
}
/// TESTS ///
#include <gtest/gtest.h>
#include <gmock/gmock.h>
TEST(TP1_Ex7, taskOrdering) {
std::vector<unsigned int> tasks = {15, 8, 3, 10};
std::vector<unsigned int> orderedTasks;
double averageTime = minimumAverageCompletionTime(tasks, orderedTasks);
EXPECT_EQ(orderedTasks.size(), 4 );
ASSERT_NEAR(averageTime, 17.75, 0.00001);
ASSERT_THAT(orderedTasks, ::testing::ElementsAre(3,8,10,15));
}
| 28.072727
| 111
| 0.619819
|
biromiro
|
7d489a715ea88a71eb316a2f9d76283ec7a3169a
| 67,258
|
cpp
|
C++
|
Visualization/JuceLibraryCode/BinaryData.cpp
|
opendragon/Core_MPlusM
|
c82bb00761551a86abe50c86e0df1f247704c848
|
[
"BSD-3-Clause"
] | null | null | null |
Visualization/JuceLibraryCode/BinaryData.cpp
|
opendragon/Core_MPlusM
|
c82bb00761551a86abe50c86e0df1f247704c848
|
[
"BSD-3-Clause"
] | null | null | null |
Visualization/JuceLibraryCode/BinaryData.cpp
|
opendragon/Core_MPlusM
|
c82bb00761551a86abe50c86e0df1f247704c848
|
[
"BSD-3-Clause"
] | null | null | null |
/* ==================================== JUCER_BINARY_RESOURCE ====================================
This is an auto-generated file: Any edits you make may be overwritten!
*/
namespace BinaryData
{
//================== PDOicon.ico ==================
static const unsigned char temp_binary_data_0[] =
{ 0,0,1,0,4,0,16,16,0,0,1,0,32,0,40,5,0,0,70,0,0,0,32,32,0,0,1,0,32,0,40,20,0,0,110,5,0,0,48,48,0,0,1,0,32,0,40,45,0,0,150,25,0,0,0,0,0,0,1,0,32,0,90,29,0,0,190,70,0,0,40,0,0,0,16,0,0,0,32,0,0,0,1,0,32,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,145,36,7,0,154,0,28,0,127,0,2,0,156,0,26,0,141,0,9,0,135,0,17,0,145,12,21,0,147,13,19,0,150,11,22,0,
145,36,7,0,148,0,31,0,85,0,3,0,158,0,29,0,127,0,10,0,0,0,0,0,0,0,0,0,154,5,48,1,162,0,190,14,141,0,18,1,159,1,179,4,153,0,63,0,153,0,116,1,152,0,142,0,154,0,122,1,157,0,136,0,144,11,44,1,154,1,198,14,141,0,18,1,159,1,185,4,152,4,62,0,0,0,0,0,0,0,0,0,
147,0,52,1,161,1,202,15,111,0,16,1,156,0,191,3,156,0,70,0,156,0,39,0,153,0,53,0,153,0,45,0,151,0,47,0,148,5,48,1,154,0,208,17,119,0,15,1,158,1,196,3,150,0,66,0,0,0,0,0,0,0,0,0,153,0,50,1,160,0,223,0,144,0,53,0,158,0,208,2,157,0,110,0,156,2,101,2,154,
2,101,0,154,0,86,1,158,0,130,0,152,0,77,1,156,0,232,0,153,0,58,1,159,1,208,3,151,0,64,0,0,0,0,0,0,0,0,0,151,0,37,1,159,1,166,1,153,0,164,1,158,0,175,1,153,1,141,0,157,0,197,3,153,0,68,0,154,0,94,1,156,0,168,1,157,0,178,1,156,0,147,1,154,0,163,1,158,0,
167,14,155,0,18,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,127,0,4,0,0,0,1,0,0,0,0,0,127,0,6,0,0,0,0,0,0,0,1,0,0,0,0,0,153,0,5,0,0,0,0,0,170,0,3,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,0,0,0,32,0,0,0,64,0,0,0,1,0,32,0,0,0,0,0,0,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,151,5,47,0,158,
0,77,0,155,0,36,0,0,0,0,0,0,0,1,0,153,0,58,0,154,0,76,0,148,0,24,0,0,0,0,0,127,31,8,0,151,0,69,0,155,0,72,0,139,0,11,0,127,0,2,0,153,0,68,0,158,0,79,0,147,0,19,0,0,0,0,0,127,0,12,0,155,0,77,3,153,0,73,28,141,0,9,0,0,0,0,0,153,0,25,0,158,0,82,4,153,0,
63,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,157,9,162,1,170,1,255,4,155,0,126,0,0,0,0,0,85,85,3,0,155,3,203,2,165,0,255,9,156,0,83,0,0,0,0,0,140,17,29,0,157,2,239,1,157,0,248,6,154,0,38,0,95,31,8,0,156,2,221,2,163,1,255,7,155,0,64,0,0,0,0,0,
147,20,38,0,156,0,250,2,159,0,237,16,148,0,31,0,0,0,0,0,157,9,81,2,165,3,255,2,156,0,205,63,127,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,155,3,162,2,166,2,255,4,155,0,125,0,0,0,0,0,127,127,2,0,154,3,202,2,163,1,255,9,155,0,82,0,0,0,0,0,149,17,29,
0,155,0,249,2,158,0,255,6,146,0,40,0,109,36,7,0,156,2,227,2,164,3,255,3,150,0,66,0,0,0,0,0,151,20,37,0,155,0,248,2,156,0,236,17,144,0,30,0,0,0,0,0,156,15,80,2,163,1,255,2,153,0,203,63,127,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156,3,161,2,166,
2,255,4,155,0,125,0,0,0,0,0,127,127,2,0,154,3,201,2,163,1,255,9,155,0,82,0,0,0,0,0,135,30,17,0,153,1,143,1,155,0,149,0,144,11,23,0,127,63,4,0,155,0,131,1,156,1,153,6,151,0,37,0,0,0,0,0,151,20,37,0,155,0,247,2,156,0,235,17,144,0,30,0,0,0,0,0,156,15,80,
2,163,1,255,2,154,0,202,63,127,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156,3,161,2,166,2,255,4,155,0,125,0,0,0,0,0,127,127,2,0,154,3,201,2,163,1,255,3,155,0,82,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,151,
20,37,0,155,0,247,2,156,0,235,17,144,0,30,0,0,0,0,0,156,15,80,2,163,1,255,2,154,0,202,63,127,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156,3,161,1,167,2,255,3,155,0,133,0,0,0,0,0,0,255,1,1,156,3,201,2,164,1,255,8,156,0,91,0,0,0,0,0,139,0,11,2,153,
0,103,4,154,0,107,15,135,0,17,0,85,0,3,2,154,0,94,4,156,2,111,17,153,0,30,0,0,0,0,0,155,21,36,1,155,0,248,1,158,0,240,14,155,0,36,0,0,0,0,0,156,9,80,2,163,1,255,2,154,0,202,63,127,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156,3,161,2,164,0,255,2,
157,2,197,31,143,0,16,0,153,12,20,1,156,0,223,2,164,1,255,3,155,0,167,42,127,0,6,4,156,8,57,1,159,1,254,1,156,0,252,15,150,0,34,0,127,31,8,0,156,2,223,1,167,2,255,3,155,0,146,0,109,0,7,3,150,7,71,1,156,0,253,2,161,2,255,4,153,0,111,0,127,0,6,2,156,6,
119,2,164,0,255,3,155,0,197,255,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,156,4,166,2,165,0,255,2,157,2,239,1,158,0,215,1,158,0,209,2,162,2,255,1,156,3,241,1,157,0,230,1,161,0,207,1,158,0,224,2,165,3,255,2,155,2,203,31,127,0,8,0,127,0,10,0,157,
2,225,2,160,2,255,1,156,0,236,1,160,0,208,1,157,0,231,2,163,1,255,1,158,0,222,1,156,0,234,1,160,0,205,1,156,0,245,2,166,0,255,3,155,0,138,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,157,0,110,1,164,0,175,3,155,0,77,1,158,1,140,1,159,1,214,1,160,
1,191,0,156,3,75,0,154,11,43,1,161,1,175,1,158,0,217,1,158,0,175,5,154,0,48,0,0,0,0,0,127,0,8,1,158,0,143,1,158,0,154,4,153,0,63,1,158,0,167,1,158,0,209,1,159,1,165,14,153,0,35,0,153,6,73,1,161,1,188,1,159,0,205,3,157,0,141,14,155,0,18,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,6,0,85,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,145,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,4,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,0,0,0,48,0,0,0,96,0,0,0,1,0,32,0,0,0,0,0,0,45,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,144,11,23,0,153,0,120,0,155,0,121,2,153,0,115,0,127,0,14,0,0,0,0,0,0,0,0,0,0,0,2,0,151,5,99,0,155,0,121,0,155,0,121,5,144,0,44,0,0,0,0,0,0,0,0,0,0,0,0,0,150,7,71,0,158,0,121,0,158,0,121,6,149,0,75,0,0,0,0,0,0,0,0,0,144,
0,46,0,158,0,132,0,156,0,132,2,153,0,110,0,85,0,3,0,0,0,0,0,0,0,0,0,127,0,14,0,152,0,124,0,156,0,132,1,153,0,131,19,137,0,26,0,0,0,0,0,0,0,0,0,0,0,1,0,150,5,100,0,158,0,132,0,160,0,132,4,149,0,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,145,20,51,2,161,5,255,2,165,3,255,2,155,0,252,16,148,0,31,0,0,0,0,0,0,0,0,0,63,63,4,0,153,6,219,2,166,2,255,3,168,2,255,10,148,0,96,0,0,0,0,0,0,0,0,0,0,0,0,0,153,6,155,2,169,2,255,2,169,2,255,4,154,0,165,0,0,0,0,0,0,0,0,0,149,2,92,2,168,5,
255,2,166,2,255,2,153,0,222,42,85,0,6,0,0,0,0,0,0,0,0,0,140,17,29,0,154,1,250,2,165,3,255,4,161,2,255,14,137,0,52,0,0,0,0,0,0,0,0,0,0,127,2,0,154,3,201,2,168,2,255,2,169,2,255,6,152,0,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,145,5,49,0,153,1,253,2,158,0,255,2,154,0,242,17,144,0,30,0,0,0,0,0,0,0,0,0,63,63,4,0,153,4,210,2,159,2,255,3,161,2,255,11,149,0,92,0,0,0,0,0,0,0,0,0,0,0,0,0,150,5,149,2,162,2,255,2,162,2,255,4,153,1,158,0,0,0,0,0,0,0,0,0,147,5,88,2,161,5,255,2,159,
2,255,3,152,0,213,42,85,0,6,0,0,0,0,0,0,0,0,0,136,18,28,0,153,1,240,2,158,0,255,2,153,0,253,15,142,0,50,0,0,0,0,0,0,0,0,0,0,127,2,0,151,1,193,2,161,2,255,2,162,2,255,9,152,0,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,145,5,
49,0,153,1,253,2,158,0,255,2,154,0,242,17,144,0,30,0,0,0,0,0,0,0,0,0,63,63,4,0,153,4,210,2,159,2,255,3,161,2,255,11,149,0,92,0,0,0,0,0,0,0,0,0,0,0,0,0,152,8,152,2,165,3,255,2,165,3,255,4,153,1,161,0,0,0,0,0,0,0,0,0,147,2,90,2,164,4,255,2,162,2,255,3,
152,0,218,42,85,0,6,0,0,0,0,0,0,0,0,0,136,18,28,0,153,1,240,2,158,0,255,2,153,0,253,15,142,0,50,0,0,0,0,0,0,0,0,0,0,127,2,0,151,1,193,2,161,2,255,2,162,2,255,9,152,0,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,145,5,49,0,153,
1,253,2,158,0,255,2,154,0,242,17,144,0,30,0,0,0,0,0,0,0,0,0,63,63,4,0,153,4,210,2,159,2,255,3,161,2,255,11,149,0,92,0,0,0,0,0,0,0,0,0,0,0,0,2,152,4,122,1,161,1,209,1,161,1,209,9,152,1,129,0,0,0,0,0,0,0,0,0,148,7,72,1,159,1,209,1,156,0,209,4,153,1,174,
51,51,0,5,0,0,0,0,0,0,0,0,0,136,18,28,0,153,1,240,2,158,0,255,2,153,0,253,15,142,0,50,0,0,0,0,0,0,0,0,0,0,127,2,0,151,1,193,2,161,2,255,2,162,2,255,9,152,0,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,145,5,49,0,153,1,253,2,158,
0,255,2,154,0,242,17,144,0,30,0,0,0,0,0,0,0,0,0,63,63,4,0,153,4,210,2,159,2,255,3,161,2,255,11,149,0,92,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,85,0,3,0,85,0,3,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,1,0,85,0,3,0,85,0,3,0,85,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,136,18,28,0,
153,1,240,2,158,0,255,2,153,0,253,15,142,0,50,0,0,0,0,0,0,0,0,0,0,127,2,0,151,1,193,2,161,2,255,2,162,2,255,9,152,0,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,145,5,49,0,153,1,253,2,158,0,255,2,154,0,242,17,144,0,30,0,0,0,0,
0,0,0,0,0,63,63,4,0,153,4,210,2,159,2,255,3,162,2,255,8,153,0,93,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,18,28,0,153,1,240,2,158,0,255,2,155,0,254,15,145,0,
51,0,0,0,0,0,0,0,0,0,0,127,2,0,151,1,193,2,161,2,255,2,162,2,255,9,152,0,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,145,5,49,0,153,1,253,2,158,0,255,2,154,1,246,21,145,0,35,0,0,0,0,0,0,0,0,0,63,63,4,0,153,1,211,2,159,2,255,
2,162,2,255,7,152,5,102,0,0,0,0,0,0,0,0,0,0,0,0,0,139,11,22,0,154,0,38,0,154,0,38,0,144,0,23,0,0,0,0,0,0,0,0,0,137,0,13,0,147,6,38,0,151,0,37,0,146,0,33,0,0,0,1,0,0,0,0,0,0,0,0,0,145,18,28,0,154,1,240,2,158,0,255,4,157,0,255,12,151,0,59,0,0,0,0,0,0,0,
0,0,0,0,1,0,152,1,194,2,160,2,255,2,162,2,255,9,152,0,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,145,5,49,0,153,1,253,2,157,0,255,1,157,0,254,12,151,0,59,0,0,0,0,0,0,0,0,0,127,42,6,1,153,4,217,2,159,2,255,2,163,1,255,9,153,
0,138,0,0,0,0,0,0,0,0,0,0,0,0,1,153,6,154,1,161,1,247,1,161,1,247,6,153,5,153,0,0,0,0,0,0,0,0,3,147,9,85,1,160,1,247,1,156,0,247,3,154,0,232,20,142,0,25,0,0,0,0,0,0,0,0,0,146,7,33,1,154,1,246,2,157,0,255,3,161,2,255,5,151,0,94,0,0,0,0,0,0,0,0,0,0,0,1,
1,151,5,203,2,160,2,255,2,162,2,255,9,152,0,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,145,5,49,0,153,1,253,2,157,0,255,2,161,2,255,4,153,0,164,0,63,0,4,0,0,0,0,0,151,20,37,0,155,0,242,2,157,0,255,2,159,2,255,2,154,0,223,15,
143,0,32,0,0,0,0,0,102,51,5,0,154,1,206,2,161,2,255,2,164,1,255,6,152,0,147,0,0,0,0,0,0,0,0,0,147,5,88,2,162,5,255,2,157,0,255,2,161,2,255,5,154,1,130,255,0,0,1,0,0,0,0,0,151,9,81,0,159,0,254,2,156,1,255,2,160,2,255,3,153,0,198,14,155,0,18,0,0,0,0,0,
146,30,33,0,154,1,236,2,157,0,255,3,162,2,255,10,151,0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,145,5,49,0,153,1,253,2,157,0,255,2,156,1,255,2,162,2,255,3,153,0,196,1,151,0,148,0,154,1,211,2,159,2,255,2,156,1,255,2,158,0,255,
2,162,2,255,1,155,0,225,1,153,0,151,0,153,0,189,2,158,0,255,2,156,1,255,3,163,1,255,7,150,0,98,0,0,0,0,0,0,0,0,0,147,5,88,2,161,5,255,2,156,1,255,3,156,4,255,3,160,2,255,2,153,0,189,1,153,1,161,0,153,1,233,2,158,0,255,2,157,0,255,3,157,3,255,2,162,2,
255,1,155,0,216,1,154,0,160,0,153,1,215,2,158,0,255,2,157,0,255,2,156,0,254,14,147,0,52,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,145,20,51,2,160,6,255,2,166,2,255,5,155,0,216,3,153,1,168,2,167,2,255,2,167,2,255,2,162,2,255,2,
160,2,255,2,164,1,255,3,152,0,149,3,153,7,131,2,162,5,255,2,168,2,255,2,163,1,255,2,160,2,255,2,165,3,255,3,153,1,199,17,136,0,15,0,0,0,0,0,0,0,0,0,149,2,92,2,168,5,255,2,167,2,255,5,155,2,185,0,154,1,183,2,168,2,255,2,167,2,255,2,161,2,255,2,162,2,255,
1,158,0,254,9,149,0,109,1,153,1,154,2,165,3,255,2,167,2,255,2,162,2,255,2,161,2,255,2,164,1,255,4,153,1,154,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,144,17,30,1,153,1,154,1,157,0,155,6,154,0,119,0,63,0,4,2,153,2,100,0,
157,2,188,0,156,0,214,1,158,0,196,4,153,0,113,0,102,0,5,0,0,0,1,0,152,6,82,0,158,0,180,0,156,0,214,1,156,0,202,3,156,0,137,0,150,0,22,0,0,0,0,0,0,0,0,0,0,0,0,0,147,5,50,1,159,0,144,1,161,0,144,3,154,0,84,0,127,0,8,2,153,4,111,0,155,0,188,0,156,0,205,
1,157,0,176,3,151,0,79,0,0,0,0,0,0,0,2,0,151,0,94,1,156,0,181,0,156,0,205,2,157,0,185,4,153,0,106,0,127,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,6,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,6,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,1,0,0,0,1,0,8,6,0,0,0,92,114,
168,102,0,0,0,1,115,82,71,66,0,174,206,28,233,0,0,29,20,73,68,65,84,120,1,237,221,11,124,21,213,157,7,240,115,102,238,220,103,114,115,3,33,33,144,240,136,81,20,16,20,148,181,128,149,186,213,138,173,186,171,27,124,180,86,219,186,90,45,214,23,85,171,221,
221,208,79,235,123,165,64,17,80,91,93,235,174,214,104,125,176,104,125,84,176,162,86,1,121,40,85,121,9,129,64,222,239,251,156,199,217,115,38,92,26,66,66,114,103,230,222,220,116,127,243,249,132,203,189,153,57,243,159,239,57,231,63,103,230,206,76,8,193,
4,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,
0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,
128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,
32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,
8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,
2,16,128,0,4,32,144,65,1,154,193,117,13,202,170,24,97,116,225,156,133,242,147,115,42,93,163,75,103,41,49,45,38,121,93,94,227,189,240,123,137,57,127,168,212,215,174,253,15,157,16,202,6,35,184,74,194,164,170,138,201,174,17,115,136,123,20,157,170,212,203,
95,24,245,237,251,181,173,213,117,90,197,82,166,85,17,98,116,197,53,56,241,13,134,73,255,235,100,221,218,172,112,17,239,179,193,135,209,74,30,8,255,225,49,37,227,201,150,216,250,86,237,134,217,247,76,67,233,55,66,255,252,123,202,11,190,8,53,76,77,200,
198,180,118,119,236,36,201,144,203,91,89,108,152,68,37,47,161,68,162,6,211,117,194,98,62,234,107,97,18,249,210,173,230,108,215,136,178,181,168,125,220,150,171,22,188,183,175,146,208,67,29,207,217,45,23,201,104,214,227,19,199,84,107,7,167,235,114,252,
244,184,100,28,223,201,212,178,4,97,185,110,162,184,53,170,25,18,99,9,141,209,120,158,228,175,139,80,163,58,168,6,118,81,67,218,154,171,143,250,228,170,249,31,167,45,54,103,183,212,126,105,194,234,107,75,74,70,87,187,58,79,140,83,114,60,239,83,229,53,
158,206,188,128,68,125,58,147,36,157,26,154,206,88,164,48,81,216,146,32,209,93,9,61,103,87,81,100,212,142,105,183,125,116,160,138,80,158,212,211,55,173,188,246,90,229,177,83,222,44,171,149,106,39,73,146,255,248,6,169,101,172,230,162,65,63,83,220,113,
170,243,182,165,71,117,141,36,10,244,145,181,81,35,82,29,32,161,221,193,104,222,142,43,110,221,124,48,93,109,203,234,214,166,53,1,220,114,75,137,239,245,73,234,229,181,84,13,41,134,148,90,167,146,120,151,164,33,35,247,224,21,85,159,221,125,207,193,254,
54,240,202,5,83,2,27,202,247,157,213,226,234,172,104,99,250,217,113,153,141,38,50,149,197,114,134,88,115,114,31,47,94,249,86,139,95,232,60,81,75,82,23,129,193,155,140,196,164,6,15,11,188,155,163,142,248,125,110,219,37,175,239,190,243,254,54,62,155,237,
233,242,149,39,20,124,204,26,206,107,86,34,23,183,18,117,182,46,145,17,68,226,113,137,88,186,255,28,170,13,51,54,137,199,70,187,62,48,155,179,65,27,101,18,252,48,79,43,120,33,167,233,164,87,191,188,251,149,58,219,129,13,160,128,27,151,148,123,94,243,
69,79,141,40,204,180,28,192,34,71,204,66,245,225,70,205,190,75,182,144,202,202,200,17,191,232,229,141,153,32,151,20,149,29,148,99,115,219,189,241,111,68,153,122,122,76,98,5,28,66,22,94,135,235,176,151,101,137,198,52,131,200,45,126,226,249,216,167,230,
173,14,24,101,171,171,111,120,119,15,175,236,212,218,93,111,101,155,171,174,148,78,95,254,196,212,58,185,225,155,45,146,122,94,130,232,147,53,153,228,153,113,29,90,70,172,72,132,121,196,196,235,151,25,76,101,134,212,236,39,222,45,138,145,247,102,94,172,
244,213,234,31,255,229,115,167,98,59,98,125,41,190,57,212,228,82,92,106,128,179,223,117,83,97,209,211,39,54,110,222,151,75,70,166,156,147,121,231,116,105,57,100,84,211,117,103,236,249,201,67,31,246,181,202,27,111,44,15,174,61,233,192,101,7,60,137,107,
90,136,62,157,184,168,36,58,179,57,8,19,157,43,133,73,12,216,36,23,227,251,15,137,200,70,206,38,79,98,220,210,188,29,119,63,187,127,209,188,104,10,197,28,158,181,226,129,17,35,255,154,215,118,245,126,89,255,65,135,204,202,13,161,157,140,237,240,92,3,
251,143,57,240,229,93,80,52,48,69,245,236,244,26,133,143,106,123,167,62,21,190,39,189,137,224,142,251,38,141,121,58,255,179,141,53,94,22,76,185,43,241,96,189,250,240,246,9,29,183,207,220,124,211,237,59,250,218,82,70,42,165,51,22,47,158,185,39,39,254,
125,62,82,187,64,85,72,129,153,28,133,149,88,104,32,245,200,103,20,179,73,50,255,151,39,78,67,147,235,21,173,232,185,220,142,9,203,155,23,188,101,185,179,49,126,232,120,218,188,7,190,81,163,36,174,171,167,198,63,18,133,248,197,14,197,180,24,72,92,34,
254,67,177,137,189,142,216,223,80,85,106,115,147,130,87,130,177,209,203,234,230,111,216,192,63,225,91,58,56,211,81,9,203,201,48,220,138,232,134,44,198,18,252,95,53,245,31,62,196,139,73,84,237,53,131,51,82,33,159,190,204,127,193,51,167,236,121,99,91,32,
182,178,73,50,78,231,93,87,18,235,73,169,114,186,109,176,25,173,202,27,15,111,125,9,185,253,212,176,255,211,223,214,78,188,254,229,162,135,207,63,153,71,111,182,197,110,179,247,249,95,86,241,156,60,117,121,224,202,53,195,90,214,126,230,213,238,109,147,
88,57,19,141,89,227,63,3,109,52,61,74,23,203,137,229,25,255,137,203,177,242,14,207,190,7,226,227,215,174,41,92,62,229,146,10,98,109,239,220,99,21,189,190,141,52,31,20,99,109,153,15,151,220,196,72,237,135,111,179,91,55,84,183,228,226,89,181,143,105,238,
146,49,19,75,86,254,242,201,77,57,173,127,170,115,197,190,199,135,251,5,102,29,38,173,250,92,178,71,129,194,135,255,48,141,154,109,141,16,173,80,245,30,152,223,28,122,239,157,188,21,19,238,152,94,89,233,239,177,196,49,223,138,209,200,153,75,134,207,40,
249,206,47,94,217,234,142,190,82,171,24,23,240,22,224,55,99,19,221,117,160,113,137,181,28,138,205,172,63,222,62,249,225,75,94,84,169,191,178,206,183,101,141,119,249,216,21,161,135,46,30,123,204,96,210,248,203,180,38,128,116,197,253,195,7,139,10,143,95,
241,218,146,205,222,216,139,141,146,241,15,150,42,165,159,224,168,206,27,146,198,136,225,110,62,167,33,248,231,63,142,122,108,214,133,188,38,251,245,186,246,190,81,99,142,63,247,187,79,125,230,137,62,213,40,27,19,14,39,164,126,214,151,202,175,41,31,74,
136,68,160,185,58,78,106,84,182,61,187,122,249,201,11,167,175,100,74,42,101,12,116,222,214,246,230,132,193,207,75,152,243,139,70,159,250,143,88,226,168,105,3,63,142,158,188,60,231,199,239,5,246,191,93,227,213,175,84,9,117,83,145,188,123,157,251,168,197,
251,253,128,242,222,42,202,35,52,94,208,225,219,121,207,199,197,143,61,119,220,178,239,149,246,187,32,159,225,65,126,56,57,249,145,192,191,109,14,52,191,89,227,50,230,106,148,74,162,243,166,212,233,143,177,34,51,153,139,216,136,225,75,4,246,95,19,9,189,
245,250,176,135,206,61,135,175,96,192,59,153,99,20,159,210,175,250,109,208,41,149,150,129,153,191,190,36,116,234,170,252,166,85,187,253,145,27,120,157,200,233,30,60,49,49,34,144,195,163,26,164,245,79,143,88,122,222,85,188,146,250,56,22,102,244,188,135,
242,103,175,46,168,95,189,219,147,184,66,229,13,57,221,177,153,73,138,50,87,196,247,217,221,187,61,37,139,175,126,226,9,111,6,170,192,246,42,42,126,81,50,122,222,140,39,158,218,238,141,44,110,39,164,200,236,168,14,117,252,158,193,137,68,32,146,48,243,
29,248,102,157,103,213,203,99,23,221,124,82,207,121,186,191,191,226,222,162,178,101,19,62,127,110,135,63,182,176,131,208,160,147,29,191,251,122,196,255,205,17,11,79,173,9,87,199,132,182,208,186,170,81,143,77,159,87,57,128,157,76,207,114,236,188,31,82,
9,96,238,131,242,5,235,3,29,175,240,172,60,195,220,39,165,169,209,244,4,21,29,77,165,90,78,131,239,207,191,30,255,232,89,151,244,204,212,162,175,127,237,215,197,21,235,134,181,189,88,35,27,147,51,25,155,57,188,212,25,105,161,7,175,127,41,113,239,67,100,
122,122,70,2,61,77,172,190,255,206,125,161,169,239,140,172,91,181,71,209,47,19,7,119,78,237,241,251,139,135,38,40,233,116,53,157,122,32,240,236,243,211,150,221,80,222,219,252,115,151,140,59,227,141,194,166,213,123,20,245,124,53,121,8,210,219,140,14,127,
70,249,97,139,46,69,243,26,148,45,143,255,246,145,153,71,181,47,135,87,119,68,113,217,159,0,36,126,58,156,79,179,238,147,231,125,148,111,252,55,63,158,46,49,179,242,17,155,145,254,55,98,216,77,164,152,255,75,233,227,101,69,15,94,62,35,185,70,30,156,52,
247,65,242,253,77,190,186,39,59,9,41,72,247,94,63,185,222,35,94,69,6,226,135,43,173,238,47,127,148,119,245,172,91,120,130,202,202,122,189,168,210,55,115,77,126,219,43,245,46,253,84,177,87,118,106,72,125,132,197,49,222,152,29,205,83,55,241,115,229,165,
39,74,42,31,30,214,125,214,75,31,32,231,110,242,85,255,129,31,82,158,40,230,203,244,36,218,151,106,24,57,213,238,79,31,13,61,116,201,153,153,90,127,86,54,148,238,27,31,72,228,199,207,127,128,124,235,243,2,227,241,38,153,230,14,74,7,59,20,144,168,36,201,
21,46,104,10,173,91,82,182,242,185,60,209,239,206,95,20,188,252,131,124,250,235,86,74,125,41,159,37,239,190,161,118,255,47,14,31,13,141,116,122,183,222,85,250,240,15,166,217,45,206,201,229,101,18,138,95,250,115,114,250,134,81,177,223,215,120,232,152,
193,72,224,201,237,17,135,116,49,79,237,236,230,145,79,252,124,14,97,46,241,249,229,247,122,207,94,151,79,158,174,117,145,226,193,111,95,157,161,104,238,95,22,141,185,247,145,252,100,204,233,124,205,238,4,192,168,26,12,172,251,250,250,124,250,216,96,
119,254,100,37,136,179,204,154,114,112,70,189,246,171,155,231,174,56,225,236,117,161,240,210,54,137,122,7,181,243,31,10,78,28,239,234,74,56,175,193,255,238,194,73,21,204,157,140,121,48,95,117,201,149,40,78,188,61,229,253,17,228,127,106,220,116,80,70,
111,61,183,223,224,163,165,136,178,243,218,45,139,42,206,169,88,122,226,201,111,23,170,79,214,184,164,17,131,217,249,147,49,138,246,165,122,106,167,53,6,159,190,41,19,35,185,62,78,104,37,195,177,247,58,103,102,78,96,211,176,240,191,182,185,104,40,245,
99,61,126,22,151,168,174,102,121,239,217,45,178,17,50,135,224,246,194,113,110,105,198,136,46,31,156,86,79,155,47,110,167,198,176,108,138,77,56,107,82,251,120,54,114,253,134,200,31,183,111,183,187,209,83,79,35,129,157,69,228,250,136,66,115,82,173,67,113,
29,19,53,116,169,222,179,251,236,58,37,49,94,156,75,201,134,73,180,44,34,105,178,172,212,78,171,149,234,254,165,78,49,202,179,161,243,39,109,248,87,144,68,163,29,19,61,51,14,190,164,175,249,176,57,249,121,58,94,179,122,4,192,207,17,201,157,178,230,17,
123,182,108,154,68,60,6,213,131,252,124,196,240,108,234,252,166,145,176,114,105,174,86,255,39,243,167,15,246,9,65,30,11,165,170,175,153,182,151,102,155,147,136,39,44,181,156,84,171,104,19,7,243,144,164,183,118,45,98,99,158,246,66,87,193,186,107,210,61,
10,200,234,4,112,184,65,247,166,212,227,51,209,238,197,17,29,229,223,134,83,241,154,252,225,239,197,231,226,247,142,78,162,113,243,189,237,64,39,198,207,101,30,142,141,143,187,146,241,153,177,57,93,11,252,66,21,157,212,157,217,116,233,143,38,13,52,190,
116,205,39,174,153,25,112,2,23,117,200,45,76,19,81,143,162,238,146,245,231,180,209,161,184,82,58,116,19,241,241,186,59,220,206,186,199,230,116,251,226,223,236,36,228,234,138,227,42,31,42,72,87,221,136,114,121,215,24,218,19,19,151,126,138,33,157,46,213,
249,53,207,70,126,129,253,150,124,150,191,175,73,110,234,204,35,185,10,53,194,37,252,166,160,73,81,22,159,25,151,105,137,121,25,103,10,29,215,174,142,104,44,50,31,250,82,67,249,194,173,121,62,240,51,255,167,113,89,109,164,252,2,73,191,238,42,140,73,241,
83,162,114,98,150,42,147,113,78,197,38,58,28,117,39,252,109,254,77,231,240,248,55,219,221,134,180,47,207,51,41,117,241,152,53,202,24,147,246,42,186,180,51,96,248,106,162,180,35,28,36,126,111,140,196,75,98,84,43,231,140,101,26,79,4,153,30,174,139,164,
36,241,31,126,52,19,86,24,253,34,87,207,221,149,96,225,38,225,226,165,210,168,118,170,158,168,49,189,220,224,151,161,59,53,154,16,59,23,93,110,29,215,22,90,35,190,113,250,223,116,213,193,208,77,0,162,209,200,148,200,106,238,231,10,191,46,190,184,101,
220,11,223,189,243,205,253,149,188,171,69,72,215,125,39,49,18,51,221,196,101,157,231,223,95,50,122,103,126,219,117,251,165,240,205,81,137,31,207,246,122,129,177,115,204,93,95,196,81,226,209,188,107,130,122,225,242,49,45,231,188,177,241,206,149,237,145,
110,227,6,126,17,12,63,218,99,244,162,95,149,21,254,213,91,255,237,122,37,178,160,93,166,142,156,137,54,248,6,170,114,231,87,230,240,253,213,90,243,34,98,231,182,205,201,146,68,130,36,154,187,221,23,207,123,41,72,66,207,134,26,75,63,58,121,211,117,173,
147,170,42,88,37,231,17,53,185,176,114,33,125,157,84,133,162,197,53,95,173,165,157,183,214,43,198,153,76,212,95,186,19,57,223,175,136,219,201,168,46,127,25,136,135,158,25,22,31,251,188,254,229,248,207,175,89,244,92,92,196,198,35,32,29,252,231,156,59,
78,11,214,140,175,153,213,194,26,175,111,144,140,111,117,141,122,196,111,109,76,98,200,170,24,52,234,110,156,205,75,73,91,2,112,122,224,114,196,22,87,46,40,42,252,237,113,245,31,86,123,232,56,39,59,156,24,78,243,118,29,243,233,165,139,71,55,126,243,63,
119,222,181,164,145,87,83,191,205,65,116,182,89,75,67,23,127,18,232,248,77,7,35,121,253,47,113,196,230,12,248,141,24,149,184,13,127,45,77,28,247,243,11,223,254,217,111,170,170,230,117,93,74,219,79,9,151,221,175,156,246,65,174,246,204,94,31,181,125,82,
138,201,6,81,180,209,159,158,176,105,209,87,182,61,50,143,95,162,96,109,186,242,135,164,240,143,39,147,173,13,62,169,200,201,58,20,213,197,120,239,242,104,35,94,246,118,158,250,139,182,91,87,127,204,235,176,223,180,252,224,149,231,6,86,206,126,231,190,
47,21,117,254,225,187,41,173,109,218,49,151,50,219,152,33,199,253,90,233,227,197,225,210,251,119,221,246,206,254,254,218,152,184,7,228,180,179,174,186,105,167,55,246,203,54,202,191,25,234,183,69,30,51,4,62,42,98,196,31,41,123,125,238,178,157,23,86,109,
163,3,106,67,199,46,241,232,223,242,129,205,208,154,204,99,105,73,110,41,72,204,250,94,244,218,93,119,239,188,107,105,67,127,21,147,220,66,113,212,254,222,141,173,127,152,18,245,45,244,242,27,239,147,159,59,249,106,30,146,196,242,119,23,54,206,190,40,
126,253,150,21,3,237,252,34,134,103,239,80,55,156,213,145,251,237,17,6,171,183,125,206,130,119,37,77,15,23,199,70,109,207,200,247,201,169,24,50,222,51,248,229,245,137,225,177,201,119,79,94,121,160,162,237,214,87,197,29,113,253,118,126,177,142,159,252,
238,141,240,203,111,93,120,91,89,66,121,190,235,102,239,84,214,60,176,121,205,206,175,251,154,134,37,166,93,25,249,225,238,155,118,221,246,231,125,3,105,99,180,106,158,190,97,126,244,87,51,162,174,59,249,125,112,186,56,50,181,51,137,4,151,144,98,99,55,
126,235,45,159,157,114,142,181,236,208,74,0,34,165,50,111,172,56,50,103,126,227,245,107,126,207,43,69,140,182,82,154,68,18,88,188,37,111,101,169,42,175,239,235,170,254,148,10,236,54,115,215,94,35,183,182,52,60,231,178,253,119,188,254,209,64,26,77,183,
197,205,255,254,215,29,237,235,203,99,202,34,55,31,122,218,153,248,118,242,91,99,213,32,203,109,25,107,167,28,199,151,53,235,80,54,134,169,167,220,117,246,13,155,238,223,184,209,188,19,32,165,213,76,170,170,74,204,109,31,125,87,129,198,234,108,39,202,
30,107,22,201,73,98,238,54,127,203,236,171,155,111,248,136,63,148,41,181,54,198,251,188,241,198,147,83,30,57,62,33,191,104,187,125,137,36,238,234,40,32,227,87,21,246,8,211,177,183,67,42,1,240,83,44,36,20,153,248,224,129,27,222,124,206,74,231,74,170,157,
246,232,129,200,216,68,224,73,183,205,12,157,44,207,124,53,27,182,59,17,108,255,234,130,125,11,94,224,123,52,107,19,15,137,205,14,143,169,10,170,164,217,110,227,54,40,83,246,70,182,23,89,139,36,61,75,137,243,54,57,234,228,21,141,215,109,88,108,231,201,
61,139,111,223,189,107,116,220,253,162,228,228,89,44,209,249,197,147,32,162,103,252,123,228,246,215,87,91,21,160,27,55,170,83,59,131,143,230,240,135,148,88,45,35,185,28,31,71,4,91,107,235,134,39,223,59,253,58,100,18,128,24,90,203,90,225,167,165,53,183,
46,226,157,223,54,236,164,176,242,118,126,130,180,216,237,100,201,10,97,252,44,182,47,86,246,242,241,79,175,178,149,156,68,121,15,220,94,178,119,36,147,54,154,143,45,74,174,32,213,87,190,97,212,21,35,197,5,181,105,107,60,41,135,196,207,221,176,248,240,
29,35,171,249,77,111,54,235,80,236,105,167,104,161,231,253,170,120,210,130,51,147,216,99,123,227,227,94,45,125,103,237,10,59,59,24,17,205,140,206,49,235,71,232,174,157,93,39,131,173,197,39,246,41,84,9,43,133,69,109,121,214,74,232,127,169,33,147,0,36,
158,155,125,241,9,143,125,114,223,21,173,253,111,86,255,115,252,180,120,238,126,89,114,29,60,250,25,78,253,47,123,212,28,98,36,145,240,196,115,195,51,22,91,25,210,30,85,30,89,107,132,248,163,173,236,30,67,242,230,67,58,98,185,71,220,244,114,244,186,50,
247,9,127,38,35,241,171,19,86,236,188,247,167,252,164,173,253,105,124,75,209,23,126,74,27,28,73,226,162,14,53,119,60,24,157,242,240,182,42,251,39,220,110,174,12,117,6,117,105,155,189,246,197,131,162,148,198,104,48,109,117,56,36,18,128,121,210,72,11,213,
140,104,61,231,69,187,153,57,217,236,138,190,251,187,120,113,92,175,179,223,201,248,152,157,143,78,188,198,200,191,4,215,60,105,121,232,159,140,75,188,138,189,91,94,152,109,207,29,208,105,177,238,75,246,252,63,37,109,97,35,208,243,211,193,120,47,234,
144,37,242,107,71,182,158,39,142,171,249,190,205,254,52,108,71,164,125,88,130,52,216,235,100,93,113,152,117,168,141,250,40,231,173,23,222,183,31,153,168,195,53,122,158,33,127,118,232,145,147,22,139,228,15,164,225,27,87,221,156,8,89,44,160,223,197,134,
68,2,16,67,97,183,90,252,254,174,159,221,221,239,195,65,251,221,226,195,51,84,26,177,156,192,126,39,18,128,24,157,248,163,163,87,237,124,141,198,15,23,111,243,63,90,32,84,173,49,187,195,91,70,124,174,118,15,79,81,98,255,54,184,19,63,86,247,24,197,127,
42,117,176,14,111,220,124,106,140,120,252,252,91,32,251,147,168,195,92,173,248,121,231,234,144,50,191,63,184,211,101,59,137,243,71,157,42,29,252,154,195,244,76,67,34,1,240,19,51,196,167,143,248,128,231,85,219,199,254,73,70,74,42,141,96,123,164,206,54,
128,185,103,243,198,115,232,201,107,147,101,59,241,58,190,182,161,41,200,31,45,109,167,235,26,252,90,21,201,29,79,91,227,73,101,59,37,126,128,237,139,23,190,203,145,28,59,102,39,219,248,227,245,162,209,6,123,123,89,190,21,188,14,13,205,31,38,241,147,
222,77,101,155,250,155,215,221,208,120,192,47,90,172,229,244,203,191,201,225,231,77,188,238,246,180,221,217,105,187,253,247,135,96,251,247,162,114,84,197,48,18,165,142,94,210,42,206,175,132,244,67,151,12,218,8,210,236,160,44,119,191,123,115,105,181,141,
98,142,90,244,132,225,39,119,232,68,182,127,241,135,237,61,208,81,161,165,254,129,56,166,209,60,9,37,54,226,19,179,183,165,94,66,31,75,84,177,97,81,198,159,220,213,199,175,7,248,177,56,60,81,244,220,253,101,202,157,187,6,184,200,128,102,27,171,6,59,92,
252,129,100,142,28,239,12,104,141,169,207,148,245,9,192,196,163,158,150,113,17,31,191,18,203,217,137,250,139,218,108,95,78,202,5,253,52,184,215,243,209,79,29,249,27,2,201,45,140,150,148,116,240,235,10,98,102,227,22,13,220,250,143,205,238,97,30,64,136,
203,10,44,199,32,58,152,76,148,182,227,220,51,246,38,183,207,169,87,57,16,178,237,46,254,54,132,68,243,118,124,248,227,242,174,107,200,29,10,174,53,183,172,147,223,127,18,177,93,1,14,197,211,91,49,78,126,139,218,91,249,246,63,227,141,199,163,5,155,27,
34,51,249,125,209,43,237,151,119,168,4,94,41,108,142,71,14,219,77,0,226,143,119,36,98,158,234,109,219,136,99,135,39,34,196,130,247,63,141,13,47,145,219,154,252,70,72,124,123,102,101,195,249,159,207,225,247,216,40,182,70,17,46,133,95,116,77,229,40,47,
139,63,177,219,98,28,252,230,105,37,54,114,223,222,53,95,109,177,178,29,125,47,195,24,255,146,204,210,223,108,56,162,76,94,135,146,238,217,193,63,115,118,188,212,208,17,206,241,178,120,135,184,209,233,136,21,102,207,155,33,144,0,40,113,43,137,166,41,
103,206,236,172,185,215,89,56,213,205,207,41,216,234,30,93,241,4,61,114,13,191,53,204,82,39,237,107,139,222,218,61,189,115,66,81,241,197,69,81,157,159,196,179,54,49,221,71,213,88,126,221,135,54,206,186,43,239,79,111,61,101,140,255,194,176,79,181,220,
86,152,206,168,75,42,11,175,93,53,189,235,238,44,107,155,211,235,82,49,201,229,192,137,87,74,2,164,168,134,103,18,71,235,80,238,108,99,138,72,222,162,247,59,90,114,175,20,150,62,180,92,169,150,214,102,97,33,113,27,102,71,115,168,237,181,101,229,206,102,
103,30,11,255,75,161,58,79,206,68,181,16,87,114,17,195,144,73,188,51,231,160,179,199,182,132,84,85,85,233,164,138,159,230,26,228,233,81,126,85,27,217,72,182,218,15,67,252,113,167,103,236,23,211,163,4,171,163,146,238,197,240,219,124,249,73,102,173,198,
233,58,52,215,209,213,253,187,175,46,171,254,159,245,231,0,132,86,192,21,104,79,135,154,92,211,25,245,136,115,210,54,198,103,50,79,0,146,81,230,240,208,54,29,91,251,247,87,38,31,88,179,188,166,214,176,199,206,174,65,156,159,48,220,236,64,211,72,219,231,
18,122,10,231,234,9,141,239,97,237,236,95,122,22,233,248,251,172,79,0,162,110,125,254,72,251,156,141,217,57,136,146,249,97,227,232,17,212,241,198,227,120,77,255,157,22,104,14,177,109,110,27,255,115,209,234,152,225,174,176,205,98,142,90,124,100,188,89,
247,18,187,215,114,28,85,172,163,31,100,125,2,16,187,103,77,211,194,115,156,62,65,227,16,163,161,51,67,150,195,24,1,56,228,57,56,197,24,113,87,160,45,45,163,204,193,217,158,129,175,53,235,207,1,136,139,216,226,97,127,164,114,128,247,139,15,124,211,29,
152,147,15,31,53,221,109,212,213,187,236,159,137,118,32,28,20,145,186,128,56,55,167,25,62,181,186,46,232,232,87,128,169,71,50,56,75,12,129,17,0,63,129,154,229,81,50,157,255,221,41,76,16,24,130,2,89,222,181,134,136,104,86,92,108,59,68,172,16,102,86,9,
32,1,216,168,142,174,235,115,188,90,123,243,88,7,190,139,182,17,8,22,181,46,192,15,227,152,225,50,226,137,81,142,94,200,101,61,160,204,46,137,4,96,219,91,54,18,17,175,115,55,184,216,142,7,5,164,44,192,207,227,144,3,227,145,0,82,134,195,2,16,128,192,144,
22,192,8,96,72,87,31,130,135,128,61,1,36,0,123,126,88,26,2,67,90,0,9,96,72,87,31,130,135,128,61,1,36,0,123,126,88,26,2,67,90,0,9,96,72,87,31,130,135,128,61,129,236,191,20,216,222,246,13,217,165,215,204,33,174,127,255,167,194,139,182,231,210,16,191,13,
202,210,221,228,10,255,219,169,90,199,152,205,181,55,175,95,111,21,162,162,130,248,62,249,106,209,63,183,248,137,207,106,28,252,198,107,201,215,58,113,221,158,5,111,124,110,53,14,44,151,30,1,36,128,244,184,218,46,181,161,129,120,195,174,250,251,234,60,
82,185,100,241,27,106,131,215,174,191,179,112,41,191,152,90,252,237,61,75,73,36,238,34,193,6,87,221,146,102,183,52,60,181,63,146,245,55,2,230,146,136,151,149,222,194,63,65,2,248,27,75,86,252,15,9,32,43,170,225,232,32,242,100,115,127,171,137,187,201,237,
220,80,74,153,97,235,34,37,153,63,213,82,50,136,198,196,93,237,22,239,187,55,83,143,248,123,229,152,178,78,0,231,0,178,174,74,16,16,4,50,39,128,4,144,57,107,172,9,2,89,39,128,4,144,117,85,130,128,32,144,57,1,36,128,204,89,99,77,16,200,58,1,36,128,172,
171,18,4,4,129,204,9,32,1,100,206,26,107,130,64,214,9,32,1,100,93,149,32,32,8,100,78,0,9,32,115,214,88,19,4,178,78,0,9,32,235,170,4,1,65,32,115,2,72,0,153,179,198,154,32,144,117,2,72,0,89,87,37,8,8,2,153,19,64,2,200,156,53,214,4,129,172,19,64,2,200,186,
42,65,64,16,200,156,0,18,64,230,172,177,38,8,100,157,0,18,64,214,85,9,2,130,64,230,4,144,0,50,103,141,53,65,32,235,4,144,0,178,174,74,16,16,4,50,39,128,4,144,57,107,172,9,2,89,39,128,4,144,117,85,130,128,32,144,57,129,180,63,19,144,63,137,82,34,148,111,
144,248,177,50,153,203,73,86,151,62,246,26,13,70,69,92,140,7,73,173,172,161,107,153,180,37,81,71,236,204,45,60,54,3,126,251,255,87,32,173,9,192,173,80,70,101,218,65,36,214,201,172,62,18,146,119,47,23,147,18,105,169,34,23,229,207,219,101,157,201,36,144,
242,58,68,215,151,72,44,229,229,6,184,0,79,123,17,211,206,234,99,61,121,124,154,78,109,217,185,100,34,25,50,241,80,133,39,73,139,113,48,209,202,92,226,25,197,206,79,60,133,203,102,108,86,18,184,8,71,230,45,32,33,185,137,174,90,45,161,207,141,114,105,
230,110,207,77,108,216,9,53,67,166,60,202,244,76,105,169,148,100,168,137,15,106,91,228,34,114,9,239,36,10,127,162,172,165,199,82,147,8,147,88,155,212,144,44,211,201,215,214,54,233,205,248,112,54,147,87,147,181,244,36,170,69,229,57,164,233,224,30,39,227,
18,101,125,176,149,68,121,241,151,146,4,115,91,183,35,146,28,245,52,90,125,36,184,136,35,223,61,170,93,81,15,92,203,226,134,151,105,22,235,144,26,178,222,65,63,20,229,57,61,37,84,253,85,53,106,52,242,103,31,91,171,67,23,175,125,149,197,72,123,99,147,
211,177,69,93,164,213,208,200,124,18,55,252,252,213,90,251,215,136,28,78,40,252,177,238,152,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,
0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,
0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,
0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,
128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,
32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,0,2,16,128,0,4,32,0,1,8,64,224,239,85,224,255,0,196,61,49,167,17,160,232,27,0,0,0,0,73,69,78,68,174,66,96,130,0,0 };
const char* PDOicon_ico = (const char*) temp_binary_data_0;
//================== PDOResources.rc ==================
static const unsigned char temp_binary_data_1[] =
"#undef WIN32_LEAN_AND_MEAN\r\n"
"#define WIN32_LEAN_AND_MEAN\r\n"
"#include <windows.h>\r\n"
"\r\n"
"VS_VERSION_INFO VERSIONINFO\r\n"
"FILEVERSION 1,6,8,0\r\n"
"BEGIN\r\n"
" BLOCK \"StringFileInfo\"\r\n"
" BEGIN\r\n"
" BLOCK \"040904E4\"\r\n"
" BEGIN\r\n"
" VALUE \"CompanyName\", \"OpenDragon\\0\"\r\n"
" VALUE \"FileDescription\", \"Platonic display output service\\0\"\r\n"
" VALUE \"FileVersion\", \"1.6.9\\0\"\r\n"
" VALUE \"LegalCopyright\", \"(c) 2016 by OpenDragon\\0\"\r\n"
" VALUE \"ProductName\", \"Platonic display output service\\0\"\r\n"
" VALUE \"ProductVersion\", \"1.6.9\\0\"\r\n"
" END\r\n"
" END\r\n"
"\r\n"
" BLOCK \"VarFileInfo\"\r\n"
" BEGIN\r\n"
" VALUE \"Translation\", 0x409, 65001\r\n"
" END\r\n"
"END\r\n"
"\r\n"
"/* Add the application icon */\r\n"
"IDI_ICON1 ICON DISCARDABLE \"PDOicon.ico\"\r\n"
"IDI_ICON2 ICON DISCARDABLE \"PDOicon.ico\"\r\n";
const char* PDOResources_rc = (const char*) temp_binary_data_1;
const char* getNamedResource (const char*, int&) throw();
const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw()
{
unsigned int hash = 0;
if (resourceNameUTF8 != 0)
while (*resourceNameUTF8 != 0)
hash = 31 * hash + (unsigned int) *resourceNameUTF8++;
switch (hash)
{
case 0xac8e7ca6: numBytes = 25624; return PDOicon_ico;
case 0x396c3602: numBytes = 750; return PDOResources_rc;
default: break;
}
numBytes = 0;
return 0;
}
const char* namedResourceList[] =
{
"PDOicon_ico",
"PDOResources_rc"
};
}
| 201.371257
| 254
| 0.597624
|
opendragon
|
7d494e85ccd5ee6a0140412d8217faae1735c7f7
| 15,433
|
cpp
|
C++
|
src/engine/components/collider/collidermath.cpp
|
senaademr/CS1950UFinal
|
efb1d223e68ee02b1386cb8a97200db6faad893d
|
[
"MIT"
] | null | null | null |
src/engine/components/collider/collidermath.cpp
|
senaademr/CS1950UFinal
|
efb1d223e68ee02b1386cb8a97200db6faad893d
|
[
"MIT"
] | null | null | null |
src/engine/components/collider/collidermath.cpp
|
senaademr/CS1950UFinal
|
efb1d223e68ee02b1386cb8a97200db6faad893d
|
[
"MIT"
] | null | null | null |
#include "collidermath.h"
#include "cylindercollider.h"
#include "spherecollider.h"
#include "boxcollider.h"
#include "compoundcollider.h"
#include "engine/components/transformcomponent.h"
#include "engine/components/physicscomponent.h"
#include "engine/components/collisioncomponent.h"
#include "engine/basics/gameobject.h"
#include "engine/util/CommonIncludes.h"
#include "collisionresponse.h"
/*****************************Actual Collisions ***************************/
CollisionResponse ColliderMath::collideCylinderCylinder(CylinderCollider* collider1, CylinderCollider* collider2){
Transform transform1 = collider1->getTransform();
Transform transform2 = collider2->getTransform();
//std::cout << "testing cylinder collide with cylinder" << std::endl;
bool areColliding = collideLineCylinder(transform1, transform2) && collideCircles(transform1, transform2);
if(areColliding){
glm::vec3 circleMtv = getCircleCircleMtv(transform1, transform2);
glm::vec3 lineMtv = getLineMtvCylinder(transform1, transform2);
glm::vec3 mtv = getSmallerMtv(circleMtv, lineMtv);
return CollisionResponse(mtv);
//ColliderMath::resolveMtv(collider1, collider2, circleMtv, lineMtv);
}
return CollisionResponse();
}
CollisionResponse ColliderMath::collideCylinderBox(CylinderCollider *cylinderCollider, BoxCollider *boxCollider){
Transform transformCylinder = cylinderCollider->getTransform();
Transform transformBox = boxCollider->getTransform();
glm::vec2 clampedPoint = clampPointXZ(transformBox, transformCylinder);
bool colliding = collideCylinderLineBox(transformCylinder, transformBox)
&& collidePointCircle(transformCylinder, clampedPoint);
if(colliding){
glm::vec2 cylinderRangeY = getRangeCylinder(transformCylinder);
glm::vec2 boxRangeY = getRangeBox(transformBox, DIMENSION::Y);
glm::vec3 lineMtv = getLineLineMtv(cylinderRangeY, boxRangeY, DIMENSION::Y);
glm::vec3 circleMtv = getPointCircleMtv(transformCylinder, transformBox);
//std::cout << "lineMtv: " << lineMtv << " circleMtv: " << circleMtv << std::endl;
glm::vec3 mtv = getSmallerMtv(lineMtv, circleMtv);
return CollisionResponse(mtv);
}
return CollisionResponse();
}
CollisionResponse ColliderMath::collideCylinderSphere(CylinderCollider *cylinderCollider, SphereCollider * sphereCollider){
//std::cout << "unimplemented collision: cylinder sphere" << std::endl;
return CollisionResponse();
}
CollisionResponse ColliderMath::collideBoxBox(BoxCollider* collider1, BoxCollider* collider2){
Transform transform1 = collider1->getTransform();
Transform transform2 = collider2->getTransform();
bool collideX = collideLineBox(transform1, transform2, DIMENSION::X);
bool collideY = collideLineBox(transform1, transform2, DIMENSION::Y);
bool collideZ = collideLineBox(transform1, transform2, DIMENSION::Z);
bool result = collideX && collideY && collideZ;
if(result){
glm::vec3 lineMtvX = getLineLineMtvBox(transform1, transform2, DIMENSION::X);
glm::vec3 lineMtvY = getLineLineMtvBox(transform1, transform2, DIMENSION::Y);
glm::vec3 lineMtvZ = getLineLineMtvBox(transform1, transform2, DIMENSION::Z);
//resolveMtv(collider1, collider2, lineMtvX, lineMtvY, lineMtvZ);
glm::vec3 mtv = getSmallerMtv(lineMtvX, lineMtvY, lineMtvZ);
return CollisionResponse(mtv);
}
return CollisionResponse();
}
CollisionResponse ColliderMath::collideBoxSphere(BoxCollider* boxCollider, SphereCollider* sphereCollider){
Transform transformBox = boxCollider->getTransform();
Transform transformSphere = sphereCollider->getTransform();
glm::vec3 clampedPoint = clampPoint(transformBox, transformSphere);
bool colliding = collidePointSphere(transformSphere, clampedPoint);
if(colliding){
glm::vec3 mtv = getPointSphereMtv(transformSphere, clampedPoint);
return CollisionResponse(mtv);
}
return CollisionResponse();
}
CollisionResponse ColliderMath::collideSphereSphere(SphereCollider* collider1, SphereCollider* collider2){
Transform transform1 = collider1->getTransform();
Transform transform2 = collider2->getTransform();
bool colliding = collideSpheres(transform1, transform2);
if(colliding){
glm::vec3 mtv = getSphereSphereMtv(transform1, transform2);
return CollisionResponse(mtv);
}
return CollisionResponse();
}
/*************************** dummy collisions *****************/
CollisionResponse ColliderMath::negateResponse(CollisionResponse response){
if(response.didCollide){
return CollisionResponse(-1.f *response.mtv);
}
return response;
}
CollisionResponse ColliderMath::collideSphereBox(SphereCollider* sphereCollider, BoxCollider* boxCollider){
return negateResponse(collideBoxSphere(boxCollider, sphereCollider));
}
CollisionResponse ColliderMath::collideBoxCylinder(BoxCollider *boxCollider, CylinderCollider *cylinderCollider){
return negateResponse(collideCylinderBox(cylinderCollider, boxCollider));
}
CollisionResponse ColliderMath::collideSphereCylinder(SphereCollider * sphereCollider, CylinderCollider *cylinderCollider){
return negateResponse(collideCylinderSphere(cylinderCollider, sphereCollider));
}
/***************************** Line collisions ***************************/
bool ColliderMath::collideLineCylinder(Transform &transform1, Transform &transform2)
{
glm::vec2 range1 = ColliderMath::getRangeCylinder(transform1);
glm::vec2 range2 = ColliderMath::getRangeCylinder(transform2);
return collideLine(range1, range2);
}
bool ColliderMath::collideLine(glm::vec2 range1, glm::vec2 range2){
bool result= (range1.x < range2.y && range2.x < range1.y);
return result;
}
bool ColliderMath::collideLineBox(Transform &transform1, Transform &transform2, DIMENSION dim){
glm::vec2 range1 = getRangeBox(transform1, dim);
glm::vec2 range2 = getRangeBox(transform2, dim);
return collideLine(range1, range2);
}
bool ColliderMath::collideSpheres(Transform &transform1, Transform &transform2){
float distance2 = glm::distance2(transform1.getPosition(), transform2.getPosition());
float radius1 = getRadius(transform1.getSize());
float radius2 = getRadius(transform2.getSize());
bool result = distance2 < powf(radius1 + radius2, 2);
return result;
}
glm::vec3 ColliderMath::getSphereSphereMtv(Transform &transform1, Transform &transform2){
glm::vec3 locationDifference = transform1.getPosition()-transform2.getPosition();
float distance = glm::length(locationDifference);
glm::vec3 direction = glm::normalize(locationDifference);
float radius1 = getRadius(transform1.getSize());
float radius2 = getRadius(transform2.getSize());
glm::vec3 mtv = (distance -radius1 - radius2 )*direction;
return mtv;
}
bool ColliderMath::collideCylinderLineBox(Transform &transformCylinder, Transform &transformBox){
glm::vec2 yRangeCylinder = getRangeCylinder(transformCylinder);
glm::vec2 yRangeBox = getRangeBox(transformBox, DIMENSION::Y);
return collideLine(yRangeCylinder, yRangeBox);
}
glm::vec3 ColliderMath::getCircleCircleMtv(Transform &transform1, Transform &transform2){
glm::vec2 circlePos1 = toCircle(transform1.getPosition());
glm::vec2 circlePos2 = toCircle(transform2.getPosition());
float length = glm::distance(circlePos1, circlePos2);
float radius1 = getRadius(transform1.getSize());
float radius2 = getRadius(transform2.getSize());
glm::vec2 mtv2d = (circlePos2-circlePos1);
mtv2d /= length;
mtv2d *= (radius1 + radius2-length);
glm::vec3 mtv = glm::vec3(mtv2d.x, 0, mtv2d.y);
return mtv;
}
glm::vec3 ColliderMath::getLineMtvCylinder(Transform &transform1, Transform &transform2){
glm::vec2 yRange1 = ColliderMath::getRangeCylinder(transform1);
glm::vec2 yRange2 = ColliderMath::getRangeCylinder(transform2);
return getLineLineMtv(yRange1, yRange2, DIMENSION::Y);
}
glm::vec3 ColliderMath::getLineLineMtvBox(Transform &transform1, Transform &transform2, DIMENSION dim){
glm::vec2 range1 = ColliderMath::getRangeBox(transform1, dim);
glm::vec2 range2 = ColliderMath::getRangeBox(transform2, dim);
return getLineLineMtv(range1, range2, dim);
}
glm::vec3 ColliderMath::getLineLineMtv(glm::vec2 range1, glm::vec2 range2, DIMENSION dim){
float aRight = range2.y - range1.x;
float aLeft = range1.y - range2.x;
float value = 1;
if(aLeft < 0 || aRight < 0){
std::cout << "error? " << std::endl;
}
if(aRight < aLeft){
value = -aRight;
}
else{
value = aLeft;
}
switch(dim){
case(DIMENSION::X):
return glm::vec3(value, 0, 0);
case(DIMENSION::Y):
return glm::vec3(0, value, 0);
case(DIMENSION::Z):
return glm::vec3(0, 0, value);
}
assert(false);
return glm::vec3(0);
}
bool ColliderMath::collideCircles(Transform &transform1, Transform &transform2){
glm::vec2 circlePos1 = toCircle(transform1.getPosition());
glm::vec2 circlePos2 = toCircle(transform2.getPosition());
float distance2 = glm::distance2(circlePos1, circlePos2);
float radius1 = getRadius(transform1.getSize());
float radius2 = getRadius(transform2.getSize());
bool result = distance2 < powf(radius1 + radius2, 2);
if(result){
}
return result;
}
glm::vec3 ColliderMath::getPointSphereMtv(Transform &transformSphere, glm::vec3 point){
float radius = getRadius(transformSphere.getSize());
glm::vec3 mtv = transformSphere.getPosition()- point;
float size = glm::length(mtv);
mtv = glm::normalize(mtv);
mtv = (radius - size)*mtv;
return mtv;
}
//if inside, find the dimension that is shortest
//TODO FIXXXXXXXX
glm::vec3 ColliderMath::getPointCircleMtv(Transform &transformCylinder,Transform &transformBox){
glm::vec2 point = clampPointXZ(transformBox, transformCylinder);
float radius = getRadius(transformCylinder.getSize());
glm::vec2 circle = toCircle(transformCylinder.getPosition());
glm::vec2 mtv = circle - point;
float size = glm::length(mtv);
if(size==0){
glm::vec2 xRange = getRangeBox(transformBox, DIMENSION::X);
glm::vec2 zRange = getRangeBox(transformBox, DIMENSION::Z);
glm::vec3 mtvX1 = glm::vec3(circle.x - xRange.x, 0, 0 );
glm::vec3 mtvX2 = glm::vec3(circle.x - xRange.y, 0, 0 );
glm::vec3 mtvX = getSmallerMtv(mtvX1, mtvX2);
//std::cout << "circleX: " << circle.x << " xRange: " << xRange << std::endl;
//std::cout << "mtvX " <<mtvX << std::endl;
glm::vec3 mtvY1 = glm::vec3(0, 0, circle.y - zRange.x);
glm::vec3 mtvY2 = glm::vec3(0, 0, circle.y - zRange.y);
glm::vec3 mtvY = getSmallerMtv(mtvY1, mtvY2);
glm::vec3 mtv = getSmallerMtv(mtvX, mtvY);
float newSize = glm::length(mtv);
return glm::normalize(mtv)* (radius + newSize);
//float toXMin = glm::distance(circle.x, xRange.x);
//return glm::vec3(100000);
}
else{
mtv = glm::normalize(mtv);
mtv = (size - radius)*mtv;
return glm::vec3(mtv.x, 0, mtv.y);
}
}
bool ColliderMath::collidePointSphere(Transform &transformSphere, glm::vec3 point){
float radius = getRadius(transformSphere.getSize());
float distance = glm::distance(transformSphere.getPosition(), point);
return distance <= radius;
}
bool ColliderMath::collidePointCircle(Transform &transformCylinder, glm::vec2 point){
glm::vec2 circle = toCircle(transformCylinder.getPosition());
float radius = getRadius(transformCylinder.getSize());
return glm::distance(circle, point) <= radius;
}
/*************************** Helper *****************************/
float ColliderMath::getRadius(glm::vec3 size){
return std::abs(size.x/2.f);
}
glm::vec2 ColliderMath::toCircle(glm::vec3 pos){
return glm::vec2(pos.x, pos.z);
}
glm::vec3 ColliderMath::clampPoint(Transform &transformBox, Transform &transformSphere){
float x = clampDimension(transformBox, transformSphere, DIMENSION::X);
float y = clampDimension(transformBox, transformSphere, DIMENSION::Y);
float z = clampDimension(transformBox, transformSphere, DIMENSION::Z);
glm::vec3 clampedPoint = glm::vec3(x,y,z);
return clampedPoint;
}
glm::vec2 ColliderMath::clampPointXZ(Transform &transformBox,Transform &transformCylinder){
float x = clampDimension(transformBox, transformCylinder, DIMENSION::X);
float z = clampDimension(transformBox, transformCylinder, DIMENSION::Z);
glm::vec2 clampedPoint = glm::vec2(x, z);
return clampedPoint;
}
float ColliderMath::clampDimension(Transform &transformBox,Transform &transformSphere, DIMENSION dim){
glm::vec2 range = getRangeBox(transformBox, dim);
glm::vec3 pos = transformSphere.getPosition();
switch(dim){
case(DIMENSION::X):
return glm::clamp(pos.x, range.x, range.y);
case(DIMENSION::Y):
return glm::clamp(pos.y, range.x, range.y);
case(DIMENSION::Z):
return glm::clamp(pos.z, range.x, range.y);
}
assert(false);
return -1;
}
/**
* @brief ColliderMath::getRangeCylinder
* Returns a vec2 representing the vertical dimension of the cylinder.
* This is different from the box range because the starting point of the cylinder is the bottom
* @param transformComponent
* @return
*/
glm::vec2 ColliderMath::getRangeCylinder(Transform &transformCylinder){
glm::vec3 pos = transformCylinder.getPosition();
glm::vec3 size = transformCylinder.getSize();
return glm::vec2(pos.y, pos.y + size.y);
}
/**
* @brief ColliderMath::getRangeBox
* Returns a vec2 representing a dimension of a box.
* This is different from the cylinder range because the starting point of a box is the center
* @param transformComponent
* @param dim
* @return
*/
glm::vec2 ColliderMath::getRangeBox(Transform &transformBox, DIMENSION dim){
glm::vec3 pos = transformBox.getPosition();
glm::vec3 size = transformBox.getSize();
switch(dim){
case(DIMENSION::X):
return getRangeBox(pos.x, size.x);
case(DIMENSION::Y):
return getRangeBox(pos.y, size.y);
case(DIMENSION::Z):
return getRangeBox(pos.z, size.z);
}
assert(false); //should never reach here
return glm::vec2(0);
}
/**
* @brief ColliderMath::getRangeBox
* Returns a vec2 representing a dimension of a box.
* This is different from the cylinder range because the starting point of a box is the center
* @param pos
* @param size
* @return
*/
glm::vec2 ColliderMath::getRangeBox(float pos, float size){
assert(size >= 0);
return glm::vec2(pos-size/2.f, pos + size/2.f);
}
glm::vec3 ColliderMath::getSmallerMtv(glm::vec3 mtv1, glm::vec3 mtv2){
if(glm::length2(mtv1) < glm::length2(mtv2)){
return mtv1;
}
else{
return mtv2;
}
}
glm::vec3 ColliderMath::getSmallerMtv(glm::vec3 mtv1, glm::vec3 mtv2, glm::vec3 mtv3){
float length1 = glm::length2(mtv1);
float length2 = glm::length2(mtv2);
float length3 = glm::length2(mtv3);
if(length1 < length2 && length1 < length3){
return mtv1;
}
else if(length2 < length3){
return mtv2;
}
else{
return mtv3;
}
}
| 36.142857
| 123
| 0.694227
|
senaademr
|
7d4a266a5b7ad0d0c4cd35de51f121afff7cfadf
| 6,674
|
cpp
|
C++
|
data/reddit/extract_train.cpp
|
Sanzo00/NeutronStarLite
|
57d92d1f7f6cd55c55a83ca086096a710185d531
|
[
"Apache-2.0"
] | 38
|
2022-03-09T10:29:08.000Z
|
2022-03-30T13:56:16.000Z
|
data/reddit/extract_train.cpp
|
Sanzo00/NeutronStarLite
|
57d92d1f7f6cd55c55a83ca086096a710185d531
|
[
"Apache-2.0"
] | 3
|
2022-03-09T10:55:27.000Z
|
2022-03-17T02:53:58.000Z
|
data/reddit/extract_train.cpp
|
Sanzo00/NeutronStarLite
|
57d92d1f7f6cd55c55a83ca086096a710185d531
|
[
"Apache-2.0"
] | 6
|
2022-03-10T07:41:31.000Z
|
2022-03-21T06:36:31.000Z
|
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib>
#include <string.h>
#include <cstring>
using namespace std;
int generate_Mask(int vertices,std::string mask_file){
FILE *fp_mask;
fp_mask=fopen(mask_file.c_str(),"w");
for(int i=0;i<vertices;i++){
int a=rand()%10;
if(a<6){
fprintf(fp_mask,"%d train\n",i);
}else
if(a<8){
fprintf(fp_mask,"%d test\n",i);
}else
if(a<10){
fprintf(fp_mask,"%d val\n",i);
}
}
fclose(fp_mask);
return 0;
}
void writeLabels(int vertices,std::string label_file)
{
std::string str;
std::string label_file_output=label_file+"_nts";
std::ifstream input_lbl(label_file.c_str(), std::ios::in);
std::ofstream output_lbl(label_file_output.c_str(), std::ios::out);
// ID F F F F F F F L
std::cout<<"called"<<std::endl;
if (!input_lbl.is_open())
{
std::cout<<"open label file fail!"<<std::endl;
return;
}
std::string la;
//std::cout<<"finish1"<<std::endl;
int id=0;
int label;
for(int j=0;j<vertices;j++)
{
input_lbl >> label;
output_lbl<<j<<" "<<label<<std::endl;
}
input_lbl.close();
output_lbl.close();
}
int sort_Mask(int vertices,std::string mask_file){
std::cout<<vertices<<std::endl;
std::string mask_file_sorted=mask_file+"sorted";
std::ifstream fp_mask(mask_file.c_str(), std::ios::in);
std::ofstream fp_mask_sorted(mask_file_sorted.c_str(), std::ios::out);
if (!fp_mask.is_open())
{
std::cout<<"open"<<mask_file<<" fail!"<<std::endl;
return 0;
}
int* value=new int[vertices];
memset(value,0,sizeof(int)*vertices);
while(!fp_mask.eof()){
int id;
std::string s;
fp_mask>>id>>s;
std::cout<<id<<" "<<s<<std::endl;
if(s.compare("train")==0){
value[id]=1;
}else if(s.compare("val")==0){
value[id]=2;
}else if(s.compare("test")==0){
value[id]=3;
}else{
;
}
}
for(int i=0;i<vertices;i++){
std::string s;
if(value[i]==1){
fp_mask_sorted<<i<<" train"<<std::endl;
}else if(value[i]==2){
fp_mask_sorted<<i<<" val"<<std::endl;
}
if(value[i]==3){
fp_mask_sorted<<i<<" test"<<std::endl;
}
}
fp_mask_sorted.close();
fp_mask.close();
//fclose(fp_mask);
return 0;
}
int sort_Label(int vertices,std::string label_file){
std::string label_file_sorted=label_file+"sorted";
std::ifstream fp_label(label_file.c_str(), std::ios::in);
std::ofstream fp_label_sorted(label_file_sorted.c_str(), std::ios::out);
if (!fp_label.is_open())
{
std::cout<<"open "<< label_file<<" fail!"<<std::endl;
return 0;
}
int* value=new int[vertices];
memset(value,0,sizeof(int)*vertices);
while(!fp_label.eof()){
int id;
int v;
fp_label>>id>>v;
value[id]=v;
}
for(int i=0;i<vertices;i++){
fp_label_sorted<<i<<" "<<value[i]<<std::endl;
}
fp_label_sorted.close();
fp_label.close();
//fclose(fp_label);
return 0;
}
void generate_edge(int vertices,std::string edge_file){
std::string edge_file_sorted=edge_file+".bin";
std::ifstream fp_edge(edge_file.c_str(), std::ios::in);
std::ofstream fp_edge_sorted(edge_file_sorted.c_str(), std::ios::binary);
if (!fp_edge.is_open())
{
std::cout<<"open "<< edge_file<<" fail!"<<std::endl;
return;
}
while(!fp_edge.eof()){
int src;
int dst;
fp_edge>>src>>dst;
fp_edge_sorted.write((char*)&src,sizeof(int));
fp_edge_sorted.write((char*)&dst,sizeof(int));
fp_edge_sorted.write((char*)&dst,sizeof(int));
fp_edge_sorted.write((char*)&src,sizeof(int));
//fp_edge_sorted<<dst<<" "<<src<<std::endl;
}
for(int i=0;i<vertices;i++){
fp_edge_sorted.write((char*)&i,sizeof(int));
fp_edge_sorted.write((char*)&i,sizeof(int));
}
fp_edge_sorted.close();
fp_edge.close();
//fclose(fp_label);
std::ifstream fp_edge_test(edge_file_sorted.c_str(), std::ios::binary);
for(int i=0;i<23446805;i++){
int src;
int dst;
fp_edge_test.read((char*)&src,sizeof(int));
fp_edge_test.read((char*)&dst,sizeof(int));
if(i>23446705)
std::cout<<"edge[0]: "<<src<<" edge[1]: "<<dst<<std::endl;
//fp_edge_sorted<<dst<<" "<<src<<std::endl;
}
return;
}
void writeFeature(int vertices, int features,std::string input_feature)
{
std::string str;
std::string output_feature=input_feature+"_nts";
std::ifstream input_ftr(input_feature.c_str(), std::ios::in);
std::ofstream output_ftr(output_feature.c_str(), std::ios::out);
std::cout<<"called"<<std::endl;
if (!input_ftr.is_open())
{
std::cout<<"open feature file fail!"<<std::endl;
return;
}
// if (!input_lbl.is_open())
// {
// std::cout<<"open label file fail!"<<std::endl;
// return;
// }
float *con_tmp = new float[features];
std::string la;
//std::cout<<"finish1"<<std::endl;
int id=0;
int label;
for(int j=0;j<vertices;j++)
{
int size_0=features;
output_ftr<<j<<" ";
for (int i = 0; i < size_0; i++){
input_ftr >> con_tmp[i];
if(i!=(size_0-1)){
output_ftr<<con_tmp[i]<<" ";
}else{
output_ftr<<con_tmp[i]<<std::endl;
}
}
// input_lbl >> label;
// output_lbl<<j<<" "<<label<<std::endl;
}
free(con_tmp);
input_ftr.close();
// input_lbl.close();
output_ftr.close();
// output_lbl.close();
}
int main(int argc, char ** argv){
//for reddit
//sort_Mask(232965, "./redditdata/reddit_small/reddit.mask");
//sort_Label(232965, "./redditdata/reddit_small/reddit.labeltable");
generate_edge(232965,"./redditdata/reddit_small/reddit_full.edge.txt");
//writeFeature(232965,602,"./redditdata/reddit_small/reddit.featuretablenorm");
return 0;
}
| 30.336364
| 79
| 0.526521
|
Sanzo00
|
7d4a3b1a7ab527c9acc73bb0b253608a9dc3274c
| 1,751
|
hpp
|
C++
|
LetsGo/ThirdParty/ApproxMVBB/Includes/ApproxMVBB/Common/LogDefines.hpp
|
wis1906/letsgo-ar-space-generation
|
02d888a44bb9eb112f308356ab42720529349338
|
[
"MIT"
] | null | null | null |
LetsGo/ThirdParty/ApproxMVBB/Includes/ApproxMVBB/Common/LogDefines.hpp
|
wis1906/letsgo-ar-space-generation
|
02d888a44bb9eb112f308356ab42720529349338
|
[
"MIT"
] | null | null | null |
LetsGo/ThirdParty/ApproxMVBB/Includes/ApproxMVBB/Common/LogDefines.hpp
|
wis1906/letsgo-ar-space-generation
|
02d888a44bb9eb112f308356ab42720529349338
|
[
"MIT"
] | null | null | null |
// ========================================================================================
// ApproxMVBB
// Copyright (C) 2014 by Gabriel Nützi <nuetzig (at) imes (d0t) mavt (d0t) ethz
// (døt) ch>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// ========================================================================================
#ifndef ApproxMVBB_Common_LogDefines_hpp
#define ApproxMVBB_Common_LogDefines_hpp
#include <iostream>
#include "ApproxMVBB/Config/Config.hpp"
#define ApproxMVBB_LOG(message) std::cout << message;
#define ApproxMVBB_LOGLEVEL(level, setlevel, message) \
if(level <= setlevel) \
{ \
ApproxMVBB_LOG(message); \
}
// Message Log
// ==================================================================================
#if ApproxMVBB_FORCE_MSGLOG_LEVEL >= 0
# define ApproxMVBB_MSGLOG_LEVEL ApproxMVBB_FORCE_MSGLOG_LEVEL // force the output level if set in the config!
#else
# ifndef NDEBUG
// Debug!
# define ApproxMVBB_MSGLOG_LEVEL 2 // 0 = no output
# else
# define ApproxMVBB_MSGLOG_LEVEL 0 // 0 = no output
# endif
#endif
#define ApproxMVBB_MSGLOG_L1(message) ApproxMVBB_LOGLEVEL(1, ApproxMVBB_MSGLOG_LEVEL, message)
#define ApproxMVBB_MSGLOG_L2(message) ApproxMVBB_LOGLEVEL(2, ApproxMVBB_MSGLOG_LEVEL, message)
#define ApproxMVBB_MSGLOG_L3(message) ApproxMVBB_LOGLEVEL(3, ApproxMVBB_MSGLOG_LEVEL, message)
// ==================================================================================
#endif
| 39.795455
| 114
| 0.5494
|
wis1906
|
7d552bfe40a9a06401a279e7d57c941c60e47bc7
| 271
|
cpp
|
C++
|
Shape/Triangle.cpp
|
AKoudounis/refactored-journey
|
81719c57104f14b141f0f7cd2aa805f9007ed79e
|
[
"MIT"
] | null | null | null |
Shape/Triangle.cpp
|
AKoudounis/refactored-journey
|
81719c57104f14b141f0f7cd2aa805f9007ed79e
|
[
"MIT"
] | null | null | null |
Shape/Triangle.cpp
|
AKoudounis/refactored-journey
|
81719c57104f14b141f0f7cd2aa805f9007ed79e
|
[
"MIT"
] | null | null | null |
//Andreas Koudounis 40089191
#include "Triangle.h"
Triangle::Triangle(Point* pt1, Point* pt2, Point* pt3) {
p1 = pt1;
p2 = pt2;
p3 = pt3;
}
Triangle::~Triangle()
{
std::cout << "Triangle object deleted";
}
void Triangle::print() const
{
}
| 12.318182
| 57
| 0.594096
|
AKoudounis
|
7d556cb8fda76759552fbb07b74ac1e8578d8717
| 1,632
|
cpp
|
C++
|
01.Introduction/01.Introduction/01.Introduction.cpp
|
zvet80/CppCourse
|
a8d488dba1ba649dfc6e6d906ed25e506ff30d99
|
[
"MIT"
] | null | null | null |
01.Introduction/01.Introduction/01.Introduction.cpp
|
zvet80/CppCourse
|
a8d488dba1ba649dfc6e6d906ed25e506ff30d99
|
[
"MIT"
] | null | null | null |
01.Introduction/01.Introduction/01.Introduction.cpp
|
zvet80/CppCourse
|
a8d488dba1ba649dfc6e6d906ed25e506ff30d99
|
[
"MIT"
] | null | null | null |
// 01.Introduction.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include <array>
using namespace std;
void GetLowerUpper(string a)
{
int lower = 0;
int upper = 0;
int total = a.length();
for (int i = 0; i < total; i++)
{
if (int(a[i]) >= 65 && int(a[i]) <= 90)
{
upper++;
}
else if (int(a[i]) >= 97 && int(a[i]) <= 122)
{
lower++;
}
}
cout << "lower: " << lower << endl << "upper: " << upper << endl << "other:" << total - upper - lower << endl;
;
}
int CountLetter(string text, char letter)
{
int count = 0;
for (int i = 0; i < text.length(); i++)
{
if (text[i] == letter)
{
count++;
}
}
return count;
}
double SquareRoot(double x)
{
return sqrt(x);
}
int main()
{
cout << "Task1: Enter symbols: " << endl;
string letters;
getline(cin, letters);
GetLowerUpper(letters);
////////////////////////
cout << "Task2: Count letters: " << endl;
string text;
char letter;
cout << "Enter text: ";
getline(cin, text);
cout << "Enter a letter to search: ";
cin >> letter;
cout << "Letter: " << letter << " is found " << CountLetter(text, letter) << " times" << endl;
//////////////////////////
cout << "Task2: Get square root: " << endl;
double x;
cout << "Enter a positive number: ";
cin >> x;
cout << "The square root of " << x << " is: " << SquareRoot(x) << endl;
//////////////////////////
cout << "Task2: Sum the numbers in array: " << endl;
int arr[] = { 24, 2, 3, 53, 3, 5, 2, 27, 2, 1 };
int sum = 0;
for (int i = 0; i < 10; i++)
{
sum += arr[i];
}
cout << sum << endl;
return 0;
}
| 19.902439
| 111
| 0.53125
|
zvet80
|
7d57e5f2f52270ca7a9a1e338350d563caeaa06d
| 8,942
|
cpp
|
C++
|
Source/MapperDefinitions.cpp
|
hamzahamidi/Xidi
|
d7585ecf23fd17dd5be4e69f63bae08aa0e96988
|
[
"BSD-3-Clause"
] | 1
|
2021-06-05T00:22:08.000Z
|
2021-06-05T00:22:08.000Z
|
Source/MapperDefinitions.cpp
|
hamzahamidi/Xidi
|
d7585ecf23fd17dd5be4e69f63bae08aa0e96988
|
[
"BSD-3-Clause"
] | null | null | null |
Source/MapperDefinitions.cpp
|
hamzahamidi/Xidi
|
d7585ecf23fd17dd5be4e69f63bae08aa0e96988
|
[
"BSD-3-Clause"
] | null | null | null |
/*****************************************************************************
* Xidi
* DirectInput interface for XInput controllers.
*****************************************************************************
* Authored by Samuel Grossman
* Copyright (c) 2016-2021
*************************************************************************//**
* @file MapperDefinitions.cpp
* Definitions of all known mapper types.
*****************************************************************************/
#include "ControllerTypes.h"
#include "ElementMapper.h"
#include "Mapper.h"
namespace Xidi
{
namespace Controller
{
// -------- MAPPER DEFINITIONS ------------------------------------- //
/// Defines all known mapper types, one element per type. The first element is the default mapper.
/// Any field that corresponds to an XInput controller element can be omitted or assigned `nullptr` and the mapper will simply ignore input from that XInput controller element.
static const Mapper kMappers[] = {
Mapper(L"StandardGamepad", {
.stickLeftX = std::make_unique<AxisMapper>(EAxis::X),
.stickLeftY = std::make_unique<AxisMapper>(EAxis::Y),
.stickRightX = std::make_unique<AxisMapper>(EAxis::Z),
.stickRightY = std::make_unique<AxisMapper>(EAxis::RotZ),
.dpadUp = std::make_unique<PovMapper>(EPovDirection::Up),
.dpadDown = std::make_unique<PovMapper>(EPovDirection::Down),
.dpadLeft = std::make_unique<PovMapper>(EPovDirection::Left),
.dpadRight = std::make_unique<PovMapper>(EPovDirection::Right),
.triggerLT = std::make_unique<ButtonMapper>(EButton::B7),
.triggerRT = std::make_unique<ButtonMapper>(EButton::B8),
.buttonA = std::make_unique<ButtonMapper>(EButton::B1),
.buttonB = std::make_unique<ButtonMapper>(EButton::B2),
.buttonX = std::make_unique<ButtonMapper>(EButton::B3),
.buttonY = std::make_unique<ButtonMapper>(EButton::B4),
.buttonLB = std::make_unique<ButtonMapper>(EButton::B5),
.buttonRB = std::make_unique<ButtonMapper>(EButton::B6),
.buttonBack = std::make_unique<ButtonMapper>(EButton::B9),
.buttonStart = std::make_unique<ButtonMapper>(EButton::B10),
.buttonLS = std::make_unique<ButtonMapper>(EButton::B11),
.buttonRS = std::make_unique<ButtonMapper>(EButton::B12)
}),
Mapper(L"DigitalGamepad", {
.stickLeftX = std::make_unique<DigitalAxisMapper>(EAxis::X),
.stickLeftY = std::make_unique<DigitalAxisMapper>(EAxis::Y),
.stickRightX = std::make_unique<DigitalAxisMapper>(EAxis::Z),
.stickRightY = std::make_unique<DigitalAxisMapper>(EAxis::RotZ),
.dpadUp = std::make_unique<DigitalAxisMapper>(EAxis::Y, AxisMapper::EDirection::Negative),
.dpadDown = std::make_unique<DigitalAxisMapper>(EAxis::Y, AxisMapper::EDirection::Positive),
.dpadLeft = std::make_unique<DigitalAxisMapper>(EAxis::X, AxisMapper::EDirection::Negative),
.dpadRight = std::make_unique<DigitalAxisMapper>(EAxis::X, AxisMapper::EDirection::Positive),
.triggerLT = std::make_unique<ButtonMapper>(EButton::B7),
.triggerRT = std::make_unique<ButtonMapper>(EButton::B8),
.buttonA = std::make_unique<ButtonMapper>(EButton::B1),
.buttonB = std::make_unique<ButtonMapper>(EButton::B2),
.buttonX = std::make_unique<ButtonMapper>(EButton::B3),
.buttonY = std::make_unique<ButtonMapper>(EButton::B4),
.buttonLB = std::make_unique<ButtonMapper>(EButton::B5),
.buttonRB = std::make_unique<ButtonMapper>(EButton::B6),
.buttonBack = std::make_unique<ButtonMapper>(EButton::B9),
.buttonStart = std::make_unique<ButtonMapper>(EButton::B10),
.buttonLS = std::make_unique<ButtonMapper>(EButton::B11),
.buttonRS = std::make_unique<ButtonMapper>(EButton::B12)
}),
Mapper(L"ExtendedGamepad", {
.stickLeftX = std::make_unique<AxisMapper>(EAxis::X),
.stickLeftY = std::make_unique<AxisMapper>(EAxis::Y),
.stickRightX = std::make_unique<AxisMapper>(EAxis::Z),
.stickRightY = std::make_unique<AxisMapper>(EAxis::RotZ),
.dpadUp = std::make_unique<PovMapper>(EPovDirection::Up),
.dpadDown = std::make_unique<PovMapper>(EPovDirection::Down),
.dpadLeft = std::make_unique<PovMapper>(EPovDirection::Left),
.dpadRight = std::make_unique<PovMapper>(EPovDirection::Right),
.triggerLT = std::make_unique<AxisMapper>(EAxis::RotX),
.triggerRT = std::make_unique<AxisMapper>(EAxis::RotY),
.buttonA = std::make_unique<ButtonMapper>(EButton::B1),
.buttonB = std::make_unique<ButtonMapper>(EButton::B2),
.buttonX = std::make_unique<ButtonMapper>(EButton::B3),
.buttonY = std::make_unique<ButtonMapper>(EButton::B4),
.buttonLB = std::make_unique<ButtonMapper>(EButton::B5),
.buttonRB = std::make_unique<ButtonMapper>(EButton::B6),
.buttonBack = std::make_unique<ButtonMapper>(EButton::B7),
.buttonStart = std::make_unique<ButtonMapper>(EButton::B8),
.buttonLS = std::make_unique<ButtonMapper>(EButton::B9),
.buttonRS = std::make_unique<ButtonMapper>(EButton::B10)
}),
Mapper(L"XInputNative", {
.stickLeftX = std::make_unique<AxisMapper>(EAxis::X),
.stickLeftY = std::make_unique<AxisMapper>(EAxis::Y),
.stickRightX = std::make_unique<AxisMapper>(EAxis::RotX),
.stickRightY = std::make_unique<AxisMapper>(EAxis::RotY),
.dpadUp = std::make_unique<PovMapper>(EPovDirection::Up),
.dpadDown = std::make_unique<PovMapper>(EPovDirection::Down),
.dpadLeft = std::make_unique<PovMapper>(EPovDirection::Left),
.dpadRight = std::make_unique<PovMapper>(EPovDirection::Right),
.triggerLT = std::make_unique<AxisMapper>(EAxis::Z),
.triggerRT = std::make_unique<AxisMapper>(EAxis::RotZ),
.buttonA = std::make_unique<ButtonMapper>(EButton::B1),
.buttonB = std::make_unique<ButtonMapper>(EButton::B2),
.buttonX = std::make_unique<ButtonMapper>(EButton::B3),
.buttonY = std::make_unique<ButtonMapper>(EButton::B4),
.buttonLB = std::make_unique<ButtonMapper>(EButton::B5),
.buttonRB = std::make_unique<ButtonMapper>(EButton::B6),
.buttonBack = std::make_unique<ButtonMapper>(EButton::B7),
.buttonStart = std::make_unique<ButtonMapper>(EButton::B8),
.buttonLS = std::make_unique<ButtonMapper>(EButton::B9),
.buttonRS = std::make_unique<ButtonMapper>(EButton::B10)
}),
Mapper(L"XInputSharedTriggers", {
.stickLeftX = std::make_unique<AxisMapper>(EAxis::X),
.stickLeftY = std::make_unique<AxisMapper>(EAxis::Y),
.stickRightX = std::make_unique<AxisMapper>(EAxis::RotX),
.stickRightY = std::make_unique<AxisMapper>(EAxis::RotY),
.dpadUp = std::make_unique<PovMapper>(EPovDirection::Up),
.dpadDown = std::make_unique<PovMapper>(EPovDirection::Down),
.dpadLeft = std::make_unique<PovMapper>(EPovDirection::Left),
.dpadRight = std::make_unique<PovMapper>(EPovDirection::Right),
.triggerLT = std::make_unique<AxisMapper>(EAxis::Z, AxisMapper::EDirection::Positive),
.triggerRT = std::make_unique<AxisMapper>(EAxis::Z, AxisMapper::EDirection::Negative),
.buttonA = std::make_unique<ButtonMapper>(EButton::B1),
.buttonB = std::make_unique<ButtonMapper>(EButton::B2),
.buttonX = std::make_unique<ButtonMapper>(EButton::B3),
.buttonY = std::make_unique<ButtonMapper>(EButton::B4),
.buttonLB = std::make_unique<ButtonMapper>(EButton::B5),
.buttonRB = std::make_unique<ButtonMapper>(EButton::B6),
.buttonBack = std::make_unique<ButtonMapper>(EButton::B7),
.buttonStart = std::make_unique<ButtonMapper>(EButton::B8),
.buttonLS = std::make_unique<ButtonMapper>(EButton::B9),
.buttonRS = std::make_unique<ButtonMapper>(EButton::B10)
})
};
}
}
| 61.668966
| 184
| 0.576269
|
hamzahamidi
|
7d57ea775a493ae0c3d98bd36ba96118ff0b9eb7
| 1,434
|
cpp
|
C++
|
code/engine.vc2008/xrGame/autosave_manager.cpp
|
Rikoshet-234/xray-oxygen
|
eaac3fa4780639152684f3251b8b4452abb8e439
|
[
"Apache-2.0"
] | 7
|
2018-03-27T12:36:07.000Z
|
2020-06-26T11:31:52.000Z
|
code/engine.vc2008/xrGame/autosave_manager.cpp
|
Rikoshet-234/xray-oxygen
|
eaac3fa4780639152684f3251b8b4452abb8e439
|
[
"Apache-2.0"
] | 2
|
2018-05-26T23:17:14.000Z
|
2019-04-14T18:33:27.000Z
|
code/engine.vc2008/xrGame/autosave_manager.cpp
|
Rikoshet-234/xray-oxygen
|
eaac3fa4780639152684f3251b8b4452abb8e439
|
[
"Apache-2.0"
] | 5
|
2020-10-18T11:55:26.000Z
|
2022-03-28T07:21:35.000Z
|
////////////////////////////////////////////////////////////////////////////
// Module : autosave_manager.cpp
// Created : 04.11.2004
// Modified : 04.11.2004
// Author : Dmitriy Iassenev
// Description : Autosave manager
////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "autosave_manager.h"
#include "../xrEngine/date_time.h"
#include "ai_space.h"
#include "level.h"
#include "xrMessages.h"
#include "UIGame.h"
#include "Actor.h"
extern LPCSTR alife_section;
CAutosaveManager::CAutosaveManager()
{
u32 hours, minutes, seconds;
LPCSTR section = alife_section;
sscanf(pSettings->r_string(section, "autosave_interval"), "%d:%d:%d", &hours, &minutes, &seconds);
m_autosave_interval = (u32)generate_time(1, 1, 1, hours, minutes, seconds);
m_last_autosave_time = Device.dwTimeGlobal;
sscanf(pSettings->r_string(section, "delay_autosave_interval"), "%d:%d:%d", &hours, &minutes, &seconds);
m_delay_autosave_interval = (u32)generate_time(1, 1, 1, hours, minutes, seconds);
m_not_ready_count = 0;
shedule.t_min = 5000;
shedule.t_max = 5000;
shedule_register();
}
CAutosaveManager::~CAutosaveManager()
{
shedule_unregister();
}
float CAutosaveManager::shedule_Scale()
{
return (.5f);
}
void CAutosaveManager::shedule_Update(u32 dt)
{
inherited::shedule_Update(dt);
}
void CAutosaveManager::on_game_loaded()
{
m_last_autosave_time = Device.dwTimeGlobal;
}
| 25.157895
| 105
| 0.656206
|
Rikoshet-234
|
7d5a2e1d415c9db70ec9fbe0cbcce50dcf3b9933
| 12,540
|
cpp
|
C++
|
test/validators/validators_factory_test.cpp
|
itzaayush/jwt-cpp
|
d892ac9e6caa4ca6b7de546ccfe8a9f8764c0763
|
[
"MIT"
] | 102
|
2016-09-02T03:57:05.000Z
|
2022-03-22T12:23:59.000Z
|
test/validators/validators_factory_test.cpp
|
itzaayush/jwt-cpp
|
d892ac9e6caa4ca6b7de546ccfe8a9f8764c0763
|
[
"MIT"
] | 41
|
2017-01-26T14:57:40.000Z
|
2020-10-16T11:28:49.000Z
|
test/validators/validators_factory_test.cpp
|
itzaayush/jwt-cpp
|
d892ac9e6caa4ca6b7de546ccfe8a9f8764c0763
|
[
"MIT"
] | 55
|
2017-02-11T22:27:14.000Z
|
2022-03-31T08:29:22.000Z
|
#include <fstream>
#include <memory>
#include <string>
#include "./constants.h"
#include "gtest/gtest.h"
#include "jwt/hmacvalidator.h"
#include "jwt/jwt.h"
#include "jwt/messagevalidatorfactory.h"
#include "jwt/nonevalidator.h"
#include "jwt/rsavalidator.h"
// Test for the various validators.
TEST(parse_test, proper_hmac) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json << "{ \"" << hmacs[i] << "\" : { \"secret\" : \"safe!\" } }";
validator_ptr valid(MessageValidatorFactory::Build(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(json.str().c_str(), valid->toJson().c_str());
EXPECT_STREQ(hmacs[i], valid->algorithm().c_str());
}
}
TEST(parse_signer_test, proper_hmac) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json << "{ \"" << hmacs[i] << "\" : { \"secret\" : \"safe!\" } }";
validator_ptr valid(MessageValidatorFactory::BuildSigner(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(json.str().c_str(), valid->toJson().c_str());
EXPECT_STREQ(hmacs[i], valid->algorithm().c_str());
}
}
TEST(parse_test, can_use_validator) {
std::string json = "{ \"HS256\" : { \"secret\" : \"secret\" } }";
validator_ptr valid(MessageValidatorFactory::Build(json));
std::string strtoken =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."
"eyJzdWIiOiJzdWJqZWN0IiwiZXhwIjoxNDM3NDMzMzk3fQ."
"VGPkHXap_i2zwUCxr7dsjBq7Nnx83h5dNGjzuifjpx8";
::json header, payload;
std::tie(header, payload) = JWT::Decode(strtoken, valid.get());
EXPECT_FALSE(header.empty());
EXPECT_FALSE(payload.empty());
}
// Test for the various validators.
TEST(parse_test, proper_rsa) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json
<< "{ \"" << rs[i]
<< "\" : { \"public\" : \""
"-----BEGIN PUBLIC KEY-----\\n"
"MFswDQYJKoZIhvcNAQEBBQADSgAwRwJAdTI8v0w96101cfpvMHPruu1kqViskOb"
"b\\n"
"Nnmy3FmhiJX0o5KNOKOEWKnTUoGfM7TbfV5WGRcXW37W4cBUQ2dLWwIDAQAB\\n"
"-----END PUBLIC KEY-----"
"\" } }";
validator_ptr valid(MessageValidatorFactory::Build(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(rs[i], valid->algorithm().c_str());
}
}
TEST(parse_signer_test, rsa_missing_file) {
std::string json =
"{ \"RS256\" : { \"public\" : { \"fromfile\" : null } } }";
ASSERT_THROW(MessageValidatorFactory::BuildSigner(json), nlohmann::json::type_error);
}
// Test for the various validators.
TEST(parse_signer_test, proper_rsa) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json
<< "{ \"" << rs[i]
<< "\" : { \"public\" : \""
"-----BEGIN PUBLIC KEY-----\\n"
"MFswDQYJKoZIhvcNAQEBBQADSgAwRwJAdTI8v0w96101cfpvMHPruu1kqViskOb"
"b\\n"
"Nnmy3FmhiJX0o5KNOKOEWKnTUoGfM7TbfV5WGRcXW37W4cBUQ2dLWwIDAQAB\\n"
"-----END PUBLIC KEY-----"
"\", \"private\" : \""
"-----BEGIN RSA PRIVATE KEY-----\\n"
"MIIEowIBAAKCAQEA4SWe3cgEULKiz2wP+"
"fYqN2TxEx6DiL4rvyqZfl0CFpVMH7wC\\n"
"ZqvglxOMtUzpdO7USdlFmyOEjtH1tioll9EAg6DMs0QrLgBj7U0XHRHeJcRrbYx"
"m\\n"
"HqtmtRxjEmLBpClJoYaJ2fEdeaVcV5D1+kWMIRLM1q3RNafb1Q62nwSyojgX09/"
"X\\n"
"+lWtkuX4NPwnn5NW13uhLyO96bANWMzPhYewwCsY7s7HCscNEhVTLQF0UmtYMgp"
"n\\n"
"kzrR9aibtmCZhf58ebn0VjtoYu3JzhzmvUK+"
"E3OZb0xp3e2f464owRIvWTlTte9h\\n"
"kDnkNKYoqY7fF/"
"adwb8xDNZEAeYAwE0jC2tE3QIDAQABAoIBAQCsLgATba5XJHW8\\n"
"GNETAL2CRXDThUdkIMMF3AcsiuZY7O4dasOPTyxffPTjhaEX6rlwjHdd0EjEjC7"
"T\\n"
"k+HR+2TgRO2mvqAi+utwg78EXTC9QzxAt9k05TGTmdTuL5YU+/"
"oyS9hKUsmOyPYY\\n"
"hWSHc/5ZIK6EEsNmvCszAaCJdadCxCF9r/jTkT2iWVtV1Zrh7+Z/"
"azX+wWSBIcEW\\n"
"Lbk6MGCt2z7mWGla4x7ToxhYWBhRdDxZ0R3VzG05e1Yjn1q2U5uxsSdBAPAISge"
"D\\n"
"7LpnwMs9NcjGnVO2cUHfK1fL7tLpMlqTsyflEyvFuN2+WatY7eaFeI/"
"jRBb3ezYF\\n"
"IcNZD8eBAoGBAPnhgL1ZhpDZRJ+M/CjV0KQmbzoMyt5B38cDJ0VNZG/"
"CObCMKwvI\\n"
"kMisBwFZEyS1oiV2Lt//8tLDnrlvxQrKQLmEzI5kCbuh3EUiG/tMF4VmKB4+JR/"
"2\\n"
"TNsHCqeNuKmVjy+"
"SYNkHDfO5MbdNBSSXaV4GuA1L3evzwTNOij39C8ThAoGBAOap\\n"
"D7XOigmuGMeOiFcivtGmCuOKfS8ZqTV2tKBcu3kv8F9CeqAFp/Qznxn/"
"M8oi91VN\\n"
"rdDwkH9aClXXSjaj2FpWHCU+hQJUbzucClOf0VgExYsdwNwEDaVrwRbo+"
"fCzt3Fy\\n"
"IdChwV7AO9sSggcGWbavbCU7F/h1g/BLHx/"
"njYN9AoGAdQIDJqclO+6BE7UQ3o5A\\n"
"hJz6uFQFKs3t22K+oNT8kth/6wu3nGzuXwkuvpLXQ/"
"lJVAFjMcDIE6lGSc7slYDf\\n"
"jf+BSavOYu4IFtdCAwo+eVi8sGypNa4/"
"jtBdTNgwADjoM353myiSf+3YOdz264t6\\n"
"62x6Ar/"
"jyvj5Hu1IDn7PZAECgYAdoYw+G8lJ0w6l3B6Rqwn+Xqk5b9oDCfXdw2ES\\n"
"1LbUq57ibeTY18EqstL2gP1DM1i4oaD5nV3CrmtzeZO0DzpE6Jj3A+"
"AMW5JqgvIk\\n"
"qfw3pW1HIMxctzyVipEkg0tQa5XeQf4sEguIQ4Os8eS4SE2QFVr8MWoz5czMOqp"
"F\\n"
"6/YW9QKBgERgOD3W9BcecygPNZfGZSZRVF0j5LT0PDgKr/"
"02CIPu2mo+2ej9GmBP\\n"
"PnLXbe/R9SG8p2+Yh2ZfXn7FlXfr9a7MkzQWR/rpmxlDyzAyaJaI/"
"vCBP+KknzPo\\n"
"zBJNQZl5S6qKrqr0ypYs6ekAQ5MEe3twWWyXG2y1QgeMIs3BTnJ1\\n"
"-----END RSA PRIVATE KEY-----"
"\" } }";
validator_ptr valid(MessageValidatorFactory::BuildSigner(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(rs[i], valid->algorithm().c_str());
}
}
// Test for the various validators.
TEST(parse_test, improper_rsa) {
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json
<< "{ \"" << rs[i]
<< "\" : { \"public\" : \""
"-----BEGIN PUBLIC KEY-----\\n"
"MFswDQYJK3ZIhvcNAQEBBQADSgAwRwJAdTI8v0w96101cfpvMHPruu1kqViskOb"
"b\\n"
"Nnmy3FmhiJX0o5KNOKOEWKnTUoGfM7TbfV5WGRcXW37W4cBUQ2dLWwIDAQAB\\n"
"-----END PUBLIC KEY-----"
"\" } }";
ASSERT_THROW(MessageValidatorFactory::Build(json.str()),
std::logic_error);
}
}
// Test for the various validators.
TEST(parse_test, proper_rsa_from_file) {
std::ofstream out("/tmp/test.key");
out << "-----BEGIN PUBLIC KEY-----\n"
"MFswDQYJKoZIhvcNAQEBBQADSgAwRwJAdTI8v0w96101cfpvMHPruu1kqViskObb\n"
"Nnmy3FmhiJX0o5KNOKOEWKnTUoGfM7TbfV5WGRcXW37W4cBUQ2dLWwIDAQAB\n"
"-----END PUBLIC KEY-----";
out.close();
for (int i = 0; i < 3; i++) {
std::ostringstream json;
json << "{ \"" << rs[i]
<< "\" : { \"public\" : { \"fromfile\" : \"/tmp/test.key\" } } }";
validator_ptr valid(MessageValidatorFactory::Build(json.str()));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(rs[i], valid->algorithm().c_str());
}
}
// Test for the various validators.
TEST(parse_test, parse_set) {
std::string json =
"{ \"set\" : [ "
"{ \"HS256\" : { \"secret\" : \"safe\" } }, "
"{ \"HS512\" : { \"secret\" : \"supersafe\" } }"
" ] }";
validator_ptr valid(MessageValidatorFactory::Build(json));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(json.c_str(), valid->toJson().c_str());
EXPECT_TRUE(valid->Accepts({{"alg", "HS256"}}));
EXPECT_FALSE(valid->Accepts({{"alg", "HS384"}}));
EXPECT_TRUE(valid->Accepts({{"alg", "HS512"}}));
}
TEST(parse_test, parse_kid) {
std::string json =
"{ \"kid\" : { "
"\"key1\" : { \"HS256\" : { \"secret\" : \"key1\" } }, "
"\"key2\" : { \"HS256\" : { \"secret\" : \"key2\" } }, "
"\"key3\" : { \"HS256\" : { \"secret\" : \"key3\" } } "
"} }";
validator_ptr valid(MessageValidatorFactory::Build(json));
EXPECT_NE(nullptr, valid.get());
EXPECT_STREQ(json.c_str(), valid->toJson().c_str());
EXPECT_TRUE(valid->Accepts({{"alg", "HS256"}, {"kid", "key1"}}));
EXPECT_FALSE(valid->Accepts({{"alg", "HS256"}, {"kid", "key5"}}));
EXPECT_FALSE(valid->Accepts({{"alg", "HS256"}}));
EXPECT_FALSE(valid->Accepts({{"alg", "HS512"}, {"kid", "key1"}}));
}
TEST(parse_test, accepts_multiple_types) {
// do not have to be of the same type..
std::string json =
"{ \"kid\" : { "
"\"key1\" : { \"HS256\" : { \"secret\" : \"key1\" } }, "
"\"key3\" : { \"HS512\" : { \"secret\" : \"key3\" } } "
"} }";
ASSERT_NO_THROW(std::unique_ptr<MessageValidator>(MessageValidatorFactory::Build(json)));
}
TEST(parse_test, rsa_not_in_pem_format) {
std::string json =
"{ \"kid\" : { "
"\"key1\" : { \"RS256\" : { \"public\" : \"key1\" } }, "
"\"key2\" : { \"RS256\" : { \"public\" : \"key2\" } }, "
"\"key3\" : { \"RS256\" : { \"public\" : \"key3\" } } "
"} }";
ASSERT_THROW(MessageValidatorFactory::Build(json), std::logic_error);
}
TEST(parse_test, non_existing) {
std::string json = "{ \"HS253\" : { \"secret\" : \"safe!\" } }";
ASSERT_THROW(MessageValidatorFactory::Build(json), std::logic_error);
}
TEST(parse_test, too_many_properties) {
std::string json =
"{ \"HS256\" : { \"secret\" : \"safe!\" }, \"FOO\" : \"BAR\" }";
ASSERT_THROW(MessageValidatorFactory::Build(json), std::logic_error);
}
TEST(parse_signer, too_many_properties) {
std::string json =
"{ \"HS256\" : { \"secret\" : \"safe!\" }, \"FOO\" : \"BAR\" }";
ASSERT_THROW(MessageValidatorFactory::BuildSigner(json), std::logic_error);
}
TEST(parse_signer, non_existing_signer) {
std::string json = "{ \"HS252\" : { \"secret\" : \"safe!\" }}";
ASSERT_THROW(MessageValidatorFactory::BuildSigner(json), std::logic_error);
}
TEST(parse_test, non_secret) {
std::string json = "{ \"HS256\" : { \"without_secret\" : \"safe!\" } }";
ASSERT_THROW(MessageValidatorFactory::Build(json), std::logic_error);
}
TEST(parse_test, bad_json) {
std::string json = "{ { \"HS256\" : { \"secret\" : \"safe!\" } }";
ASSERT_THROW(MessageValidatorFactory::Build(json), nlohmann::json::parse_error);
}
TEST(parse_signer_test, bad_json) {
std::string json = "{ { \"HS256\" : { \"secret\" : \"safe!\" } }";
ASSERT_THROW(MessageValidatorFactory::BuildSigner(json), nlohmann::json::parse_error);
}
void roundtrip(MessageValidator *validator) {
std::string json = validator->toJson();
validator_ptr msg(MessageValidatorFactory::Build(json));
EXPECT_STREQ(json.c_str(), msg->toJson().c_str());
}
void roundtrip_signer(MessageSigner *signer) {
std::string json = signer->toJson();
validator_ptr msg(MessageValidatorFactory::BuildSigner(json));
EXPECT_STREQ(json.c_str(), msg->toJson().c_str());
}
TEST(parse, round_trip_none) {
NoneValidator msg;
roundtrip(&msg);
}
TEST(parse_signer, round_trip_none) {
NoneValidator msg;
roundtrip_signer(&msg);
}
TEST(parse, round_trip_hs256) {
HS256Validator msg("secret");
roundtrip(&msg);
}
TEST(parse, round_trip_hs384) {
HS384Validator msg("secret");
roundtrip(&msg);
}
TEST(parse, round_trip_hs512) {
HS512Validator msg("secret");
roundtrip(&msg);
}
TEST(parse_signer, round_trip_hs256) {
HS256Validator msg("secret");
roundtrip_signer(&msg);
}
TEST(parse_signer, round_trip_hs384) {
HS384Validator msg("secret");
roundtrip_signer(&msg);
}
TEST(parse_signer, round_trip_hs512) {
HS512Validator msg("secret");
roundtrip_signer(&msg);
}
TEST(parse, round_trip_rs256) {
RS256Validator msg(pubkey);
roundtrip(&msg);
}
TEST(parse, round_trip_rs384) {
RS384Validator msg(pubkey);
roundtrip(&msg);
}
TEST(parse, round_trip_rs512) {
RS512Validator msg(pubkey);
roundtrip(&msg);
}
TEST(parse_signer, round_trip_rs256) {
RS256Validator msg(pubkey, privkey);
roundtrip_signer(&msg);
}
TEST(parse_signer, round_trip_rs384) {
RS384Validator msg(pubkey, privkey);
roundtrip_signer(&msg);
}
TEST(parse_signer, round_trip_rs512) {
RS512Validator msg(pubkey, privkey);
roundtrip_signer(&msg);
}
| 35.625
| 93
| 0.589394
|
itzaayush
|
7d5d6898d50e1481b8849485887fa8d1a9f5aa9c
| 6,065
|
cpp
|
C++
|
tengine/tools/toyviewer.cpp
|
BSVino/Digitanks
|
1bd1ed115493bce22001ae6684b70b8fcf135db0
|
[
"BSD-4-Clause"
] | 5
|
2015-07-03T18:42:32.000Z
|
2017-08-25T10:28:12.000Z
|
tengine/tools/toyviewer.cpp
|
BSVino/Digitanks
|
1bd1ed115493bce22001ae6684b70b8fcf135db0
|
[
"BSD-4-Clause"
] | null | null | null |
tengine/tools/toyviewer.cpp
|
BSVino/Digitanks
|
1bd1ed115493bce22001ae6684b70b8fcf135db0
|
[
"BSD-4-Clause"
] | null | null | null |
#include "toyviewer.h"
#include <tinker_platform.h>
#include <files.h>
#include <glgui/rootpanel.h>
#include <glgui/menu.h>
#include <glgui/filedialog.h>
#include <glgui/checkbox.h>
#include <models/models.h>
#include <tinker/application.h>
#include <renderer/game_renderingcontext.h>
#include <renderer/game_renderer.h>
#include <game/gameserver.h>
#include <tinker/keys.h>
#include <ui/gamewindow.h>
#include <toys/toy.h>
#include "workbench.h"
REGISTER_WORKBENCH_TOOL(ToyViewer);
CToyPreviewPanel::CToyPreviewPanel()
{
SetBackgroundColor(Color(0, 0, 0, 150));
SetBorder(glgui::CPanel::BT_SOME);
m_pInfo = new glgui::CLabel("", "sans-serif", 16);
AddControl(m_pInfo);
m_pShowPhysicsLabel = new glgui::CLabel("Show physics:", "sans-serif", 10);
m_pShowPhysicsLabel->SetAlign(glgui::CLabel::TA_TOPLEFT);
AddControl(m_pShowPhysicsLabel);
m_pShowPhysics = new glgui::CCheckBox();
AddControl(m_pShowPhysics);
}
void CToyPreviewPanel::Layout()
{
float flWidth = glgui::CRootPanel::Get()->GetWidth();
float flHeight = glgui::CRootPanel::Get()->GetHeight();
float flMenuBarBottom = glgui::CRootPanel::Get()->GetMenuBar()->GetBottom();
float flCurrLeft = 20;
float flCurrTop = flMenuBarBottom + 10;
SetDimensions(flCurrLeft, flCurrTop, 200, flHeight-30-flMenuBarBottom);
tstring sFilename = ToyViewer()->GetToyPreview();
tstring sAbsoluteGamePath = FindAbsolutePath(".");
tstring sAbsoluteFilename = FindAbsolutePath(sFilename);
if (sAbsoluteFilename.find(sAbsoluteGamePath) == 0)
sFilename = ToForwardSlashes(sAbsoluteFilename.substr(sAbsoluteGamePath.length()));
m_pInfo->SetText(sFilename);
m_pInfo->SetPos(0, 15);
m_pInfo->SetSize(GetWidth(), 25);
m_pShowPhysicsLabel->Layout_AlignTop(m_pInfo);
m_pShowPhysicsLabel->SetWidth(10);
m_pShowPhysicsLabel->SetHeight(1);
m_pShowPhysicsLabel->EnsureTextFits();
m_pShowPhysicsLabel->Layout_FullWidth();
m_pShowPhysics->SetTop(m_pShowPhysicsLabel->GetTop()+12);
m_pShowPhysics->SetLeft(m_pShowPhysicsLabel->GetLeft());
BaseClass::Layout();
}
CToyViewer* CToyViewer::s_pToyViewer = nullptr;
CToyViewer::CToyViewer()
{
s_pToyViewer = this;
m_pToyPreviewPanel = new CToyPreviewPanel();
m_pToyPreviewPanel->SetVisible(false);
glgui::CRootPanel::Get()->AddControl(m_pToyPreviewPanel);
m_iToyPreview = ~0;
m_bRotatingPreview = false;
m_angPreview = EAngle(-20, 20, 0);
m_flPreviewDistance = 10;
}
CToyViewer::~CToyViewer()
{
}
void CToyViewer::Activate()
{
Layout();
if (!m_sToyPreview.length() || m_iToyPreview == ~0)
ChooseToyCallback("");
BaseClass::Activate();
}
void CToyViewer::Deactivate()
{
BaseClass::Deactivate();
m_pToyPreviewPanel->SetVisible(false);
}
void CToyViewer::Layout()
{
m_pToyPreviewPanel->SetVisible(false);
if (m_iToyPreview != ~0)
m_pToyPreviewPanel->SetVisible(true);
SetupMenu();
}
void CToyViewer::SetupMenu()
{
GetFileMenu()->ClearSubmenus();
GetFileMenu()->AddSubmenu("Open", this, ChooseToy);
}
void CToyViewer::RenderScene()
{
CModel* pModel = CModelLibrary::GetModel(m_iToyPreview);
if (m_iToyPreview != ~0)
{
TAssert(pModel);
if (!pModel)
m_iToyPreview = ~0;
}
GameServer()->GetRenderer()->SetRenderingTransparent(false);
if (m_iToyPreview != ~0 && pModel)
{
CGameRenderingContext c(GameServer()->GetRenderer(), true);
if (!c.GetActiveFrameBuffer())
c.UseFrameBuffer(GameServer()->GetRenderer()->GetSceneBuffer());
c.SetColor(Color(255, 255, 255));
c.RenderModel(m_iToyPreview);
if (m_pToyPreviewPanel->m_pShowPhysics->GetState() && pModel->m_pToy)
{
CGameRenderingContext c(GameServer()->GetRenderer(), true);
c.ClearDepth();
c.UseProgram("model");
c.SetUniform("bDiffuse", false);
c.SetColor(Color(0, 100, 155, (int)(255*0.3f)));
c.SetBlend(BLEND_ALPHA);
c.SetUniform("vecColor", Color(0, 100, 155, (char)(255*0.3f)));
for (size_t i = 0; i < pModel->m_pToy->GetPhysicsNumBoxes(); i++)
{
CGameRenderingContext c(GameServer()->GetRenderer(), true);
c.Transform(pModel->m_pToy->GetPhysicsBox(i).GetMatrix4x4());
c.RenderWireBox(CToy::s_aabbBoxDimensions);
}
if (pModel->m_pToy->GetPhysicsNumTris())
{
CGameRenderingContext c(GameServer()->GetRenderer(), true);
c.BeginRenderVertexArray();
c.SetPositionBuffer(pModel->m_pToy->GetPhysicsVerts());
c.EndRenderVertexArrayTriangles(pModel->m_pToy->GetPhysicsNumTris(), pModel->m_pToy->GetPhysicsTris());
}
// Reset for other stuff.
c.SetUniform("bDiffuse", true);
c.SetUniform("vecColor", Color(255, 255, 255, 255));
}
}
}
void CToyViewer::ChooseToyCallback(const tstring& sArgs)
{
glgui::CFileDialog::ShowOpenDialog(".", ".toy", this, OpenToy);
}
void CToyViewer::OpenToyCallback(const tstring& sArgs)
{
tstring sGamePath = GetRelativePath(sArgs, ".");
CModelLibrary::ReleaseModel(m_iToyPreview);
m_iToyPreview = CModelLibrary::AddModel(sGamePath);
if (m_iToyPreview != ~0)
{
m_sToyPreview = sGamePath;
m_flPreviewDistance = CModelLibrary::GetModel(m_iToyPreview)->m_aabbVisBoundingBox.Size().Length()*2;
}
Layout();
}
bool CToyViewer::MouseInput(int iButton, tinker_mouse_state_t iState)
{
if (iButton == TINKER_KEY_MOUSE_LEFT)
{
m_bRotatingPreview = (iState == TINKER_MOUSE_PRESSED);
return true;
}
return false;
}
void CToyViewer::MouseMotion(int x, int y)
{
if (m_bRotatingPreview)
{
int lx, ly;
if (GameWindow()->GetLastMouse(lx, ly))
{
m_angPreview.y -= (float)(x-lx);
m_angPreview.p -= (float)(y-ly);
}
}
}
void CToyViewer::MouseWheel(int x, int y)
{
if (y > 0)
{
for (int i = 0; i < y; i++)
m_flPreviewDistance *= 0.9f;
}
else if (y < 0)
{
for (int i = 0; i < -y; i++)
m_flPreviewDistance *= 1.1f;
}
}
TVector CToyViewer::GetCameraPosition()
{
if (m_iToyPreview == ~0)
return TVector(0, 0, 0);
CModel* pMesh = CModelLibrary::GetModel(m_iToyPreview);
if (!pMesh)
return TVector(0, 0, 0);
return pMesh->m_aabbVisBoundingBox.Center() - AngleVector(m_angPreview)*m_flPreviewDistance;
}
Vector CToyViewer::GetCameraDirection()
{
return AngleVector(m_angPreview);
}
| 23.060837
| 107
| 0.716076
|
BSVino
|
7d5f50a48f7e26b4301ed55a2c8703c9ffafe22b
| 2,428
|
cpp
|
C++
|
SiteData.cpp
|
RCjig/pw_manager
|
ed4da0ebccb6ab20813598ecf5731f0411f274e6
|
[
"Apache-2.0"
] | null | null | null |
SiteData.cpp
|
RCjig/pw_manager
|
ed4da0ebccb6ab20813598ecf5731f0411f274e6
|
[
"Apache-2.0"
] | null | null | null |
SiteData.cpp
|
RCjig/pw_manager
|
ed4da0ebccb6ab20813598ecf5731f0411f274e6
|
[
"Apache-2.0"
] | null | null | null |
#include "SiteData.h"
#include <ios>
#include <iostream>
using namespace std;
static int callback(void * used, int argc, char ** argv, char ** szColName) {
// set pointer structs values
select_wrapper * encSelect = (select_wrapper *) used;
encSelect->password = string(argv[0]);
// get rid of warning
if (0 > 1)
cout << encSelect;
return 0;
}
string SiteData::getPassword(char key) {
// decrypt passowrd using XOR cipher backwards
string password = "";
for (unsigned int i = 0; i < encPass.size(); i++) {
password += encPass[i] ^ (int(key) + i) % 255;
}
return password;
}
string SiteData::encodePassword(string password, char key) {
// encrypt passowrd using XOR cipher
string encryptPW = "";
for (unsigned int i = 0; i < password.size(); i++) {
encryptPW += password[i] ^ (int(key) + i) % 255;
}
return encryptPW;
}
void SiteData::insertPass(sqlite3 * db) {
// check if database exists
if (!db) {
return;
}
// create prepared statement
sqlite3_stmt * stmt;
const char * pzTest;
const char * szSQL;
string insert = "INSERT INTO passwords (id, website, user, password) values (?, ?, ?, ?)";
szSQL = insert.c_str();
int rc = sqlite3_prepare(db, szSQL, strlen(szSQL), &stmt, &pzTest);
if (rc == SQLITE_OK) {
// prepare params and bind to prepared statement
const char * websiteStmt = site.c_str();
const char * userStmt = user.c_str();
const char * passwordStmt = encPass.c_str();
sqlite3_bind_null(stmt, 1);
sqlite3_bind_text(stmt, 2, websiteStmt, strlen(websiteStmt), 0);
sqlite3_bind_text(stmt, 3, userStmt, strlen(userStmt), 0);
sqlite3_bind_text(stmt, 4, passwordStmt, strlen(passwordStmt), 0);
// execute
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
}
void SiteData::selectPass(sqlite3 * db) {
// check if database exists
if (!db) {
return;
}
// create prepared statement
char * szErrMsg = 0;
const char * pSQL;
string select = "SELECT password FROM passwords WHERE website = '" + site +
"' AND user = '" + user + "'";
pSQL = select.c_str();
// use struct to obtain select data
select_wrapper result;
int rc = sqlite3_exec(db, pSQL, callback, &result, &szErrMsg);
// check for error else set encrypted password
if (rc != SQLITE_OK) {
cerr << "Error: " << szErrMsg << endl;
sqlite3_free(szErrMsg);
} else {
encPass = result.password;
}
}
| 25.291667
| 92
| 0.645387
|
RCjig
|
7d5f54a7c49337653bb4f4e20ceed3b0b7ae30ed
| 6,300
|
cpp
|
C++
|
src/orbital/graphics/Graphics.cpp
|
JohannesMP/orbital
|
9dca53deb6989fbe4c5171c4e9517c2e548ea3fa
|
[
"MIT"
] | null | null | null |
src/orbital/graphics/Graphics.cpp
|
JohannesMP/orbital
|
9dca53deb6989fbe4c5171c4e9517c2e548ea3fa
|
[
"MIT"
] | null | null | null |
src/orbital/graphics/Graphics.cpp
|
JohannesMP/orbital
|
9dca53deb6989fbe4c5171c4e9517c2e548ea3fa
|
[
"MIT"
] | 1
|
2018-10-23T23:53:00.000Z
|
2018-10-23T23:53:00.000Z
|
//
// Created by jim on 24.01.18.
//
#include "Graphics.h"
#include <glm/gtx/matrix_transform_2d.hpp>
#include <orbital/math/elementary.h>
#include <orbital/common/convert.h>
Graphics::Graphics(
size_t const rows,
size_t cols
)
{
if (0 == rows)
{
throw std::runtime_error{"graphics cannot have 0 rows"};
}
if (0 == cols)
{
cols = static_cast<size_t>(rows / charRatio());
}
mScanlines.resize(rows);
for (auto &scanline : mScanlines)
{
scanline.resize(cols);
}
clear();
// Span over whole viewport
mProjection = glm::scale(mat{1}, {cols / 2.0, rows / 2.0});
// Origin should sit in the center
mProjection = glm::translate(mProjection, {1, 1});
// Y-Axis should point upwards
mProjection = glm::scale(mProjection, {1, -1});
// Scale against viewport distort
mProjection = glm::scale(mProjection, {rows / static_cast<Decimal>(cols) / charRatio(), 1});
push();
updateTransform();
}
void
Graphics::clear()
{
for (auto &scanline : mScanlines)
{
std::fill(scanline.begin(), scanline.end(), ' ');
}
}
void
Graphics::pixel(
WorldVector const &worldVector,
char const c
)
{
FramebufferVector vec = mapToFramebuffer(worldVector);
if (!withinFramebufferBounds(vec))
{
return;
}
char &target = framebufferPixel(FramebufferLocation{vec});
if (mOverwrite || (!mOverwrite && ' ' == target))
{
target = c;
}
}
void
Graphics::label(
WorldVector const &worldVector,
std::string_view const &text
)
{
auto vec = mapToFramebuffer(worldVector);
if (!withinFramebufferBounds(vec))
{
return;
}
FramebufferLocation loc{vec};
// If text length exceeds scanline length from a given column,
// the text must be trimmed to a smaller size to avoid:
auto span = std::min(text.length(), columns() - loc.x);
if (mOverwrite)
{
// Simply copy the whole text into framebuffer:
std::copy(text.begin(), text.begin() + span, mScanlines[loc.y].begin() + loc.x);
}
else
{
for (int i = 0; i < span; i++)
{
char &target = framebufferPixel(loc);
if (' ' == target)
{
target = text[i];
}
}
}
}
FramebufferVector
Graphics::mapToFramebuffer(
WorldVector const &vec
)
{
return mTransform * vec3{vec, 1.0};
}
Graphics::WorldVector
Graphics::mapToWorld(
FramebufferVector const &vec
)
{
return glm::inverse(mTransform) * vec3{vec, 1.0};
}
void
Graphics::border()
{
for (std::string &scanline : mScanlines)
{
scanline.front() = scanline.back() = '|';
}
std::fill(mScanlines.front().begin() + 1, mScanlines.front().end() - 1, '-');
std::fill(mScanlines.back().begin() + 1, mScanlines.back().end() - 1, '-');
mScanlines.front().front() = '+';
mScanlines.front().back() = '+';
mScanlines.back().front() = '+';
mScanlines.back().back() = '+';
}
void
Graphics::translate(
WorldVector const &v
)
{
mTransformStack.back().translate(v);
updateTransform();
}
void
Graphics::scale(
Decimal const s
)
{
mTransformStack.back().scale(s);
updateTransform();
}
void
Graphics::rotate(
Radian<Decimal> const theta
)
{
mTransformStack.back().rotate(theta);
updateTransform();
}
void
Graphics::updateTransform()
{
mat view{1};
for (auto transform : mTransformStack)
{
view *= transform.transformation();
}
mTransform = mProjection * view;
}
std::size_t
Graphics::columns() const
{
return static_cast<int>(mScanlines[0].length());
}
void
Graphics::resetTransform()
{
mTransformStack.back().reset();
updateTransform();
}
void
Graphics::present()
{
for (auto &scanline : mScanlines)
{
std::cout << scanline << '\n';
}
std::cout << std::flush;
}
bool
Graphics::withinFramebufferBounds(
const FramebufferVector &v
) const
{
return v.y >= 0 && v.y < rows() && v.x >= 0 && v.x < columns();
}
void
Graphics::push()
{
mTransformStack.emplace_back();
}
void
Graphics::pop()
{
mTransformStack.pop_back();
updateTransform();
}
mat const &
Graphics::transformation()
{
return mTransform;
}
void
Graphics::ellipse(const Ellipse<Decimal> &ellipse)
{
// Skip ellipse rendering if the viewport is completely contained by the ellipse shape,
// i.e. no lines are visible anyway.
vec ll = mapToWorld({0, rows() - 1});
vec ur = mapToWorld({columns() - 1, 0});
if (ellipse.contains(Rectangle<Decimal>{ll, ur}))
{
return;
}
// Since the stepper calculates the pixel distance based on vector subtraction and *not* on ellipse arc length,
// the ellipse must be divided into 4 quarters
stepper(ellipse, 0_pi, 0.5_pi);
stepper(ellipse, 0.5_pi, 1_pi);
stepper(ellipse, 1_pi, 1.5_pi);
stepper(ellipse, 1.5_pi, 2_pi);
}
void
Graphics::stepper(
const Ellipse<Decimal> &ellipse,
Radian<Decimal> const ts,
Radian<Decimal> const te
)
{
// Calculate distance the painted pixels of the start and end arc would have within the framebuffer:
auto const vs = convert<WorldVector>(ellipse.point(ts));
auto const ve = convert<WorldVector>(ellipse.point(te));
Decimal const d = vectorDistance(mapToFramebuffer(ve), mapToFramebuffer(vs));
// 1.4142... is the distance between to diagonal pixels:
if (1.5 < d)
{
// Distance between painted pixels in framebuffers spans over at least one pixel,
// continue stepping in smaller steps:
Radian<Decimal> const ta = average(ts, te);
stepper(ellipse, ts, ta);
stepper(ellipse, ta, te);
}
else
{
// Paint pixel:
pixel(vs, '+');
}
}
void
Graphics::overwrite(
bool const b
)
{
mOverwrite = b;
}
std::size_t
Graphics::rows() const
{
return static_cast<int>(mScanlines.size());
}
char &
Graphics::framebufferPixel(
const FramebufferLocation &loc
)
{
return mScanlines.at(loc.y).at(loc.x);
}
char const &
Graphics::framebufferPixel(
FramebufferLocation const &loc
) const
{
return mScanlines.at(loc.y).at(loc.x);
}
| 20.257235
| 115
| 0.61
|
JohannesMP
|
7d661387415c9fd340937d5049995710e681adb0
| 2,017
|
inl
|
C++
|
Common/DyMath/Include/Math/Common/Inline/XGlobalUtilities/GetBiggerType.inl
|
liliilli/DianYing
|
6e19f67e5d932e346a0ce63a648bed1a04ef618e
|
[
"MIT"
] | 4
|
2019-03-17T19:46:54.000Z
|
2019-12-09T20:11:01.000Z
|
Common/DyMath/Include/Math/Common/Inline/XGlobalUtilities/GetBiggerType.inl
|
liliilli/DianYing
|
6e19f67e5d932e346a0ce63a648bed1a04ef618e
|
[
"MIT"
] | 11
|
2019-06-09T13:53:27.000Z
|
2020-02-09T09:47:28.000Z
|
Common/DyMath/Include/Math/Common/Inline/XGlobalUtilities/GetBiggerType.inl
|
liliilli/DianYing
|
6e19f67e5d932e346a0ce63a648bed1a04ef618e
|
[
"MIT"
] | 1
|
2019-06-04T15:20:18.000Z
|
2019-06-04T15:20:18.000Z
|
#pragma once
///
/// MIT License
/// Copyright (c) 2018-2019 Jongmin Yun
///
/// 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.
///
namespace dy::math
{
template <typename TLeft, typename TRight, typename = void>
struct GetBiggerType_T;
template <typename TLeft, typename TRight>
struct GetBiggerType_T<
TLeft, TRight,
std::enable_if_t<kCategoryOf<TLeft> == kCategoryOf<TRight>>> final
{
static constexpr auto kCategory = kCategoryOf<TLeft>;
static constexpr auto kLeftSize = sizeof(TLeft) * 8;
static constexpr auto kRightSize = sizeof(TRight) * 8;
static constexpr auto kBiggerSize = kLeftSize > kRightSize ? kLeftSize : kRightSize;
using Type = typename GetCoverableTypeOf<kCategory, kBiggerSize>::Type;
};
template <typename TLeftType, typename TRightType>
struct GetBiggerType_T<
TLeftType, TRightType,
std::enable_if_t<
(kCategoryOf<TLeftType> == EValueCategory::Real)
^ (kCategoryOf<TRightType> == EValueCategory::Real)>> final
{
static constexpr EValueCategory kLeftCategory = kCategoryOf<TLeftType>;
static constexpr EValueCategory kRightCategory = kCategoryOf<TRightType>;
static constexpr auto kLeftSize = sizeof(TLeftType) * 8;
static constexpr auto kRightSize = sizeof(TRightType) * 8;
static constexpr auto kBiggerSize = kLeftSize > kRightSize ? kLeftSize : kRightSize;
using Type = std::conditional_t<
kLeftCategory == EValueCategory::Real,
typename GetCoverableTypeOf<kLeftCategory, kBiggerSize>::Type,
typename GetCoverableTypeOf<kRightCategory, kBiggerSize>::Type>;
};
} /// ::dy::math namespace
| 38.056604
| 86
| 0.752603
|
liliilli
|
de097b69e3439a94ca773bf913638ce2add4e97a
| 115,226
|
cpp
|
C++
|
Source/Decoda/Decoda/LuaInject/LuaDll.cpp
|
KoSukeWork/BabeLua
|
0904f8ba15174fcfe88d75e37349c4f4f15403ef
|
[
"MIT"
] | null | null | null |
Source/Decoda/Decoda/LuaInject/LuaDll.cpp
|
KoSukeWork/BabeLua
|
0904f8ba15174fcfe88d75e37349c4f4f15403ef
|
[
"MIT"
] | null | null | null |
Source/Decoda/Decoda/LuaInject/LuaDll.cpp
|
KoSukeWork/BabeLua
|
0904f8ba15174fcfe88d75e37349c4f4f15403ef
|
[
"MIT"
] | 1
|
2020-12-07T13:47:47.000Z
|
2020-12-07T13:47:47.000Z
|
/*
Decoda
Copyright (C) 2007-2013 Unknown Worlds Entertainment, Inc.
This file is part of Decoda.
Decoda 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.
Decoda 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 Decoda. If not, see <http://www.gnu.org/licenses/>.
*/
#include "LuaDll.h"
#include "Hook.h"
#include "DebugBackend.h"
#include "StdCall.h"
#include "CriticalSection.h"
#include "CriticalSectionLock.h"
#include "DebugHelp.h"
#include <windows.h>
#include <tlhelp32.h>
#include <psapi.h>
#include <windows.h>
#include <malloc.h>
#include <assert.h>
#include <set>
#include <hash_map>
#include <hash_set>
// Macro for convenient pointer addition.
// Essentially treats the last two parameters as DWORDs. The first
// parameter is used to typecast the result to the appropriate pointer type.
#define MAKE_PTR(cast, ptr, addValue ) (cast)( (DWORD)(ptr)+(DWORD)(addValue))
// When this is defined, additional information about what's going on will be
// output for debugging.
//#define VERBOSE
//#define LOG
typedef const char* (__stdcall *lua_Reader_stdcall) (lua_State*, void*, size_t*);
typedef void (__stdcall *lua_Hook_stdcall) (lua_State*, lua_Debug*);
typedef lua_State* (*lua_open_cdecl_t) (int stacksize);
typedef lua_State* (*lua_open_500_cdecl_t) ();
typedef lua_State* (*lua_newstate_cdecl_t) (lua_Alloc, void*);
typedef void (*lua_close_cdecl_t) (lua_State*);
typedef lua_State* (*lua_newthread_cdecl_t) (lua_State*);
typedef int (*lua_error_cdecl_t) (lua_State*);
typedef int (*lua_sethook_cdecl_t) (lua_State*, lua_Hook, int, int);
typedef int (*lua_gethookmask_cdecl_t) (lua_State*);
typedef int (*lua_getinfo_cdecl_t) (lua_State*, const char*, lua_Debug* ar);
typedef void (*lua_remove_cdecl_t) (lua_State*, int);
typedef void (*lua_settable_cdecl_t) (lua_State*, int);
typedef void (*lua_gettable_cdecl_t) (lua_State*, int);
typedef void (*lua_rawget_cdecl_t) (lua_State *L, int idx);
typedef void (*lua_rawgeti_cdecl_t) (lua_State *L, int idx, int n);
typedef void (*lua_rawset_cdecl_t) (lua_State *L, int idx);
typedef void (*lua_pushstring_cdecl_t) (lua_State*, const char*);
typedef void (*lua_pushlstring_cdecl_t) (lua_State*, const char*, size_t);
typedef int (*lua_type_cdecl_t) (lua_State*, int);
typedef const char* (*lua_typename_cdecl_t) (lua_State*, int);
typedef void (*lua_settop_cdecl_t) (lua_State*, int);
typedef const char* (*lua_getlocal_cdecl_t) (lua_State*, const lua_Debug*, int);
typedef const char* (*lua_setlocal_cdecl_t) (lua_State*, const lua_Debug*, int);
typedef int (*lua_getstack_cdecl_t) (lua_State*, int, lua_Debug*);
typedef void (*lua_insert_cdecl_t) (lua_State*, int);
typedef void (*lua_pushnil_cdecl_t) (lua_State*);
typedef void (*lua_pushcclosure_cdecl_t) (lua_State*, lua_CFunction, int);
typedef void (*lua_pushvalue_cdecl_t) (lua_State*, int);
typedef void (*lua_pushinteger_cdecl_t) (lua_State*, int);
typedef void (*lua_pushnumber_cdecl_t) (lua_State*, lua_Number);
typedef const char* (*lua_tostring_cdecl_t) (lua_State*, int);
typedef const char* (*lua_tolstring_cdecl_t) (lua_State*, int, size_t*);
typedef int (*lua_toboolean_cdecl_t) (lua_State*, int);
typedef int (*lua_tointeger_cdecl_t) (lua_State*, int);
typedef lua_Integer (*lua_tointegerx_cdecl_t) (lua_State*, int, int*);
typedef lua_CFunction (*lua_tocfunction_cdecl_t) (lua_State*, int);
typedef lua_Number (*lua_tonumber_cdecl_t) (lua_State*, int);
typedef lua_Number (*lua_tonumberx_cdecl_t) (lua_State*, int, int*);
typedef void* (*lua_touserdata_cdecl_t) (lua_State*, int);
typedef int (*lua_gettop_cdecl_t) (lua_State*);
typedef int (*lua_load_cdecl_t) (lua_State*, lua_Reader, void*, const char *chunkname);
typedef void (*lua_call_cdecl_t) (lua_State*, int, int);
typedef void (*lua_callk_cdecl_t) (lua_State*, int, int, int, lua_CFunction);
typedef int (*lua_pcall_cdecl_t) (lua_State*, int, int, int);
typedef int (*lua_pcallk_cdecl_t) (lua_State*, int, int, int, int, lua_CFunction);
typedef void (*lua_newtable_cdecl_t) (lua_State*);
typedef void (*lua_createtable_cdecl_t) (lua_State*, int, int);
typedef int (*lua_next_cdecl_t) (lua_State*, int);
typedef int (*lua_rawequal_cdecl_t) (lua_State *L, int idx1, int idx2);
typedef int (*lua_getmetatable_cdecl_t) (lua_State*, int objindex);
typedef int (*lua_setmetatable_cdecl_t) (lua_State*, int objindex);
typedef int (*luaL_ref_cdecl_t) (lua_State *L, int t);
typedef void (*luaL_unref_cdecl_t) (lua_State *L, int t, int ref);
typedef int (*luaL_newmetatable_cdecl_t) (lua_State *L, const char *tname);
typedef int (*luaL_loadbuffer_cdecl_t) (lua_State *L, const char *buff, size_t sz, const char *name);
typedef int (*luaL_loadfile_cdecl_t) (lua_State *L, const char *fileName);
typedef const lua_WChar* (*lua_towstring_cdecl_t) (lua_State *L, int index);
typedef int (*lua_iswstring_cdecl_t) (lua_State *L, int index);
typedef const char* (*lua_getupvalue_cdecl_t) (lua_State *L, int funcindex, int n);
typedef const char* (*lua_setupvalue_cdecl_t) (lua_State *L, int funcindex, int n);
typedef void (*lua_getfenv_cdecl_t) (lua_State *L, int index);
typedef int (*lua_setfenv_cdecl_t) (lua_State *L, int index);
typedef void (*lua_pushlightuserdata_cdecl_t)(lua_State *L, void *p);
typedef int (*lua_cpcall_cdecl_t) (lua_State *L, lua_CFunction func, void *ud);
typedef int (*lua_pushthread_cdecl_t) (lua_State *L);
typedef void * (*lua_newuserdata_cdecl_t) (lua_State *L, size_t size);
typedef lua_State* (*luaL_newstate_cdecl_t) ();
typedef int (*lua_checkstack_cdecl_t) (lua_State* L, int extra);
typedef lua_State* (__stdcall *lua_open_stdcall_t) (int stacksize);
typedef lua_State* (__stdcall *lua_open_500_stdcall_t) ();
typedef lua_State* (__stdcall *lua_newstate_stdcall_t) (lua_Alloc, void*);
typedef void (__stdcall *lua_close_stdcall_t) (lua_State*);
typedef lua_State* (__stdcall *lua_newthread_stdcall_t) (lua_State*);
typedef int (__stdcall *lua_error_stdcall_t) (lua_State*);
typedef int (__stdcall *lua_sethook_stdcall_t) (lua_State*, lua_Hook_stdcall, int, int);
typedef int (__stdcall *lua_gethookmaskstdcall_t) (lua_State*);
typedef int (__stdcall *lua_getinfo_stdcall_t) (lua_State*, const char*, lua_Debug* ar);
typedef void (__stdcall *lua_remove_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_settable_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_gettable_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_rawget_stdcall_t) (lua_State *L, int idx);
typedef void (__stdcall *lua_rawgeti_stdcall_t) (lua_State *L, int idx, int n);
typedef void (__stdcall *lua_rawset_stdcall_t) (lua_State *L, int idx);
typedef void (__stdcall *lua_pushstring_stdcall_t) (lua_State*, const char*);
typedef void (__stdcall *lua_pushlstring_stdcall_t) (lua_State*, const char*, size_t);
typedef int (__stdcall *lua_type_stdcall_t) (lua_State*, int);
typedef const char* (__stdcall *lua_typename_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_settop_stdcall_t) (lua_State*, int);
typedef const char* (__stdcall *lua_getlocal_stdcall_t) (lua_State*, const lua_Debug*, int);
typedef const char* (__stdcall *lua_setlocal_stdcall_t) (lua_State*, const lua_Debug*, int);
typedef int (__stdcall *lua_getstack_stdcall_t) (lua_State*, int, lua_Debug*);
typedef void (__stdcall *lua_insert_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_pushnil_stdcall_t) (lua_State*);
typedef void (__stdcall *lua_pushcclosure_stdcall_t) (lua_State*, lua_CFunction, int);
typedef void (__stdcall *lua_pushvalue_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_pushinteger_stdcall_t) (lua_State*, int);
typedef void (__stdcall *lua_pushnumber_stdcall_t) (lua_State*, lua_Number);
typedef const char* (__stdcall *lua_tostring_stdcall_t) (lua_State*, int);
typedef const char* (__stdcall *lua_tolstring_stdcall_t) (lua_State*, int, size_t*);
typedef int (__stdcall *lua_toboolean_stdcall_t) (lua_State*, int);
typedef int (__stdcall *lua_tointeger_stdcall_t) (lua_State*, int);
typedef lua_Integer (__stdcall *lua_tointegerx_stdcall_t) (lua_State*, int, int*);
typedef lua_CFunction (__stdcall *lua_tocfunction_stdcall_t) (lua_State*, int);
typedef lua_Number (__stdcall *lua_tonumber_stdcall_t) (lua_State*, int);
typedef lua_Number (__stdcall *lua_tonumberx_stdcall_t) (lua_State*, int, int*);
typedef void* (__stdcall *lua_touserdata_stdcall_t) (lua_State*, int);
typedef int (__stdcall *lua_gettop_stdcall_t) (lua_State*);
typedef int (__stdcall *lua_load_stdcall_t) (lua_State*, lua_Reader_stdcall, void*, const char *chunkname);
typedef void (__stdcall *lua_call_stdcall_t) (lua_State*, int, int);
typedef void (__stdcall *lua_callk_stdcall_t) (lua_State*, int, int, int, lua_CFunction);
typedef int (__stdcall *lua_pcall_stdcall_t) (lua_State*, int, int, int);
typedef int (__stdcall *lua_pcallk_stdcall_t) (lua_State*, int, int, int, int, lua_CFunction);
typedef void (__stdcall *lua_newtable_stdcall_t) (lua_State*);
typedef void (__stdcall *lua_createtable_stdcall_t) (lua_State*, int, int);
typedef int (__stdcall *lua_next_stdcall_t) (lua_State*, int);
typedef int (__stdcall *lua_rawequal_stdcall_t) (lua_State *L, int idx1, int idx2);
typedef int (__stdcall *lua_getmetatable_stdcall_t) (lua_State*, int objindex);
typedef int (__stdcall *lua_setmetatable_stdcall_t) (lua_State*, int objindex);
typedef int (__stdcall *luaL_ref_stdcall_t) (lua_State *L, int t);
typedef void (__stdcall *luaL_unref_stdcall_t) (lua_State *L, int t, int ref);
typedef int (__stdcall *luaL_newmetatable_stdcall_t) (lua_State *L, const char *tname);
typedef int (__stdcall *luaL_loadbuffer_stdcall_t) (lua_State *L, const char *buff, size_t sz, const char *name);
typedef int (__stdcall *luaL_loadfile_stdcall_t) (lua_State *L, const char *fileName);
typedef const lua_WChar* (__stdcall *lua_towstring_stdcall_t) (lua_State *L, int index);
typedef int (__stdcall *lua_iswstring_stdcall_t) (lua_State *L, int index);
typedef const char* (__stdcall *lua_getupvalue_stdcall_t) (lua_State *L, int funcindex, int n);
typedef const char* (__stdcall *lua_setupvalue_stdcall_t) (lua_State *L, int funcindex, int n);
typedef void (__stdcall *lua_getfenv_stdcall_t) (lua_State *L, int index);
typedef int (__stdcall *lua_setfenv_stdcall_t) (lua_State *L, int index);
typedef void (__stdcall *lua_pushlightuserdata_stdcall_t)(lua_State *L, void *p);
typedef int (__stdcall *lua_cpcall_stdcall_t) (lua_State *L, lua_CFunction func, void *ud);
typedef int (__stdcall *lua_pushthread_stdcall_t) (lua_State *L);
typedef void * (__stdcall *lua_newuserdata_stdcall_t) (lua_State *L, size_t size);
typedef lua_State* (__stdcall *luaL_newstate_stdcall_t) ();
typedef int (__stdcall *lua_checkstack_stdcall_t) (lua_State* L, int extra);
typedef HMODULE (WINAPI *LoadLibraryExW_t) (LPCWSTR lpFileName, HANDLE hFile, DWORD dwFlags);
typedef ULONG (WINAPI *LdrLockLoaderLock_t) (ULONG flags, PULONG disposition, PULONG cookie);
typedef LONG (WINAPI *LdrUnlockLoaderLock_t) (ULONG flags, ULONG cookie);
/**
* Structure that holds pointers to all of the Lua API functions.
*/
struct LuaInterface
{
int version; // One of 401, 500, 510
bool finishedLoading;
bool stdcall;
// Use these instead of the LUA_* constants in lua.h. The value of these
// change depending on the version of Lua we're using.
int registryIndex;
int globalsIndex;
// cdecl functions.
lua_open_cdecl_t lua_open_dll_cdecl;
lua_open_500_cdecl_t lua_open_500_dll_cdecl;
lua_newstate_cdecl_t lua_newstate_dll_cdecl;
lua_close_cdecl_t lua_close_dll_cdecl;
lua_newthread_cdecl_t lua_newthread_dll_cdecl;
lua_error_cdecl_t lua_error_dll_cdecl;
lua_gettop_cdecl_t lua_gettop_dll_cdecl;
lua_sethook_cdecl_t lua_sethook_dll_cdecl;
lua_gethookmask_cdecl_t lua_gethookmask_dll_cdecl;
lua_getinfo_cdecl_t lua_getinfo_dll_cdecl;
lua_remove_cdecl_t lua_remove_dll_cdecl;
lua_settable_cdecl_t lua_settable_dll_cdecl;
lua_gettable_cdecl_t lua_gettable_dll_cdecl;
lua_rawget_cdecl_t lua_rawget_dll_cdecl;
lua_rawgeti_cdecl_t lua_rawgeti_dll_cdecl;
lua_rawset_cdecl_t lua_rawset_dll_cdecl;
lua_pushstring_cdecl_t lua_pushstring_dll_cdecl;
lua_pushlstring_cdecl_t lua_pushlstring_dll_cdecl;
lua_type_cdecl_t lua_type_dll_cdecl;
lua_typename_cdecl_t lua_typename_dll_cdecl;
lua_settop_cdecl_t lua_settop_dll_cdecl;
lua_getlocal_cdecl_t lua_getlocal_dll_cdecl;
lua_setlocal_cdecl_t lua_setlocal_dll_cdecl;
lua_getstack_cdecl_t lua_getstack_dll_cdecl;
lua_insert_cdecl_t lua_insert_dll_cdecl;
lua_pushnil_cdecl_t lua_pushnil_dll_cdecl;
lua_pushvalue_cdecl_t lua_pushvalue_dll_cdecl;
lua_pushinteger_cdecl_t lua_pushinteger_dll_cdecl;
lua_pushnumber_cdecl_t lua_pushnumber_dll_cdecl;
lua_pushcclosure_cdecl_t lua_pushcclosure_dll_cdecl;
lua_tostring_cdecl_t lua_tostring_dll_cdecl;
lua_tolstring_cdecl_t lua_tolstring_dll_cdecl;
lua_toboolean_cdecl_t lua_toboolean_dll_cdecl;
lua_tointeger_cdecl_t lua_tointeger_dll_cdecl;
lua_tointegerx_cdecl_t lua_tointegerx_dll_cdecl;
lua_tocfunction_cdecl_t lua_tocfunction_dll_cdecl;
lua_tonumber_cdecl_t lua_tonumber_dll_cdecl;
lua_tonumberx_cdecl_t lua_tonumberx_dll_cdecl;
lua_touserdata_cdecl_t lua_touserdata_dll_cdecl;
lua_load_cdecl_t lua_load_dll_cdecl;
lua_call_cdecl_t lua_call_dll_cdecl;
lua_callk_cdecl_t lua_callk_dll_cdecl;
lua_pcall_cdecl_t lua_pcall_dll_cdecl;
lua_pcallk_cdecl_t lua_pcallk_dll_cdecl;
lua_newtable_cdecl_t lua_newtable_dll_cdecl;
lua_createtable_cdecl_t lua_createtable_dll_cdecl;
lua_next_cdecl_t lua_next_dll_cdecl;
lua_rawequal_cdecl_t lua_rawequal_dll_cdecl;
lua_getmetatable_cdecl_t lua_getmetatable_dll_cdecl;
lua_setmetatable_cdecl_t lua_setmetatable_dll_cdecl;
luaL_ref_cdecl_t luaL_ref_dll_cdecl;
luaL_unref_cdecl_t luaL_unref_dll_cdecl;
luaL_newmetatable_cdecl_t luaL_newmetatable_dll_cdecl;
luaL_loadbuffer_cdecl_t luaL_loadbuffer_dll_cdecl;
luaL_loadfile_cdecl_t luaL_loadfile_dll_cdecl;
lua_towstring_cdecl_t lua_towstring_dll_cdecl;
lua_iswstring_cdecl_t lua_iswstring_dll_cdecl;
lua_getupvalue_cdecl_t lua_getupvalue_dll_cdecl;
lua_setupvalue_cdecl_t lua_setupvalue_dll_cdecl;
lua_getfenv_cdecl_t lua_getfenv_dll_cdecl;
lua_setfenv_cdecl_t lua_setfenv_dll_cdecl;
lua_pushlightuserdata_cdecl_t lua_pushlightuserdata_dll_cdecl;
lua_cpcall_cdecl_t lua_cpcall_dll_cdecl;
lua_pushthread_cdecl_t lua_pushthread_dll_cdecl;
lua_newuserdata_cdecl_t lua_newuserdata_dll_cdecl;
luaL_newstate_cdecl_t luaL_newstate_dll_cdecl;
lua_checkstack_cdecl_t lua_checkstack_dll_cdecl;
// stdcall functions.
lua_open_stdcall_t lua_open_dll_stdcall;
lua_open_500_stdcall_t lua_open_500_dll_stdcall;
lua_newstate_stdcall_t lua_newstate_dll_stdcall;
lua_close_stdcall_t lua_close_dll_stdcall;
lua_newthread_stdcall_t lua_newthread_dll_stdcall;
lua_error_stdcall_t lua_error_dll_stdcall;
lua_gettop_stdcall_t lua_gettop_dll_stdcall;
lua_sethook_stdcall_t lua_sethook_dll_stdcall;
lua_gethookmaskstdcall_t lua_gethookmask_dll_stdcall;
lua_getinfo_stdcall_t lua_getinfo_dll_stdcall;
lua_remove_stdcall_t lua_remove_dll_stdcall;
lua_settable_stdcall_t lua_settable_dll_stdcall;
lua_gettable_stdcall_t lua_gettable_dll_stdcall;
lua_rawget_stdcall_t lua_rawget_dll_stdcall;
lua_rawgeti_stdcall_t lua_rawgeti_dll_stdcall;
lua_rawset_stdcall_t lua_rawset_dll_stdcall;
lua_pushstring_stdcall_t lua_pushstring_dll_stdcall;
lua_pushlstring_stdcall_t lua_pushlstring_dll_stdcall;
lua_type_stdcall_t lua_type_dll_stdcall;
lua_typename_stdcall_t lua_typename_dll_stdcall;
lua_settop_stdcall_t lua_settop_dll_stdcall;
lua_getlocal_stdcall_t lua_getlocal_dll_stdcall;
lua_setlocal_stdcall_t lua_setlocal_dll_stdcall;
lua_getstack_stdcall_t lua_getstack_dll_stdcall;
lua_insert_stdcall_t lua_insert_dll_stdcall;
lua_pushnil_stdcall_t lua_pushnil_dll_stdcall;
lua_pushvalue_stdcall_t lua_pushvalue_dll_stdcall;
lua_pushinteger_stdcall_t lua_pushinteger_dll_stdcall;
lua_pushnumber_stdcall_t lua_pushnumber_dll_stdcall;
lua_pushcclosure_stdcall_t lua_pushcclosure_dll_stdcall;
lua_tostring_stdcall_t lua_tostring_dll_stdcall;
lua_tolstring_stdcall_t lua_tolstring_dll_stdcall;
lua_toboolean_stdcall_t lua_toboolean_dll_stdcall;
lua_tointeger_stdcall_t lua_tointeger_dll_stdcall;
lua_tointegerx_stdcall_t lua_tointegerx_dll_stdcall;
lua_tocfunction_stdcall_t lua_tocfunction_dll_stdcall;
lua_tonumber_stdcall_t lua_tonumber_dll_stdcall;
lua_tonumberx_stdcall_t lua_tonumberx_dll_stdcall;
lua_touserdata_stdcall_t lua_touserdata_dll_stdcall;
lua_load_stdcall_t lua_load_dll_stdcall;
lua_call_stdcall_t lua_call_dll_stdcall;
lua_callk_stdcall_t lua_callk_dll_stdcall;
lua_pcall_stdcall_t lua_pcall_dll_stdcall;
lua_pcallk_stdcall_t lua_pcallk_dll_stdcall;
lua_newtable_stdcall_t lua_newtable_dll_stdcall;
lua_createtable_stdcall_t lua_createtable_dll_stdcall;
lua_next_stdcall_t lua_next_dll_stdcall;
lua_rawequal_stdcall_t lua_rawequal_dll_stdcall;
lua_getmetatable_stdcall_t lua_getmetatable_dll_stdcall;
lua_setmetatable_stdcall_t lua_setmetatable_dll_stdcall;
luaL_ref_stdcall_t luaL_ref_dll_stdcall;
luaL_unref_stdcall_t luaL_unref_dll_stdcall;
luaL_newmetatable_stdcall_t luaL_newmetatable_dll_stdcall;
luaL_loadbuffer_stdcall_t luaL_loadbuffer_dll_stdcall;
luaL_loadfile_stdcall_t luaL_loadfile_dll_stdcall;
lua_towstring_stdcall_t lua_towstring_dll_stdcall;
lua_iswstring_stdcall_t lua_iswstring_dll_stdcall;
lua_getupvalue_stdcall_t lua_getupvalue_dll_stdcall;
lua_setupvalue_stdcall_t lua_setupvalue_dll_stdcall;
lua_getfenv_stdcall_t lua_getfenv_dll_stdcall;
lua_setfenv_stdcall_t lua_setfenv_dll_stdcall;
lua_pushlightuserdata_stdcall_t lua_pushlightuserdata_dll_stdcall;
lua_cpcall_stdcall_t lua_cpcall_dll_stdcall;
lua_pushthread_stdcall_t lua_pushthread_dll_stdcall;
lua_newuserdata_stdcall_t lua_newuserdata_dll_stdcall;
luaL_newstate_stdcall_t luaL_newstate_dll_stdcall;
lua_checkstack_stdcall_t lua_checkstack_dll_stdcall;
lua_CFunction DecodaOutput;
lua_CFunction CPCallHandler;
lua_Hook HookHandler;
};
struct CPCallHandlerArgs
{
lua_CFunction_dll function;
void* data;
};
/**
* This macro outputs the prolog code for a naked intercept function. It
* should be the first code in the function.
*/
#define INTERCEPT_PROLOG() \
__asm \
{ \
__asm push ebp \
__asm mov ebp, esp \
__asm sub esp, __LOCAL_SIZE \
}
/**
* This macro outputs the epilog code for a naked intercept function. It
* should be the last code in the function. argsSize is the number of
* bytes for the argments to the function (not including the the api parameter).
* The return from the function should be stored in the "result" variable, and
* the "stdcall" bool variable determines if the function was called using the
* stdcall or cdecl calling convention.
*/
#define INTERCEPT_EPILOG(argsSize) \
__asm \
{ \
__asm mov eax, result \
__asm cmp stdcall, 0 \
__asm mov esp, ebp \
__asm pop ebp \
__asm jne stdcall_ret \
__asm ret 4 \
__asm stdcall_ret: \
__asm ret (4 + argsSize) \
}
/**
* This macro outputs the epilog code for a naked intercept function that doesn't
* have a return value. It should be the last code in the function. argsSize is the
* number of bytes for the argments to the function (not including the the api
* parameter). The "stdcall" bool variable determines if the function was called using
* the stdcall or cdecl calling convention.
*/
#define INTERCEPT_EPILOG_NO_RETURN(argsSize) \
__asm \
{ \
__asm cmp stdcall, 0 \
__asm mov esp, ebp \
__asm pop ebp \
__asm jne stdcall_ret \
__asm ret 4 \
__asm stdcall_ret: \
__asm ret (4 + argsSize) \
}
LoadLibraryExW_t LoadLibraryExW_dll = NULL;
LdrLockLoaderLock_t LdrLockLoaderLock_dll = NULL;
LdrUnlockLoaderLock_t LdrUnlockLoaderLock_dll = NULL;
bool g_loadedLuaFunctions = false;
std::set<std::string> g_loadedModules;
CriticalSection g_loadedModulesCriticalSection;
std::vector<LuaInterface> g_interfaces;
stdext::hash_map<void*, void*> g_hookedFunctionMap;
stdext::hash_set<std::string> g_warnedAboutLua; // Indivates that we've warned the module contains Lua functions but none were loaded.
stdext::hash_set<std::string> g_warnedAboutPdb; // Indicates that we've warned about a module having a mismatched PDB.
bool g_warnedAboutThreads = false;
bool g_warnedAboutJit = false;
std::string g_symbolsDirectory;
static DWORD g_disableInterceptIndex = 0;
bool g_initializedDebugHelp = false;
/**
* Function called after a library has been loaded by the host application.
* We use this to check for the Lua dll.
*/
void PostLoadLibrary(HMODULE hModule);
/**
* Data structure passed into the MemoryReader function.
*/
struct Memory
{
const char* buffer;
size_t size;
};
/**
* lua_Reader function used to read from a memory buffer.
*/
const char* MemoryReader_cdecl(lua_State* L, void* data, size_t* size)
{
Memory* memory = static_cast<Memory*>(data);
if (memory->size > 0)
{
*size = memory->size;
memory->size = 0;
return memory->buffer;
}
else
{
return NULL;
}
}
/**
* lua_Reader function used to read from a memory buffer.
*/
const char* __stdcall MemoryReader_stdcall(lua_State* L, void* data, size_t* size)
{
Memory* memory = static_cast<Memory*>(data);
if (memory->size > 0)
{
*size = memory->size;
memory->size = 0;
return memory->buffer;
}
else
{
return NULL;
}
}
#pragma auto_inline(off)
int DecodaOutputWorker(unsigned long api, lua_State* L, bool& stdcall)
{
stdcall = g_interfaces[api].stdcall;
const char* message = lua_tostring_dll(api, L, 1);
// DebugBackend::Get().Message(message);
std::string outputMessage = "[LUA print] ";
outputMessage += message;
DebugBackend::Get().Message(outputMessage.c_str());
return 0;
}
#pragma auto_inline()
__declspec(naked) int DecodaOutput(unsigned long api, lua_State* L)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
result = DecodaOutputWorker(api, L, stdcall);
INTERCEPT_EPILOG(4)
}
#pragma auto_inline(off)
int CPCallHandlerWorker(unsigned long api, lua_State* L, bool& stdcall)
{
stdcall = g_interfaces[api].stdcall;
CPCallHandlerArgs args = *static_cast<CPCallHandlerArgs*>(lua_touserdata_dll(api, L, 1));
// Remove the old args and put the new one on the stack.
lua_pop_dll(api, L, 1);
lua_pushlightuserdata_dll(api, L, args.data);
return args.function(api, L);
}
#pragma auto_inline()
__declspec(naked) int CPCallHandler(unsigned long api, lua_State* L)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
result = CPCallHandlerWorker(api, L, stdcall);
INTERCEPT_EPILOG(4)
}
int lua_cpcall_dll(unsigned long api, lua_State *L, lua_CFunction_dll func, void *udn)
{
CPCallHandlerArgs args;
args.function = func;
args.data = udn;
return lua_cpcall_dll(api, L, g_interfaces[api].CPCallHandler, &args);
}
#pragma auto_inline(off)
void HookHandlerWorker(unsigned long api, lua_State* L, lua_Debug* ar, bool& stdcall)
{
stdcall = g_interfaces[api].stdcall;
return DebugBackend::Get().HookCallback(api, L, ar);
}
#pragma auto_inline()
__declspec(naked) void HookHandler(unsigned long api, lua_State* L, lua_Debug* ar)
{
bool stdcall;
INTERCEPT_PROLOG()
HookHandlerWorker(api, L, ar, stdcall);
INTERCEPT_EPILOG_NO_RETURN(8)
}
void SetHookMode(unsigned long api, lua_State* L, HookMode mode)
{
if(mode == HookMode_None)
{
lua_sethook_dll(api, L, NULL, 0, 0);
}
else
{
int mask;
switch (mode)
{
case HookMode_CallsOnly:
mask = LUA_MASKCALL;
break;
case HookMode_CallsAndReturns:
mask = LUA_MASKCALL|LUA_MASKRET;
break;
case HookMode_Full:
mask = LUA_MASKCALL|LUA_MASKRET|LUA_MASKLINE;
break;
}
lua_sethook_dll(api, L, g_interfaces[api].HookHandler, mask, 0);
}
}
int lua_gethookmask(unsigned long api, lua_State *L)
{
if (g_interfaces[api].lua_gethookmask_dll_cdecl != NULL)
{
return g_interfaces[api].lua_gethookmask_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_gethookmask_dll_stdcall(L);
}
}
HookMode GetHookMode(unsigned long api, lua_State* L)
{
int mask = lua_gethookmask(api, L);
if(mask == 0)
{
return HookMode_None;
}
else if(mask == (LUA_MASKCALL))
{
return HookMode_CallsOnly;
}
else if(mask == (LUA_MASKCALL|LUA_MASKRET))
{
return HookMode_CallsAndReturns;
}
else
{
return HookMode_Full;
}
}
bool lua_pushthread_dll(unsigned long api, lua_State *L)
{
// These structures are taken out of the Lua 5.0 source code.
union lua_Value_500
{
void* gc;
void* p;
lua_Number n;
int b;
};
struct lua_TObject_500
{
int tt;
lua_Value_500 value;
};
struct lua_State_500
{
void* next;
unsigned char tt;
unsigned char marked;
lua_TObject_500* top;
};
#pragma pack(1)
union lua_Value_500_pack1
{
void* gc;
void* p;
lua_Number n;
int b;
};
struct lua_TObject_500_pack1
{
int tt;
lua_Value_500_pack1 value;
};
struct lua_State_500_pack1
{
void* next;
unsigned char tt;
unsigned char marked;
lua_TObject_500_pack1* top;
};
#pragma pack()
if (g_interfaces[api].lua_pushthread_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushthread_dll_cdecl(L);
return true;
}
else if (g_interfaces[api].lua_pushthread_dll_stdcall != NULL)
{
g_interfaces[api].lua_pushthread_dll_stdcall(L);
return true;
}
else
{
// The actual push thread function doesn't exist (probably Lua 5.0), so
// emulate it. The lua_pushthread function just pushes the state onto the
// stack and sets the type to LUA_TTHREAD. We use the pushlightuserdata
// function which basically does the same thing, except we need to modify the
// type of the object on the top of the stack.
lua_pushlightuserdata_dll(api, L, L);
// Check that the thing we think is pointing to the top of the stack actually
// is so that we don't overwrite something in memory.
bool success = false;
// If the structures are laid out differently in the implementation of Lua
// we might get crashes, so we wrap the access in a try block.
__try
{
lua_State_500* S = reinterpret_cast<lua_State_500*>(L);
lua_TObject_500* top = S->top - 1;
if (top->tt == LUA_TLIGHTUSERDATA && top->value.p == L)
{
top->tt = LUA_TTHREAD;
top->value.gc = L;
success = true;
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
}
if (!success)
{
// The unpacked version didn't work out right, so try the version with no alignment.
__try
{
lua_State_500_pack1* S = reinterpret_cast<lua_State_500_pack1*>(L);
lua_TObject_500_pack1* top = S->top - 1;
if (top->tt == LUA_TLIGHTUSERDATA && top->value.p == L)
{
top->tt = LUA_TTHREAD;
top->value.gc = L;
success = true;
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
}
}
if (!success)
{
lua_pop_dll(api, L, 1);
if (!g_warnedAboutThreads)
{
DebugBackend::Get().Message("Warning 1006: lua_pushthread could not be emulated due to modifications to Lua. Coroutines may be unstable", MessageType_Warning);
g_warnedAboutThreads = true;
}
}
return success;
}
}
void* lua_newuserdata_dll(unsigned long api, lua_State *L, size_t size)
{
if (g_interfaces[api].lua_newuserdata_dll_cdecl != NULL)
{
return g_interfaces[api].lua_newuserdata_dll_cdecl(L, size);
}
else
{
return g_interfaces[api].lua_newuserdata_dll_stdcall(L, size);
}
}
void EnableIntercepts(bool enableIntercepts)
{
int value = reinterpret_cast<int>(TlsGetValue(g_disableInterceptIndex));
if (enableIntercepts)
{
--value;
}
else
{
++value;
}
TlsSetValue(g_disableInterceptIndex, reinterpret_cast<LPVOID>(value));
}
bool GetAreInterceptsEnabled()
{
int value = reinterpret_cast<int>(TlsGetValue(g_disableInterceptIndex));
return value <= 0;
}
void RegisterDebugLibrary(unsigned long api, lua_State* L)
{
lua_register_dll(api, L, "decoda_output", g_interfaces[api].DecodaOutput);
}
int GetGlobalsIndex(unsigned long api)
{
return g_interfaces[api].globalsIndex;
}
int GetRegistryIndex(unsigned long api)
{
return g_interfaces[api].registryIndex;
}
int lua_abs_index_dll(unsigned long api, lua_State* L, int i)
{
if (i > 0 || i <= GetRegistryIndex(api))
{
return i;
}
else
{
return lua_gettop_dll(api, L) + i + 1;
}
}
int lua_upvalueindex_dll(unsigned long api, int i)
{
return GetGlobalsIndex(api) - i;
}
void lua_setglobal_dll(unsigned long api, lua_State* L, const char* s)
{
lua_setfield_dll(api, L, GetGlobalsIndex(api), s);
}
void lua_getglobal_dll(unsigned long api, lua_State* L, const char* s)
{
lua_getfield_dll(api, L, GetGlobalsIndex(api), s);
}
void lua_rawgetglobal_dll(unsigned long api, lua_State* L, const char* s)
{
lua_pushstring_dll(api, L, s);
lua_rawget_dll(api, L, GetGlobalsIndex(api));
}
lua_State* lua_newstate_dll(unsigned long api, lua_Alloc f, void* ud)
{
if (g_interfaces[api].lua_newstate_dll_cdecl != NULL)
{
return g_interfaces[api].lua_newstate_dll_cdecl(f, ud);
}
else if (g_interfaces[api].lua_newstate_dll_stdcall != NULL)
{
return g_interfaces[api].lua_newstate_dll_stdcall(f, ud);
}
// This is an older version of Lua that doesn't support lua_newstate, so emulate it
// with lua_open.
if (g_interfaces[api].lua_open_500_dll_cdecl != NULL)
{
return g_interfaces[api].lua_open_500_dll_cdecl();
}
else if (g_interfaces[api].lua_open_500_dll_stdcall != NULL)
{
return g_interfaces[api].lua_open_500_dll_stdcall();
}
else if (g_interfaces[api].lua_open_dll_cdecl != NULL)
{
return g_interfaces[api].lua_open_dll_cdecl(0);
}
else if (g_interfaces[api].lua_open_dll_stdcall != NULL)
{
return g_interfaces[api].lua_open_dll_stdcall(0);
}
assert(0);
return NULL;
}
void lua_close_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_close_dll_cdecl != NULL)
{
g_interfaces[api].lua_close_dll_cdecl(L);
}
else
{
g_interfaces[api].lua_close_dll_stdcall(L);
}
}
lua_State* lua_newthread_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_newthread_dll_cdecl != NULL)
{
return g_interfaces[api].lua_newthread_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_newthread_dll_stdcall(L);
}
}
int lua_error_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_error_dll_cdecl != NULL)
{
return g_interfaces[api].lua_error_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_error_dll_stdcall(L);
}
}
int lua_sethook_dll(unsigned long api, lua_State* L, lua_Hook f, int mask, int count)
{
if (g_interfaces[api].lua_sethook_dll_cdecl != NULL)
{
return g_interfaces[api].lua_sethook_dll_cdecl(L, f, mask, count);
}
else
{
return g_interfaces[api].lua_sethook_dll_stdcall(L, (lua_Hook_stdcall)f, mask, count);
}
}
int lua_getinfo_dll(unsigned long api, lua_State* L, const char* what, lua_Debug* ar)
{
if (g_interfaces[api].lua_getinfo_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getinfo_dll_cdecl(L, what, ar);
}
else
{
return g_interfaces[api].lua_getinfo_dll_stdcall(L, what, ar);
}
}
void lua_remove_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_remove_dll_cdecl != NULL)
{
g_interfaces[api].lua_remove_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_remove_dll_stdcall(L, index);
}
}
void lua_settable_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_settable_dll_cdecl != NULL)
{
g_interfaces[api].lua_settable_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_settable_dll_stdcall(L, index);
}
}
void lua_gettable_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_gettable_dll_cdecl != NULL)
{
g_interfaces[api].lua_gettable_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_gettable_dll_stdcall(L, index);
}
}
void lua_rawget_dll(unsigned long api, lua_State* L, int idx)
{
if (g_interfaces[api].lua_rawget_dll_cdecl != NULL)
{
g_interfaces[api].lua_rawget_dll_cdecl(L, idx);
}
else
{
g_interfaces[api].lua_rawget_dll_stdcall(L, idx);
}
}
void lua_rawgeti_dll(unsigned long api, lua_State *L, int idx, int n)
{
if (g_interfaces[api].lua_rawgeti_dll_cdecl != NULL)
{
g_interfaces[api].lua_rawgeti_dll_cdecl(L, idx, n);
}
else
{
g_interfaces[api].lua_rawgeti_dll_stdcall(L, idx, n);
}
}
void lua_rawset_dll(unsigned long api, lua_State* L, int idx)
{
if (g_interfaces[api].lua_rawset_dll_cdecl != NULL)
{
g_interfaces[api].lua_rawset_dll_cdecl(L, idx);
}
else
{
g_interfaces[api].lua_rawset_dll_stdcall(L, idx);
}
}
void lua_pushstring_dll(unsigned long api, lua_State* L, const char* s)
{
if (g_interfaces[api].lua_pushstring_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushstring_dll_cdecl(L, s);
}
else
{
g_interfaces[api].lua_pushstring_dll_stdcall(L, s);
}
}
void lua_pushlstring_dll(unsigned long api, lua_State* L, const char* s, size_t len)
{
if (g_interfaces[api].lua_pushlstring_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushlstring_dll_cdecl(L, s, len);
}
else
{
g_interfaces[api].lua_pushlstring_dll_stdcall(L, s, len);
}
}
int lua_type_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_type_dll_cdecl != NULL)
{
return g_interfaces[api].lua_type_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_type_dll_stdcall(L, index);
}
}
const char* lua_typename_dll(unsigned long api, lua_State* L, int type)
{
if (g_interfaces[api].lua_typename_dll_cdecl != NULL)
{
return g_interfaces[api].lua_typename_dll_cdecl(L, type);
}
else
{
return g_interfaces[api].lua_typename_dll_stdcall(L, type);
}
}
int lua_checkstack_dll(unsigned long api, lua_State* L, int extra)
{
if (g_interfaces[api].lua_checkstack_dll_cdecl != NULL)
{
return g_interfaces[api].lua_checkstack_dll_cdecl(L, extra);
}
else
{
return g_interfaces[api].lua_checkstack_dll_stdcall(L, extra);
}
}
void lua_getfield_dll(unsigned long api, lua_State* L, int index, const char* k)
{
// Since Lua 4.0 doesn't include lua_getfield, we just emulate its
// behavior for simplicity.
index = lua_abs_index_dll(api, L, index);
lua_pushstring_dll(api, L, k);
lua_gettable_dll(api, L, index);
}
void lua_setfield_dll(unsigned long api, lua_State* L, int index, const char* k)
{
// Since Lua 4.0 doesn't include lua_setfield, we just emulate its
// behavior for simplicity.
index = lua_abs_index_dll(api, L, index);
lua_pushstring_dll(api, L, k);
lua_insert_dll(api, L, -2);
lua_settable_dll(api, L, index);
}
void lua_settop_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_settop_dll_cdecl != NULL)
{
g_interfaces[api].lua_settop_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_settop_dll_stdcall(L, index);
}
}
const char* lua_getlocal_dll(unsigned long api, lua_State* L, const lua_Debug* ar, int n)
{
if (g_interfaces[api].lua_getlocal_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getlocal_dll_cdecl(L, ar, n);
}
else
{
return g_interfaces[api].lua_getlocal_dll_stdcall(L, ar, n);
}
}
const char* lua_setlocal_dll(unsigned long api, lua_State* L, const lua_Debug* ar, int n)
{
if (g_interfaces[api].lua_setlocal_dll_cdecl != NULL)
{
return g_interfaces[api].lua_setlocal_dll_cdecl(L, ar, n);
}
else
{
return g_interfaces[api].lua_setlocal_dll_stdcall(L, ar, n);
}
}
int lua_getstack_dll(unsigned long api, lua_State* L, int level, lua_Debug* ar)
{
if (g_interfaces[api].lua_getstack_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getstack_dll_cdecl(L, level, ar);
}
else
{
return g_interfaces[api].lua_getstack_dll_stdcall(L, level, ar);
}
}
void lua_insert_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_insert_dll_cdecl != NULL)
{
g_interfaces[api].lua_insert_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_insert_dll_stdcall(L, index);
}
}
void lua_pushnil_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_pushnil_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushnil_dll_cdecl(L);
}
else
{
g_interfaces[api].lua_pushnil_dll_stdcall(L);
}
}
void lua_pushcclosure_dll(unsigned long api, lua_State* L, lua_CFunction fn, int n)
{
if (g_interfaces[api].lua_pushcclosure_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushcclosure_dll_cdecl(L, fn, n);
}
else
{
g_interfaces[api].lua_pushcclosure_dll_stdcall(L, fn, n);
}
}
void lua_pushvalue_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_pushvalue_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushvalue_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_pushvalue_dll_stdcall(L, index);
}
}
void lua_pushnumber_dll(unsigned long api, lua_State* L, lua_Number value)
{
if (g_interfaces[api].lua_pushnumber_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushnumber_dll_cdecl(L, value);
}
else
{
g_interfaces[api].lua_pushnumber_dll_stdcall(L, value);
}
}
void lua_pushinteger_dll(unsigned long api, lua_State* L, int value)
{
if (g_interfaces[api].lua_pushinteger_dll_cdecl != NULL ||
g_interfaces[api].lua_pushinteger_dll_stdcall != NULL)
{
// Lua 5.0 version.
if (g_interfaces[api].lua_pushinteger_dll_cdecl != NULL)
{
return g_interfaces[api].lua_pushinteger_dll_cdecl(L, value);
}
else
{
return g_interfaces[api].lua_pushinteger_dll_stdcall(L, value);
}
}
else
{
// Fallback to lua_pushnumber on Lua 4.0.
lua_pushnumber_dll(api, L, static_cast<lua_Number>(value));
}
}
void lua_pushlightuserdata_dll(unsigned long api, lua_State* L, void* p)
{
if (g_interfaces[api].lua_pushlightuserdata_dll_cdecl != NULL)
{
g_interfaces[api].lua_pushlightuserdata_dll_cdecl(L, p);
}
else
{
g_interfaces[api].lua_pushlightuserdata_dll_stdcall(L, p);
}
}
const char* lua_tostring_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_tostring_dll_cdecl != NULL ||
g_interfaces[api].lua_tostring_dll_stdcall != NULL)
{
// Lua 4.0 implementation.
if (g_interfaces[api].lua_tostring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tostring_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_tostring_dll_stdcall(L, index);
}
}
else
{
// Lua 5.0 version.
if (g_interfaces[api].lua_tolstring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tolstring_dll_cdecl(L, index, NULL);
}
else
{
return g_interfaces[api].lua_tolstring_dll_stdcall(L, index, NULL);
}
}
}
const char* lua_tolstring_dll(unsigned long api, lua_State* L, int index, size_t* len)
{
if (g_interfaces[api].lua_tolstring_dll_cdecl != NULL ||
g_interfaces[api].lua_tolstring_dll_stdcall != NULL)
{
// Lua 5.0 version.
if (g_interfaces[api].lua_tolstring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tolstring_dll_cdecl(L, index, len);
}
else
{
return g_interfaces[api].lua_tolstring_dll_stdcall(L, index, len);
}
}
else
{
// Lua 4.0 implementation. lua_tolstring doesn't exist, so we just use lua_tostring
// and compute the length ourself. This means strings with embedded zeros doesn't work
// in Lua 4.0.
const char* string = NULL;
if (g_interfaces[api].lua_tostring_dll_cdecl != NULL)
{
string = g_interfaces[api].lua_tostring_dll_cdecl(L, index);
}
else
{
string = g_interfaces[api].lua_tostring_dll_stdcall(L, index);
}
if (len)
{
if (string)
{
*len = strlen(string);
}
else
{
*len = 0;
}
}
return string;
}
}
int lua_toboolean_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_toboolean_dll_cdecl != NULL)
{
return g_interfaces[api].lua_toboolean_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_toboolean_dll_stdcall(L, index);
}
}
int lua_tointeger_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_tointegerx_dll_cdecl != NULL ||
g_interfaces[api].lua_tointegerx_dll_stdcall != NULL)
{
// Lua 5.2 implementation.
if (g_interfaces[api].lua_tointegerx_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tointegerx_dll_cdecl(L, index, NULL);
}
else
{
return g_interfaces[api].lua_tointegerx_dll_stdcall(L, index, NULL);
}
}
if (g_interfaces[api].lua_tointeger_dll_cdecl != NULL ||
g_interfaces[api].lua_tointeger_dll_stdcall != NULL)
{
// Lua 5.0 implementation.
if (g_interfaces[api].lua_tointeger_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tointeger_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_tointeger_dll_stdcall(L, index);
}
}
else
{
// On Lua 4.0 fallback to lua_tonumber.
return static_cast<int>(lua_tonumber_dll(api, L, index));
}
}
lua_CFunction lua_tocfunction_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_tocfunction_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tocfunction_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_tocfunction_dll_stdcall(L, index);
}
}
lua_Number lua_tonumber_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_tonumberx_dll_cdecl != NULL ||
g_interfaces[api].lua_tonumberx_dll_stdcall != NULL)
{
// Lua 5.2 implementation.
if (g_interfaces[api].lua_tonumberx_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tonumberx_dll_cdecl(L, index, NULL);
}
else
{
return g_interfaces[api].lua_tonumberx_dll_stdcall(L, index, NULL);
}
}
// Lua 5.0 and earlier.
if (g_interfaces[api].lua_tonumber_dll_cdecl != NULL)
{
return g_interfaces[api].lua_tonumber_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_tonumber_dll_stdcall(L, index);
}
}
void* lua_touserdata_dll(unsigned long api, lua_State *L, int index)
{
if (g_interfaces[api].lua_touserdata_dll_cdecl != NULL)
{
return g_interfaces[api].lua_touserdata_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_touserdata_dll_stdcall(L, index);
}
}
int lua_gettop_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_gettop_dll_cdecl != NULL)
{
return g_interfaces[api].lua_gettop_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_gettop_dll_stdcall(L);
}
}
int lua_loadbuffer_dll(unsigned long api, lua_State* L, const char* buffer, size_t size, const char* chunkname)
{
Memory memory;
memory.buffer = buffer;
memory.size = size;
if (g_interfaces[api].lua_load_dll_cdecl != NULL)
{
return g_interfaces[api].lua_load_dll_cdecl(L, MemoryReader_cdecl, &memory, chunkname);
}
else
{
return g_interfaces[api].lua_load_dll_stdcall(L, MemoryReader_stdcall, &memory, chunkname);
}
}
void lua_call_dll(unsigned long api, lua_State* L, int nargs, int nresults)
{
if (g_interfaces[api].lua_call_dll_cdecl != NULL)
{
return g_interfaces[api].lua_call_dll_cdecl(L, nargs, nresults);
}
else
{
return g_interfaces[api].lua_call_dll_stdcall(L, nargs, nresults);
}
}
int lua_pcallk_dll(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k)
{
if (g_interfaces[api].lua_pcallk_dll_cdecl != NULL)
{
return g_interfaces[api].lua_pcallk_dll_cdecl(L, nargs, nresults, errfunc, ctx, k);
}
else
{
return g_interfaces[api].lua_pcallk_dll_stdcall(L, nargs, nresults, errfunc, ctx, k);
}
}
int lua_pcall_dll(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc)
{
// Lua 5.2.
if (g_interfaces[api].lua_pcallk_dll_cdecl != NULL ||
g_interfaces[api].lua_pcallk_dll_stdcall != NULL)
{
return lua_pcallk_dll(api, L, nargs, nresults, errfunc, 0, NULL);
}
// Lua 5.1 and earlier.
if (g_interfaces[api].lua_pcall_dll_cdecl != NULL)
{
return g_interfaces[api].lua_pcall_dll_cdecl(L, nargs, nresults, errfunc);
}
else
{
return g_interfaces[api].lua_pcall_dll_stdcall(L, nargs, nresults, errfunc);
}
}
void lua_newtable_dll(unsigned long api, lua_State* L)
{
if (g_interfaces[api].lua_newtable_dll_cdecl != NULL ||
g_interfaces[api].lua_newtable_dll_stdcall != NULL)
{
// Lua 4.0 implementation.
if (g_interfaces[api].lua_newtable_dll_cdecl != NULL)
{
return g_interfaces[api].lua_newtable_dll_cdecl(L);
}
else
{
return g_interfaces[api].lua_newtable_dll_stdcall(L);
}
}
else
{
// Lua 5.0 version.
if (g_interfaces[api].lua_createtable_dll_cdecl != NULL)
{
g_interfaces[api].lua_createtable_dll_cdecl(L, 0, 0);
}
else
{
g_interfaces[api].lua_createtable_dll_stdcall(L, 0, 0);
}
}
}
int lua_next_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_next_dll_cdecl != NULL)
{
return g_interfaces[api].lua_next_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_next_dll_stdcall(L, index);
}
}
int lua_rawequal_dll(unsigned long api, lua_State *L, int idx1, int idx2)
{
if (g_interfaces[api].lua_rawequal_dll_cdecl != NULL)
{
return g_interfaces[api].lua_rawequal_dll_cdecl(L, idx1, idx2);
}
else
{
return g_interfaces[api].lua_rawequal_dll_stdcall(L, idx1, idx2);
}
}
int lua_getmetatable_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_getmetatable_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getmetatable_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_getmetatable_dll_stdcall(L, index);
}
}
int lua_setmetatable_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_setmetatable_dll_cdecl != NULL)
{
return g_interfaces[api].lua_setmetatable_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_setmetatable_dll_stdcall(L, index);
}
}
int luaL_ref_dll(unsigned long api, lua_State *L, int t)
{
if (g_interfaces[api].luaL_ref_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_ref_dll_cdecl(L, t);
}
else if (g_interfaces[api].luaL_ref_dll_stdcall != NULL)
{
return g_interfaces[api].luaL_ref_dll_stdcall(L, t);
}
// We don't require that luaL_ref be present, so provide a suitable
// implementation if it's not.
return LUA_NOREF;
}
void luaL_unref_dll(unsigned long api, lua_State *L, int t, int ref)
{
if (g_interfaces[api].luaL_unref_dll_cdecl != NULL)
{
g_interfaces[api].luaL_unref_dll_cdecl(L, t, ref);
}
else if (g_interfaces[api].luaL_ref_dll_stdcall != NULL)
{
g_interfaces[api].luaL_unref_dll_stdcall(L, t, ref);
}
}
int luaL_newmetatable_dll(unsigned long api, lua_State *L, const char *tname)
{
if (g_interfaces[api].luaL_newmetatable_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_newmetatable_dll_cdecl(L, tname);
}
else
{
return g_interfaces[api].luaL_newmetatable_dll_stdcall(L, tname);
}
}
int luaL_loadbuffer_dll(unsigned long api, lua_State *L, const char *buff, size_t sz, const char *name)
{
if (g_interfaces[api].luaL_loadbuffer_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_loadbuffer_dll_cdecl(L, buff, sz, name);
}
else
{
return g_interfaces[api].luaL_loadbuffer_dll_stdcall(L, buff, sz, name);
}
}
int luaL_loadfile_dll(unsigned long api, lua_State* L, const char* fileName)
{
if (g_interfaces[api].luaL_loadfile_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_loadfile_dll_cdecl(L, fileName);
}
else
{
return g_interfaces[api].luaL_loadfile_dll_stdcall(L, fileName);
}
}
lua_State* luaL_newstate_dll(unsigned long api)
{
if (g_interfaces[api].luaL_newstate_dll_cdecl != NULL)
{
return g_interfaces[api].luaL_newstate_dll_cdecl();
}
else
{
return g_interfaces[api].luaL_newstate_dll_stdcall();
}
}
const lua_WChar* lua_towstring_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_towstring_dll_cdecl != NULL ||
g_interfaces[api].lua_towstring_dll_stdcall != NULL)
{
if (g_interfaces[api].lua_towstring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_towstring_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_towstring_dll_stdcall(L, index);
}
}
else
{
// The application is not using LuaPlus, so just return NULL.
return NULL;
}
}
int lua_iswstring_dll(unsigned long api, lua_State* L, int index)
{
if (g_interfaces[api].lua_iswstring_dll_cdecl != NULL ||
g_interfaces[api].lua_iswstring_dll_stdcall != NULL)
{
if (g_interfaces[api].lua_iswstring_dll_cdecl != NULL)
{
return g_interfaces[api].lua_iswstring_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_iswstring_dll_stdcall(L, index);
}
}
else
{
// The application is not using LuaPlus, so just return 0.
return 0;
}
}
const char* lua_getupvalue_dll(unsigned long api, lua_State *L, int funcindex, int n)
{
if (g_interfaces[api].lua_getupvalue_dll_cdecl != NULL)
{
return g_interfaces[api].lua_getupvalue_dll_cdecl(L, funcindex, n);
}
else
{
return g_interfaces[api].lua_getupvalue_dll_stdcall(L, funcindex, n);
}
}
const char* lua_setupvalue_dll(unsigned long api, lua_State *L, int funcindex, int n)
{
if (g_interfaces[api].lua_setupvalue_dll_cdecl != NULL)
{
return g_interfaces[api].lua_setupvalue_dll_cdecl(L, funcindex, n);
}
else
{
return g_interfaces[api].lua_setupvalue_dll_stdcall(L, funcindex, n);
}
}
void lua_getfenv_dll(unsigned long api, lua_State *L, int index)
{
if (g_interfaces[api].lua_getfenv_dll_cdecl != NULL)
{
g_interfaces[api].lua_getfenv_dll_cdecl(L, index);
}
else
{
g_interfaces[api].lua_getfenv_dll_stdcall(L, index);
}
}
int lua_setfenv_dll(unsigned long api, lua_State *L, int index)
{
if (g_interfaces[api].lua_setfenv_dll_cdecl != NULL)
{
return g_interfaces[api].lua_setfenv_dll_cdecl(L, index);
}
else
{
return g_interfaces[api].lua_setfenv_dll_stdcall(L, index);
}
}
int lua_cpcall_dll(unsigned long api, lua_State *L, lua_CFunction func, void *ud)
{
if (g_interfaces[api].lua_cpcall_dll_cdecl != NULL)
{
return g_interfaces[api].lua_cpcall_dll_cdecl(L, func, ud);
}
else
{
return g_interfaces[api].lua_cpcall_dll_stdcall(L, func, ud);
}
}
HMODULE WINAPI LoadLibraryExW_intercept(LPCWSTR fileName, HANDLE hFile, DWORD dwFlags)
{
// We have to call the loader lock (if it is available) so that we don't get deadlocks
// in the case where Dll initialization acquires the loader lock and calls LoadLibrary
// while another thread is inside PostLoadLibrary.
ULONG cookie;
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrLockLoaderLock_dll(0, 0, &cookie);
}
HMODULE hModule = LoadLibraryExW_dll(fileName, hFile, dwFlags);
if (hModule != NULL)
{
PostLoadLibrary(hModule);
}
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrUnlockLoaderLock_dll(0, cookie);
}
return hModule;
}
void FinishLoadingLua(unsigned long api, bool stdcall)
{
#define SET_STDCALL(function) \
if ( g_interfaces[api].function##_dll_cdecl != NULL) { \
g_interfaces[api].function##_dll_stdcall = reinterpret_cast<function##_stdcall_t>(g_interfaces[api].function##_dll_cdecl); \
g_interfaces[api].function##_dll_cdecl = NULL; \
}
if (g_interfaces[api].finishedLoading)
{
return;
}
g_interfaces[api].stdcall = stdcall;
if (stdcall)
{
SET_STDCALL(lua_newstate);
SET_STDCALL(lua_open);
SET_STDCALL(lua_open_500);
SET_STDCALL(lua_newstate);
SET_STDCALL(lua_newthread);
SET_STDCALL(lua_close);
SET_STDCALL(lua_error);
SET_STDCALL(lua_sethook);
SET_STDCALL(lua_getinfo);
SET_STDCALL(lua_remove);
SET_STDCALL(lua_settable);
SET_STDCALL(lua_gettable);
SET_STDCALL(lua_rawget);
SET_STDCALL(lua_rawgeti);
SET_STDCALL(lua_rawset);
SET_STDCALL(lua_pushstring);
SET_STDCALL(lua_pushlstring);
SET_STDCALL(lua_type);
SET_STDCALL(lua_typename);
SET_STDCALL(lua_settop);
SET_STDCALL(lua_gettop);
SET_STDCALL(lua_getlocal);
SET_STDCALL(lua_setlocal);
SET_STDCALL(lua_getstack);
SET_STDCALL(lua_insert);
SET_STDCALL(lua_pushnil);
SET_STDCALL(lua_pushvalue);
SET_STDCALL(lua_pushinteger);
SET_STDCALL(lua_pushnumber);
SET_STDCALL(lua_pushcclosure);
SET_STDCALL(lua_pushlightuserdata);
SET_STDCALL(lua_tostring);
SET_STDCALL(lua_tolstring);
SET_STDCALL(lua_toboolean);
SET_STDCALL(lua_tointeger);
SET_STDCALL(lua_tointegerx);
SET_STDCALL(lua_tocfunction);
SET_STDCALL(lua_tonumber);
SET_STDCALL(lua_tonumberx);
SET_STDCALL(lua_touserdata);
SET_STDCALL(lua_call);
SET_STDCALL(lua_callk);
SET_STDCALL(lua_pcall);
SET_STDCALL(lua_pcallk);
SET_STDCALL(lua_newtable);
SET_STDCALL(lua_createtable);
SET_STDCALL(lua_load);
SET_STDCALL(lua_next);
SET_STDCALL(lua_rawequal);
SET_STDCALL(lua_getmetatable);
SET_STDCALL(lua_setmetatable);
SET_STDCALL(luaL_ref);
SET_STDCALL(luaL_unref);
SET_STDCALL(luaL_newmetatable);
SET_STDCALL(luaL_loadbuffer);
SET_STDCALL(luaL_loadfile);
SET_STDCALL(lua_getupvalue);
SET_STDCALL(lua_setupvalue);
SET_STDCALL(lua_getfenv);
SET_STDCALL(lua_setfenv);
SET_STDCALL(lua_cpcall);
SET_STDCALL(lua_pushthread);
SET_STDCALL(lua_newuserdata);
SET_STDCALL(lua_pushthread);
SET_STDCALL(lua_checkstack);
}
g_interfaces[api].finishedLoading = true;
DebugBackend::Get().CreateApi(api);
}
#pragma auto_inline(off)
void lua_call_worker(unsigned long api, lua_State* L, int nargs, int nresults, bool& stdcall)
{
if (!g_interfaces[api].finishedLoading)
{
int result;
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_call_dll_cdecl, (void*)L, (void*)nargs, (void*)nresults, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
DebugBackend::Get().AttachState(api, L);
if (g_interfaces[api].lua_call_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].lua_call_dll_stdcall != NULL)
{
stdcall = true;
}
if (lua_gettop_dll(api, L) < nargs + 1)
{
DebugBackend::Get().Message("Warning 1005: lua_call called with too few arguments on the stack", MessageType_Warning);
}
if (DebugBackend::Get().Call(api, L, nargs, nresults, 0))
{
lua_error_dll(api, L);
}
}
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) void lua_call_intercept(unsigned long api, lua_State* L, int nargs, int nresults)
{
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
lua_call_worker(api, L, nargs, nresults, stdcall);
INTERCEPT_EPILOG_NO_RETURN(12)
}
#pragma auto_inline(off)
void lua_callk_worker(unsigned long api, lua_State* L, int nargs, int nresults, int ctk, lua_CFunction k, bool& stdcall)
{
if (!g_interfaces[api].finishedLoading)
{
int result;
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_callk_dll_cdecl, (void*)L, (void*)nargs, (void*)nresults, (void*)ctk, (void*)k, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
DebugBackend::Get().AttachState(api, L);
if (g_interfaces[api].lua_callk_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].lua_callk_dll_stdcall != NULL)
{
stdcall = true;
}
if (lua_gettop_dll(api, L) < nargs + 1)
{
DebugBackend::Get().Message("Warning 1005: lua_call called with too few arguments on the stack", MessageType_Warning);
}
if (DebugBackend::Get().Call(api, L, nargs, nresults, 0))
{
lua_error_dll(api, L);
}
}
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) void lua_callk_intercept(unsigned long api, lua_State* L, int nargs, int nresults, int ctx, lua_CFunction k)
{
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
lua_callk_worker(api, L, nargs, nresults, ctx, k, stdcall);
INTERCEPT_EPILOG_NO_RETURN(20)
}
#pragma auto_inline(off)
int lua_pcall_worker(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc, bool& stdcall)
{
int result;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_pcall_dll_cdecl, (void*)L, (void*)nargs, (void*)nresults, (void*)errfunc, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
DebugBackend::Get().AttachState(api, L);
if (g_interfaces[api].lua_pcall_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].lua_pcall_dll_stdcall != NULL)
{
stdcall = true;
}
if (lua_gettop_dll(api, L) < nargs + 1)
{
DebugBackend::Get().Message("Warning 1005: lua_pcall called with too few arguments on the stack", MessageType_Warning);
}
if (GetAreInterceptsEnabled())
{
result = DebugBackend::Get().Call(api, L, nargs, nresults, errfunc);
}
else
{
result = lua_pcall_dll(api, L, nargs, nresults, errfunc);
}
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int lua_pcall_intercept(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_pcall_worker(api, L, nargs, nresults, errfunc, stdcall);
INTERCEPT_EPILOG(16)
}
#pragma auto_inline(off)
int lua_pcallk_worker(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k, bool& stdcall)
{
int result;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_pcall_dll_cdecl, (void*)L, (void*)nargs,
(void*)nresults, (void*)errfunc, (void*)ctx, (void*)k, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
DebugBackend::Get().AttachState(api, L);
if (g_interfaces[api].lua_pcallk_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].lua_pcallk_dll_stdcall != NULL)
{
stdcall = true;
}
if (lua_gettop_dll(api, L) < nargs + 1)
{
DebugBackend::Get().Message("Warning 1005: lua_pcallk called with too few arguments on the stack", MessageType_Warning);
}
if (GetAreInterceptsEnabled())
{
result = DebugBackend::Get().Call(api, L, nargs, nresults, errfunc);
}
else
{
result = lua_pcallk_dll(api, L, nargs, nresults, errfunc, ctx, k);
}
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int lua_pcallk_intercept(unsigned long api, lua_State* L, int nargs, int nresults, int errfunc, int ctx, lua_CFunction k)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_pcallk_worker(api, L, nargs, nresults, errfunc, ctx, k, stdcall);
INTERCEPT_EPILOG(24)
}
#pragma auto_inline(off)
lua_State* lua_newstate_worker(unsigned long api, lua_Alloc f, void* ud, bool& stdcall)
{
lua_State* result = NULL;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_newstate_dll_cdecl, (void*)f, ud, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].lua_newstate_dll_cdecl != NULL)
{
result = g_interfaces[api].lua_newstate_dll_cdecl(f, ud);
stdcall = false;
}
else if (g_interfaces[api].lua_newstate_dll_stdcall != NULL)
{
result = g_interfaces[api].lua_newstate_dll_stdcall(f, ud);
stdcall = true;
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* lua_newstate_intercept(unsigned long api, lua_Alloc f, void* ud)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_newstate_worker(api, f, ud, stdcall);
INTERCEPT_EPILOG(8)
}
#pragma auto_inline(off)
lua_State* lua_newthread_worker(unsigned long api, lua_State* L, bool& stdcall)
{
lua_State* result = NULL;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_newthread_dll_cdecl, L, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].lua_newthread_dll_cdecl != NULL)
{
result = g_interfaces[api].lua_newthread_dll_cdecl(L);
stdcall = false;
}
else if (g_interfaces[api].lua_newthread_dll_stdcall != NULL)
{
result = g_interfaces[api].lua_newthread_dll_stdcall(L);
stdcall = true;
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* lua_newthread_intercept(unsigned long api, lua_State* L)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_newthread_worker(api, L, stdcall);
INTERCEPT_EPILOG(4)
}
#pragma auto_inline(off)
lua_State* lua_open_worker(unsigned long api, int stacksize, bool& stdcall)
{
lua_State* result = NULL;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_open_dll_cdecl, (void*)stacksize, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].lua_open_dll_cdecl != NULL)
{
result = g_interfaces[api].lua_open_dll_cdecl(stacksize);
stdcall = false;
}
else if (g_interfaces[api].lua_open_dll_stdcall != NULL)
{
result = g_interfaces[api].lua_open_dll_stdcall(stacksize);
stdcall = true;
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
#pragma auto_inline(off)
lua_State* lua_open_500_worker(unsigned long api, bool& stdcall)
{
lua_State* result = NULL;
if (!g_interfaces[api].finishedLoading)
{
// We can't test stdcall with the Lua 5.0 lua_open function since it doesn't
// take any arguments. To do the test, we create a dummy state and destroy it
// using the lua_close function to do the test.
lua_State* L = g_interfaces[api].lua_open_500_dll_cdecl();
stdcall = GetIsStdCallConvention( g_interfaces[api].lua_close_dll_cdecl, (void*)L, (void**)&result);
FinishLoadingLua(api, stdcall);
}
if (g_interfaces[api].lua_open_500_dll_cdecl != NULL)
{
result = g_interfaces[api].lua_open_500_dll_cdecl();
stdcall = false;
}
else if (g_interfaces[api].lua_open_500_dll_stdcall != NULL)
{
result = g_interfaces[api].lua_open_500_dll_stdcall();
stdcall = true;
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* lua_open_intercept(unsigned long api, int stacksize)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_open_worker(api, stacksize, stdcall);
INTERCEPT_EPILOG(4)
}
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* lua_open_500_intercept(unsigned long api)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_open_500_worker(api, stdcall);
INTERCEPT_EPILOG(0)
}
#pragma auto_inline(off)
int lua_load_worker(unsigned long api, lua_State* L, lua_Reader reader, void* data, const char* name, bool& stdcall)
{
// If we haven't finished loading yet this will be wrong, but we'll fix it up
// when we access the reader function.
stdcall = (g_interfaces[api].lua_load_dll_stdcall != NULL);
// Read all of the data out of the reader and into a big buffer.
std::vector<char> buffer;
const char* chunk;
size_t chunkSize;
do
{
if (!g_interfaces[api].finishedLoading)
{
// In this case we must have attached the debugger so we're intercepting a lua_load
// function before we've initialized.
stdcall = GetIsStdCallConvention(reader, L, data, &chunkSize, (void**)&chunk);
FinishLoadingLua(api, stdcall);
}
else if (stdcall)
{
// We assume that since the lua_load function is stdcall the reader function is as well.
chunk = reinterpret_cast<lua_Reader_stdcall>(reader)(L, data, &chunkSize);
}
else
{
// We assume that since the lua_load function is cdecl the reader function is as well.
chunk = reader(L, data, &chunkSize);
}
// We allow the reader to return 0 for the chunk size since Lua supports
// that, although according to the manual it should return NULL to signal
// the end of the data.
if (chunk != NULL && chunkSize > 0)
{
buffer.insert(buffer.end(), chunk, chunk + chunkSize);
}
}
while (chunk != NULL && chunkSize > 0);
const char* source = NULL;
if (!buffer.empty())
{
source = &buffer[0];
}
// Make sure the debugger knows about this state. This is necessary since we might have
// attached the debugger after the state was created.
DebugBackend::Get().AttachState(api, L);
// Disables JIT compilation if LuaJIT is being used. Otherwise we won't get hooks for
// this chunk.
if (DebugBackend::Get().EnableJit(api, L, false))
{
if (!g_warnedAboutJit)
{
DebugBackend::Get().Message("Warning 1007: Just-in-time compilation of Lua code disabled to allow debugging", MessageType_Warning);
g_warnedAboutJit = true;
}
}
int result = lua_loadbuffer_dll(api, L, source, buffer.size(), name);
if (!buffer.empty())
{
result = DebugBackend::Get().PostLoadScript(api, result, L, source, buffer.size(), name);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int lua_load_intercept(unsigned long api, lua_State* L, lua_Reader reader, void* data, const char* name)
{
bool stdcall;
int result;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_load_worker(api, L, reader, data, name, stdcall);
INTERCEPT_EPILOG(16)
}
#pragma auto_inline(off)
void lua_close_worker(unsigned long api, lua_State* L, bool& stdcall)
{
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].lua_close_dll_cdecl, L, NULL);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].lua_close_dll_cdecl != NULL)
{
g_interfaces[api].lua_close_dll_cdecl(L);
stdcall = false;
}
else if (g_interfaces[api].lua_close_dll_stdcall != NULL)
{
g_interfaces[api].lua_close_dll_stdcall(L);
stdcall = true;
}
DebugBackend::Get().DetachState(api, L);
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) void lua_close_intercept(unsigned long api, lua_State* L)
{
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
lua_close_worker(api, L, stdcall);
INTERCEPT_EPILOG_NO_RETURN(4)
}
#pragma auto_inline(off)
int luaL_newmetatable_worker(unsigned long api, lua_State *L, const char* tname, bool& stdcall)
{
int result;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].luaL_newmetatable_dll_cdecl, L, (void*)tname, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].luaL_newmetatable_dll_cdecl != NULL)
{
result = g_interfaces[api].luaL_newmetatable_dll_cdecl(L, tname);
stdcall = false;
}
else if (g_interfaces[api].luaL_newmetatable_dll_stdcall != NULL)
{
result = g_interfaces[api].luaL_newmetatable_dll_stdcall(L, tname);
stdcall = true;
}
if (result != 0)
{
// Only register if we haven't seen this name before.
DebugBackend::Get().RegisterClassName(api, L, tname, lua_gettop_dll(api, L));
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int luaL_newmetatable_intercept(unsigned long api, lua_State* L, const char* tname)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = luaL_newmetatable_worker(api, L, tname, stdcall);
INTERCEPT_EPILOG(8)
}
#pragma auto_inline(off)
int lua_sethook_worker(unsigned long api, lua_State *L, lua_Hook f, int mask, int count, bool& stdcall)
{
// Currently we're using the hook and can't let anyone else use it.
// What we should do is implement the lua hook on top of our existing hook.
int result = 0;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].lua_sethook_dll_cdecl, L, f, (void*)mask, (void*)count, (void**)&result);
FinishLoadingLua(api, stdcall);
DebugBackend::Get().AttachState(api, L);
}
else
{
if (g_interfaces[api].luaL_newmetatable_dll_cdecl != NULL)
{
stdcall = false;
}
else if (g_interfaces[api].luaL_newmetatable_dll_stdcall != NULL)
{
stdcall = true;
}
// Note, the lua_hook call is currently bypassed.
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int lua_sethook_intercept(unsigned long api, lua_State *L, lua_Hook f, int mask, int count)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = lua_sethook_worker(api, L, f, mask, count, stdcall);
INTERCEPT_EPILOG(16)
}
#pragma auto_inline(off)
int luaL_loadbuffer_worker(unsigned long api, lua_State *L, const char *buff, size_t sz, const char *name, bool& stdcall)
{
int result = 0;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].luaL_loadbuffer_dll_cdecl, L, (void*)buff, (void*)sz, (void*)name, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].luaL_loadbuffer_dll_cdecl != NULL)
{
result = g_interfaces[api].luaL_loadbuffer_dll_cdecl(L, buff, sz, name);
stdcall = false;
}
else if (g_interfaces[api].luaL_loadbuffer_dll_stdcall != NULL)
{
result = g_interfaces[api].luaL_loadbuffer_dll_stdcall(L, buff, sz, name);
stdcall = true;
}
// Make sure the debugger knows about this state. This is necessary since we might have
// attached the debugger after the state was created.
DebugBackend::Get().AttachState(api, L);
return DebugBackend::Get().PostLoadScript(api, result, L, buff, sz, name);
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int luaL_loadbuffer_intercept(unsigned long api, lua_State *L, const char *buff, size_t sz, const char *name)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = luaL_loadbuffer_worker(api, L, buff, sz, name, stdcall);
INTERCEPT_EPILOG(16)
}
#pragma auto_inline(off)
int luaL_loadfile_worker(unsigned long api, lua_State *L, const char *fileName, bool& stdcall)
{
int result = 0;
if (!g_interfaces[api].finishedLoading)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].luaL_loadfile_dll_cdecl, L, (void*)fileName, (void**)&result);
FinishLoadingLua(api, stdcall);
}
else if (g_interfaces[api].luaL_loadfile_dll_cdecl != NULL)
{
result = g_interfaces[api].luaL_loadfile_dll_cdecl(L, fileName);
stdcall = false;
}
else if (g_interfaces[api].luaL_loadfile_dll_stdcall != NULL)
{
result = g_interfaces[api].luaL_loadfile_dll_stdcall(L, fileName);
stdcall = true;
}
// Make sure the debugger knows about this state. This is necessary since we might have
// attached the debugger after the state was created.
DebugBackend::Get().AttachState(api, L);
// Load the file.
FILE* file = fopen(fileName, "rb");
if (file != NULL)
{
std::string name = "@";
name += fileName;
fseek(file, 0, SEEK_END);
unsigned int length = ftell(file);
char* buffer = new char[length];
fseek(file, 0, SEEK_SET);
fread(buffer, 1, length, file);
fclose(file);
result = DebugBackend::Get().PostLoadScript(api, result, L, buffer, length, name.c_str());
delete [] buffer;
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) int luaL_loadfile_intercept(unsigned long api, lua_State *L, const char *fileName)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = luaL_loadfile_worker(api, L, fileName, stdcall);
INTERCEPT_EPILOG(8)
}
#pragma auto_inline(off)
lua_State* luaL_newstate_worker(unsigned long api, bool& stdcall)
{
lua_State* result = NULL;
if (g_interfaces[api].luaL_newstate_dll_cdecl != NULL)
{
result = g_interfaces[api].luaL_newstate_dll_cdecl();
}
else if (g_interfaces[api].luaL_newstate_dll_stdcall != NULL)
{
result = g_interfaces[api].luaL_newstate_dll_stdcall();
}
// Since we couldn't test if luaL_newstate was stdcall or cdecl (since it
// doesn't have any arguments), call another function. lua_gettop is a good
// choice since it has no side effects.
if (!g_interfaces[api].finishedLoading && result != NULL)
{
stdcall = GetIsStdCallConvention(g_interfaces[api].lua_gettop_dll_cdecl, result, NULL);
FinishLoadingLua(api, stdcall);
}
if (result != NULL)
{
DebugBackend::Get().AttachState(api, result);
}
return result;
}
#pragma auto_inline()
// This function cannot be called like a normal function. It changes its
// calling convention at run-time and removes and extra argument from the stack.
__declspec(naked) lua_State* luaL_newstate_intercept(unsigned long api)
{
lua_State* result;
bool stdcall;
INTERCEPT_PROLOG()
// We push the actual functionality of this function into a separate, "normal"
// function so avoid interferring with the inline assembly and other strange
// aspects of this function.
result = luaL_newstate_worker(api, stdcall);
INTERCEPT_EPILOG(0)
}
std::string GetEnvironmentVariable(const std::string& name)
{
DWORD size = ::GetEnvironmentVariable(name.c_str(), NULL, 0);
std::string result;
if (size > 0)
{
char* buffer = new char[size];
buffer[0] = 0;
GetEnvironmentVariable(name.c_str(), buffer, size);
result = buffer;
delete [] buffer;
}
return result;
}
std::string GetApplicationDirectory()
{
char fileName[_MAX_PATH];
GetModuleFileNameEx(GetCurrentProcess(), NULL, fileName, _MAX_PATH);
char* term = strrchr(fileName, '\\');
if (term != NULL)
{
*term = 0;
}
return fileName;
}
bool LoadLuaFunctions(const stdext::hash_map<std::string, DWORD64>& symbols, HANDLE hProcess)
{
#define GET_FUNCTION_OPTIONAL(function) \
{ \
stdext::hash_map<std::string, DWORD64>::const_iterator iterator = symbols.find(#function); \
if (iterator != symbols.end()) \
{ \
luaInterface.function##_dll_cdecl = reinterpret_cast<function##_cdecl_t>(iterator->second); \
} \
}
#define GET_FUNCTION(function) \
GET_FUNCTION_OPTIONAL(function) \
if (luaInterface.function##_dll_cdecl == NULL) \
{ \
if (report) \
{ \
DebugBackend::Get().Message("Warning 1004: Couldn't hook Lua function '" #function "'", MessageType_Warning); \
} \
return false; \
}
#define HOOK_FUNCTION(function) \
if (luaInterface.function##_dll_cdecl != NULL) \
{ \
void* original = luaInterface.function##_dll_cdecl; \
luaInterface.function##_dll_cdecl = (function##_cdecl_t)(HookFunction(original, function##_intercept, api)); \
}
LuaInterface luaInterface = { 0 };
luaInterface.finishedLoading = false;
luaInterface.stdcall = false;
unsigned long api = g_interfaces.size();
bool report = false;
// Check if the lua_tag function exists. This function is only in Lua 4.0 and not in Lua 5.0.
// This helps us differentiate between those two versions.
luaInterface.registryIndex = 0;
luaInterface.globalsIndex = 0;
if (symbols.find("lua_tag") != symbols.end())
{
luaInterface.version = 401;
}
else
{
if (symbols.find("lua_open") != symbols.end())
{
luaInterface.version = 500;
luaInterface.registryIndex = -10000;
luaInterface.globalsIndex = -10001;
}
else if (symbols.find("lua_callk") != symbols.end())
{
luaInterface.version = 520;
luaInterface.registryIndex = -10000;
luaInterface.globalsIndex = -10001;
}
else
{
luaInterface.version = 510;
luaInterface.registryIndex = -10000;
luaInterface.globalsIndex = -10002;
}
}
// Only present in Lua 4.0 and Lua 5.0 (not 5.1)
GET_FUNCTION_OPTIONAL(lua_open);
if (luaInterface.lua_open_dll_cdecl == NULL)
{
GET_FUNCTION(lua_newstate);
}
// Start reporting errors about functions we couldn't hook.
report = true;
GET_FUNCTION(lua_newthread);
GET_FUNCTION(lua_close);
GET_FUNCTION(lua_error);
GET_FUNCTION(lua_sethook);
GET_FUNCTION(lua_getinfo);
GET_FUNCTION(lua_remove);
GET_FUNCTION(lua_settable);
GET_FUNCTION(lua_gettable);
GET_FUNCTION(lua_rawget);
GET_FUNCTION(lua_rawgeti);
GET_FUNCTION(lua_rawset);
GET_FUNCTION(lua_pushstring);
GET_FUNCTION(lua_pushlstring);
GET_FUNCTION(lua_type);
GET_FUNCTION(lua_typename);
GET_FUNCTION(lua_settop);
GET_FUNCTION(lua_gettop);
GET_FUNCTION(lua_getlocal);
GET_FUNCTION(lua_setlocal);
GET_FUNCTION(lua_getstack);
GET_FUNCTION(lua_insert);
GET_FUNCTION(lua_pushnil);
GET_FUNCTION(lua_pushvalue);
GET_FUNCTION(lua_pushcclosure);
GET_FUNCTION(lua_pushnumber);
GET_FUNCTION(lua_pushlightuserdata);
GET_FUNCTION(lua_checkstack);
GET_FUNCTION(lua_gethookmask);
// Only present in Lua 5.1 (*number funtions used in Lua 4.0)
GET_FUNCTION_OPTIONAL(lua_pushinteger);
GET_FUNCTION_OPTIONAL(lua_tointeger);
GET_FUNCTION_OPTIONAL(lua_tointegerx);
// Only present in Lua 4.0 and 5.0 (exists as a macro in Lua 5.1)
GET_FUNCTION_OPTIONAL(lua_tostring);
if (luaInterface.lua_tostring_dll_cdecl == NULL)
{
GET_FUNCTION(lua_tolstring);
}
GET_FUNCTION_OPTIONAL(lua_tonumberx);
if (luaInterface.lua_tonumberx_dll_cdecl == NULL)
{
// If the Lua 5.2 tonumber isn't present, require the previous version.
GET_FUNCTION(lua_tonumber);
}
GET_FUNCTION(lua_toboolean);
GET_FUNCTION(lua_tocfunction);
GET_FUNCTION(lua_touserdata);
// Exists as a macro in Lua 5.2
GET_FUNCTION_OPTIONAL(lua_callk);
if (luaInterface.lua_callk_dll_cdecl == NULL)
{
GET_FUNCTION(lua_call);
}
// Exists as a macro in Lua 5.2
GET_FUNCTION_OPTIONAL(lua_pcallk);
if (luaInterface.lua_pcallk_dll_cdecl == NULL)
{
GET_FUNCTION(lua_pcall);
}
// Only present in Lua 4.0 and 5.0 (exists as a macro in Lua 5.1)
GET_FUNCTION_OPTIONAL(lua_newtable);
if (luaInterface.lua_newtable_dll_cdecl == NULL)
{
GET_FUNCTION(lua_createtable);
}
GET_FUNCTION(lua_load);
GET_FUNCTION(lua_next);
GET_FUNCTION(lua_rawequal);
GET_FUNCTION(lua_getmetatable);
GET_FUNCTION(lua_setmetatable);
GET_FUNCTION_OPTIONAL(luaL_ref);
GET_FUNCTION_OPTIONAL(luaL_unref);
GET_FUNCTION(luaL_newmetatable);
GET_FUNCTION(lua_getupvalue);
GET_FUNCTION(lua_setupvalue);
// We don't currently need these.
GET_FUNCTION_OPTIONAL(lua_getfenv);
GET_FUNCTION_OPTIONAL(lua_setfenv);
GET_FUNCTION_OPTIONAL(lua_cpcall);
if (luaInterface.version >= 510)
{
GET_FUNCTION(lua_pushthread);
}
else
{
// This function doesn't exist in Lua 5.0, so make it optional.
GET_FUNCTION_OPTIONAL(lua_pushthread);
}
GET_FUNCTION(lua_newuserdata);
// This function isn't strictly necessary. We only hook it
// in case the base function was inlined.
GET_FUNCTION_OPTIONAL(luaL_newstate);
GET_FUNCTION_OPTIONAL(luaL_loadbuffer);
GET_FUNCTION_OPTIONAL(luaL_loadfile);
// These functions only exists in LuaPlus.
GET_FUNCTION_OPTIONAL(lua_towstring);
GET_FUNCTION_OPTIONAL(lua_iswstring);
// Hook the functions we need to intercept calls to.
if (luaInterface.version == 500)
{
luaInterface.lua_open_500_dll_cdecl = reinterpret_cast<lua_open_500_cdecl_t>(luaInterface.lua_open_dll_cdecl);
luaInterface.lua_open_dll_cdecl = NULL;
}
HOOK_FUNCTION(lua_open);
HOOK_FUNCTION(lua_open_500);
HOOK_FUNCTION(lua_newstate);
HOOK_FUNCTION(lua_close);
HOOK_FUNCTION(lua_newthread);
HOOK_FUNCTION(lua_pcall);
HOOK_FUNCTION(lua_pcallk);
HOOK_FUNCTION(lua_call);
HOOK_FUNCTION(lua_callk);
HOOK_FUNCTION(lua_load);
HOOK_FUNCTION(luaL_newmetatable);
HOOK_FUNCTION(lua_sethook);
HOOK_FUNCTION(luaL_loadbuffer);
HOOK_FUNCTION(luaL_loadfile);
HOOK_FUNCTION(luaL_newstate);
#ifdef VERBOSE
DebugBackend::Get().Message("Found all necessary Lua functions");
#endif
// Setup our API.
luaInterface.DecodaOutput = (lua_CFunction)InstanceFunction(DecodaOutput, api);
luaInterface.CPCallHandler = (lua_CFunction)InstanceFunction(CPCallHandler, api);
luaInterface.HookHandler = (lua_Hook)InstanceFunction(HookHandler, api);
g_interfaces.push_back( luaInterface );
if (!g_loadedLuaFunctions)
{
DebugBackend::Get().Message("Debugger attached to process");
g_loadedLuaFunctions = true;
}
return true;
}
static PIMAGE_NT_HEADERS PEHeaderFromHModule(HMODULE hModule)
{
PIMAGE_NT_HEADERS pNTHeader = 0;
__try
{
if ( PIMAGE_DOS_HEADER(hModule)->e_magic != IMAGE_DOS_SIGNATURE )
__leave;
pNTHeader = PIMAGE_NT_HEADERS(PBYTE(hModule)
+ PIMAGE_DOS_HEADER(hModule)->e_lfanew);
if ( pNTHeader->Signature != IMAGE_NT_SIGNATURE )
pNTHeader = 0;
}
__except( EXCEPTION_EXECUTE_HANDLER )
{
}
return pNTHeader;
}
/**
* Gets a list of the files that are imported by a module.
*/
bool GetModuleImports(HANDLE hProcess, HMODULE hModule, std::vector<std::string>& imports)
{
PIMAGE_NT_HEADERS pExeNTHdr = PEHeaderFromHModule( hModule );
if ( !pExeNTHdr )
{
return false;
}
DWORD importRVA = pExeNTHdr->OptionalHeader.DataDirectory
[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
if ( !importRVA )
{
return false;
}
// Convert imports RVA to a usable pointer
PIMAGE_IMPORT_DESCRIPTOR pImportDesc = MAKE_PTR( PIMAGE_IMPORT_DESCRIPTOR,
hModule, importRVA );
// Iterate through each import descriptor, and redirect if appropriate
while ( pImportDesc->FirstThunk )
{
PSTR pszImportModuleName = MAKE_PTR( PSTR, hModule, pImportDesc->Name);
imports.push_back(pszImportModuleName);
pImportDesc++; // Advance to next import descriptor
}
return true;
}
bool GetFileExists(const char* fileName)
{
return GetFileAttributes(fileName) != INVALID_FILE_ATTRIBUTES;
}
void ReplaceExtension(char fileName[_MAX_PATH], const char* extension)
{
char* start = strrchr(fileName, '.');
if (start == NULL)
{
strcat(fileName, extension);
}
else
{
strcpy(start + 1, extension);
}
}
void GetFileTitle(const char* fileName, char fileTitle[_MAX_PATH])
{
const char* slash1 = strrchr(fileName, '\\');
const char* slash2 = strrchr(fileName, '/');
const char* pathEnd = max(slash1, slash2);
if (pathEnd == NULL)
{
// There's no path so the whole thing is the file title.
strcpy(fileTitle, fileName);
}
else
{
strcpy(fileTitle, pathEnd + 1);
}
}
void GetFilePath(const char* fileName, char path[_MAX_PATH])
{
const char* slash1 = strrchr(fileName, '\\');
const char* slash2 = strrchr(fileName, '/');
const char* pathEnd = max(slash1, slash2);
if (pathEnd == NULL)
{
// There's no path on the file name.
path[0] = 0;
}
else
{
size_t length = pathEnd - fileName + 1;
memcpy(path, fileName, length);
path[length] = 0;
}
}
bool LocateSymbolFile(const IMAGEHLP_MODULE64& moduleInfo, char fileName[_MAX_PATH])
{
// The search order for symbol files is described here:
// http://msdn2.microsoft.com/en-us/library/ms680689.aspx
// This function doesn't currently support the full spec.
const char* imageFileName = moduleInfo.LoadedImageName;
// First check the absolute path specified in the CodeView data.
if (GetFileExists(moduleInfo.CVData))
{
strncpy(fileName, moduleInfo.CVData, _MAX_PATH);
return true;
}
char symbolTitle[_MAX_PATH];
GetFileTitle(moduleInfo.CVData, symbolTitle);
// Now check in the same directory as the image.
char imagePath[_MAX_PATH];
GetFilePath(imageFileName, imagePath);
strcat(imagePath, symbolTitle);
if (GetFileExists(imagePath))
{
strncpy(fileName, imagePath, _MAX_PATH);
return true;
}
return false;
}
BOOL CALLBACK GatherSymbolsCallback(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
{
stdext::hash_map<std::string, DWORD64>* symbols = reinterpret_cast<stdext::hash_map<std::string, DWORD64>*>(UserContext);
if (pSymInfo != NULL && pSymInfo->Name != NULL)
{
symbols->insert(std::make_pair(pSymInfo->Name, pSymInfo->Address));
}
return TRUE;
}
BOOL CALLBACK FindSymbolsCallback(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
{
bool* found = reinterpret_cast<bool*>(UserContext);
*found = true;
return FALSE;
}
bool ScanForSignature(DWORD64 start, DWORD64 length, const char* signature)
{
unsigned int signatureLength = strlen(signature);
for (DWORD64 i = start; i < start + length - signatureLength; ++i)
{
void* p = reinterpret_cast<void*>(i);
// Check that we have read access to the data. For some reason under Windows
// Vista part of the DLL is not accessible (possibly some sort of new delay
// loading mechanism for DLLs?)
if (IsBadReadPtr(reinterpret_cast<LPCSTR>(p), signatureLength))
{
break;
}
if (memcmp(p, signature, signatureLength) == 0)
{
return true;
}
}
return false;
}
void LoadSymbolsRecursively(std::set<std::string>& loadedModules, stdext::hash_map<std::string, DWORD64>& symbols, HANDLE hProcess, HMODULE hModule)
{
assert(hModule != NULL);
char moduleName[_MAX_PATH];
GetModuleBaseName(hProcess, hModule, moduleName, _MAX_PATH);
if (loadedModules.find(moduleName) == loadedModules.end())
{
// Record that we've loaded this module so that we don't
// try to load it again.
loadedModules.insert(moduleName);
MODULEINFO moduleInfo = { 0 };
GetModuleInformation(hProcess, hModule, &moduleInfo, sizeof(moduleInfo));
char moduleFileName[_MAX_PATH];
GetModuleFileNameEx(hProcess, hModule, moduleFileName, _MAX_PATH);
DWORD64 base = SymLoadModule64_dll(hProcess, NULL, moduleFileName, moduleName, (DWORD64)moduleInfo.lpBaseOfDll, moduleInfo.SizeOfImage);
#ifdef VERBOSE
char message[1024];
_snprintf(message, 1024, "Examining '%s' %s\n", moduleName, base ? "(symbols loaded)" : "");
DebugBackend::Get().Log(message);
#endif
// Check to see if there was a symbol file we failed to load (usually
// becase it didn't match the version of the module).
IMAGEHLP_MODULE64 module;
memset(&module, 0, sizeof(module));
module.SizeOfStruct = sizeof(module);
BOOL result = SymGetModuleInfo64_dll(hProcess, base, &module);
if (result && module.SymType == SymNone)
{
// No symbols were found. Check to see if the module file name + ".pdb"
// exists, since the symbol file and/or module names may have been renamed.
char pdbFileName[_MAX_PATH];
strcpy(pdbFileName, moduleFileName);
ReplaceExtension(pdbFileName, "pdb");
if (GetFileExists(pdbFileName))
{
SymUnloadModule64_dll(hProcess, base);
base = SymLoadModule64_dll(hProcess, NULL, pdbFileName, moduleName, (DWORD64)moduleInfo.lpBaseOfDll, moduleInfo.SizeOfImage);
if (base != 0)
{
result = SymGetModuleInfo64_dll(hProcess, base, &module);
}
else
{
result = FALSE;
}
}
}
if (result)
{
// Check to see if we've already warned about this module.
if (g_warnedAboutPdb.find(moduleFileName) == g_warnedAboutPdb.end())
{
if (strlen(module.CVData) > 0 && (module.SymType == SymExport || module.SymType == SymNone))
{
char symbolFileName[_MAX_PATH];
if (LocateSymbolFile(module, symbolFileName))
{
char message[1024];
_snprintf(message, 1024, "Warning 1002: Symbol file '%s' located but it does not match module '%s'", symbolFileName, moduleFileName);
DebugBackend::Get().Message(message, MessageType_Warning);
}
// Remember that we've checked on this file, so no need to check again.
g_warnedAboutPdb.insert(moduleFileName);
}
}
}
if (base != 0)
{
// SymFromName is really slow, so we gather up our own list of the symbols that we
// can index much faster.
SymEnumSymbols_dll(hProcess, base, "lua*", GatherSymbolsCallback, reinterpret_cast<PVOID>(&symbols));
}
// Check to see if the module contains the Lua signature but we didn't find any Lua functions.
if (g_warnedAboutLua.find(moduleFileName) == g_warnedAboutLua.end())
{
// Check to see if this module contains any Lua functions loaded from the symbols.
bool foundLuaFunctions = false;
if (base != 0)
{
SymEnumSymbols_dll(hProcess, base, "lua_*", FindSymbolsCallback, &foundLuaFunctions);
}
if (!foundLuaFunctions)
{
// Check to see if this module contains a string from the Lua source code. If it's there, it probably
// means this module has Lua compiled into it.
bool luaFile = ScanForSignature((DWORD64)hModule, moduleInfo.SizeOfImage, "$Lua:");
if (luaFile)
{
char message[1024];
_snprintf(message, 1024, "Warning 1001: '%s' appears to contain Lua functions however no Lua functions could located with the symbolic information", moduleFileName);
DebugBackend::Get().Message(message, MessageType_Warning);
}
}
// Remember that we've checked on this file, so no need to check again.
g_warnedAboutLua.insert(moduleFileName);
}
// Get the imports for the module. These are loaded before we're able to hook
// LoadLibrary for the module.
std::vector<std::string> imports;
GetModuleImports(hProcess, hModule, imports);
for (unsigned int i = 0; i < imports.size(); ++i)
{
HMODULE hImportModule = GetModuleHandle(imports[i].c_str());
// Sometimes the import module comes back NULL, which means that for some reason
// it wasn't loaded. Perhaps these are delay loaded and we'll catch them later?
if (hImportModule != NULL)
{
LoadSymbolsRecursively(loadedModules, symbols, hProcess, hImportModule);
}
}
}
}
BOOL CALLBACK SymbolCallbackFunction(HANDLE hProcess, ULONG code, ULONG64 data, ULONG64 UserContext)
{
if (code == CBA_DEBUG_INFO)
{
DebugBackend::Get().Message(reinterpret_cast<char*>(data));
}
return TRUE;
}
void PostLoadLibrary(HMODULE hModule)
{
extern HINSTANCE g_hInstance;
if (hModule == g_hInstance)
{
// Don't investigate ourself.
return;
}
HANDLE hProcess = GetCurrentProcess();
char moduleName[_MAX_PATH];
GetModuleBaseName(hProcess, hModule, moduleName, _MAX_PATH);
CriticalSectionLock lock(g_loadedModulesCriticalSection);
if (g_loadedModules.find(moduleName) == g_loadedModules.end())
{
// Record that we've loaded this module so that we don't
// try to load it again.
g_loadedModules.insert(moduleName);
if (!g_initializedDebugHelp)
{
if (!SymInitialize_dll(hProcess, g_symbolsDirectory.c_str(), FALSE))
{
return;
}
g_initializedDebugHelp = true;
}
//SymSetOptions(SYMOPT_DEBUG);
std::set<std::string> loadedModules;
stdext::hash_map<std::string, DWORD64> symbols;
LoadSymbolsRecursively(loadedModules, symbols, hProcess, hModule);
LoadLuaFunctions(symbols, hProcess);
//SymCleanup_dll(hProcess);
//hProcess = NULL;
}
}
void HookLoadLibrary()
{
HMODULE hModuleKernel = GetModuleHandle("kernel32.dll");
if (hModuleKernel != NULL)
{
// LoadLibraryExW is called by the other LoadLibrary functions, so we
// only need to hook it.
LoadLibraryExW_dll = (LoadLibraryExW_t) HookFunction( GetProcAddress(hModuleKernel, "LoadLibraryExW"), LoadLibraryExW_intercept);
}
// These NTDLL functions are undocumented and don't exist in Windows 2000.
HMODULE hModuleNt = GetModuleHandle("ntdll.dll");
if (hModuleNt != NULL)
{
LdrLockLoaderLock_dll = (LdrLockLoaderLock_t) GetProcAddress(hModuleNt, "LdrLockLoaderLock");
LdrUnlockLoaderLock_dll = (LdrUnlockLoaderLock_t) GetProcAddress(hModuleNt, "LdrUnlockLoaderLock");
}
}
bool InstallLuaHooker(HINSTANCE hInstance, const char* symbolsDirectory)
{
// Load the dbghelp functions. We have to do this dynamically since the
// older version of dbghelp that ships with Windows doesn't successfully
// load the symbols from PDBs. We can't simply include our new DLL since
// it needs to be in the directory for the application we're *debugging*
// since this DLL is injected.
if (!LoadDebugHelp(hInstance))
{
return false;
}
g_symbolsDirectory = symbolsDirectory;
// Add the "standard" stuff to the symbols directory search path.
g_symbolsDirectory += ";" + GetApplicationDirectory();
g_symbolsDirectory += ";" + GetEnvironmentVariable("_NT_SYMBOL_PATH");
g_symbolsDirectory += ";" + GetEnvironmentVariable("_NT_ALTERNATE_SYMBOL_PATH");
// Hook LoadLibrary* functions so that we can intercept those calls and search
// for Lua functions.
HookLoadLibrary();
// Avoid deadlock if a new DLL is loaded during this function.
ULONG cookie;
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrLockLoaderLock_dll(0, 0, &cookie);
}
// Process all of the loaded modules.
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0);
if (hSnapshot == NULL)
{
// If for some reason we couldn't take a snapshot, just load the
// main module. This shouldn't ever happen, but we do it just in
// case.
HMODULE hModule = GetModuleHandle(NULL);
PostLoadLibrary(hModule);
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrUnlockLoaderLock_dll(0, cookie);
}
return true;
}
MODULEENTRY32 module;
module.dwSize = sizeof(MODULEENTRY32);
BOOL moreModules = Module32First(hSnapshot, &module);
while (moreModules)
{
PostLoadLibrary(module.hModule);
moreModules = Module32Next(hSnapshot, &module);
}
CloseHandle(hSnapshot);
hSnapshot = NULL;
if (LdrLockLoaderLock_dll != NULL &&
LdrUnlockLoaderLock_dll != NULL)
{
LdrUnlockLoaderLock_dll(0, cookie);
}
return true;
}
bool GetIsLuaLoaded()
{
return g_loadedLuaFunctions;
}
bool GetIsStdCall(unsigned long api)
{
return g_interfaces[api].stdcall;
}
struct CFunctionArgs
{
unsigned long api;
lua_CFunction_dll function;
};
#pragma auto_inline(off)
int CFunctionHandlerWorker(CFunctionArgs* args, lua_State* L, bool& stdcall)
{
stdcall = g_interfaces[args->api].stdcall;
return args->function(args->api, L);
}
#pragma auto_inline()
__declspec(naked) int CFunctionHandler(CFunctionArgs* args, lua_State* L)
{
int result;
bool stdcall;
INTERCEPT_PROLOG()
stdcall = false;
result = CFunctionHandlerWorker(args, L, stdcall);
INTERCEPT_EPILOG(4)
}
lua_CFunction CreateCFunction(unsigned long api, lua_CFunction_dll function)
{
// This is never deallocated, but it doesn't really matter since we never
// destroy these functions.
CFunctionArgs* args = new CFunctionArgs;
args->api = api;
args->function = function;
return (lua_CFunction)InstanceFunction(CFunctionHandler, reinterpret_cast<unsigned long>(args));
}
| 31.534209
| 185
| 0.63523
|
KoSukeWork
|
de0b01b7a122dc6a5665f7aa8c2ea7043f687258
| 1,065
|
cpp
|
C++
|
backends/mysql/factory.cpp
|
staticlibs/lookaside_soci
|
b3326cff7d4cf2dc122179eb8b988f2521944550
|
[
"BSL-1.0"
] | null | null | null |
backends/mysql/factory.cpp
|
staticlibs/lookaside_soci
|
b3326cff7d4cf2dc122179eb8b988f2521944550
|
[
"BSL-1.0"
] | null | null | null |
backends/mysql/factory.cpp
|
staticlibs/lookaside_soci
|
b3326cff7d4cf2dc122179eb8b988f2521944550
|
[
"BSL-1.0"
] | null | null | null |
//
// Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton
// MySQL backend copyright (C) 2006 Pawel Aleksander Fedorynski
// 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)
//
#define SOCI_MYSQL_SOURCE
#include "soci-mysql.h"
#include <backend-loader.h>
#include <ciso646>
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
using namespace soci;
using namespace soci::details;
// concrete factory for MySQL concrete strategies
mysql_session_backend * mysql_backend_factory::make_session(
connection_parameters const & parameters) const
{
return new mysql_session_backend(parameters);
}
mysql_backend_factory const soci::mysql;
extern "C"
{
// for dynamic backend loading
SOCI_MYSQL_DECL backend_factory const * factory_mysql()
{
return &soci::mysql;
}
SOCI_MYSQL_DECL void register_factory_mysql()
{
soci::dynamic_backends::register_backend("mysql", soci::mysql);
}
} // extern "C"
| 23.152174
| 68
| 0.728638
|
staticlibs
|
de1512531606f78f11f625dbbea6669b2579e2e4
| 1,843
|
cpp
|
C++
|
CK2ToEU4/Source/Mappers/MonumentsMapper/BuildTriggerBuilder.cpp
|
Zemurin/CK2ToEU4
|
f28971fb877497cc4117689d1600a8721466c365
|
[
"MIT"
] | 3
|
2020-05-06T21:50:00.000Z
|
2022-03-15T19:16:19.000Z
|
CK2ToEU4/Source/Mappers/MonumentsMapper/BuildTriggerBuilder.cpp
|
Zemurin/CK2ToEU4
|
f28971fb877497cc4117689d1600a8721466c365
|
[
"MIT"
] | 3
|
2022-02-01T19:35:02.000Z
|
2022-03-02T17:34:16.000Z
|
CK2ToEU4/Source/Mappers/MonumentsMapper/BuildTriggerBuilder.cpp
|
Zemurin/CK2ToEU4
|
f28971fb877497cc4117689d1600a8721466c365
|
[
"MIT"
] | 1
|
2020-05-06T21:50:04.000Z
|
2020-05-06T21:50:04.000Z
|
#include "BuildTriggerBuilder.h"
#include "CommonRegexes.h"
#include "ParserHelpers.h"
#include <iomanip>
mappers::BuildTriggerBuilder::BuildTriggerBuilder()
{
registerKeys();
clearRegisteredKeywords();
}
mappers::BuildTriggerBuilder::BuildTriggerBuilder(std::istream& theStream)
{
registerKeys();
parseStream(theStream);
clearRegisteredKeywords();
buildTrigger += "\n\t}";
}
void mappers::BuildTriggerBuilder::registerKeys()
{
registerKeyword("religious_groups", [this](const std::string& mods, std::istream& theStream) {
const auto& groups = commonItems::stringList(theStream).getStrings();
for (auto& group: groups)
{
buildTrigger += ("AND = {\n\t\t\t\treligion_group = " + group + "\n\t\t\t\thas_owner_religion = yes\n\t\t\t}\n\t\t");
}
});
registerKeyword("cultural_groups", [this](const std::string& mods, std::istream& theStream) {
const auto& groups = commonItems::stringList(theStream).getStrings();
for (auto& group: groups)
{
buildTrigger += ("AND = {\n\t\t\t\tculture_group = " + group + "\n\t\t\t\thas_owner_culture = yes\n\t\t\t}\n\t\t");
}
});
registerKeyword("cultural", [this](const std::string& mods, std::istream& theStream) {
cultural = commonItems::getString(theStream).find("yes") != std::string::npos;
});
registerKeyword("religious", [this](const std::string& mods, std::istream& theStream) {
religious = commonItems::getString(theStream).find("yes") != std::string::npos;
});
registerKeyword("other", [this](const std::string& mods, std::istream& theStream) {
auto tempInput = commonItems::stringOfItem(theStream).getString();
tempInput = tempInput.substr(tempInput.find('{') + 1, tempInput.length());
tempInput = tempInput.substr(0, tempInput.find_last_of('}'));
buildTrigger += tempInput;
});
registerRegex(commonItems::catchallRegex, commonItems::ignoreItem);
}
| 37.612245
| 120
| 0.708627
|
Zemurin
|
de1762591476a9ae30810597e9db0c6e6f0d2d72
| 3,001
|
hpp
|
C++
|
include/paal/greedy/knapsack_unbounded_two_app.hpp
|
Kommeren/AA
|
e537b58d50e93d4a72709821b9ea413008970c6b
|
[
"BSL-1.0"
] | null | null | null |
include/paal/greedy/knapsack_unbounded_two_app.hpp
|
Kommeren/AA
|
e537b58d50e93d4a72709821b9ea413008970c6b
|
[
"BSL-1.0"
] | null | null | null |
include/paal/greedy/knapsack_unbounded_two_app.hpp
|
Kommeren/AA
|
e537b58d50e93d4a72709821b9ea413008970c6b
|
[
"BSL-1.0"
] | 1
|
2021-02-24T06:23:56.000Z
|
2021-02-24T06:23:56.000Z
|
//=======================================================================
// Copyright (c) 2013 Piotr Wygocki
//
// 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)
//=======================================================================
/**
* @file knapsack_unbounded_two_app.hpp
* @brief
* @author Piotr Wygocki
* @version 1.0
* @date 2013-10-07
*/
#ifndef PAAL_KNAPSACK_UNBOUNDED_TWO_APP_HPP
#define PAAL_KNAPSACK_UNBOUNDED_TWO_APP_HPP
#include "paal/utils/accumulate_functors.hpp"
#include "paal/utils/type_functions.hpp"
#include "paal/greedy/knapsack/knapsack_greedy.hpp"
#include <boost/iterator/counting_iterator.hpp>
#include <boost/iterator/filter_iterator.hpp>
#include <type_traits>
#include <utility>
namespace paal {
namespace detail {
template <typename KnapsackData,
typename ObjectIter = typename KnapsackData::object_iter,
typename Size = typename KnapsackData::size,
typename Value = typename KnapsackData::value>
std::tuple<Value, Size,
std::pair<ObjectIter, unsigned>>
get_greedy_fill(KnapsackData knap_data, unbounded_tag) {
auto density = knap_data.get_density();
auto most_dense_iter = max_element_functor(
knap_data.get_objects(), density).base();
unsigned nr = knap_data.get_capacity() / knap_data.get_size(*most_dense_iter);
Value value_sum = Value(nr) * knap_data.get_value(*most_dense_iter);
Size size_sum = Size (nr) * knap_data.get_size (*most_dense_iter);
return std::make_tuple(value_sum, size_sum,
std::make_pair(most_dense_iter, nr));
}
template <typename ObjectsIterAndNr, typename OutputIter>
void greedy_to_output(ObjectsIterAndNr most_dense_iter_and_nr, OutputIter & out,
unbounded_tag) {
auto nr = most_dense_iter_and_nr.second;
auto most_dense_iter = most_dense_iter_and_nr.first;
for (unsigned i = 0; i < nr; ++i) {
*out = *most_dense_iter;
++out;
}
}
} //! detail
///this version of algorithm might permute, the input range
template <typename OutputIterator, typename Objects,
typename ObjectSizeFunctor, typename ObjectValueFunctor,
//this enable if assures that range can be permuted
typename std::enable_if<!detail::is_range_const<Objects>::value>::type * = nullptr>
typename detail::knapsack_base<Objects, ObjectSizeFunctor,
ObjectValueFunctor>::return_type
knapsack_unbounded_two_app(
Objects && objects,
typename detail::FunctorOnRangePValue<ObjectSizeFunctor, Objects> capacity,
OutputIterator out, ObjectValueFunctor value, ObjectSizeFunctor size) {
return detail::knapsack_general_two_app(
detail::make_knapsack_data(std::forward<Objects>(objects), capacity, size, value, out),
detail::unbounded_tag{});
}
} //! paal
#endif // PAAL_KNAPSACK_UNBOUNDED_TWO_APP_HPP
| 37.049383
| 99
| 0.682439
|
Kommeren
|
de186757d5f211e9eefcc8284dab4f7f0f29630d
| 1,920
|
hpp
|
C++
|
include/clotho/cuda/sampling/random_sample_sequence.hpp
|
putnampp/clotho
|
6dbfd82ef37b4265381cd78888cd6da8c61c68c2
|
[
"ECL-2.0",
"Apache-2.0"
] | 3
|
2015-06-16T21:27:57.000Z
|
2022-01-25T23:26:54.000Z
|
include/clotho/cuda/sampling/random_sample_sequence.hpp
|
putnampp/clotho
|
6dbfd82ef37b4265381cd78888cd6da8c61c68c2
|
[
"ECL-2.0",
"Apache-2.0"
] | 3
|
2015-06-16T21:12:42.000Z
|
2015-06-23T12:41:00.000Z
|
include/clotho/cuda/sampling/random_sample_sequence.hpp
|
putnampp/clotho
|
6dbfd82ef37b4265381cd78888cd6da8c61c68c2
|
[
"ECL-2.0",
"Apache-2.0"
] | null | null | null |
// Copyright 2015 Patrick Putnam
//
// 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.
#ifndef RANDOM_SAMPLE_SEQUENCE_SPACE_HPP_
#define RANDOM_SAMPLE_SEQUENCE_SPACE_HPP_
#include "clotho/cuda/sampling/random_sample_def.hpp"
#include "clotho/cuda/data_spaces/sequence_space/device_sequence_space.hpp"
#include "clotho/cuda/data_spaces/basic_data_space.hpp"
template < class StateType, class IntType, class IntType2 = unsigned int >
__global__ void random_sample( StateType * states
, device_sequence_space< IntType > * src
, unsigned int N
, basic_data_space< IntType2 > * index_space ) {
typedef StateType state_type;
unsigned int tid = threadIdx.y * blockDim.x + threadIdx.x;
state_type local_state = states[ tid ];
IntType2 M = src->seq_count;
if( tid == 0 ) {
_resize_space_impl( index_space, N );
}
__syncthreads();
unsigned int i = tid;
unsigned int * ids = index_space->data;
unsigned int tpb = blockDim.x * blockDim.y;
while( i < N ) {
float x = curand_uniform( &local_state );
IntType2 pidx = (IntType2)(x * M);
pidx = ((pidx >= M) ? 0 : pidx); // wrap around indexes
ids[ i ] = pidx;
i += tpb;
}
states[tid] = local_state;
}
#endif // RANDOM_SAMPLE_SEQUENCE_SPACE_HPP_
| 32.542373
| 80
| 0.657292
|
putnampp
|
de1bc3d98cf3febde5e05f2ab8b3ce6f4fabfdc4
| 2,739
|
cpp
|
C++
|
src/ssd/NVM_Transaction_Flash.cpp
|
rakeshnadig/MQSIM_Fine_Grained_Mapping_Reference
|
61546ccbae3ecd4312757cb54ac9af5a0d01e9ae
|
[
"MIT"
] | null | null | null |
src/ssd/NVM_Transaction_Flash.cpp
|
rakeshnadig/MQSIM_Fine_Grained_Mapping_Reference
|
61546ccbae3ecd4312757cb54ac9af5a0d01e9ae
|
[
"MIT"
] | null | null | null |
src/ssd/NVM_Transaction_Flash.cpp
|
rakeshnadig/MQSIM_Fine_Grained_Mapping_Reference
|
61546ccbae3ecd4312757cb54ac9af5a0d01e9ae
|
[
"MIT"
] | null | null | null |
#include "NVM_Transaction_Flash.h"
#include "assert.h"
namespace SSD_Components
{
NVM_Transaction_Flash::NVM_Transaction_Flash(
Transaction_Source_Type source,
Transaction_Type type,
stream_id_type stream_id,
unsigned int data_size_in_byte,
LPA_type lpa,
PPA_type ppa,
User_Request* user_request):
NVM_Transaction(
stream_id,
source,
type,
user_request),
Data_and_metadata_size_in_byte(data_size_in_byte),
Physical_address_determined(false),
FLIN_Barrier(false)
{
LPAs.push_back (lpa);
PPAs.push_back (ppa);
}
NVM_Transaction_Flash::NVM_Transaction_Flash(
Transaction_Source_Type source,
Transaction_Type type,
stream_id_type stream_id,
unsigned int data_size_in_byte,
LPA_type lpa,
PPA_type ppa,
const NVM::FlashMemory::Physical_Page_Address& address,
User_Request* user_request) :
NVM_Transaction(
stream_id,
source,
type,
user_request),
Data_and_metadata_size_in_byte(data_size_in_byte),
Address(address),
Physical_address_determined(false)
{
LPAs.push_back (lpa);
PPAs.push_back (ppa);
}
//FGM - LPAs
unsigned int NVM_Transaction_Flash::num_lpas ()
{
return LPAs.size ();
}
LPA_type NVM_Transaction_Flash::get_lpa ()
{
if (!LPAs.empty()) return LPAs[0];
}
LPA_type NVM_Transaction_Flash::get_lpa (int idx)
{
if (!LPAs.empty()) return LPAs[idx];
}
void NVM_Transaction_Flash::set_lpa (LPA_type lpa)
{
if (!LPAs.empty()) LPAs.push_back (lpa);
else LPAs[0] = lpa;
}
void NVM_Transaction_Flash::set_lpa (LPA_type lpa, int idx)
{
assert(LPAs.size() >= idx);
if (LPAs.empty()) LPAs.push_back(lpa);
else LPAs[idx] = lpa;
}
//FGM - PPAs
unsigned int NVM_Transaction_Flash::num_ppas ()
{
return PPAs.size ();
}
PPA_type NVM_Transaction_Flash::get_ppa ()
{
if (!PPAs.empty()) return PPAs[0];
}
PPA_type NVM_Transaction_Flash::get_ppa (int idx)
{
if (!PPAs.empty()) return PPAs[idx];
}
void NVM_Transaction_Flash::set_ppa (PPA_type ppa)
{
if (!PPAs.empty()) PPAs.push_back (ppa);
else PPAs[0] = ppa;
}
void NVM_Transaction_Flash::set_ppa (PPA_type ppa, int idx)
{
assert(PPAs.size() >= idx);
if (PPAs.empty()) PPAs.push_back (ppa);
else PPAs[idx] = ppa;
}
//FGM - LPAs for GC
void NVM_Transaction_Flash::replace_lpa(LPA_type lpa, int idx, int i)
{
assert(!LPAs.empty());
LPAs.erase ( LPAs.begin() + idx );
LPAs.insert( LPAs.begin()+ idx, lpa);
Waiting_LPAs.erase( Waiting_LPAs.begin() + i );
}
void NVM_Transaction_Flash:: set_waiting_lpas (LPA_type lpa)
{
Waiting_LPAs.push_back(lpa);
}
LPA_type NVM_Transaction_Flash:: get_waiting_lpas (int idx)
{
assert(!Waiting_LPAs.empty());
return Waiting_LPAs[idx];
}
}
| 22.08871
| 70
| 0.700256
|
rakeshnadig
|
de1cad88979b70e2929438d25bd08990d0b61807
| 571
|
cpp
|
C++
|
Hackerrank/Ice Cream Parlor.cpp
|
SurgicalSteel/Competitive-Programming
|
3662b676de94796f717b25dc8d1b93c6851fb274
|
[
"MIT"
] | 14
|
2016-02-11T09:26:13.000Z
|
2022-03-27T01:14:29.000Z
|
Hackerrank/Ice Cream Parlor.cpp
|
SurgicalSteel/Competitive-Programming
|
3662b676de94796f717b25dc8d1b93c6851fb274
|
[
"MIT"
] | null | null | null |
Hackerrank/Ice Cream Parlor.cpp
|
SurgicalSteel/Competitive-Programming
|
3662b676de94796f717b25dc8d1b93c6851fb274
|
[
"MIT"
] | 7
|
2016-10-25T19:29:35.000Z
|
2021-12-05T18:31:39.000Z
|
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int tc,m,n,temp;
scanf("%d",&tc);
for(int i=0;i<tc;i++)
{
vector<int> v;
cin>>m>>n;
for(int x=0;x<n;x++)
{
cin>>temp;
v.push_back(temp);
}
for(int x=0;x<v.size();x++)
{
for(int y=x+1;y<v.size();y++)
{
if(v[x]+v[y]==m)
printf("%d %d\n",x+1,y+1);
}
}
}
return 0;
}
| 19.033333
| 42
| 0.401051
|
SurgicalSteel
|
de1d06e0de9697325f3340fbd3fbeb80b7bd7893
| 499
|
cpp
|
C++
|
app/src/main/cpp/src/meshes/sphere.cpp
|
danielesteban/GLTest
|
62f9e45adc1073d3d8ad5072266dc8a353f6e421
|
[
"MIT"
] | 3
|
2018-01-01T14:27:29.000Z
|
2019-01-20T03:14:41.000Z
|
app/src/main/cpp/src/meshes/sphere.cpp
|
danielesteban/GLTest
|
62f9e45adc1073d3d8ad5072266dc8a353f6e421
|
[
"MIT"
] | null | null | null |
app/src/main/cpp/src/meshes/sphere.cpp
|
danielesteban/GLTest
|
62f9e45adc1073d3d8ad5072266dc8a353f6e421
|
[
"MIT"
] | null | null | null |
#include "sphere.hpp"
void Sphere::init(btDiscreteDynamicsWorld *world, Model *model, const btVector3 position) {
Mesh::init(world, model, position, btQuaternion(0.0f, 0.0f, 0.0f, 1.0f), btScalar(5.0f));
albedo = glm::vec4(
(float) rand() / (float) RAND_MAX,
(float) rand() / (float) RAND_MAX,
(float) rand() / (float) RAND_MAX,
1.0f
);
}
void Sphere::render(const Camera *camera) {
glUniform4fv(model->shader->albedo, 1, glm::value_ptr(albedo));
Mesh::render(camera);
}
| 29.352941
| 91
| 0.661323
|
danielesteban
|
de20076bcede28ced3262762f5efb7d754b21b9f
| 2,441
|
cpp
|
C++
|
ICPC/UESTC_kanna_prpr training - 2017-11-21 /h.cpp
|
emengdeath/acmcode
|
cc1b0e067464e754d125856004a991d6eb92a2cd
|
[
"MIT"
] | null | null | null |
ICPC/UESTC_kanna_prpr training - 2017-11-21 /h.cpp
|
emengdeath/acmcode
|
cc1b0e067464e754d125856004a991d6eb92a2cd
|
[
"MIT"
] | null | null | null |
ICPC/UESTC_kanna_prpr training - 2017-11-21 /h.cpp
|
emengdeath/acmcode
|
cc1b0e067464e754d125856004a991d6eb92a2cd
|
[
"MIT"
] | null | null | null |
#include<iostream>
#include<algorithm>
#include<cstdio>
#define N 1000000
using namespace std;
int f[N][2],size[N];
int n,tot;
int g[N],d[N],a[N][4],fa[N],b[N];
struct node{
int x,l,r;
}c[N];
int sum;
void ins(int x,int y){
a[++sum][0]=y,a[sum][1]=g[x],g[x]=sum;
}
void dfs(int x){
size[x]=1;
for (int i=g[x];i;i=a[i][1])
dfs(a[i][0]),size[x]+=size[a[i][0]];
d[0]=0;
for (int i=g[x];i;i=a[i][1])
d[++d[0]]=i;
f[x][0]=f[x][1]=0;
while (d[0]){
int v=f[x][0];
int i=d[d[0]--];
if (f[a[i][0]][0]>=f[a[i][0]][1])a[i][2]=0;
else
a[i][2]=1;
f[x][0]=f[x][0]+max(f[a[i][0]][0],f[a[i][0]][1]);
if (f[x][1]+max(f[a[i][0]][0],f[a[i][0]][1])>=v+f[a[i][0]][0]+1){
if (f[a[i][0]][0]>=f[a[i][0]][1])
a[i][3]=0;
else
a[i][3]=1;
}else
a[i][3]=2;
f[x][1]=max(f[x][1]+max(f[a[i][0]][0],f[a[i][0]][1]),v+f[a[i][0]][0]+1);
}
}
void dfs1(int x,int y){
if (!g[x])return;
for (int i=g[x];i;i=a[i][1]){
if (y){
if (a[i][3]==0){
b[++b[0]]=a[i][0],dfs1(a[i][0],0);
}else
if (a[i][3]==1){
dfs1(a[i][0],1);
}else
y=0,dfs1(a[i][0],0);
}else{
if (a[i][2]==0)b[++b[0]]=a[i][0],dfs1(a[i][0],0);
else
dfs1(a[i][0],1);
}
}
}
bool cmp(const node&a,const node&b){
return a.r-a.l>b.r-b.l;
}
void update(int x,int y){
ins(x,y);
fa[y]=x;
}
int main(){
freopen("hidden.in","r",stdin);
freopen("hidden.out","w",stdout);
scanf("%d",&n);
for (int i=2;i<=n;i++){
scanf("%d",&fa[i]);
if (fa[i])
ins(fa[i],i);
}
c[++tot].x=1;
c[tot].l=b[0]+1;
dfs(1);
if (f[1][0]>=f[1][1])b[++b[0]]=1,dfs1(1,0);
else
dfs1(1,1);
c[tot].r=b[0];
for (int i=2;i<=n;i++)
if (!fa[i]){
dfs(i);
if (f[i][1]*2==size[i]){
update(1,i);
continue;
}
c[++tot].x=i;
c[tot].l=b[0]+1;
b[++b[0]]=i;
for (int j=g[i];j;j=a[j][1]){
dfs(a[j][0]);
if (f[a[j][0]][0]>=f[a[j][0]][1])b[++b[0]]=a[j][0],dfs1(a[j][0],0);
else
dfs1(a[j][0],1);
}
c[tot].r=b[0];
}
sort(c+2,c+tot+1,cmp);
int l=1;
d[0]=0;
for (int i=c[1].l;i<=c[1].r;i++)
d[++d[0]]=b[i];
for (int i=2;i<=tot;i++){
if (l<=d[0]){
update(d[l],c[i].x);
l++;
for (int j=c[i].l+1;j<=c[i].r;j++)
d[++d[0]]=b[j];
}else{
update(1,c[i].x);
d[++d[0]]=c[i].x;
swap(d[l],d[d[0]]);
for (int j=c[i].l+1;j<=c[i].r;j++)
d[++d[0]]=b[j];
}
}
dfs(1);
printf("%d\n",max(f[1][1],f[1][0]));
printf("%d",fa[2]);
for (int i=3;i<=n;i++)
printf(" %d",fa[i]);
return 0;
}
| 19.373016
| 74
| 0.436706
|
emengdeath
|
de24e400710212eb9a22f123a370205a326213a9
| 1,424
|
cpp
|
C++
|
src/States/Menu/MainMenu.cpp
|
BertilBraun/MyClone
|
9573084e9a561b91995683ba016088174414a545
|
[
"MIT"
] | 4
|
2019-01-10T18:39:53.000Z
|
2022-01-15T21:38:28.000Z
|
src/States/Menu/MainMenu.cpp
|
BOTOrtwin/MyClone
|
9573084e9a561b91995683ba016088174414a545
|
[
"MIT"
] | 14
|
2018-09-30T21:48:35.000Z
|
2018-10-05T08:46:40.000Z
|
src/States/Menu/MainMenu.cpp
|
BOTOrtwin/MyClone
|
9573084e9a561b91995683ba016088174414a545
|
[
"MIT"
] | 1
|
2019-12-23T19:35:54.000Z
|
2019-12-23T19:35:54.000Z
|
#include "MainMenu.h"
#include "Utils/ToggleKey.h"
#include "Application.h"
#include "MenuWorldSelect.h"
MainMenu::MainMenu(Application& applic) :
StateBase(applic),
background(glm::vec2(0.5f, 0.5f), glm::vec2(1, 1), "GUI/background.jpg", (*app->getWindow()))
{
buttons.emplace_back(glm::vec2(0.5f, 0.4f), glm::vec2(0.2f, 0.065f), "Button", "HoverButton", "PLAY", (*app->getWindow()), [&] { app->pushState<MenuWorldSelect>(*app); });
buttons.emplace_back(glm::vec2(0.5f, 0.5f), glm::vec2(0.2f, 0.065f), "Button", "HoverButton", "OPTIONS NA", (*app->getWindow()));
buttons.emplace_back(glm::vec2(0.5f, 0.6f), glm::vec2(0.2f, 0.065f), "Button", "HoverButton", "QUIT", (*app->getWindow()), [&] { app->popState(); });
}
MainMenu::~MainMenu()
{
}
void MainMenu::handleInput(float deltaTime, const Camera & camera)
{
}
void MainMenu::update(float deltaTime) {
for (Button& button : buttons)
button.pressed((*app->getWindow()));
}
void MainMenu::render(MasterRenderer & renderer) {
background.draw(renderer);
for (Button& button : buttons)
button.draw(renderer);
}
void MainMenu::onOpen() {
const sf::RenderWindow& window = (*app->getWindow());
sf::Mouse::setPosition(sf::Vector2i(sf::Vector2f(window.getSize()) / 2.0f), window);
app->turnOnMouse();
updateCamera = false;
}
void MainMenu::onResume() {
app->turnOnMouse();
updateCamera = false;
for (Button& button : buttons)
button.resetButton();
}
| 27.921569
| 172
| 0.67486
|
BertilBraun
|
de27a6c8f9bbc73849ed220220a0e518f1332b0c
| 10,225
|
cpp
|
C++
|
OpenGL3DRendering/src/Renderer/Renderer.cpp
|
Sarius587/OpenGL3DRendering
|
fb87593a2c36c473ae5665fba6f16cfb55461b21
|
[
"Apache-2.0"
] | 1
|
2020-06-01T06:35:39.000Z
|
2020-06-01T06:35:39.000Z
|
OpenGL3DRendering/src/Renderer/Renderer.cpp
|
Sarius587/OpenGL3DRendering
|
fb87593a2c36c473ae5665fba6f16cfb55461b21
|
[
"Apache-2.0"
] | null | null | null |
OpenGL3DRendering/src/Renderer/Renderer.cpp
|
Sarius587/OpenGL3DRendering
|
fb87593a2c36c473ae5665fba6f16cfb55461b21
|
[
"Apache-2.0"
] | null | null | null |
#include "oglpch.h"
#include "Renderer.h"
#include "RendererAPI.h"
#include "Framebuffer.h"
namespace OpenGLRendering {
struct MeshInfo
{
Ref<VertexArray> VertexArray;
Ref<Material> Material;
glm::mat4 ModelMatrix;
};
struct RendererData
{
Ref<Camera> Camera;
Ref<Cubemap> Cubemap;
Ref<Shader> PBRShaderTextured;
Ref<Shader> PBRShader;
Ref<Shader> CubemapShader;
Ref<Shader> ColorGradingShader;
Ref<Shader> InvertColorShader;
Ref<Framebuffer> MultisampleFramebuffer;
Ref<Framebuffer> IntermediateFramebuffer;
Ref<Framebuffer> FinalFramebuffer;
std::vector<MeshInfo> Meshes;
LightInfo LightInfo;
Ref<VertexArray> QuadVertexArray;
bool RenderedToFinalBuffer;
RendererStats Stats;
};
static RendererData s_RendererData;
void Renderer::Init()
{
s_RendererData.PBRShaderTextured = CreateRef<Shader>("src/Resources/ShaderSource/PBR/vertex_textured_pbr.glsl", "src/Resources/ShaderSource/PBR/fragment_textured_pbr.glsl");
s_RendererData.PBRShader = CreateRef<Shader>("src/Resources/ShaderSource/PBR/vertex_static_pbr.glsl", "src/Resources/ShaderSource/PBR/fragment_static_pbr.glsl");
s_RendererData.CubemapShader = CreateRef<Shader>("src/Resources/ShaderSource/Cubemap/background_vertex.glsl", "src/Resources/ShaderSource/Cubemap/background_fragment.glsl");
s_RendererData.ColorGradingShader = CreateRef<Shader>("src/Resources/ShaderSource/PostProcessing/color_grading_vertex.glsl", "src/Resources/ShaderSource/PostProcessing/color_grading_fragment.glsl");
s_RendererData.InvertColorShader = CreateRef<Shader>("src/Resources/ShaderSource/PostProcessing/color_invert_vertex.glsl", "src/Resources/ShaderSource/PostProcessing/color_invert_fragment.glsl");
float quadVertices[] =
{
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
};
uint32_t quadIndices[] =
{
0, 1, 2,
0, 2, 3,
};
s_RendererData.QuadVertexArray = CreateRef<VertexArray>();
Ref<VertexBuffer> vb = CreateRef<VertexBuffer>(quadVertices, 5 * 4 * 4);
vb->SetLayout(
{
{ ShaderDataType::Float3, "a_Position" },
{ ShaderDataType::Float2, "a_TexCoords" },
});
Ref<IndexBuffer> ib = CreateRef<IndexBuffer>(quadIndices, 6);
s_RendererData.QuadVertexArray->AddVertexBuffer(vb);
s_RendererData.QuadVertexArray->SetIndexBuffer(ib);
FramebufferSettings settings = { 1920, 1080, true, true, 8 };
s_RendererData.MultisampleFramebuffer = CreateRef<Framebuffer>(settings);
settings = { 1920, 1080 };
s_RendererData.IntermediateFramebuffer = CreateRef<Framebuffer>(settings);
s_RendererData.FinalFramebuffer = CreateRef<Framebuffer>(settings);
}
void Renderer::OnResize(uint32_t width, uint32_t height)
{
s_RendererData.MultisampleFramebuffer->Resize(width, height);
s_RendererData.IntermediateFramebuffer->Resize(width, height);
s_RendererData.FinalFramebuffer->Resize(width, height);
}
void Renderer::BeginScene(Ref<Camera>& camera, Ref<Cubemap>& cubemap, const LightInfo& lightInfo)
{
s_RendererData.Camera = camera;
s_RendererData.Cubemap = cubemap;
s_RendererData.LightInfo = lightInfo;
s_RendererData.Stats.VertexCount = 0;
s_RendererData.Stats.FaceCount = 0;
s_RendererData.Stats.DrawCalls = 0;
s_RendererData.RenderedToFinalBuffer = false;
}
void Renderer::EndScene()
{
s_RendererData.MultisampleFramebuffer->Bind();
RendererAPI::Clear();
s_RendererData.Cubemap->BindIrradianceMap(0);
s_RendererData.Cubemap->BindPrefilterMap(1);
s_RendererData.Cubemap->BindBrdfLutTexture(2);
for (const MeshInfo& mesh : s_RendererData.Meshes)
{
if (mesh.Material->IsUsingTextures())
{
s_RendererData.PBRShaderTextured->Bind();
s_RendererData.PBRShaderTextured->SetMat4("u_Projection", s_RendererData.Camera->GetProjectionMatrix());
s_RendererData.PBRShaderTextured->SetMat4("u_View", s_RendererData.Camera->GetViewMatrix());
s_RendererData.PBRShaderTextured->SetMat4("u_Model", mesh.ModelMatrix);
s_RendererData.PBRShaderTextured->SetFloat3("u_LightPos", s_RendererData.LightInfo.LightPos);
s_RendererData.PBRShaderTextured->SetFloat3("u_LightColor", s_RendererData.LightInfo.LightColor);
s_RendererData.PBRShaderTextured->SetFloat3("u_CameraPos", s_RendererData.Camera->GetPosition());
s_RendererData.PBRShaderTextured->SetInt("u_IrradianceMap", 0);
s_RendererData.PBRShaderTextured->SetInt("u_PrefilterMap", 1);
s_RendererData.PBRShaderTextured->SetInt("u_BrdfLutTexture", 2);
const std::unordered_map<TextureType, Ref<Texture2D>>& textures = mesh.Material->GetTextures();
if (textures.find(TextureType::ALBEDO) != textures.end())
{
textures.at(TextureType::ALBEDO)->Bind(3);
s_RendererData.PBRShaderTextured->SetInt("u_TextureAlbedo", 3);
}
if (textures.find(TextureType::NORMAL) != textures.end())
{
textures.at(TextureType::NORMAL)->Bind(4);
s_RendererData.PBRShaderTextured->SetInt("u_TextureNormal", 4);
}
if (textures.find(TextureType::METALLIC_SMOOTHNESS) != textures.end())
{
textures.at(TextureType::METALLIC_SMOOTHNESS)->Bind(5);
s_RendererData.PBRShaderTextured->SetInt("u_TextureMetallicSmooth", 5);
}
if (textures.find(TextureType::AMBIENT_OCCLUSION) != textures.end())
{
textures.at(TextureType::AMBIENT_OCCLUSION)->Bind(6);
s_RendererData.PBRShaderTextured->SetInt("u_TextureAmbient", 6);
}
RendererAPI::DrawIndexed(mesh.VertexArray, 0);
s_RendererData.Stats.DrawCalls += 1;
}
else
{
s_RendererData.PBRShader->Bind();
s_RendererData.PBRShader->SetMat4("u_Projection", s_RendererData.Camera->GetProjectionMatrix());
s_RendererData.PBRShader->SetMat4("u_View", s_RendererData.Camera->GetViewMatrix());
s_RendererData.PBRShader->SetMat4("u_Model", mesh.ModelMatrix);
s_RendererData.PBRShader->SetFloat3("u_LightPos", s_RendererData.LightInfo.LightPos);
s_RendererData.PBRShader->SetFloat3("u_LightColor", s_RendererData.LightInfo.LightColor);
s_RendererData.PBRShader->SetFloat3("u_CameraPos", s_RendererData.Camera->GetPosition());
s_RendererData.PBRShader->SetInt("u_IrradianceMap", 0);
s_RendererData.PBRShader->SetInt("u_PrefilterMap", 1);
s_RendererData.PBRShader->SetInt("u_BrdfLutTexture", 2);
s_RendererData.PBRShader->SetFloat3("u_Albedo", mesh.Material->GetAlbedo());
s_RendererData.PBRShader->SetFloat("u_Roughness", mesh.Material->GetRoughness());
s_RendererData.PBRShader->SetFloat("u_Metallic", mesh.Material->GetMetallic());
s_RendererData.PBRShader->SetFloat("u_Ambient", mesh.Material->GetAmbientOcclusion());
RendererAPI::DrawIndexed(mesh.VertexArray, 0);
s_RendererData.Stats.DrawCalls += 1;
}
}
s_RendererData.Cubemap->BindEnvironmentMap(0);
s_RendererData.CubemapShader->Bind();
s_RendererData.CubemapShader->SetMat4("u_Projection", s_RendererData.Camera->GetProjectionMatrix());
s_RendererData.CubemapShader->SetMat4("u_View", s_RendererData.Camera->GetViewMatrix());
s_RendererData.CubemapShader->SetInt("u_EnvironmentMap", 0);
RendererAPI::DrawIndexed(s_RendererData.Cubemap->GetVertexArray(), 0);
s_RendererData.Stats.DrawCalls += 1;
s_RendererData.Meshes.clear();
RendererAPI::BlitFramebuffer(s_RendererData.MultisampleFramebuffer, s_RendererData.IntermediateFramebuffer);
}
void Renderer::Submit(Ref<Mesh>& mesh, const glm::mat4& modelMatrix)
{
s_RendererData.Meshes.push_back({ mesh->GetVertexArray(), mesh->GetMaterial(), modelMatrix });
s_RendererData.Stats.VertexCount += mesh->GetVertexCount();
s_RendererData.Stats.FaceCount += mesh->GetFaceCount();
}
void Renderer::Submit(Ref<Model>& model, uint16_t lod, uint16_t meshesPerLod)
{
for (unsigned int i = lod * meshesPerLod; i < (lod + 1) * meshesPerLod && i < model->GetMeshes().size(); i++)
{
const Mesh& mesh = model->GetMeshes()[i];
s_RendererData.Meshes.push_back({ mesh.GetVertexArray(), mesh.GetMaterial(), model->GetModelMatrix() });
s_RendererData.Stats.VertexCount += mesh.GetVertexCount();
s_RendererData.Stats.FaceCount += mesh.GetFaceCount();
}
}
void Renderer::Submit(Ref<Model>& model)
{
for (const Mesh& mesh : model->GetMeshes())
{
s_RendererData.Meshes.push_back({ mesh.GetVertexArray(), mesh.GetMaterial(), model->GetModelMatrix() });
s_RendererData.Stats.VertexCount += mesh.GetVertexCount();
s_RendererData.Stats.FaceCount += mesh.GetFaceCount();
}
}
void Renderer::ColorGrade(const glm::vec4& color)
{
if (s_RendererData.RenderedToFinalBuffer)
s_RendererData.IntermediateFramebuffer->Bind();
else
s_RendererData.FinalFramebuffer->Bind();
RendererAPI::Clear();
if (s_RendererData.RenderedToFinalBuffer)
s_RendererData.FinalFramebuffer->BindColorTexture(0);
else
s_RendererData.IntermediateFramebuffer->BindColorTexture(0);
s_RendererData.ColorGradingShader->Bind();
s_RendererData.ColorGradingShader->SetInt("u_Frame", 0);
s_RendererData.ColorGradingShader->SetFloat4("u_GradingColor", color);
RendererAPI::DrawIndexed(s_RendererData.QuadVertexArray, 0);
s_RendererData.RenderedToFinalBuffer = !s_RendererData.RenderedToFinalBuffer;
s_RendererData.FinalFramebuffer->Unbind();
}
void Renderer::InvertColor()
{
if (s_RendererData.RenderedToFinalBuffer)
s_RendererData.IntermediateFramebuffer->Bind();
else
s_RendererData.FinalFramebuffer->Bind();
RendererAPI::Clear();
if (s_RendererData.RenderedToFinalBuffer)
s_RendererData.FinalFramebuffer->BindColorTexture(0);
else
s_RendererData.IntermediateFramebuffer->BindColorTexture(0);
s_RendererData.InvertColorShader->Bind();
s_RendererData.InvertColorShader->SetInt("u_Frame", 0);
RendererAPI::DrawIndexed(s_RendererData.QuadVertexArray, 0);
s_RendererData.RenderedToFinalBuffer = !s_RendererData.RenderedToFinalBuffer;
s_RendererData.FinalFramebuffer->Unbind();
}
const RendererStats& Renderer::GetStatistics()
{
return s_RendererData.Stats;
}
uint32_t Renderer::GetFrameTextureId()
{
return s_RendererData.RenderedToFinalBuffer ? s_RendererData.FinalFramebuffer->GetColorTextureId() : s_RendererData.IntermediateFramebuffer->GetColorTextureId();
}
}
| 36.3879
| 200
| 0.757653
|
Sarius587
|
de2e81e9973c5234f6acbefde666cdf584e596e1
| 6,211
|
cc
|
C++
|
src/STP.cc
|
VadimNvr/SDN_RunOS
|
74df09f78f8672f144a283823b24de3106f8e419
|
[
"Apache-2.0"
] | null | null | null |
src/STP.cc
|
VadimNvr/SDN_RunOS
|
74df09f78f8672f144a283823b24de3106f8e419
|
[
"Apache-2.0"
] | null | null | null |
src/STP.cc
|
VadimNvr/SDN_RunOS
|
74df09f78f8672f144a283823b24de3106f8e419
|
[
"Apache-2.0"
] | null | null | null |
/*
* Copyright 2015 Applied Research Center for Computer Networks
*
* 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 "STP.hh"
#include "Topology.hh"
REGISTER_APPLICATION(STP, {"switch-manager", "link-discovery", "topology", ""})
void SwitchSTP::computeSTP()
{
parent->computePathForSwitch(this->sw->id());
}
void SwitchSTP::resetBroadcast()
{
for (auto port : ports) {
if (port.second->to_switch)
unsetBroadcast(port.second->port_no);
}
}
void SwitchSTP::setSwitchPort(uint32_t port_no, uint64_t dpid)
{
ports.at(port_no)->to_switch = true;
ports.at(port_no)->nextSwitch = parent->switch_list[dpid];
}
void STP::init(Loader* loader, const Config& config)
{
QObject* ld = ILinkDiscovery::get(loader);
connect(ld, SIGNAL(linkDiscovered(switch_and_port, switch_and_port)),
this, SLOT(onLinkDiscovered(switch_and_port, switch_and_port)));
connect(ld, SIGNAL(linkBroken(switch_and_port, switch_and_port)),
this, SLOT(onLinkBroken(switch_and_port, switch_and_port)));
SwitchManager* sw = SwitchManager::get(loader);
connect(sw, &SwitchManager::switchDiscovered, this, &STP::onSwitchDiscovered);
connect(sw, &SwitchManager::switchDown, this, &STP::onSwitchDown);
topo = Topology::get(loader);
}
STPPorts STP::getSTP(uint64_t dpid)
{
std::vector<uint32_t> ports;
if (switch_list.count(dpid) == 0) {
return ports;
}
SwitchSTP* sw = switch_list[dpid];
if (!sw->computed) {
return ports;
}
for (auto port : sw->ports) {
if (port.second->broadcast)
ports.push_back(port.second->port_no);
}
return ports;
}
void STP::onLinkDiscovered(switch_and_port from, switch_and_port to)
{
if (switch_list.count(from.dpid) == 0)
return;
if (switch_list.count(to.dpid) == 0)
return;
SwitchSTP* sw = switch_list[from.dpid];
if (!sw->existsPort(from.port)) {
Port* port = new Port(from.port);
sw->ports[from.port] = port;
}
if (!sw->root)
sw->unsetBroadcast(from.port);
sw->setSwitchPort(from.port, to.dpid);
sw = switch_list[to.dpid];
if (!sw->existsPort(to.port)) {
Port* port = new Port(to.port);
sw->ports[to.port] = port;
}
if (!sw->root)
sw->unsetBroadcast(to.port);
sw->setSwitchPort(to.port, from.dpid);
// recompute pathes for all switches
for (auto ss : switch_list) {
if (!ss.second->root)
ss.second->computed = false;
}
}
void STP::onLinkBroken(switch_and_port from, switch_and_port to)
{
// recompute pathes for all switches
for (auto ss : switch_list) {
if (!ss.second->root)
ss.second->computed = false;
}
}
void STP::onSwitchDiscovered(Switch* dp)
{
SwitchSTP* sw;
if (switch_list.empty())
sw = new SwitchSTP(dp, this, true, true);
else
sw = new SwitchSTP(dp, this);
switch_list[dp->id()] = sw;
connect(dp, &Switch::portUp, this, &STP::onPortUp);
connect(sw->timer, SIGNAL(timeout()), sw, SLOT(computeSTP()));
sw->timer->start(POLL_TIMEOUT * 1000);
}
void STP::onSwitchDown(Switch* dp)
{
if (switch_list.count(dp->id()) > 0) {
SwitchSTP* sw = switch_list[dp->id()];
sw->timer->stop();
switch_list.erase(dp->id());
delete sw;
}
}
void STP::onPortUp(Switch *dp, of13::Port port)
{
if (switch_list.count(dp->id()) > 0) {
SwitchSTP* sw = switch_list[dp->id()];
if ( !sw->existsPort(port.port_no()) && port.port_no() < of13::OFPP_MAX ) {
Port* p = new Port(port.port_no());
sw->ports[port.port_no()] = p;
}
}
}
SwitchSTP* STP::findRoot()
{
for (auto it : switch_list) {
if (it.second->root)
return it.second;
}
return nullptr;
}
void STP::computePathForSwitch(uint64_t dpid)
{
static std::mutex compute;
if (!switch_list[dpid]->computed) {
SwitchSTP* root = findRoot();
if (root == nullptr) {
LOG(ERROR) << "Root switch not found!";
SwitchSTP* sw = switch_list[dpid];
sw->root = true;
sw->computed = true;
return;
}
SwitchSTP* sw = switch_list[dpid];
std::vector<uint32_t> old_broadcast = getSTP(dpid);
compute.lock();
sw->resetBroadcast();
data_link_route route = topo->computeRoute(dpid, root->sw->id());
if (route.size() > 0) {
uint32_t broadcast_port = route[0].port;
if (sw->existsPort(broadcast_port))
sw->setBroadcast(broadcast_port);
sw->nextSwitchToRoot = switch_list[route[1].dpid];
// getting broadcast port on second switch
data_link_route r_route = topo->computeRoute(route[1].dpid, dpid);
SwitchSTP* r_sw = switch_list[r_route[0].dpid];
uint32_t r_broadcast_port = r_route[0].port;
if (r_sw->existsPort(r_broadcast_port))
r_sw->setBroadcast(r_broadcast_port);
for (auto port : sw->ports) {
if (port.second->to_switch) {
if (port.second->nextSwitch->nextSwitchToRoot == sw) {
sw->setBroadcast(port.second->port_no);
}
}
}
if (getSTP(dpid).size() == old_broadcast.size())
sw->computed = true;
} else {
LOG(WARNING) << "Path between " << FORMAT_DPID << dpid
<< " and root switch " << FORMAT_DPID << root->sw->id() << " not found";
}
compute.unlock();
}
}
| 28.62212
| 88
| 0.596844
|
VadimNvr
|
de3d806a2ca4d876c343358a63de74ae59c8d1e9
| 1,096
|
hpp
|
C++
|
Octree/OctreeLeaf.hpp
|
kashinoleg/Octree
|
3eef96c1dc2b0369eb72e56b20e8fc7feca9d1e5
|
[
"ICU"
] | null | null | null |
Octree/OctreeLeaf.hpp
|
kashinoleg/Octree
|
3eef96c1dc2b0369eb72e56b20e8fc7feca9d1e5
|
[
"ICU"
] | null | null | null |
Octree/OctreeLeaf.hpp
|
kashinoleg/Octree
|
3eef96c1dc2b0369eb72e56b20e8fc7feca9d1e5
|
[
"ICU"
] | null | null | null |
#pragma once
#include "OctreeArray.hpp"
#include "OctreeCell.hpp"
#include "OctreeBranch.hpp"
/**
* outer node implementation of an octree cell.stores pointers to items.
*/
namespace hxa {
class OctreeLeaf : public OctreeCell {
private:
OctreeArray<const void*> items_m;
public:
OctreeLeaf();
OctreeLeaf(const OctreeLeaf*const leafs[8]);
private:
explicit OctreeLeaf(const void* pItem);
public:
virtual ~OctreeLeaf();
OctreeLeaf(const OctreeLeaf&);
OctreeLeaf& operator=(const OctreeLeaf&);
virtual void insertItem(const OctreeData& thisData, OctreeCell*& pThis, const void* pItem, const OctreeAgentV& agent);
virtual bool removeItem(OctreeCell*& pThis, const void* pItem,
const int maxItemsPerCell, int& itemCount);
virtual void visit(const OctreeData& thisData, OctreeVisitorV& visitor) const;
virtual OctreeCell* clone() const;
virtual void getInfo(int& byteSize, int& leafCount, int& itemCount, int& maxDepth) const;
static void insertItemMaybeCreate(const OctreeData& cellData, OctreeCell*& pCell, const void* pItem, const OctreeAgentV& agent);
};
}
| 34.25
| 130
| 0.75365
|
kashinoleg
|
de432f1072702f047a9ff38adc61b3285afe52ba
| 412
|
hpp
|
C++
|
src/Generator.hpp
|
ageorgiev97/yat
|
293adda152025d7c7bfbb2e982aa9d2ff5a461d9
|
[
"Apache-2.0"
] | 1
|
2019-12-11T21:50:13.000Z
|
2019-12-11T21:50:13.000Z
|
src/Generator.hpp
|
ageorgiev97/yat
|
293adda152025d7c7bfbb2e982aa9d2ff5a461d9
|
[
"Apache-2.0"
] | 4
|
2019-11-30T21:55:18.000Z
|
2019-11-30T23:00:08.000Z
|
src/Generator.hpp
|
ageorgiev97/yat
|
293adda152025d7c7bfbb2e982aa9d2ff5a461d9
|
[
"Apache-2.0"
] | null | null | null |
#pragma once
#include <memory>
#include <unordered_map>
#include "Llvm.hpp"
#include "Expressions.hpp"
#include "Statements.hpp"
#include "Scope.hpp"
#include "Function.hpp"
namespace yat
{
extern llvm::LLVMContext GlobalContext;
extern std::unique_ptr<llvm::Module> GlobalModule;
extern std::unordered_map<std::string, Function> functions;
void GenerateCode(Statement const& expression);
}
| 19.619048
| 63
| 0.742718
|
ageorgiev97
|
de43e22d76b73a49cbfe76e8f08efcf00e7cedbe
| 3,766
|
cpp
|
C++
|
python/src/distance/edge_edge.cpp
|
ipc-sim/ipc-toolk
|
81873d0288810e30166d871419da4104329860e3
|
[
"MIT"
] | 61
|
2020-08-04T21:08:25.000Z
|
2022-02-25T02:24:31.000Z
|
python/src/distance/edge_edge.cpp
|
dbelgrod/ipc-toolkit
|
0b7ca9b5f867db63bd68dd02ce54a9d00b0fc337
|
[
"MIT"
] | 2
|
2020-10-12T05:54:40.000Z
|
2021-10-10T18:39:30.000Z
|
python/src/distance/edge_edge.cpp
|
dbelgrod/ipc-toolkit
|
0b7ca9b5f867db63bd68dd02ce54a9d00b0fc337
|
[
"MIT"
] | 7
|
2020-11-26T12:47:38.000Z
|
2022-03-25T04:55:49.000Z
|
#include <pybind11/pybind11.h>
#include <pybind11/eigen.h>
#include <ipc/distance/distance_type.hpp>
#include <ipc/distance/edge_edge.hpp>
#include "../utils.hpp"
namespace py = pybind11;
using namespace ipc;
void define_edge_edge_distance_functions(py::module_& m)
{
m.def(
"edge_edge_distance",
[](const Eigen::Vector3d& ea0, const Eigen::Vector3d& ea1,
const Eigen::Vector3d& eb0, const Eigen::Vector3d& eb1,
const EdgeEdgeDistanceType* dtype) {
if (dtype == nullptr) {
return edge_edge_distance(ea0, ea1, eb0, eb1);
} else {
return edge_edge_distance(ea0, ea1, eb0, eb1, *dtype);
}
},
R"ipc_Qu8mg5v7(
Compute the distance between a two lines segments in 3D.
Parameters:
ea0: first vertex of the first edge
ea1: second vertex of the first edge
eb0: first vertex of the second edge
eb1: second vertex of the second edge
dtype: (optional) edge-edge distance type to compute
Returns:
The distance between the two edges.
Note:
The distance is actually squared distance.
)ipc_Qu8mg5v7",
py::arg("ea0"), py::arg("ea1"), py::arg("eb0"), py::arg("eb1"),
py::arg("dtype") = py::none());
m.def(
"edge_edge_distance_gradient",
[](const Eigen::Vector3d& ea0, const Eigen::Vector3d& ea1,
const Eigen::Vector3d& eb0, const Eigen::Vector3d& eb1,
const EdgeEdgeDistanceType* dtype) {
Vector<double, 12> grad;
if (dtype == nullptr) {
edge_edge_distance_gradient(ea0, ea1, eb0, eb1, grad);
} else {
edge_edge_distance_gradient(ea0, ea1, eb0, eb1, *dtype, grad);
}
return grad;
},
R"ipc_Qu8mg5v7(
Compute the gradient of the distance between a two lines segments.
Parameters:
ea0: first vertex of the first edge
ea1: second vertex of the first edge
eb0: first vertex of the second edge
eb1: second vertex of the second edge
dtype: (optional) point edge distance type to compute
Returns:
The gradient of the distance wrt ea0, ea1, eb0, and eb1.
Note:
The distance is actually squared distance.
)ipc_Qu8mg5v7",
py::arg("ea0"), py::arg("ea1"), py::arg("eb0"), py::arg("eb1"),
py::arg("dtype") = py::none());
m.def(
"edge_edge_distance_hessian",
[](const Eigen::Vector3d& ea0, const Eigen::Vector3d& ea1,
const Eigen::Vector3d& eb0, const Eigen::Vector3d& eb1,
const EdgeEdgeDistanceType* dtype) {
Eigen::Matrix<double, 12, 12> hess;
if (dtype == nullptr) {
edge_edge_distance_hessian(ea0, ea1, eb0, eb1, hess);
} else {
edge_edge_distance_hessian(ea0, ea1, eb0, eb1, *dtype, hess);
}
return hess;
},
R"ipc_Qu8mg5v7(
Compute the hessian of the distance between a two lines segments.
Parameters:
ea0: first vertex of the first edge
ea1: second vertex of the first edge
eb0: first vertex of the second edge
eb1: second vertex of the second edge
dtype: (optional) point edge distance type to compute
Returns:
The hessian of the distance wrt ea0, ea1, eb0, and eb1.
Note:
The distance is actually squared distance.
)ipc_Qu8mg5v7",
py::arg("ea0"), py::arg("ea1"), py::arg("eb0"), py::arg("eb1"),
py::arg("dtype") = py::none());
}
| 34.87037
| 78
| 0.568508
|
ipc-sim
|
de49013ba0bb5819c9de5d827f8a9f5731b10d95
| 1,843
|
cpp
|
C++
|
SGPLibraryCode/modules/sgp_particle/core/sgp_SPARK_Emitter.cpp
|
phoenixzz/VoronoiMapGen
|
5afd852f8bb0212baba9d849178eb135f62df903
|
[
"MIT"
] | 11
|
2017-03-03T03:31:15.000Z
|
2019-03-01T17:09:12.000Z
|
SGPLibraryCode/modules/sgp_particle/core/sgp_SPARK_Emitter.cpp
|
phoenixzz/VoronoiMapGen
|
5afd852f8bb0212baba9d849178eb135f62df903
|
[
"MIT"
] | null | null | null |
SGPLibraryCode/modules/sgp_particle/core/sgp_SPARK_Emitter.cpp
|
phoenixzz/VoronoiMapGen
|
5afd852f8bb0212baba9d849178eb135f62df903
|
[
"MIT"
] | 2
|
2017-03-03T03:31:17.000Z
|
2021-05-27T21:50:43.000Z
|
Emitter::Emitter() : Registerable(), Transformable(),
zone( &getDefaultZone() ),
full(true),
tank(-1),
flow(0.0f),
forceMin(0.0f),
forceMax(0.0f),
fraction( random(0.0f,1.0f) ),
active(true)
{}
Zone& Emitter::getDefaultZone()
{
static PointZone defaultZone;
return defaultZone;
}
void Emitter::registerChildren(bool registerAll)
{
Registerable::registerChildren(registerAll);
registerChild(zone, registerAll);
}
void Emitter::copyChildren(const Registerable& object, bool createBase)
{
const Emitter& emitter = dynamic_cast<const Emitter&>(object);
Registerable::copyChildren(emitter, createBase);
zone = dynamic_cast<Zone*>(copyChild(emitter.zone, createBase));
}
void Emitter::destroyChildren(bool keepChildren)
{
destroyChild(zone, keepChildren);
Registerable::destroyChildren(keepChildren);
}
Registerable* Emitter::findByName(const String& name)
{
Registerable* object = Registerable::findByName(name);
if (object != NULL)
return object;
return zone->findByName(name);
}
void Emitter::changeTank(int32 deltaTank)
{
if(tank >= 0)
{
tank += deltaTank;
if(tank < 0)
tank = 0;
}
}
void Emitter::changeFlow(float deltaFlow)
{
if(flow >= 0.0f)
{
flow += deltaFlow;
if(flow < 0.0f)
flow = 0.0f;
}
}
void Emitter::setZone(Zone* _zone, bool full)
{
decrementChildReference(this->zone);
incrementChildReference(_zone);
if(_zone == NULL)
_zone = &getDefaultZone();
this->zone = _zone;
this->full = full;
}
uint32 Emitter::updateNumber(float deltaTime)
{
int32 nbBorn;
if(flow < 0.0f)
{
nbBorn = jmax(0, tank);
tank = 0;
}
else if(tank != 0)
{
fraction += flow * deltaTime;
nbBorn = static_cast<int>(fraction);
if(tank >= 0)
{
nbBorn = jmin(tank, nbBorn);
tank -= nbBorn;
}
fraction -= nbBorn;
}
else
nbBorn = 0;
return static_cast<uint32>(nbBorn);
}
| 17.721154
| 71
| 0.689094
|
phoenixzz
|
de4bb4c00d0cac29cdc3be2ad9870fa1e1ae63dc
| 1,414
|
hpp
|
C++
|
src/meshInfo/geometry.hpp
|
guhanfeng/HSF
|
d2f091e990bb5a18473db0443872e37de6b6a83f
|
[
"Apache-2.0"
] | null | null | null |
src/meshInfo/geometry.hpp
|
guhanfeng/HSF
|
d2f091e990bb5a18473db0443872e37de6b6a83f
|
[
"Apache-2.0"
] | null | null | null |
src/meshInfo/geometry.hpp
|
guhanfeng/HSF
|
d2f091e990bb5a18473db0443872e37de6b6a83f
|
[
"Apache-2.0"
] | null | null | null |
/**
* @file: compute.hpp
* @author: Liu Hongbin
* @brief:
* @date: 2019-11-28 10:39:09
* @last Modified by: lenovo
* @last Modified time: 2019-11-28 16:13:43
*/
#ifndef GEOMETRY_HPP
#define GEOMETRY_HPP
#include <cmath>
#include "utilities.hpp"
namespace HSF
{
// face area
scalar calculateQUADArea(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z);
scalar calculateTRIArea(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z);
scalar calculateFaceArea(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes);
// face normal vector
void calculateQUADNormVec(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, scalar* normVec);
void calculateFaceNormVec(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes, scalar* normVec);
// face center coordinate
void calculateFaceCenter(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes, scalar* center);
// cell volume
scalar calculateCellVol(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes);
scalar calculateHEXAVol(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z);
// cell center coordinate
void calculateCellCenter(const Array<scalar>& x, const Array<scalar>& y,
const Array<scalar>& z, label nnodes, scalar* center);
}
#endif
| 27.72549
| 73
| 0.729137
|
guhanfeng
|
de4dc80505f378ad0c688b4bd30bc1c4e8f56282
| 21,265
|
cpp
|
C++
|
hackathon/zhi/mapping3D_swc/mapping3D_swc_plugin.cpp
|
RivuletStudio/vaa3d_tools
|
58c267d4731df9a71e596200c45e9634aea8491c
|
[
"MIT"
] | null | null | null |
hackathon/zhi/mapping3D_swc/mapping3D_swc_plugin.cpp
|
RivuletStudio/vaa3d_tools
|
58c267d4731df9a71e596200c45e9634aea8491c
|
[
"MIT"
] | 1
|
2016-12-03T05:33:13.000Z
|
2016-12-03T05:33:13.000Z
|
hackathon/zhi/mapping3D_swc/mapping3D_swc_plugin.cpp
|
RivuletStudio/vaa3d_tools
|
58c267d4731df9a71e596200c45e9634aea8491c
|
[
"MIT"
] | null | null | null |
/* mapping3D_swc_plugin.cpp
* This is a test plugin, you can use it as a demo.
* 2015-6-25 : by Zhi Zhou
*/
#include "v3d_message.h"
#include <vector>
#include "mapping3D_swc_plugin.h"
#include "openSWCDialog.h"
#include "../neurontracing_mip/my_surf_objs.h"
#include "../neurontracing_mip/smooth_curve.h"
#include "../neurontracing_mip/fastmarching_linker.h"
#include "../APP2_large_scale/readRawfile_func.h"
using namespace std;
Q_EXPORT_PLUGIN2(mapping3D_swc, mapping3D_swc);
QStringList mapping3D_swc::menulist() const
{
return QStringList()
<<tr("mapping")
<<tr("about");
}
QStringList mapping3D_swc::funclist() const
{
return QStringList()
<<tr("func1")
<<tr("help");
}
struct Point;
struct Point
{
double x,y,z,r;
V3DLONG type;
Point* p;
V3DLONG childNum;
};
typedef vector<Point*> Segment;
typedef vector<Point*> Tree;
bool map3Dfunc(NeuronTree nt,unsigned char * &data1d, V3DLONG N, V3DLONG M,V3DLONG P,vector<MyMarker*> & outswc_final);
bool map3Dfunc_raw(NeuronTree nt,string &image_name,vector<MyMarker*> & outswc_final);
void mapping3D_swc::domenu(const QString &menu_name, V3DPluginCallback2 &callback, QWidget *parent)
{
if (menu_name == tr("mapping"))
{
v3dhandle curwin = callback.currentImageWindow();
if (!curwin)
{
QMessageBox::information(0, "", "You don't have any image open in the main window.");
return;
}
Image4DSimple* p4DImage = callback.getImage(curwin);
if (!p4DImage)
{
QMessageBox::information(0, "", "The image pointer is invalid. Ensure your data is valid and try again!");
return;
}
unsigned char* data1d = p4DImage->getRawData();
V3DLONG pagesz = p4DImage->getTotalUnitNumberPerChannel();
QString image_name = callback.getImageName(curwin);
V3DLONG N = p4DImage->getXDim();
V3DLONG M = p4DImage->getYDim();
V3DLONG P = p4DImage->getZDim();
V3DLONG sc = p4DImage->getCDim();
// int mip_plane = 0;
OpenSWCDialog * openDlg = new OpenSWCDialog(0, &callback);
if (!openDlg->exec())
return;
NeuronTree nt = openDlg->nt;
vector<MyMarker*> outswc_final;
if(map3Dfunc(nt, data1d, N,M,P,outswc_final))
{
QString final_swc = openDlg->file_name + "_3D.swc"; ;
saveSWC_file(final_swc.toStdString(), outswc_final);
v3d_msg(QString("Now you can drag and drop the generated swc fle [%1] into Vaa3D.").arg(final_swc.toStdString().c_str()));
}
}
// V3DLONG siz = nt.listNeuron.size();
// Tree tree;
// for (V3DLONG i=0;i<siz;i++)
// {
// NeuronSWC s = nt.listNeuron[i];
// Point* pt = new Point;
// pt->x = s.x;
// pt->y = s.y;
// pt->z = s.z;
// pt->r = s.r;
// pt ->type = s.type;
// pt->p = NULL;
// pt->childNum = 0;
// tree.push_back(pt);
// }
// for (V3DLONG i=0;i<siz;i++)
// {
// if (nt.listNeuron[i].pn<0) continue;
// V3DLONG pid = nt.hashNeuron.value(nt.listNeuron[i].pn);
// tree[i]->p = tree[pid];
// tree[pid]->childNum++;
// }
// vector<Segment*> seg_list;
// for (V3DLONG i=0;i<siz;i++)
// {
// if (tree[i]->childNum!=1)//tip or branch point
// {
// Segment* seg = new Segment;
// Point* cur = tree[i];
// do
// {
// seg->push_back(cur);
// cur = cur->p;
// }
// while(cur && cur->childNum==1);
// seg_list.push_back(seg);
// }
// }
// vector<MyMarker*> outswc;
// vector<MyMarker*> outswc_final;
// for (V3DLONG i=0;i<seg_list.size();i++)
// {
// vector<MyMarker> nearpos_vec, farpos_vec; // for near/far locs testing
// nearpos_vec.clear();
// farpos_vec.clear();
// if(seg_list[i]->size() > 2)
// {
// for (V3DLONG j=0;j<seg_list[i]->size();j++)
// {
// Point* node = seg_list[i]->at(j);
// XYZ loc0_t, loc1_t;
// loc0_t = XYZ(node->x, node->y, node->z);
// switch (mip_plane)
// {
// case 0: loc1_t = XYZ(node->x, node->y, P-1); break;
// case 1: loc1_t = XYZ(node->x, M-1, node->z); break;
// case 2: loc1_t = XYZ(N-1, node->y, node->z); break;
// default:
// return;
// }
// XYZ loc0 = loc0_t;
// XYZ loc1 = loc1_t;
// nearpos_vec.push_back(MyMarker(loc0.x, loc0.y, loc0.z));
// farpos_vec.push_back(MyMarker(loc1.x, loc1.y, loc1.z));
// }
// fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, N,M,P, 1, 5);
// smooth_curve(outswc,5);
// for(V3DLONG d = 0; d <outswc.size(); d++)
// {
// outswc[d]->radius = 2;
// outswc[d]->type = 2;
// outswc_final.push_back(outswc[d]);
// }
// outswc.clear();
// }
// else if(seg_list[i]->size() == 2)
// {
// Point* node1 = seg_list[i]->at(0);
// Point* node2 = seg_list[i]->at(1);
// for (V3DLONG j=0;j<3;j++)
// {
// XYZ loc0_t, loc1_t;
// if(j ==0)
// {
// loc0_t = XYZ(node1->x, node1->y, node1->z);
// switch (mip_plane)
// {
// case 0: loc1_t = XYZ(node1->x, node1->y, P-1); break;
// case 1: loc1_t = XYZ(node1->x, M-1, node1->z); break;
// case 2: loc1_t = XYZ(N-1, node1->y, node1->z); break;
// default:
// return;
// }
// }
// else if(j ==1)
// {
// loc0_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z));
// switch (mip_plane)
// {
// case 0: loc1_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), P-1); break;
// case 1: loc1_t = XYZ(0.5*(node1->x + node2->x), M-1, 0.5*(node1->z + node2->z)); break;
// case 2: loc1_t = XYZ(N-1, 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z)); break;
// default:
// return;
// }
// }
// else
// {
// loc0_t = XYZ(node2->x, node2->y, node2->z);
// switch (mip_plane)
// {
// case 0: loc1_t = XYZ(node2->x, node2->y, P-1); break;
// case 1: loc1_t = XYZ(node2->x, M-1, node2->z); break;
// case 2: loc1_t = XYZ(N-1, node2->y, node2->z); break;
// default:
// return;
// } }
// XYZ loc0 = loc0_t;
// XYZ loc1 = loc1_t;
// nearpos_vec.push_back(MyMarker(loc0.x, loc0.y, loc0.z));
// farpos_vec.push_back(MyMarker(loc1.x, loc1.y, loc1.z));
// }
// fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, N,M,P, 1, 5);
// smooth_curve(outswc,5);
// for(V3DLONG d = 0; d <outswc.size(); d++)
// {
// outswc[d]->radius = 2;
// outswc[d]->type = 2;
// outswc_final.push_back(outswc[d]);
// }
// outswc.clear();
// }
// }
else
{
v3d_msg(tr("This is a plugin to map 2D tracing back to 3D locations based on 3D image content..."
"Developed by Zhi Zhou, 2015-6-25"));
}
}
bool mapping3D_swc::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent)
{
vector<char*> infiles, inparas, outfiles;
if(input.size() >= 1) infiles = *((vector<char*> *)input.at(0).p);
if(input.size() >= 2) inparas = *((vector<char*> *)input.at(1).p);
if(output.size() >= 1) outfiles = *((vector<char*> *)output.at(0).p);
if (func_name == tr("mapping"))
{
if(infiles.size() != 2 && infiles.size() != 3)
{
cerr<<"Invalid input"<<endl;
return false;
}
string inimg_file = infiles[0];
string inswc_file = infiles[1];
string outswc_file = (infiles.size() == 3) ? infiles[2] : "";
if(outswc_file == "") outswc_file = inswc_file + "_3D.swc";
cout<<"inimg_file = "<<inimg_file<<endl;
cout<<"inswc_file = "<<inswc_file<<endl;
cout<<"outswc_file = "<<outswc_file<<endl;
// unsigned char * inimg1d = 0;
// V3DLONG in_sz[4];
// int datatype;
// simple_loadimage_wrapper(callback,const_cast<char *>(inimg_file.c_str()), inimg1d, in_sz, datatype);
// V3DLONG N = in_sz[0];
// V3DLONG M = in_sz[1];
// V3DLONG P = in_sz[2];
NeuronTree nt = readSWC_file(QString(inswc_file.c_str()));
vector<MyMarker*> outswc_final;
//if(map3Dfunc(nt, inimg1d, N,M,P,outswc_final))
if(map3Dfunc_raw(nt, inimg_file,outswc_final))
{
saveSWC_file(outswc_file, outswc_final);
v3d_msg(QString("Now you can drag and drop the generated swc fle [%1] into Vaa3D.").arg(outswc_file.c_str()),0);
}
// if(inimg1d) {delete []inimg1d; inimg1d=0;}
return true;
}
else if (func_name == tr("help"))
{
v3d_msg("To be implemented.");
}
else return false;
return true;
}
bool map3Dfunc(NeuronTree nt,unsigned char * &data1d, V3DLONG N, V3DLONG M,V3DLONG P,vector<MyMarker*> & outswc_final)
{
int mip_plane = 0;
V3DLONG siz = nt.listNeuron.size();
Tree tree;
for (V3DLONG i=0;i<siz;i++)
{
NeuronSWC s = nt.listNeuron[i];
Point* pt = new Point;
pt->x = s.x;
pt->y = s.y;
pt->z = s.z;
pt->r = s.r;
pt ->type = s.type;
pt->p = NULL;
pt->childNum = 0;
tree.push_back(pt);
}
for (V3DLONG i=0;i<siz;i++)
{
if (nt.listNeuron[i].pn<0) continue;
V3DLONG pid = nt.hashNeuron.value(nt.listNeuron[i].pn);
tree[i]->p = tree[pid];
tree[pid]->childNum++;
}
vector<Segment*> seg_list;
for (V3DLONG i=0;i<siz;i++)
{
if (tree[i]->childNum!=1)//tip or branch point
{
Segment* seg = new Segment;
Point* cur = tree[i];
do
{
seg->push_back(cur);
cur = cur->p;
}
while(cur && cur->childNum==1);
seg_list.push_back(seg);
}
}
vector<MyMarker*> outswc;
for (V3DLONG i=0;i<seg_list.size();i++)
{
vector<MyMarker> nearpos_vec, farpos_vec; // for near/far locs testing
nearpos_vec.clear();
farpos_vec.clear();
if(seg_list[i]->size() > 2)
{
for (V3DLONG j=0;j<seg_list[i]->size();j++)
{
Point* node = seg_list[i]->at(j);
XYZ loc0_t, loc1_t;
loc0_t = XYZ(node->x, node->y, node->z);
switch (mip_plane)
{
case 0: loc1_t = XYZ(node->x, node->y, P-1); break;
case 1: loc1_t = XYZ(node->x, M-1, node->z); break;
case 2: loc1_t = XYZ(N-1, node->y, node->z); break;
default:
return false;
}
XYZ loc0 = loc0_t;
XYZ loc1 = loc1_t;
nearpos_vec.push_back(MyMarker(loc0.x, loc0.y, loc0.z));
farpos_vec.push_back(MyMarker(loc1.x, loc1.y, loc1.z));
}
fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, N,M,P, 1, 5);
smooth_curve(outswc,5);
for(V3DLONG d = 0; d <outswc.size(); d++)
{
outswc[d]->radius = 2;
outswc[d]->type = 2;
outswc_final.push_back(outswc[d]);
}
outswc.clear();
}
else if(seg_list[i]->size() == 2)
{
Point* node1 = seg_list[i]->at(0);
Point* node2 = seg_list[i]->at(1);
for (V3DLONG j=0;j<3;j++)
{
XYZ loc0_t, loc1_t;
if(j ==0)
{
loc0_t = XYZ(node1->x, node1->y, node1->z);
switch (mip_plane)
{
case 0: loc1_t = XYZ(node1->x, node1->y, P-1); break;
case 1: loc1_t = XYZ(node1->x, M-1, node1->z); break;
case 2: loc1_t = XYZ(N-1, node1->y, node1->z); break;
default:
return false;
}
}
else if(j ==1)
{
loc0_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z));
switch (mip_plane)
{
case 0: loc1_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), P-1); break;
case 1: loc1_t = XYZ(0.5*(node1->x + node2->x), M-1, 0.5*(node1->z + node2->z)); break;
case 2: loc1_t = XYZ(N-1, 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z)); break;
default:
return false;
}
}
else
{
loc0_t = XYZ(node2->x, node2->y, node2->z);
switch (mip_plane)
{
case 0: loc1_t = XYZ(node2->x, node2->y, P-1); break;
case 1: loc1_t = XYZ(node2->x, M-1, node2->z); break;
case 2: loc1_t = XYZ(N-1, node2->y, node2->z); break;
default:
return false;
} }
XYZ loc0 = loc0_t;
XYZ loc1 = loc1_t;
nearpos_vec.push_back(MyMarker(loc0.x, loc0.y, loc0.z));
farpos_vec.push_back(MyMarker(loc1.x, loc1.y, loc1.z));
}
fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, N,M,P, 1, 5);
smooth_curve(outswc,5);
for(V3DLONG d = 0; d <outswc.size(); d++)
{
outswc[d]->radius = 2;
outswc[d]->type = 2;
outswc_final.push_back(outswc[d]);
}
outswc.clear();
}
}
return true;
}
bool map3Dfunc_raw(NeuronTree nt,string &image_name,vector<MyMarker*> & outswc_final)
{
V3DLONG siz = nt.listNeuron.size();
Tree tree;
for (V3DLONG i=0;i<siz;i++)
{
NeuronSWC s = nt.listNeuron[i];
Point* pt = new Point;
pt->x = s.x;
pt->y = s.y;
pt->z = s.z;
pt->r = s.r;
pt ->type = s.type;
pt->p = NULL;
pt->childNum = 0;
tree.push_back(pt);
}
for (V3DLONG i=0;i<siz;i++)
{
if (nt.listNeuron[i].pn<0) continue;
V3DLONG pid = nt.hashNeuron.value(nt.listNeuron[i].pn);
tree[i]->p = tree[pid];
tree[pid]->childNum++;
}
vector<Segment*> seg_list;
for (V3DLONG i=0;i<siz;i++)
{
if (tree[i]->childNum!=1)//tip or branch point
{
Segment* seg = new Segment;
Point* cur = tree[i];
do
{
seg->push_back(cur);
cur = cur->p;
}
while(cur && cur->childNum==1);
seg_list.push_back(seg);
}
}
vector<MyMarker*> outswc;
unsigned char * data1d = 0;
V3DLONG *im3D_zz = 0;
V3DLONG *im3D_sz = 0;
int datatype;
if (!loadRawRegion(const_cast<char *>(image_name.c_str()), data1d, im3D_zz, im3D_sz,datatype,0,0,0,1,1,1))
{
return false;
}
if(data1d) {delete []data1d; data1d = 0;}
V3DLONG N = im3D_zz[0];
V3DLONG M = im3D_zz[1];
V3DLONG P = im3D_zz[2];
for (V3DLONG i=0;i<seg_list.size();i++)
{
V3DLONG xb = N-1;
V3DLONG xe = 0;
V3DLONG yb = M-1;
V3DLONG ye = 0;
for (V3DLONG j=0;j<seg_list[i]->size();j++)
{
Point* node = seg_list[i]->at(j);
if(node->x < xb) xb = node->x;
if(node->x > xe) xe = node->x;
if(node->y < yb) yb = node->y;
if(node->y > ye) ye = node->y;
}
vector<MyMarker> nearpos_vec, farpos_vec; // for near/far locs testing
nearpos_vec.clear();
farpos_vec.clear();
if(seg_list[i]->size() > 2)
{
for (V3DLONG j=0;j<seg_list[i]->size();j++)
{
Point* node = seg_list[i]->at(j);
XYZ loc0_t, loc1_t;
loc0_t = XYZ(node->x, node->y, node->z);
loc1_t = XYZ(node->x, node->y, P-1);
XYZ loc0 = loc0_t;
XYZ loc1 = loc1_t;
nearpos_vec.push_back(MyMarker(loc0.x - xb, loc0.y - yb, loc0.z));
farpos_vec.push_back(MyMarker(loc1.x - xb, loc1.y - yb, loc1.z));
}
if (!loadRawRegion(const_cast<char *>(image_name.c_str()), data1d, im3D_zz, im3D_sz,datatype,xb,yb,0,xe+1,ye+1,P))
{
printf("can not load the region");
if(data1d) {delete []data1d; data1d = 0;}
return false;
}
fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, xe-xb+1,ye-yb+1,P, 1, 5);
smooth_curve(outswc,5);
for(V3DLONG d = 0; d <outswc.size(); d++)
{
outswc[d]->radius = 2;
outswc[d]->type = 2;
outswc[d]->x = outswc[d]->x + xb;
outswc[d]->y = outswc[d]->y + yb;
outswc_final.push_back(outswc[d]);
}
if(data1d) {delete []data1d; data1d = 0;}
outswc.clear();
}
else if(seg_list[i]->size() == 2)
{
Point* node1 = seg_list[i]->at(0);
Point* node2 = seg_list[i]->at(1);
for (V3DLONG j=0;j<3;j++)
{
XYZ loc0_t, loc1_t;
if(j ==0)
{
loc0_t = XYZ(node1->x, node1->y, node1->z);
loc1_t = XYZ(node1->x, node1->y, P-1);
}
else if(j ==1)
{
loc0_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), 0.5*(node1->z + node2->z));
loc1_t = XYZ(0.5*(node1->x + node2->x), 0.5*(node1->y + node2->y), P-1);
}
else
{
loc0_t = XYZ(node2->x, node2->y, node2->z);
loc1_t = XYZ(node2->x, node2->y, P-1);
}
XYZ loc0 = loc0_t;
XYZ loc1 = loc1_t;
nearpos_vec.push_back(MyMarker(loc0.x - xb, loc0.y - yb, loc0.z));
farpos_vec.push_back(MyMarker(loc1.x - xb, loc1.y - yb, loc1.z));
}
if (!loadRawRegion(const_cast<char *>(image_name.c_str()), data1d, im3D_zz, im3D_sz,datatype,xb,yb,0,xe+1,ye+1,P))
{
printf("can not load the region");
if(data1d) {delete []data1d; data1d = 0;}
return false;
}
fastmarching_drawing_dynamic(nearpos_vec, farpos_vec, (unsigned char*)data1d, outswc, xe-xb+1,ye-yb+1,P, 1, 5);
smooth_curve(outswc,5);
for(V3DLONG d = 0; d <outswc.size(); d++)
{
outswc[d]->radius = 2;
outswc[d]->type = 2;
outswc[d]->x = outswc[d]->x + xb;
outswc[d]->y = outswc[d]->y + yb;
outswc_final.push_back(outswc[d]);
}
if(data1d) {delete []data1d; data1d = 0;}
outswc.clear();
}
}
return true;
}
| 33.541009
| 162
| 0.452104
|
RivuletStudio
|
de4f2c08e0ce27edb82f5bf71f7a60466fea9d61
| 3,530
|
cpp
|
C++
|
android-31/java/security/cert/CertificateFactory.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 12
|
2020-03-26T02:38:56.000Z
|
2022-03-14T08:17:26.000Z
|
android-31/java/security/cert/CertificateFactory.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 1
|
2021-01-27T06:07:45.000Z
|
2021-11-13T19:19:43.000Z
|
android-29/java/security/cert/CertificateFactory.cpp
|
YJBeetle/QtAndroidAPI
|
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
|
[
"Apache-2.0"
] | 3
|
2021-02-02T12:34:55.000Z
|
2022-03-08T07:45:57.000Z
|
#include "../../io/InputStream.hpp"
#include "../../../JString.hpp"
#include "../Provider.hpp"
#include "./CRL.hpp"
#include "./CertPath.hpp"
#include "./Certificate.hpp"
#include "./CertificateFactorySpi.hpp"
#include "./CertificateFactory.hpp"
namespace java::security::cert
{
// Fields
// QJniObject forward
CertificateFactory::CertificateFactory(QJniObject obj) : JObject(obj) {}
// Constructors
// Methods
java::security::cert::CertificateFactory CertificateFactory::getInstance(JString arg0)
{
return callStaticObjectMethod(
"java.security.cert.CertificateFactory",
"getInstance",
"(Ljava/lang/String;)Ljava/security/cert/CertificateFactory;",
arg0.object<jstring>()
);
}
java::security::cert::CertificateFactory CertificateFactory::getInstance(JString arg0, JString arg1)
{
return callStaticObjectMethod(
"java.security.cert.CertificateFactory",
"getInstance",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/security/cert/CertificateFactory;",
arg0.object<jstring>(),
arg1.object<jstring>()
);
}
java::security::cert::CertificateFactory CertificateFactory::getInstance(JString arg0, java::security::Provider arg1)
{
return callStaticObjectMethod(
"java.security.cert.CertificateFactory",
"getInstance",
"(Ljava/lang/String;Ljava/security/Provider;)Ljava/security/cert/CertificateFactory;",
arg0.object<jstring>(),
arg1.object()
);
}
java::security::cert::CRL CertificateFactory::generateCRL(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCRL",
"(Ljava/io/InputStream;)Ljava/security/cert/CRL;",
arg0.object()
);
}
JObject CertificateFactory::generateCRLs(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCRLs",
"(Ljava/io/InputStream;)Ljava/util/Collection;",
arg0.object()
);
}
java::security::cert::CertPath CertificateFactory::generateCertPath(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCertPath",
"(Ljava/io/InputStream;)Ljava/security/cert/CertPath;",
arg0.object()
);
}
java::security::cert::CertPath CertificateFactory::generateCertPath(JObject arg0) const
{
return callObjectMethod(
"generateCertPath",
"(Ljava/util/List;)Ljava/security/cert/CertPath;",
arg0.object()
);
}
java::security::cert::CertPath CertificateFactory::generateCertPath(java::io::InputStream arg0, JString arg1) const
{
return callObjectMethod(
"generateCertPath",
"(Ljava/io/InputStream;Ljava/lang/String;)Ljava/security/cert/CertPath;",
arg0.object(),
arg1.object<jstring>()
);
}
java::security::cert::Certificate CertificateFactory::generateCertificate(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCertificate",
"(Ljava/io/InputStream;)Ljava/security/cert/Certificate;",
arg0.object()
);
}
JObject CertificateFactory::generateCertificates(java::io::InputStream arg0) const
{
return callObjectMethod(
"generateCertificates",
"(Ljava/io/InputStream;)Ljava/util/Collection;",
arg0.object()
);
}
JObject CertificateFactory::getCertPathEncodings() const
{
return callObjectMethod(
"getCertPathEncodings",
"()Ljava/util/Iterator;"
);
}
java::security::Provider CertificateFactory::getProvider() const
{
return callObjectMethod(
"getProvider",
"()Ljava/security/Provider;"
);
}
JString CertificateFactory::getType() const
{
return callObjectMethod(
"getType",
"()Ljava/lang/String;"
);
}
} // namespace java::security::cert
| 27.364341
| 118
| 0.724363
|
YJBeetle
|
de53b158c280826d87aad3d27c95fcec1b745b1a
| 4,999
|
cc
|
C++
|
modules/canbus/vehicle/wey/protocol/fail_241.cc
|
Shokoofeh/apollo
|
71d6ea753b4595eb38cc54d6650c8de677b173df
|
[
"Apache-2.0"
] | 2
|
2019-02-21T05:52:59.000Z
|
2019-07-27T03:24:16.000Z
|
modules/canbus/vehicle/wey/protocol/fail_241.cc
|
Shokoofeh/apollo
|
71d6ea753b4595eb38cc54d6650c8de677b173df
|
[
"Apache-2.0"
] | null | null | null |
modules/canbus/vehicle/wey/protocol/fail_241.cc
|
Shokoofeh/apollo
|
71d6ea753b4595eb38cc54d6650c8de677b173df
|
[
"Apache-2.0"
] | 1
|
2021-12-03T23:30:00.000Z
|
2021-12-03T23:30:00.000Z
|
/******************************************************************************
* Copyright 2019 The Apollo Authors. 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 "modules/canbus/vehicle/wey/protocol/fail_241.h"
#include "glog/logging.h"
#include "modules/drivers/canbus/common/byte.h"
#include "modules/drivers/canbus/common/canbus_consts.h"
namespace apollo {
namespace canbus {
namespace wey {
using ::apollo::drivers::canbus::Byte;
Fail241::Fail241() {}
const int32_t Fail241::ID = 0x241;
void Fail241::Parse(const std::uint8_t* bytes, int32_t length,
ChassisDetail* chassis) const {
chassis->mutable_wey()->mutable_fail_241()->
set_engfail(engfail(bytes, length));
chassis->mutable_wey()->mutable_fail_241()->
set_espfail(espfail(bytes, length));
chassis->mutable_wey()->mutable_fail_241()->
set_epbfail(epbfail(bytes, length));
chassis->mutable_wey()->mutable_fail_241()->
set_shiftfail(shiftfail(bytes, length));
chassis->mutable_wey()->mutable_fail_241()->
set_epsfail(epsfail(bytes, length));
}
// config detail: {'description': 'Engine Fail status', 'enum': {0:
// 'ENGFAIL_NO_FAIL', 1: 'ENGFAIL_FAIL'}, 'precision': 1.0, 'len': 1, 'name':
// 'engfail', 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]',
// 'bit': 7, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Fail_241::EngfailType Fail241::engfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 0);
int32_t x = t0.get_byte(7, 1);
Fail_241::EngfailType ret = static_cast<Fail_241::EngfailType>(x);
return ret;
}
// config detail: {'description': 'ESP fault', 'enum': {0:'ESPFAIL_NO_FAILURE',
// 1: 'ESPFAIL_FAILURE'}, 'precision': 1.0, 'len': 1, 'name': 'espfail',
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 14,
// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Fail_241::EspfailType Fail241::espfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(6, 1);
Fail_241::EspfailType ret = static_cast<Fail_241::EspfailType>(x);
return ret;
}
// config detail: {'description': 'error indication of EPB system', 'enum': {0:
// 'EPBFAIL_UNDEFINED', 1: 'EPBFAIL_NO_ERROR', 2: 'EPBFAIL_ERROR', 3:
// 'EPBFAIL_DIAGNOSIS'}, 'precision': 1.0, 'len': 2, 'name': 'epbfail',
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|3]', 'bit': 35,
// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Fail_241::EpbfailType Fail241::epbfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 4);
int32_t x = t0.get_byte(2, 2);
Fail_241::EpbfailType ret = static_cast<Fail_241::EpbfailType>(x);
return ret;
}
// config detail: {'description': 'Driver display failure messages', 'enum': {0:
// 'SHIFTFAIL_NO_FAIL', 1: 'SHIFTFAIL_TRANSMISSION_MALFUNCTION', 2:
// 'SHIFTFAIL_TRANSMISSION_P_ENGAGEMENT_FAULT', 3:
// 'SHIFTFAIL_TRANSMISSION_P_DISENGAGEMENT_FAULT', 4: 'SHIFTFAIL_RESERVED',
// 15: 'SHIFTFAIL_TRANSMISSION_LIMIT_FUNCTION'}, 'precision': 1.0, 'len': 4,
// 'name': 'shiftfail', 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|15]', 'bit': 31, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
Fail_241::ShiftfailType Fail241::shiftfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 3);
int32_t x = t0.get_byte(4, 4);
Fail_241::ShiftfailType ret = static_cast<Fail_241::ShiftfailType>(x);
return ret;
}
// config detail: {'description': 'Electrical steering fail status', 'enum':
// {0: 'EPSFAIL_NO_FAULT', 1: 'EPSFAIL_FAULT'}, 'precision': 1.0, 'len': 1,
// 'name': 'epsfail', 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 21, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
Fail_241::EpsfailType Fail241::epsfail(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(5, 1);
Fail_241::EpsfailType ret = static_cast<Fail_241::EpsfailType>(x);
return ret;
}
} // namespace wey
} // namespace canbus
} // namespace apollo
| 41.658333
| 80
| 0.625925
|
Shokoofeh
|
de584d8d2205e07aa38d7dcf7a51f33f803960b8
| 4,690
|
cpp
|
C++
|
drivers/I2C_SPI/AusExGroveI2cTouchSensor/src/AusExGroveI2cTouchSensor.cpp
|
houtbrion/AusEx
|
fd74cbab4281da6ba4f285412f2d1f53f40206c9
|
[
"Apache-1.1"
] | null | null | null |
drivers/I2C_SPI/AusExGroveI2cTouchSensor/src/AusExGroveI2cTouchSensor.cpp
|
houtbrion/AusEx
|
fd74cbab4281da6ba4f285412f2d1f53f40206c9
|
[
"Apache-1.1"
] | null | null | null |
drivers/I2C_SPI/AusExGroveI2cTouchSensor/src/AusExGroveI2cTouchSensor.cpp
|
houtbrion/AusEx
|
fd74cbab4281da6ba4f285412f2d1f53f40206c9
|
[
"Apache-1.1"
] | null | null | null |
#include "AusExGroveI2cTouchSensor.h"
/*
*
*/
AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS(TwoWire *theWire, int32_t sensorID ){
_i2c_if=theWire;
_sensorID=sensorID;
}
bool AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::begin(uint32_t addr){
_i2c_addr=addr;
_i2c_if->begin();
mpr121Setup();
return true;
}
void AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::mpr121Setup() {
// Section A - Controls filtering when data is > baseline.
write(MHD_R, 0x01);
write(NHD_R, 0x01);
write(NCL_R, 0x00);
write(FDL_R, 0x00);
// Section B - Controls filtering when data is < baseline.
write(MHD_F, 0x01);
write(NHD_F, 0x01);
write(NCL_F, 0xFF);
write(FDL_F, 0x02);
// Section C - Sets touch and release thresholds for each electrode
write(ELE0_T, TOU_THRESH);
write(ELE0_R, REL_THRESH);
write(ELE1_T, TOU_THRESH);
write(ELE1_R, REL_THRESH);
write(ELE2_T, TOU_THRESH);
write(ELE2_R, REL_THRESH);
write(ELE3_T, TOU_THRESH);
write(ELE3_R, REL_THRESH);
write(ELE4_T, TOU_THRESH);
write(ELE4_R, REL_THRESH);
write(ELE5_T, TOU_THRESH);
write(ELE5_R, REL_THRESH);
write(ELE6_T, TOU_THRESH);
write(ELE6_R, REL_THRESH);
write(ELE7_T, TOU_THRESH);
write(ELE7_R, REL_THRESH);
write(ELE8_T, TOU_THRESH);
write(ELE8_R, REL_THRESH);
write(ELE9_T, TOU_THRESH);
write(ELE9_R, REL_THRESH);
write(ELE10_T, TOU_THRESH);
write(ELE10_R, REL_THRESH);
write(ELE11_T, TOU_THRESH);
write(ELE11_R, REL_THRESH);
// Section D
// Set the Filter Configuration
// Set ESI2
write(FIL_CFG, 0x04);
//set_register(0x5A,ATO_CFGU, 0xC9); // USL = (Vdd-0.7)/vdd*256 = 0xC9 @3.3V mpr121Write(ATO_CFGL, 0x82); // LSL = 0.65*USL = 0x82 @3.3V
//set_register(0x5A,ATO_CFGL, 0x82); // Target = 0.9*USL = 0xB5 @3.3V
//set_register(0x5A,ATO_CFGT,0xb5);
//set_register(0x5A,ATO_CFG0, 0x1B);
// Section E
// Electrode Configuration
// Set ELE_CFG to 0x00 to return to standby mode
write(ELE_CFG, 0x0C); // Enables all 12 Electrodes
// Section F
// Enable Auto Config and auto Reconfig
//write(ATO_CFG0, 0x0B);
//write(ATO_CFGU, 0xC9); // USL = (Vdd-0.7)/vdd*256 = 0xC9 @3.3V
//write(ATO_CFGL, 0x82); // LSL = 0.65*USL = 0x82 @3.3V
//write(ATO_CFGT, 0xB5); // Target = 0.9*USL = 0xB5 @3.3V
}
void AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::write(uint8_t _register, uint8_t _data)
{
//_i2c_addr->begin();
_i2c_if->beginTransmission(_i2c_addr);
_i2c_if->write(_register);
_i2c_if->write(_data);
_i2c_if->endTransmission();
}
int8_t AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::read(uint8_t _register)
{
int8_t data;
_i2c_if->beginTransmission(_i2c_addr);
_i2c_if->write(_register);
_i2c_if->endTransmission();
_i2c_if->requestFrom(_i2c_addr, 1);
if(_i2c_if->available() > 0){
data = _i2c_if->read();
}
_i2c_if->endTransmission();
return data;
}
int16_t AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::readLong()
{
uint8_t l,h;
_i2c_if->requestFrom(_i2c_addr, 2);
l = _i2c_if->read();
h = _i2c_if->read();
return (h << 8) | l;
}
bool AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::getEvent(sensors_event_t* event){
/* Clear the event */
memset(event, 0, sizeof(sensors_event_t));
event->size = sizeof(sensors_event_t);
event->sensor_id = _sensorID;
event->type = AUSEX_GROVE_I2C_TOUCH_SENSOR_TYPE;
event->timestamp = millis();
/* Calculate the actual lux value */
event->AUSEX_GROVE_I2C_TOUCH_SENSOR_RETURN_VALUE = readLong();
return true;
}
void AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::getSensor(sensor_t* sensor){
/* Clear the sensor_t object */
memset(sensor, 0, sizeof(sensor_t));
/* Insert the sensor name in the fixed length char array */
strncpy (sensor->name, AUSEX_GROVE_I2C_TOUCH_SENSOR_NAME , sizeof(sensor->name) - 1);
sensor->name[sizeof(sensor->name)- 1] = 0;
sensor->version = AUSEX_GROVE_I2C_TOUCH_SENSOR_LIBRARY_VERSION;
sensor->sensor_id = _sensorID;
sensor->type = AUSEX_GROVE_I2C_TOUCH_SENSOR_TYPE;
sensor->min_value = AUSEX_GROVE_I2C_TOUCH_SENSOR_MIN_VALUE;
sensor->max_value = AUSEX_GROVE_I2C_TOUCH_SENSOR_MAX_VALUE;
sensor->resolution = AUSEX_GROVE_I2C_TOUCH_SENSOR_RESOLUTION;
sensor->min_delay = AUSEX_GROVE_I2C_TOUCH_SENSOR_MIN_DELAY;
sensor->init_delay = AUSEX_GROVE_I2C_TOUCH_SENSOR_INIT_DELAY;
}
bool AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::enableAutoRange(bool enabled) {
return false;
}
int AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::setMode(int mode) {
return -1;
}
int AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::getMode(void) {
return -1;
}
bool AUSEX_GROVE_I2C_TOUCH_SENSOR_CLASS::getTouchState(AUSEX_GROVE_I2C_TOUCH_SENSOR_VALUE_TYPE val, uint8_t num){
if(val & (1<<num)) return true;
return false;
}
| 30.258065
| 142
| 0.724733
|
houtbrion
|
de5b72aaeb5f997dd3537633617d4e1a3bcdc334
| 533
|
hpp
|
C++
|
src/include/XESystem.hpp
|
devxkh/FrankE
|
72faca02759b54aaec842831f3c7a051e7cf5335
|
[
"MIT"
] | 11
|
2017-01-17T15:02:25.000Z
|
2020-11-27T16:54:42.000Z
|
src/include/XESystem.hpp
|
devxkh/FrankE
|
72faca02759b54aaec842831f3c7a051e7cf5335
|
[
"MIT"
] | 9
|
2016-10-23T20:15:38.000Z
|
2018-02-06T11:23:17.000Z
|
src/include/XESystem.hpp
|
devxkh/FrankE
|
72faca02759b54aaec842831f3c7a051e7cf5335
|
[
"MIT"
] | 2
|
2019-08-29T10:23:51.000Z
|
2020-04-03T06:08:34.000Z
|
#ifndef XE_INTERFACE_SYSTEM_HPP
#define XE_INTERFACE_SYSTEM_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
//#include <XESystem/gkDebugger.h>
#include <XESystem/SystemConfig.hpp>
//#include <ThirdParty/plog/Log.h>
//
//INITIALIZE_EASYLOGGINGPP
#endif // XE_INTERFACE_SYSTEM_HPP
////////////////////////////////////////////////////////////
/// \defgroup system System module
///
////////////////////////////////////////////////////////////
| 28.052632
| 60
| 0.420263
|
devxkh
|
de5ce2395e0a1a352fadf0042b3eec426822b9f2
| 1,106
|
hh
|
C++
|
nel/src/memory.hh
|
jwebb68/nel
|
a5bfe9038921448da52cdeeba45984a54d79423c
|
[
"MIT"
] | null | null | null |
nel/src/memory.hh
|
jwebb68/nel
|
a5bfe9038921448da52cdeeba45984a54d79423c
|
[
"MIT"
] | null | null | null |
nel/src/memory.hh
|
jwebb68/nel
|
a5bfe9038921448da52cdeeba45984a54d79423c
|
[
"MIT"
] | null | null | null |
#ifndef NEL_MEMORY_HH
#define NEL_MEMORY_HH
#include <cstdint> // uint8_t
#include <cstddef> // size_t
#include <utility> // std::move, std::swap
namespace nel {
void memcpy(uint8_t *const d, uint8_t const *const s, size_t const n) noexcept;
void memset(uint8_t *const d, uint8_t const s, size_t const n) noexcept;
void memmove(uint8_t *const d, uint8_t *const s, size_t const n) noexcept;
void memswap(uint8_t *const d, uint8_t *const s, size_t const n) noexcept;
template<typename T>
void memmove(T *d, T *s, size_t n) noexcept
{
for (size_t i = 0; i < n; ++i) {
d[i] = std::move(s[i]);
}
}
template<typename T>
void memcpy(T *const d, T const *const s, size_t n) noexcept
{
for (size_t i = 0; i < n; ++i) {
d[i] = s[i];
}
}
template<typename T>
void memset(T *const d, T const &s, size_t n) noexcept
{
for (size_t i = 0; i < n; ++i) {
d[i] = s;
}
}
template<typename T>
void memswap(T *const d, T *const s, size_t n) noexcept
{
for (size_t i = 0; i < n; ++i) {
std::swap(*d, *s);
}
}
} // namespace nel
#endif//NEL_MEMORY_HH
| 20.109091
| 79
| 0.618445
|
jwebb68
|
de60633e2d2eb8f8099ed123e45c1e17d7d1892b
| 227
|
hpp
|
C++
|
CCP4M_Old/include/ProjectManagement/ProjectFileGenerator.hpp
|
Electrux/CCPP-Code
|
3c5e5b866cf050c11bced9651b112eb31dd2465d
|
[
"BSD-3-Clause"
] | 6
|
2019-08-29T23:31:17.000Z
|
2021-11-14T20:35:47.000Z
|
CCP4M_Old/include/ProjectManagement/ProjectFileGenerator.hpp
|
Electrux/CCPP-Code
|
3c5e5b866cf050c11bced9651b112eb31dd2465d
|
[
"BSD-3-Clause"
] | null | null | null |
CCP4M_Old/include/ProjectManagement/ProjectFileGenerator.hpp
|
Electrux/CCPP-Code
|
3c5e5b866cf050c11bced9651b112eb31dd2465d
|
[
"BSD-3-Clause"
] | 1
|
2019-09-01T12:22:58.000Z
|
2019-09-01T12:22:58.000Z
|
#ifndef PROJECTFILEGENERATOR_HPP
#define PROJECTFILEGENERATOR_HPP
#include "ProjectData.hpp"
#include "FSFuncs.hpp"
#include "ConfigMgr.hpp"
int GenerateProjectFiles( ProjectData & data );
#endif // PROJECTFILEGENERATOR_HPP
| 20.636364
| 47
| 0.810573
|
Electrux
|
de6207b4dcb7fcfddaae34e792c0b597dfc72b3a
| 3,378
|
hpp
|
C++
|
include/RaZ/Math/MathUtils.hpp
|
Sausty/RaZ
|
211cc1c0c4a7374520a3141fc069b7717e2e5e0f
|
[
"MIT"
] | null | null | null |
include/RaZ/Math/MathUtils.hpp
|
Sausty/RaZ
|
211cc1c0c4a7374520a3141fc069b7717e2e5e0f
|
[
"MIT"
] | null | null | null |
include/RaZ/Math/MathUtils.hpp
|
Sausty/RaZ
|
211cc1c0c4a7374520a3141fc069b7717e2e5e0f
|
[
"MIT"
] | null | null | null |
#pragma once
#ifndef RAZ_MATHUTILS_HPP
#define RAZ_MATHUTILS_HPP
#include <algorithm>
#include <cassert>
#include <type_traits>
namespace Raz::MathUtils {
/// Computes the linear interpolation between two values, according to a coefficient.
/// \tparam T Type to compute the interpolation with.
/// \param min Minimum value (lower bound).
/// \param max Maximum value (upper bound).
/// \param coeff Coefficient between 0 (returns `min`) and 1 (returns `max`).
/// \return Computed linear interpolation between `min` and `max`.
template <typename T>
constexpr T interpolate(T min, T max, T coeff) noexcept {
static_assert(std::is_floating_point_v<T>, "Error: Interpolation type must be floating point.");
assert("Error: The interpolation coefficient must be between 0 & 1." && (coeff >= 0 && coeff <= 1));
return min * (1 - coeff) + max * coeff;
}
/// Computes the [Hermite interpolation](https://en.wikipedia.org/wiki/Hermite_interpolation) between two thresholds.
///
/// Any value below `minThresh` will return 0, and any above `maxThresh` will return 1. Between both thresholds, a smooth interpolation is performed.
///
/// 1.0 | |___
/// | .-~"|
/// | ,^ |
/// | / |
/// | / |
/// | / |
/// | ,v |
/// 0.0 ___|,.-" |
/// ^ ^
/// minThresh maxThresh
///
/// This is equivalent to [GLSL's smoothstep function](http://docs.gl/sl4/smoothstep).
/// \tparam T Type to compute the interpolation with.
/// \param minThresh Minimum threshold value.
/// \param maxThresh Maximum threshold value.
/// \param value Value to be interpolated.
/// \return 0 if `value` is lower than `minThresh`.
/// \return 1 if `value` is greater than `maxThresh`.
/// \return The interpolated value (between 0 & 1) otherwise.
template <typename T>
constexpr T smoothstep(T minThresh, T maxThresh, T value) noexcept {
assert("Error: The smoothstep's maximum threshold must be greater than the minimum one." && maxThresh > minThresh);
const T clampedVal = std::clamp((value - minThresh) / (maxThresh - minThresh), static_cast<T>(0), static_cast<T>(1));
return clampedVal * clampedVal * (3 - 2 * clampedVal);
}
/// Computes the [smootherstep](https://en.wikipedia.org/wiki/Smoothstep#Variations) between two thresholds.
/// This is Ken Perlin's smoothstep variation, which produces a slightly smoother smoothstep.
/// \tparam T Type to compute the interpolation with.
/// \param minThresh Minimum threshold value.
/// \param maxThresh Maximum threshold value.
/// \param value Value to be interpolated.
/// \return 0 if `value` is lower than `minThresh`.
/// \return 1 if `value` is greater than `maxThresh`.
/// \return The interpolated value (between 0 & 1) otherwise.
template <typename T>
constexpr T smootherstep(T minThresh, T maxThresh, T value) noexcept {
assert("Error: The smootherstep's maximum threshold must be greater than the minimum one." && maxThresh > minThresh);
const T clampedVal = std::clamp((value - minThresh) / (maxThresh - minThresh), static_cast<T>(0), static_cast<T>(1));
return clampedVal * clampedVal * clampedVal * (clampedVal * (clampedVal * 6 - 15) + 10);
}
} // namespace Raz::MathUtils
#endif // RAZ_MATHUTILS_HPP
| 43.87013
| 149
| 0.65897
|
Sausty
|
de62423217435b714daacef3ad51497d1a4d690a
| 3,286
|
hpp
|
C++
|
Axis.CommonLibrary/domain/elements/DoF.hpp
|
renato-yuzup/axis-fem
|
2e8d325eb9c8e99285f513b4c1218ef53eb0ab22
|
[
"MIT"
] | 2
|
2021-07-23T08:49:54.000Z
|
2021-07-29T22:07:30.000Z
|
Axis.CommonLibrary/domain/elements/DoF.hpp
|
renato-yuzup/axis-fem
|
2e8d325eb9c8e99285f513b4c1218ef53eb0ab22
|
[
"MIT"
] | null | null | null |
Axis.CommonLibrary/domain/elements/DoF.hpp
|
renato-yuzup/axis-fem
|
2e8d325eb9c8e99285f513b4c1218ef53eb0ab22
|
[
"MIT"
] | null | null | null |
/// <summary>
/// Contains the definition for the class axis::domain::elements::DoF.
/// </summary>
/// <author>Renato T. Yamassaki</author>
#pragma once
#include "foundation/Axis.CommonLibrary.hpp"
#include "foundation/memory/pointer.hpp"
#include "nocopy.hpp"
namespace axis { namespace domain {
namespace boundary_conditions {
// a prototype
class AXISCOMMONLIBRARY_API BoundaryCondition;
}
namespace elements {
// another prototype
class AXISCOMMONLIBRARY_API Node;
/// <summary>
/// Represents a degree-of-freedom (DoF) that a node has. In other words, one possible
/// direction of movement of a node.
/// </summary>
class AXISCOMMONLIBRARY_API DoF
{
public:
typedef long id_type;
/**********************************************************************************************//**
* @fn :::DoF(id_type id, int localIndex, Node& node);
*
* @brief Creates a new degree-of-freedom.
*
* @author Renato T. Yamassaki
* @date 12 jun 2012
*
* @param id Numerical identifier which relates this
* dof with its position in a global matrix.
* @param localIndex Zero-based index of the dof in the node.
* @param [in,out] node The node to which this dof belongs.
**************************************************************************************************/
DoF(id_type id, int localIndex, const axis::foundation::memory::RelativePointer& node);
/// <summary>
/// Destroys this object.
/// </summary>
~DoF(void);
/// <summary>
/// Destroys this object.
/// </summary>
void Destroy(void) const;
/// <summary>
/// Returns the numerical identifier of this dof.
/// </summary>
id_type GetId(void) const;
int GetLocalIndex(void) const;
Node& GetParentNode(void);
const Node& GetParentNode(void) const;
/// <summary>
/// Returns if there is boundary condition applied to this dof.
/// </summary>
bool HasBoundaryConditionApplied(void) const;
/// <summary>
/// Return the boundary condition applied to this dof.
/// </summary>
axis::domain::boundary_conditions::BoundaryCondition& GetBoundaryCondition(void) const;
/// <summary>
/// Sets a new boundary condition applied to this dof.
/// </summary>
/// <param name="condition">The boundary condition to be applied to this dof.</param>
void SetBoundaryCondition(axis::domain::boundary_conditions::BoundaryCondition& condition);
/// <summary>
/// Sets a new boundary condition to this dof removing any applied before.
/// </summary>
/// <param name="condition">The boundary condition to be applied to this dof.</param>
void ReplaceBoundaryCondition(axis::domain::boundary_conditions::BoundaryCondition& condition);
/// <summary>
/// Removes any boundary condition applied to this dof.
/// </summary>
void RemoveBoundaryCondition(void);
static axis::foundation::memory::RelativePointer Create(
id_type id, int localIndex, const axis::foundation::memory::RelativePointer& node);
void *operator new(size_t bytes);
void operator delete(void *ptr);
void *operator new(size_t bytes, void *ptr);
void operator delete(void *, void *);
private:
id_type _id;
int _localIndex;
axis::domain::boundary_conditions::BoundaryCondition *_condition;
axis::foundation::memory::RelativePointer _parentNode;
DISALLOW_COPY_AND_ASSIGN(DoF);
};
} } }
| 30.146789
| 101
| 0.673767
|
renato-yuzup
|
de69117248769fece90923ed8a531e23e9866066
| 316
|
cpp
|
C++
|
atcoder/abc116/A.cpp
|
SashiRin/protrode
|
c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c
|
[
"MIT"
] | 1
|
2019-08-03T13:42:16.000Z
|
2019-08-03T13:42:16.000Z
|
atcoder/abc116/A.cpp
|
SashiRin/protrode
|
c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c
|
[
"MIT"
] | null | null | null |
atcoder/abc116/A.cpp
|
SashiRin/protrode
|
c03d0a6e9a5ac87d0f3d3af5d39b05a10f58527c
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;
int main() {
vector<int> nums(3);
for (int i = 0; i < 3; ++i) {
cin >> nums[i];
}
sort(nums.begin(), nums.end());
cout << nums[0] * nums[1] / 2 << endl;
return 0;
}
| 18.588235
| 42
| 0.53481
|
SashiRin
|
de69d155868cb9b451780809dc5173551ad2facf
| 1,188
|
cpp
|
C++
|
洛谷/模拟/P1042.cpp
|
codehuanglei/-
|
933a55b5c5a49163f12e0c39b4edfa9c4f01678f
|
[
"MIT"
] | null | null | null |
洛谷/模拟/P1042.cpp
|
codehuanglei/-
|
933a55b5c5a49163f12e0c39b4edfa9c4f01678f
|
[
"MIT"
] | null | null | null |
洛谷/模拟/P1042.cpp
|
codehuanglei/-
|
933a55b5c5a49163f12e0c39b4edfa9c4f01678f
|
[
"MIT"
] | null | null | null |
#include<bits/stdc++.h>
using namespace std;
const int MAX = 65535;
int arr[MAX] = {0};
char ch;
int main(){
for(int i = 1;cin >> ch && ch != 'E'; i++){
if(ch == 'W'){
arr[i] = 1;
}
if(ch == 'L'){
arr[i] = 2;
}
}
int w = 0, l = 0;
for(int i = 1; 1; i++){
if(arr[i] == 1){
w++;
}
if(arr[i] == 2){
l++;
}
if(arr[i] == 0){
cout<< w << ":" << l<<endl;
break;
}
if(w - l >= 2 || l - w >= 2){
if(w >= 11 || l >= 11){
cout<< w << ":"<< l << endl;
w = 0;
l = 0;
}
}
}
cout<< endl;
w = l = 0;
for(int i = 1; 1; i++){
if(arr[i] == 1){
w++;
}
if(arr[i] == 2){
l++;
}
if(arr[i] == 0){
cout<< w << ":" << l<<endl;
break;
}
if(w - l >= 2 || l - w >= 2){
if(w >= 21 || l >= 21){
cout<< w << ":"<< l << endl;
w = 0;
l = 0;
}
}
}
return 0;
}
| 20.842105
| 47
| 0.244108
|
codehuanglei
|
de6a14af5c852ebfe2b51977061ef15749adf264
| 1,662
|
hpp
|
C++
|
Source/wali/include/wali/LongestSaturatingPathSemiring.hpp
|
jusito/WALi-OpenNWA
|
2bb4aca02c5a5d444fd038e8aa3eecd7d1ccbb99
|
[
"MIT"
] | 15
|
2015-03-07T17:25:57.000Z
|
2022-02-04T20:17:00.000Z
|
Source/wali/include/wali/LongestSaturatingPathSemiring.hpp
|
jusito/WALi-OpenNWA
|
2bb4aca02c5a5d444fd038e8aa3eecd7d1ccbb99
|
[
"MIT"
] | 1
|
2018-03-03T05:58:55.000Z
|
2018-03-03T12:26:10.000Z
|
Source/wali/include/wali/LongestSaturatingPathSemiring.hpp
|
jusito/WALi-OpenNWA
|
2bb4aca02c5a5d444fd038e8aa3eecd7d1ccbb99
|
[
"MIT"
] | 15
|
2015-09-25T17:44:35.000Z
|
2021-07-18T18:25:38.000Z
|
#ifndef WALI_LONGESTSATURATING_PATH_SEMIRING_HPP
#define WALI_LONGESTSATURATING_PATH_SEMIRING_HPP
#include "wali/SemElem.hpp"
#include "wali/MergeFn.hpp"
#include "wali/ref_ptr.hpp"
#include "wali/Key.hpp"
#include <set>
namespace wali {
/// This is a funny domain. But maybe it'll be useful? I just use it for
/// testing.
///
/// The domain is {0, 1, 2, ...., big, bottom} for some 'big' (given in the
/// constructor). Extend is saturating addition strictly evaluated, combine
/// is maximum, semiring zero is bottom, and semiring one is distance 0.
class LongestSaturatingPathSemiring : public wali::SemElem
{
public:
//-----------------------------
// semiring one and zero
//-----------------------------
sem_elem_t one() const;
sem_elem_t zero() const;
//---------------------------------
// semiring operations
//---------------------------------
sem_elem_t extend( SemElem* rhs );
sem_elem_t combine( SemElem* rhs );
bool equal(SemElem *rhs) const;
bool containerLessThan(SemElem const * rhs) const;
//------------------------------------
// output
//------------------------------------
std::ostream & print(std::ostream &out) const;
unsigned int getNum() const;
size_t hash() const;
private:
unsigned int v;
unsigned int biggest;
public:
//---------------------
// Constructors
//---------------------
LongestSaturatingPathSemiring(unsigned int big) : v(0), biggest(big) { }
LongestSaturatingPathSemiring(unsigned int _v, unsigned int big) : v(_v), biggest(big) {}
};
}
#endif // REACH_SEMIRING
| 24.086957
| 93
| 0.561372
|
jusito
|
de6b176e78f826c786378659d8757f9f98fae5fa
| 560
|
cpp
|
C++
|
Chapter_9/overloading_variadic_non-template.cpp
|
wagnerhsu/packt-CPP-Templates-Up-and-Running
|
2dcede8bb155d609a1b8d9765bfd4167e3a57289
|
[
"MIT"
] | null | null | null |
Chapter_9/overloading_variadic_non-template.cpp
|
wagnerhsu/packt-CPP-Templates-Up-and-Running
|
2dcede8bb155d609a1b8d9765bfd4167e3a57289
|
[
"MIT"
] | null | null | null |
Chapter_9/overloading_variadic_non-template.cpp
|
wagnerhsu/packt-CPP-Templates-Up-and-Running
|
2dcede8bb155d609a1b8d9765bfd4167e3a57289
|
[
"MIT"
] | null | null | null |
#include <iostream>
void foo(int val1, int val2)
{
std::cout << "From non-template" << std::endl;
std::cout << val1 << " " << val2 << std::endl;
}
template<typename T>
void foo(T val1, T val2)
{
std::cout << "From non-variadic" << std::endl;
std::cout << val1 << " " << val2 << std::endl;
}
template<typename T, typename... rest>
void foo(T val, rest... argPack)
{
std::cout << "From variadic" << std::endl;
std::cout << val << std::endl;
foo(argPack...);
}
int main()
{
foo(10, 20);
foo(10, 20, 30, 40);
return 0;
}
| 19.310345
| 50
| 0.55
|
wagnerhsu
|
de6bec73380ead55000e692d1463d900d1472f4a
| 12,254
|
cc
|
C++
|
src/trace_processor/args_table_unittest.cc
|
zakerinasab/perfetto
|
7f86589d1522ce8bfc59f6b569ca52496a53eb79
|
[
"Apache-2.0"
] | null | null | null |
src/trace_processor/args_table_unittest.cc
|
zakerinasab/perfetto
|
7f86589d1522ce8bfc59f6b569ca52496a53eb79
|
[
"Apache-2.0"
] | null | null | null |
src/trace_processor/args_table_unittest.cc
|
zakerinasab/perfetto
|
7f86589d1522ce8bfc59f6b569ca52496a53eb79
|
[
"Apache-2.0"
] | null | null | null |
/*
* Copyright (C) 2018 The Android Open Source Project
*
* 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 "src/trace_processor/args_table.h"
#include "src/trace_processor/sqlite/scoped_db.h"
#include "src/trace_processor/trace_processor_context.h"
#include "src/trace_processor/trace_storage.h"
#include "test/gtest_and_gmock.h"
namespace perfetto {
namespace trace_processor {
namespace {
class ArgsTableUnittest : public ::testing::Test {
public:
ArgsTableUnittest() {
sqlite3* db = nullptr;
PERFETTO_CHECK(sqlite3_initialize() == SQLITE_OK);
PERFETTO_CHECK(sqlite3_open(":memory:", &db) == SQLITE_OK);
db_.reset(db);
context_.storage.reset(new TraceStorage());
ArgsTable::RegisterTable(db_.get(), context_.storage.get());
}
void PrepareValidStatement(const std::string& sql) {
int size = static_cast<int>(sql.size());
sqlite3_stmt* stmt;
ASSERT_EQ(sqlite3_prepare_v2(*db_, sql.c_str(), size, &stmt, nullptr),
SQLITE_OK);
stmt_.reset(stmt);
}
const char* GetColumnAsText(int colId) {
return reinterpret_cast<const char*>(sqlite3_column_text(*stmt_, colId));
}
void AssertArgRowValues(int arg_set_id,
const char* flat_key,
const char* key,
base::Optional<int64_t> int_value,
base::Optional<const char*> string_value,
base::Optional<double> real_value);
protected:
TraceProcessorContext context_;
ScopedDb db_;
ScopedStmt stmt_;
};
// Test helper.
void ArgsTableUnittest::AssertArgRowValues(
int arg_set_id,
const char* flat_key,
const char* key,
base::Optional<int64_t> int_value,
base::Optional<const char*> string_value,
base::Optional<double> real_value) {
ASSERT_EQ(sqlite3_column_int(*stmt_, 0), arg_set_id);
ASSERT_STREQ(GetColumnAsText(1), flat_key);
ASSERT_STREQ(GetColumnAsText(2), key);
if (int_value.has_value()) {
ASSERT_EQ(sqlite3_column_int64(*stmt_, 3), int_value.value());
} else {
ASSERT_EQ(sqlite3_column_type(*stmt_, 3), SQLITE_NULL);
}
if (string_value.has_value()) {
ASSERT_STREQ(GetColumnAsText(4), string_value.value());
} else {
ASSERT_EQ(sqlite3_column_type(*stmt_, 4), SQLITE_NULL);
}
if (real_value.has_value()) {
ASSERT_DOUBLE_EQ(sqlite3_column_double(*stmt_, 5), real_value.value());
} else {
ASSERT_EQ(sqlite3_column_type(*stmt_, 5), SQLITE_NULL);
}
}
TEST_F(ArgsTableUnittest, IntValue) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
static const int kValue = 123;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString(kFlatKey);
arg.key = context_.storage->InternString(kKey);
arg.value = Variadic::Integer(kValue);
context_.storage->mutable_args()->AddArgSet({arg}, 0, 1);
PrepareValidStatement("SELECT * FROM args");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, kValue, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, StringValue) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
static const char kValue[] = "123";
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString(kFlatKey);
arg.key = context_.storage->InternString(kKey);
arg.value = Variadic::String(context_.storage->InternString(kValue));
context_.storage->mutable_args()->AddArgSet({arg}, 0, 1);
PrepareValidStatement("SELECT * FROM args");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, base::nullopt, kValue, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, RealValue) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
static const double kValue = 0.123;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString(kFlatKey);
arg.key = context_.storage->InternString(kKey);
arg.value = Variadic::Real(kValue);
context_.storage->mutable_args()->AddArgSet({arg}, 0, 1);
PrepareValidStatement("SELECT * FROM args");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, base::nullopt, base::nullopt, kValue);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, BoolValueTreatedAsInt) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
static const bool kValue = true;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString(kFlatKey);
arg.key = context_.storage->InternString(kKey);
arg.value = Variadic::Boolean(kValue);
context_.storage->mutable_args()->AddArgSet({arg}, 0, 1);
// Boolean returned in the "int_value" column, and is comparable to an integer
// literal.
PrepareValidStatement("SELECT * FROM args WHERE int_value = 1");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, kValue, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, PointerValueTreatedAsInt) {
static const uint64_t kSmallValue = 1ull << 30;
static const uint64_t kTopBitSetValue = 1ull << 63;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString("flat_key_small");
arg.key = context_.storage->InternString("key_small");
arg.value = Variadic::Pointer(kSmallValue);
TraceStorage::Args::Arg arg2;
arg2.flat_key = context_.storage->InternString("flat_key_large");
arg2.key = context_.storage->InternString("key_large");
arg2.value = Variadic::Pointer(kTopBitSetValue);
context_.storage->mutable_args()->AddArgSet({arg, arg2}, 0, 2);
// Pointer returned in the "int_value" column, as a signed 64 bit. And is
// comparable to an integer literal.
static const int64_t kExpectedSmallValue = static_cast<int64_t>(kSmallValue);
PrepareValidStatement(std::string("SELECT * FROM args WHERE int_value = ") +
std::to_string(kExpectedSmallValue));
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, "flat_key_small", "key_small", kExpectedSmallValue,
base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
static const int64_t kExpectedTopBitSetValue =
static_cast<int64_t>(kTopBitSetValue); // negative
PrepareValidStatement(std::string("SELECT * FROM args WHERE int_value = ") +
std::to_string(kExpectedTopBitSetValue));
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, "flat_key_large", "key_large", kExpectedTopBitSetValue,
base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, UintValueTreatedAsInt) {
static const uint64_t kSmallValue = 1ull << 30;
static const uint64_t kTopBitSetValue = 1ull << 63;
TraceStorage::Args::Arg arg;
arg.flat_key = context_.storage->InternString("flat_key_small");
arg.key = context_.storage->InternString("key_small");
arg.value = Variadic::UnsignedInteger(kSmallValue);
TraceStorage::Args::Arg arg2;
arg2.flat_key = context_.storage->InternString("flat_key_large");
arg2.key = context_.storage->InternString("key_large");
arg2.value = Variadic::UnsignedInteger(kTopBitSetValue);
context_.storage->mutable_args()->AddArgSet({arg, arg2}, 0, 2);
// Unsigned returned in the "int_value" column, as a signed 64 bit. And is
// comparable to an integer literal.
static const int64_t kExpectedSmallValue = static_cast<int64_t>(kSmallValue);
PrepareValidStatement(std::string("SELECT * FROM args WHERE int_value = ") +
std::to_string(kExpectedSmallValue));
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, "flat_key_small", "key_small", kExpectedSmallValue,
base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
static const int64_t kExpectedTopBitSetValue =
static_cast<int64_t>(kTopBitSetValue); // negative
PrepareValidStatement(std::string("SELECT * FROM args WHERE int_value = ") +
std::to_string(kExpectedTopBitSetValue));
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, "flat_key_large", "key_large", kExpectedTopBitSetValue,
base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
TEST_F(ArgsTableUnittest, IntegerLikeValuesSortByIntRepresentation) {
static const char kFlatKey[] = "flat_key";
static const char kKey[] = "key";
TraceStorage::Args::Arg bool_arg_true;
bool_arg_true.flat_key = context_.storage->InternString(kFlatKey);
bool_arg_true.key = context_.storage->InternString(kKey);
bool_arg_true.value = Variadic::Boolean(true);
TraceStorage::Args::Arg bool_arg_false;
bool_arg_false.flat_key = context_.storage->InternString(kFlatKey);
bool_arg_false.key = context_.storage->InternString(kKey);
bool_arg_false.value = Variadic::Boolean(false);
TraceStorage::Args::Arg pointer_arg_42;
pointer_arg_42.flat_key = context_.storage->InternString(kFlatKey);
pointer_arg_42.key = context_.storage->InternString(kKey);
pointer_arg_42.value = Variadic::Pointer(42);
TraceStorage::Args::Arg unsigned_arg_10;
unsigned_arg_10.flat_key = context_.storage->InternString(kFlatKey);
unsigned_arg_10.key = context_.storage->InternString(kKey);
unsigned_arg_10.value = Variadic::UnsignedInteger(10);
// treated as null by the int_value column
TraceStorage::Args::Arg string_arg;
string_arg.flat_key = context_.storage->InternString(kFlatKey);
string_arg.key = context_.storage->InternString(kKey);
string_arg.value =
Variadic::String(context_.storage->InternString("string_content"));
context_.storage->mutable_args()->AddArgSet(
{bool_arg_true, bool_arg_false, pointer_arg_42, unsigned_arg_10,
string_arg},
0, 5);
// Ascending sort by int representations:
// { null (string), 0 (false), 1 (true), 10, 42 }
PrepareValidStatement("SELECT * FROM args ORDER BY int_value ASC");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, base::nullopt, "string_content",
base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 0, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 1, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 10, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 42, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
// Desceding order.
PrepareValidStatement("SELECT * FROM args ORDER BY int_value DESC");
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 42, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 10, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 1, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, 0, base::nullopt, base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_ROW);
AssertArgRowValues(1, kFlatKey, kKey, base::nullopt, "string_content",
base::nullopt);
ASSERT_EQ(sqlite3_step(*stmt_), SQLITE_DONE);
}
} // namespace
} // namespace trace_processor
} // namespace perfetto
| 39.025478
| 80
| 0.71952
|
zakerinasab
|
de6d301d3637b7189e571f714ed564941bae1ff9
| 127,143
|
cpp
|
C++
|
src/plugProjectKandoU/vsGameSection.cpp
|
projectPiki/pikmin2
|
a431d992acde856d092889a515ecca0e07a3ea7c
|
[
"Unlicense"
] | 33
|
2021-12-08T11:10:59.000Z
|
2022-03-26T19:59:37.000Z
|
src/plugProjectKandoU/vsGameSection.cpp
|
projectPiki/pikmin2
|
a431d992acde856d092889a515ecca0e07a3ea7c
|
[
"Unlicense"
] | 6
|
2021-12-22T17:54:31.000Z
|
2022-01-07T21:43:18.000Z
|
src/plugProjectKandoU/vsGameSection.cpp
|
projectPiki/pikmin2
|
a431d992acde856d092889a515ecca0e07a3ea7c
|
[
"Unlicense"
] | 2
|
2022-01-04T06:00:49.000Z
|
2022-01-26T07:27:28.000Z
|
#include "Game/VsGameSection.h"
#include "types.h"
/*
Generated from dpostproc
.section .ctors, "wa" # 0x80472F00 - 0x804732C0
.4byte __sinit_vsGameSection_cpp
.section .rodata # 0x804732E0 - 0x8049E220
.global lbl_8047FF98
lbl_8047FF98:
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x56734761
.4byte 0x6D655365
.4byte 0x6374696F
.4byte 0x6E000000
.4byte 0x50534761
.4byte 0x6D652E68
.4byte 0x00000000
.global lbl_8047FFC0
lbl_8047FFC0:
.asciz "P2Assert"
.skip 3
.4byte 0x50535363
.4byte 0x656E652E
.4byte 0x68000000
.global lbl_8047FFD8
lbl_8047FFD8:
.4byte 0x63617665
.4byte 0x696E666F
.4byte 0x2E747874
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.global lbl_8047FFF4
lbl_8047FFF4:
.4byte 0x76734761
.4byte 0x6D655365
.4byte 0x6374696F
.4byte 0x6E2E6370
.4byte 0x70000000
.global lbl_80480008
lbl_80480008:
.4byte 0x7A616E6E
.4byte 0x656E6E0A
.4byte 0x00000000
.global lbl_80480014
lbl_80480014:
.4byte 0x2F757365
.4byte 0x722F4D61
.4byte 0x746F6261
.4byte 0x2F636861
.4byte 0x6C6C656E
.4byte 0x67652F6B
.4byte 0x6665732D
.4byte 0x73746167
.4byte 0x65732E74
.4byte 0x78740000
.global lbl_8048003C
lbl_8048003C:
.4byte 0x2F757365
.4byte 0x722F4D61
.4byte 0x746F6261
.4byte 0x2F636861
.4byte 0x6C6C656E
.4byte 0x67652F73
.4byte 0x74616765
.4byte 0x732E7478
.4byte 0x74000000
.global lbl_80480060
lbl_80480060:
.4byte 0x2F757365
.4byte 0x722F6162
.4byte 0x652F7673
.4byte 0x2F737461
.4byte 0x6765732E
.4byte 0x74787400
.global lbl_80480078
lbl_80480078:
.4byte 0x6F702D63
.4byte 0x2D6D6F72
.4byte 0x65000000
.4byte 0x6D6F7265
.4byte 0x2D796573
.4byte 0x00000000
.4byte 0x6D6F7265
.4byte 0x2D7A656E
.4byte 0x6B616900
.4byte 0x7330435F
.4byte 0x63765F65
.4byte 0x73636170
.4byte 0x65000000
.global lbl_804800AC
lbl_804800AC:
.4byte 0x7330335F
.4byte 0x6F72696D
.4byte 0x61646F77
.4byte 0x6E000000
.global lbl_804800BC
lbl_804800BC:
.4byte 0x63726561
.4byte 0x74654661
.4byte 0x6C6C5069
.4byte 0x6B6D696E
.4byte 0x73000000
.global lbl_804800D0
lbl_804800D0:
.4byte 0x6E6F2073
.4byte 0x70616365
.4byte 0x20666F72
.4byte 0x206E6577
.4byte 0x2079656C
.4byte 0x6C6F770A
.4byte 0x00000000
.global lbl_804800EC
lbl_804800EC:
.4byte 0x6E6F2065
.4byte 0x6E747279
.4byte 0x20666F72
.4byte 0x2070656C
.4byte 0x6C65740A
.4byte 0x00000000
.4byte 0x62697274
.4byte 0x68206661
.4byte 0x696C6564
.4byte 0x20210A00
.4byte 0x6F6F7375
.4byte 0x67692025
.4byte 0x640A0000
.4byte 0x25642070
.4byte 0x6C617965
.4byte 0x7249440A
.4byte 0x00000000
.4byte 0x25642074
.4byte 0x79706549
.4byte 0x440A0000
.4byte 0x41726745
.4byte 0x6E656D79
.4byte 0x54797065
.4byte 0x00000000
.4byte 0x50696B69
.4byte 0x496E6974
.4byte 0x41726700
.4byte 0x50656C6C
.4byte 0x6574496E
.4byte 0x69744172
.4byte 0x67000000
.section .data, "wa" # 0x8049E220 - 0x804EFC20
.global lbl_804B60E8
lbl_804B60E8:
.4byte 0x00000000
.4byte 0x00000000
.4byte 0x00000000
.global __vt__Q24Game20GameMessageVsUseCard
__vt__Q24Game20GameMessageVsUseCard:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game20GameMessageVsUseCardFPQ24Game13VsGameSection
.global __vt__Q24Game20GameMessageVsGotCard
__vt__Q24Game20GameMessageVsGotCard:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game20GameMessageVsGotCardFPQ24Game13VsGameSection
.global __vt__Q24Game23GameMessageVsPikminDead
__vt__Q24Game23GameMessageVsPikminDead:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game23GameMessageVsPikminDeadFPQ24Game13VsGameSection
.global __vt__Q24Game30GameMessageVsBirthTekiTreasure
__vt__Q24Game30GameMessageVsBirthTekiTreasure:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte
actVs__Q24Game30GameMessageVsBirthTekiTreasureFPQ24Game13VsGameSection
.global __vt__Q24Game21GameMessagePelletDead
__vt__Q24Game21GameMessagePelletDead:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game21GameMessagePelletDeadFPQ24Game13VsGameSection
.global __vt__Q24Game21GameMessagePelletBorn
__vt__Q24Game21GameMessagePelletBorn:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game21GameMessagePelletBornFPQ24Game13VsGameSection
.global __vt__Q24Game21GameMessageVsAddEnemy
__vt__Q24Game21GameMessageVsAddEnemy:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game21GameMessageVsAddEnemyFPQ24Game13VsGameSection
.global __vt__Q24Game23GameMessageVsGetOtakara
__vt__Q24Game23GameMessageVsGetOtakara:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game23GameMessageVsGetOtakaraFPQ24Game13VsGameSection
.global __vt__Q24Game27GameMessageVsRedOrSuckStart
__vt__Q24Game27GameMessageVsRedOrSuckStart:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte
actVs__Q24Game27GameMessageVsRedOrSuckStartFPQ24Game13VsGameSection .global
__vt__Q24Game27GameMessageVsBattleFinished
__vt__Q24Game27GameMessageVsBattleFinished:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte
actVs__Q24Game27GameMessageVsBattleFinishedFPQ24Game13VsGameSection .global
__vt__Q24Game22GameMessageVsGetDoping
__vt__Q24Game22GameMessageVsGetDoping:
.4byte 0
.4byte 0
.4byte actCommon__Q24Game11GameMessageFPQ24Game15BaseGameSection
.4byte actSingle__Q24Game11GameMessageFPQ24Game17SingleGameSection
.4byte actVs__Q24Game22GameMessageVsGetDopingFPQ24Game13VsGameSection
.global "__vt__Q24Game36StateMachine<Q24Game13VsGameSection>"
"__vt__Q24Game36StateMachine<Q24Game13VsGameSection>":
.4byte 0
.4byte 0
.4byte
"init__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSection"
.4byte
"start__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSectioniPQ24Game8StateArg"
.4byte
"exec__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSection"
.4byte
"transit__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSectioniPQ24Game8StateArg"
.global __vt__Q24Game13VsGameSection
__vt__Q24Game13VsGameSection:
.4byte 0
.4byte 0
.4byte __dt__Q24Game13VsGameSectionFv
.4byte run__7SectionFv
.4byte update__7SectionFv
.4byte draw__7SectionFR8Graphics
.4byte init__Q24Game15BaseGameSectionFv
.4byte drawInit__7SectionFR8Graphics
.4byte
drawInit__Q24Game15BaseGameSectionFR8GraphicsQ27Section13EDrawInitMode .4byte
doExit__7SectionFv .4byte forceFinish__Q24Game15BaseGameSectionFv .4byte
forceReset__7SectionFv .4byte getCurrentSection__7SectionFv .4byte
doLoadingStart__7SectionFv .4byte doLoading__7SectionFv .4byte
doUpdate__Q24Game13VsGameSectionFv .4byte
doDraw__Q24Game13VsGameSectionFR8Graphics .4byte isFinishable__7SectionFv
.4byte initHIO__Q24Game14BaseHIOSectionFPQ24Game11HIORootNode
.4byte refreshHIO__Q24Game14BaseHIOSectionFv
.4byte sendMessage__Q24Game13VsGameSectionFRQ24Game11GameMessage
.4byte pre2dDraw__Q24Game13VsGameSectionFR8Graphics
.4byte getCurrFloor__Q24Game13VsGameSectionFv
.4byte isDevelopSection__Q24Game15BaseGameSectionFv
.4byte addChallengeScore__Q24Game13VsGameSectionFi
.4byte startMainBgm__Q24Game13VsGameSectionFv
.4byte section_fadeout__Q24Game13VsGameSectionFv
.4byte goNextFloor__Q24Game13VsGameSectionFPQ34Game8ItemHole4Item
.4byte goCave__Q24Game15BaseGameSectionFPQ34Game8ItemCave4Item
.4byte
goMainMap__Q24Game15BaseGameSectionFPQ34Game15ItemBigFountain4Item .4byte
getCaveID__Q24Game15BaseGameSectionFv .4byte
getCurrentCourseInfo__Q24Game15BaseGameSectionFv .4byte
challengeDisablePelplant__Q24Game13VsGameSectionFv .4byte
getCaveFilename__Q24Game13VsGameSectionFv .4byte
getEditorFilename__Q24Game13VsGameSectionFv .4byte
getVsEditNumber__Q24Game13VsGameSectionFv .4byte
openContainerWindow__Q24Game15BaseGameSectionFv .4byte
closeContainerWindow__Q24Game15BaseGameSectionFv .4byte
playMovie_firstexperience__Q24Game15BaseGameSectionFiPQ24Game8Creature .4byte
playMovie_bootup__Q24Game15BaseGameSectionFPQ24Game5Onyon .4byte
playMovie_helloPikmin__Q24Game15BaseGameSectionFPQ24Game4Piki .4byte
enableTimer__Q24Game15BaseGameSectionFfUl .4byte
disableTimer__Q24Game15BaseGameSectionFUl .4byte
getTimerType__Q24Game15BaseGameSectionFv .4byte
onMovieStart__Q24Game13VsGameSectionFPQ24Game11MovieConfigUlUl .4byte
onMovieDone__Q24Game13VsGameSectionFPQ24Game11MovieConfigUlUl .4byte
onMovieCommand__Q24Game15BaseGameSectionFi .4byte
startFadeout__Q24Game15BaseGameSectionFf .4byte
startFadein__Q24Game15BaseGameSectionFf .4byte
startFadeoutin__Q24Game15BaseGameSectionFf .4byte
startFadeblack__Q24Game15BaseGameSectionFv .4byte
startFadewhite__Q24Game15BaseGameSectionFv .4byte
gmOrimaDown__Q24Game13VsGameSectionFi .4byte
gmPikminZero__Q24Game13VsGameSectionFv .4byte
openCaveInMenu__Q24Game15BaseGameSectionFPQ34Game8ItemCave4Itemi .4byte
openCaveMoreMenu__Q24Game13VsGameSectionFPQ34Game8ItemHole4ItemP10Controller
.4byte
openKanketuMenu__Q24Game13VsGameSectionFPQ34Game15ItemBigFountain4ItemP10Controller
.4byte on_setCamController__Q24Game15BaseGameSectionFi
.4byte onTogglePlayer__Q24Game15BaseGameSectionFv
.4byte onPlayerJoin__Q24Game15BaseGameSectionFv
.4byte onInit__Q24Game13VsGameSectionFv
.4byte onUpdate__Q24Game15BaseGameSectionFv
.4byte initJ3D__Q24Game15BaseGameSectionFv
.4byte initViewports__Q24Game15BaseGameSectionFR8Graphics
.4byte initResources__Q24Game15BaseGameSectionFv
.4byte initGenerators__Q24Game15BaseGameSectionFv
.4byte initLights__Q24Game15BaseGameSectionFv
.4byte draw3D__Q24Game15BaseGameSectionFR8Graphics
.4byte draw2D__Q24Game15BaseGameSectionFR8Graphics
.4byte drawParticle__Q24Game15BaseGameSectionFR8Graphicsi
.4byte draw_Ogawa2D__Q24Game15BaseGameSectionFR8Graphics
.4byte do_drawOtakaraWindow__Q24Game15BaseGameSectionFR8Graphics
.4byte onSetupFloatMemory__Q24Game13VsGameSectionFv
.4byte postSetupFloatMemory__Q24Game13VsGameSectionFv
.4byte onSetSoundScene__Q24Game13VsGameSectionFv
.4byte onStartHeap__Q24Game15BaseGameSectionFv
.4byte onClearHeap__Q24Game13VsGameSectionFv
.4byte player2enabled__Q24Game13VsGameSectionFv
.global __vt__Q34Game6VsGame3FSM
__vt__Q34Game6VsGame3FSM:
.4byte 0
.4byte 0
.4byte init__Q34Game6VsGame3FSMFPQ24Game13VsGameSection
.4byte
"start__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSectioniPQ24Game8StateArg"
.4byte
"exec__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSection"
.4byte
transit__Q34Game6VsGame3FSMFPQ24Game13VsGameSectioniPQ24Game8StateArg
.section .sbss # 0x80514D80 - 0x80516360
.global lbl_80515A88
lbl_80515A88:
.skip 0x4
.global lbl_80515A8C
lbl_80515A8C:
.skip 0x4
.global mRedWinCount__Q24Game13VsGameSection
mRedWinCount__Q24Game13VsGameSection:
.skip 0x4
.global mBlueWinCount__Q24Game13VsGameSection
mBlueWinCount__Q24Game13VsGameSection:
.skip 0x4
.global mDrawCount__Q24Game13VsGameSection
mDrawCount__Q24Game13VsGameSection:
.skip 0x8
.section .sdata2, "a" # 0x80516360 - 0x80520E40
.global lbl_805194A8
lbl_805194A8:
.4byte 0x00000000
.global lbl_805194AC
lbl_805194AC:
.float 0.5
.global lbl_805194B0
lbl_805194B0:
.4byte 0x72616E64
.4byte 0x6F6D0000
.global lbl_805194B8
lbl_805194B8:
.float 1.0
.4byte 0x00000000
.global lbl_805194C0
lbl_805194C0:
.4byte 0x40490000
.4byte 0x00000000
.global lbl_805194C8
lbl_805194C8:
.4byte 0x43300000
.4byte 0x80000000
.global lbl_805194D0
lbl_805194D0:
.4byte 0x6F702D6B
.4byte 0x6B000000
.global lbl_805194D8
lbl_805194D8:
.4byte 0x6D6F7265
.4byte 0x2D6E6F00
.global lbl_805194E0
lbl_805194E0:
.4byte 0x6B6B2D79
.4byte 0x65730000
.global lbl_805194E8
lbl_805194E8:
.4byte 0x6B6B2D6E
.4byte 0x6F000000
.global lbl_805194F0
lbl_805194F0:
.4byte 0x47000000
.global lbl_805194F4
lbl_805194F4:
.4byte 0x41700000
.global lbl_805194F8
lbl_805194F8:
.4byte 0x41F00000
.global lbl_805194FC
lbl_805194FC:
.4byte 0x40C90FDB
.global lbl_80519500
lbl_80519500:
.4byte 0x44408000
.global lbl_80519504
lbl_80519504:
.4byte 0x44548000
.global lbl_80519508
lbl_80519508:
.4byte 0x42F00000
.global lbl_8051950C
lbl_8051950C:
.4byte 0x43A2F983
.global lbl_80519510
lbl_80519510:
.4byte 0xC3A2F983
.global lbl_80519514
lbl_80519514:
.4byte 0x4528C000
.global lbl_80519518
lbl_80519518:
.4byte 0x43160000
.global lbl_8051951C
lbl_8051951C:
.4byte 0x41200000
.global lbl_80519520
lbl_80519520:
.4byte 0x41A00000
.global lbl_80519524
lbl_80519524:
.4byte 0x3E4CCCCD
.global lbl_80519528
lbl_80519528:
.4byte 0x3F4CCCCD
.global lbl_8051952C
lbl_8051952C:
.float 0.1
.global lbl_80519530
lbl_80519530:
.4byte 0xBDCCCCCD
.global lbl_80519534
lbl_80519534:
.4byte 0xBF000000
.global lbl_80519538
lbl_80519538:
.4byte 0xBF4CCCCD
.global lbl_8051953C
lbl_8051953C:
.4byte 0x3D50E560
.global lbl_80519540
lbl_80519540:
.4byte 0x3C23D70A
.global lbl_80519544
lbl_80519544:
.4byte 0x41C80000
.global lbl_80519548
lbl_80519548:
.4byte 0x3ECCCCCD
.global lbl_8051954C
lbl_8051954C:
.4byte 0x3F19999A
.global lbl_80519550
lbl_80519550:
.float 0.3
.global lbl_80519554
lbl_80519554:
.4byte 0x3F0CCCCD
.global lbl_80519558
lbl_80519558:
.4byte 0x3F666666
.global lbl_8051955C
lbl_8051955C:
.4byte 0x40000000
.global lbl_80519560
lbl_80519560:
.4byte 0x40400000
.4byte 0x00000000
.global lbl_80519568
lbl_80519568:
.4byte 0x43300000
.4byte 0x00000000
.global lbl_80519570
lbl_80519570:
.4byte 0x430C0000
.global lbl_80519574
lbl_80519574:
.4byte 0xC1200000
.global lbl_80519578
lbl_80519578:
.4byte 0xBF800000
.global lbl_8051957C
lbl_8051957C:
.4byte 0x40800000
.global lbl_80519580
lbl_80519580:
.float 0.25
.4byte 0x00000000
.section .sbss2, "", @nobits # 0x80520e40 - 0x80520ED8
.global lbl_80520E68
lbl_80520E68:
.skip 0x4
.global lbl_80520E6C
lbl_80520E6C:
.skip 0x4
.global lbl_80520E70
lbl_80520E70:
.skip 0x4
.global lbl_80520E74
lbl_80520E74:
.skip 0x4
.global lbl_80520E78
lbl_80520E78:
.skip 0x4
.global lbl_80520E7C
lbl_80520E7C:
.skip 0x4
*/
namespace Game {
/*
* --INFO--
* Address: 801C0DF8
* Size: 0000D0
*/
void VsGame::FSM::init(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
li r4, 5
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r3
bl "create__Q24Game36StateMachine<Q24Game13VsGameSection>Fi"
li r3, 0x44
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0E2C
bl __ct__Q34Game6VsGame10TitleStateFv
mr r4, r3
lbl_801C0E2C:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
li r3, 0xa4
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0E4C
bl __ct__Q34Game6VsGame9LoadStateFv
mr r4, r3
lbl_801C0E4C:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
li r3, 0x28
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0E6C
bl __ct__Q34Game6VsGame9GameStateFv
mr r4, r3
lbl_801C0E6C:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
li r3, 0x28
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0E8C
bl __ct__Q34Game6VsGame7VSStateFv
mr r4, r3
lbl_801C0E8C:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
li r3, 0x3c
bl __nw__FUl
or. r4, r3, r3
beq lbl_801C0EAC
bl __ct__Q34Game6VsGame11ResultStateFv
mr r4, r3
lbl_801C0EAC:
mr r3, r31
bl
"registerState__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game32FSMState<Q24Game13VsGameSection>"
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: ........
* Size: 000038
*/
void VsGame::FSM::draw(Game::VsGameSection*, Graphics&)
{
// UNUSED FUNCTION
}
/*
* --INFO--
* Address: 801C0EC8
* Size: 000004
*/
void VsGame::State::draw(Game::VsGameSection*, Graphics&) { }
/*
* --INFO--
* Address: 801C0ECC
* Size: 000020
*/
void VsGame::FSM::transit(Game::VsGameSection*, int, Game::StateArg*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
bl
"transit__Q24Game36StateMachine<Q24Game13VsGameSection>FPQ24Game13VsGameSectioniPQ24Game8StateArg"
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C0EEC
* Size: 0000FC
*/
VsGameSection::VsGameSection(JKRHeap*, bool)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r5
stw r30, 8(r1)
mr r30, r3
bl __ct__Q24Game15BaseGameSectionFP7JKRHeap
lis r4, __vt__Q24Game13VsGameSection@ha
addi r3, r30, 0x184
addi r0, r4, __vt__Q24Game13VsGameSection@l
stw r0, 0(r30)
bl __ct__16DvdThreadCommandFv
li r0, 0
addi r3, r30, 0x214
stb r0, 0x1f8(r30)
bl __ct__Q24Game13PikiContainerFv
addi r3, r30, 0x21c
bl __ct__Q24Game13PikiContainerFv
stb r31, 0x174(r30)
li r0, 1
lis r3, gGameConfig__4Game@ha
li r6, 0
stb r0, 0x205(r30)
li r5, -1
li r4, 2
li r0, -2
stw r6, 0x338(r30)
addi r3, r3, gGameConfig__4Game@l
stw r6, 0x340(r30)
stw r5, 0x34c(r30)
stw r4, 0x348(r30)
stw r4, 0x344(r30)
stw r6, 0x3d8(r30)
stw r6, 0x3d4(r30)
stw r6, 0x3e0(r30)
stw r6, 0x3dc(r30)
stw r0, 0x328(r30)
stw r6, 0x178(r30)
lwz r0, 0x278(r3)
cmpwi r0, 0
ble lbl_801C0FCC
slwi r31, r0, 0xa
li r3, 0x1c
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C0FB4
mr r4, r31
bl __ct__6VSFifoFUl
mr r0, r3
lbl_801C0FB4:
stw r0, 0x178(r30)
lwz r3, 0x178(r30)
bl becomeCurrent__6VSFifoFv
lwz r3, 0x178(r30)
lwz r3, 4(r3)
bl GXSetGPFifo
lbl_801C0FCC:
lwz r0, 0x14(r1)
mr r3, r30
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C0FE8
* Size: 0000CC
*/
VsGameSection::~VsGameSection(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
or. r30, r3, r3
beq lbl_801C1098
lis r3, __vt__Q24Game13VsGameSection@ha
addi r0, r3, __vt__Q24Game13VsGameSection@l
stw r0, 0(r30)
lwz r3, 0x178(r30)
cmplwi r3, 0
beq lbl_801C1064
lwz r3, 4(r3)
bl GXSaveCPUFifo
lbl_801C1028:
bl isGPActive__6VSFifoFv
clrlwi. r0, r3, 0x18
bne lbl_801C1028
bl GXDrawDone
lwz r3, sCurrentFifo__12JUTGraphFifo@sda21(r13)
lwz r4, 8(r3)
lwz r3, 4(r3)
mr r5, r4
bl GXInitFifoPtrs
lwz r3, sCurrentFifo__12JUTGraphFifo@sda21(r13)
lwz r3, 4(r3)
bl GXSetCPUFifo
lwz r3, sCurrentFifo__12JUTGraphFifo@sda21(r13)
lwz r3, 4(r3)
bl GXSetGPFifo
lbl_801C1064:
addic. r0, r30, 0x184
beq lbl_801C107C
addic. r3, r30, 0x1e0
beq lbl_801C107C
li r4, 0
bl __dt__10JSUPtrLinkFv
lbl_801C107C:
mr r3, r30
li r4, 0
bl __dt__Q24Game15BaseGameSectionFv
extsh. r0, r31
ble lbl_801C1098
mr r3, r30
bl __dl__FPv
lbl_801C1098:
lwz r0, 0x14(r1)
mr r3, r30
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
} // namespace Game
/*
* --INFO--
* Address: 801C10B4
* Size: 00005C
*/
void VSFifo::isGPActive()
{
/*
stwu r1, -0x10(r1)
mflr r0
addi r4, r13, mGpStatus__6VSFifo@sda21
addi r6, r13, mGpStatus__6VSFifo@sda21
stw r0, 0x14(r1)
addi r7, r13, mGpStatus__6VSFifo@sda21
addi r3, r13, mGpStatus__6VSFifo@sda21
addi r4, r4, 1
stw r31, 0xc(r1)
addi r31, r13, mGpStatus__6VSFifo@sda21
addi r31, r31, 2
addi r6, r6, 3
mr r5, r31
addi r7, r7, 4
bl GXGetGPStatus
lbz r0, 0(r31)
lwz r31, 0xc(r1)
cntlzw r0, r0
srwi r3, r0, 5
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
namespace Game {
/*
* --INFO--
* Address: 801C1110
* Size: 000034
*/
void VsGameSection::section_fadeout(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r4, r3
stw r0, 0x14(r1)
lwz r3, 0x180(r3)
lwz r12, 0(r3)
lwz r12, 0x38(r12)
mtctr r12
bctrl
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1144
* Size: 000004
*/
void VsGame::State::on_section_fadeout(Game::VsGameSection*) { }
/*
* --INFO--
* Address: 801C1148
* Size: 000090
*/
void VsGameSection::startMainBgm(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
lis r3, lbl_8047FF98@ha
stw r0, 0x14(r1)
stw r31, 0xc(r1)
addi r31, r3, lbl_8047FF98@l
stw r30, 8(r1)
lwz r0, spSceneMgr__8PSSystem@sda21(r13)
cmplwi r0, 0
bne lbl_801C1184
addi r3, r31, 0x1c
addi r5, r31, 0x28
li r4, 0x1d3
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C1184:
lwz r30, spSceneMgr__8PSSystem@sda21(r13)
lwz r0, 4(r30)
cmplwi r0, 0
bne lbl_801C11A8
addi r3, r31, 0x34
addi r5, r31, 0x28
li r4, 0xc7
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C11A8:
lwz r3, 4(r30)
lwz r3, 4(r3)
lwz r12, 0(r3)
lwz r12, 0x1c(r12)
mtctr r12
bctrl
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C11D8
* Size: 00020C
*/
void VsGameSection::onInit(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
lfs f1, lbl_805194A8@sda21(r2)
stw r0, 0x14(r1)
lfs f0, lbl_805194AC@sda21(r2)
stw r31, 0xc(r1)
mr r31, r3
stfs f1, 0x350(r3)
stfs f0, 0x354(r3)
stfs f1, 0x1f4(r3)
stfs f1, 0x1f0(r3)
bl clearGetDopeCount__Q24Game13VsGameSectionFv
mr r3, r31
bl clearGetCherryCount__Q24Game13VsGameSectionFv
lbz r0, 0x174(r31)
cmplwi r0, 0
beq lbl_801C122C
lwz r3, gameSystem__4Game@sda21(r13)
li r0, 1
stw r0, 0x44(r3)
b lbl_801C1238
lbl_801C122C:
lwz r3, gameSystem__4Game@sda21(r13)
li r0, 2
stw r0, 0x44(r3)
lbl_801C1238:
lwz r4, gameSystem__4Game@sda21(r13)
li r5, 1
li r0, 0
lis r3, lbl_8047FFD8@ha
stb r5, 0x48(r4)
addi r4, r3, lbl_8047FFD8@l
addi r3, r31, 0x224
stb r0, 0x11c(r31)
stw r0, 0x1fc(r31)
stw r0, 0x3bc(r31)
stb r0, 0x204(r31)
crclr 6
bl sprintf
addi r3, r31, 0x2a4
addi r4, r2, lbl_805194B0@sda21
crclr 6
bl sprintf
mr r3, r31
bl setupFixMemory__Q24Game15BaseGameSectionFv
li r3, 0x94
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C129C
bl __ct__Q34Game13ChallengeGame9StageListFv
mr r0, r3
lbl_801C129C:
stw r0, 0x20c(r31)
mr r3, r31
lwz r4, 0x20c(r31)
bl addGenNode__Q24Game14BaseHIOSectionFP5CNode
li r3, 0xcc
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C12C4
bl __ct__Q34Game6VsGame9StageListFv
mr r0, r3
lbl_801C12C4:
stw r0, 0x210(r31)
mr r3, r31
lwz r4, 0x210(r31)
bl addGenNode__Q24Game14BaseHIOSectionFP5CNode
mr r3, r31
bl loadChallengeStageList__Q24Game13VsGameSectionFv
mr r3, r31
bl loadVsStageList__Q24Game13VsGameSectionFv
li r3, 0x1c
bl __nw__FUl
cmplwi r3, 0
beq lbl_801C1314
lis r5, "__vt__Q24Game36StateMachine<Q24Game13VsGameSection>"@ha
lis r4, __vt__Q34Game6VsGame3FSM@ha
addi r0, r5, "__vt__Q24Game36StateMachine<Q24Game13VsGameSection>"@l
li r5, -1
stw r0, 0(r3)
addi r0, r4, __vt__Q34Game6VsGame3FSM@l
stw r5, 0x18(r3)
stw r0, 0(r3)
lbl_801C1314:
stw r3, 0x17c(r31)
mr r4, r31
lwz r3, 0x17c(r31)
lwz r12, 0(r3)
lwz r12, 8(r12)
mtctr r12
bctrl
mr r3, r31
bl initPlayData__Q24Game13VsGameSectionFv
lwz r3, 0x17c(r31)
mr r4, r31
li r5, 0
li r6, 0
lwz r12, 0(r3)
lwz r12, 0xc(r12)
mtctr r12
bctrl
li r0, 0
lfs f0, lbl_805194A8@sda21(r2)
stw r0, 0x324(r31)
li r3, 0x5c
stfs f0, 0x35c(r31)
stfs f0, 0x358(r31)
stfs f0, 0x374(r31)
stfs f0, 0x370(r31)
stfs f0, 0x364(r31)
stfs f0, 0x360(r31)
stfs f0, 0x36c(r31)
stfs f0, 0x368(r31)
stfs f0, 0x37c(r31)
stfs f0, 0x378(r31)
stw r0, 0x384(r31)
stw r0, 0x380(r31)
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C13AC
bl __ct__Q25Radar3MgrFv
mr r0, r3
lbl_801C13AC:
stw r0, mgr__5Radar@sda21(r13)
li r0, 0
stw r0, 0x388(r31)
stw r0, 0x38c(r31)
stw r0, 0x390(r31)
stw r0, 0x394(r31)
stw r0, 0x398(r31)
stw r0, 0x39c(r31)
stw r0, 0x3a0(r31)
lwz r31, 0xc(r1)
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C13E4
* Size: 000034
*/
void start__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game13VsGameSectioniPQ24Game8StateArg(void)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
li r0, 0
stw r0, 0x180(r4)
lwz r12, 0x0(r3)
lwz r12, 0x14(r12)
mtctr r12
bctrl
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1418
* Size: 000008
*/
void VsGameSection::getCurrFloor(void)
{
/*
lwz r3, 0x324(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C1420
* Size: 0001B8
*/
void VsGameSection::doUpdate(void)
{
/*
stwu r1, -0x40(r1)
mflr r0
stw r0, 0x44(r1)
stfd f31, 0x30(r1)
psq_st f31, 56(r1), 0, qr0
stw r31, 0x2c(r1)
stw r30, 0x28(r1)
stw r29, 0x24(r1)
mr r29, r3
lbz r0, 0x204(r3)
cmplwi r0, 0
beq lbl_801C1460
li r0, 0
li r3, 0
stb r0, 0x34(r29)
b lbl_801C15B4
lbl_801C1460:
lwz r3, 0x17c(r29)
mr r4, r29
lwz r12, 0(r3)
lwz r12, 0x10(r12)
mtctr r12
bctrl
lwz r3, gameSystem__4Game@sda21(r13)
lwz r0, 0x44(r3)
cmpwi r0, 1
bne lbl_801C15B0
li r3, 1
bl getMapPikmins__Q24Game8GameStatFi
lwz r4, 0x344(r29)
addi r0, r4, -3
subf r31, r0, r3
li r3, 0
bl getMapPikmins__Q24Game8GameStatFi
lwz r4, 0x348(r29)
cmpwi r31, 0
addi r0, r4, -3
subf r30, r0, r3
bge lbl_801C14BC
li r31, 1
lbl_801C14BC:
cmpwi r30, 0
bge lbl_801C14C8
li r30, 1
lbl_801C14C8:
cmpwi r31, 0
beq lbl_801C14D8
cmpwi r30, 0
bne lbl_801C1500
lbl_801C14D8:
cmpwi r31, 0
bne lbl_801C14EC
lfs f0, lbl_805194B8@sda21(r2)
stfs f0, 0x354(r29)
b lbl_801C15B0
lbl_801C14EC:
cmpwi r30, 0
bne lbl_801C15B0
lfs f0, lbl_805194A8@sda21(r2)
stfs f0, 0x354(r29)
b lbl_801C15B0
lbl_801C1500:
cmpw r30, r31
ble lbl_801C1544
lis r3, 0x4330
xoris r4, r30, 0x8000
xoris r0, r31, 0x8000
stw r4, 0xc(r1)
lfd f2, lbl_805194C8@sda21(r2)
stw r3, 8(r1)
lfd f0, 8(r1)
stw r0, 0x14(r1)
fsubs f1, f0, f2
stw r3, 0x10(r1)
lfd f0, 0x10(r1)
fsubs f0, f0, f2
fdivs f0, f1, f0
stfs f0, 0x350(r29)
b lbl_801C157C
lbl_801C1544:
lis r3, 0x4330
xoris r4, r31, 0x8000
xoris r0, r30, 0x8000
stw r4, 0x14(r1)
lfd f2, lbl_805194C8@sda21(r2)
stw r3, 0x10(r1)
lfd f0, 0x10(r1)
stw r0, 0xc(r1)
fsubs f1, f0, f2
stw r3, 8(r1)
lfd f0, 8(r1)
fsubs f0, f0, f2
fdivs f0, f1, f0
stfs f0, 0x350(r29)
lbl_801C157C:
lfd f1, lbl_805194C0@sda21(r2)
bl log10
frsp f31, f1
lfs f1, 0x350(r29)
bl log10
frsp f0, f1
cmpw r31, r30
fdivs f0, f0, f31
stfs f0, 0x354(r29)
bge lbl_801C15B0
lfs f0, 0x354(r29)
fneg f0, f0
stfs f0, 0x354(r29)
lbl_801C15B0:
lbz r3, 0x34(r29)
lbl_801C15B4:
psq_l f31, 56(r1), 0, qr0
lwz r0, 0x44(r1)
lfd f31, 0x30(r1)
lwz r31, 0x2c(r1)
lwz r30, 0x28(r1)
lwz r29, 0x24(r1)
mtlr r0
addi r1, r1, 0x40
blr
*/
}
/*
* --INFO--
* Address: 801C15D8
* Size: 00003C
*/
void VsGameSection::pre2dDraw(Graphics&)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r5, r3
stw r0, 0x14(r1)
lwz r3, 0x180(r3)
cmplwi r3, 0
beq lbl_801C1604
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lbl_801C1604:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1614
* Size: 000004
*/
void VsGame::State::pre2dDraw(Graphics&, Game::VsGameSection*) { }
/*
* --INFO--
* Address: 801C1618
* Size: 000050
*/
void VsGameSection::doDraw(Graphics&)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r6, r3
mr r5, r4
stw r0, 0x14(r1)
lbz r0, 0x204(r3)
cmplwi r0, 0
bne lbl_801C1658
lwz r3, 0x180(r6)
cmplwi r3, 0
beq lbl_801C1658
lwz r12, 0(r3)
mr r4, r6
lwz r12, 0x20(r12)
mtctr r12
bctrl
lbl_801C1658:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1668
* Size: 0001DC
*/
void VsGameSection::onSetSoundScene(void)
{
/*
stwu r1, -0x60(r1)
mflr r0
lis r4, lbl_8047FF98@ha
stw r0, 0x64(r1)
stw r31, 0x5c(r1)
addi r31, r4, lbl_8047FF98@l
stw r30, 0x58(r1)
mr r30, r3
addi r3, r1, 8
bl __ct__Q26PSGame9SceneInfoFv
lis r5, __vt__Q26PSGame13CaveFloorInfo@ha
lis r3, 0x0000FFFF@ha
li r4, 0
li r0, 0xff
addi r5, r5, __vt__Q26PSGame13CaveFloorInfo@l
addi r3, r3, 0x0000FFFF@l
stw r5, 8(r1)
lwz r5, gameSystem__4Game@sda21(r13)
stw r4, 0x40(r1)
stw r4, 0x44(r1)
stb r4, 0x48(r1)
stw r3, 0x4c(r1)
stb r0, 0x50(r1)
stb r0, 0x51(r1)
lwz r0, 0x44(r5)
cmpwi r0, 2
beq lbl_801C16DC
cmpwi r0, 3
bne lbl_801C16E0
lbl_801C16DC:
li r4, 1
lbl_801C16E0:
clrlwi. r0, r4, 0x18
beq lbl_801C1714
li r0, 6
mr r3, r30
stb r0, 0xe(r1)
lwz r12, 0(r30)
lwz r12, 0x58(r12)
mtctr r12
bctrl
stb r3, 0x48(r1)
lwz r0, 0x338(r30)
stb r0, 0x51(r1)
b lbl_801C1724
lbl_801C1714:
li r0, 7
stb r0, 0xe(r1)
lwz r0, 0x340(r30)
stb r0, 0x48(r1)
lbl_801C1724:
lwz r4, mapMgr__4Game@sda21(r13)
li r3, 0
lwz r5, gameSystem__4Game@sda21(r13)
lwz r4, 0x2c(r4)
lwz r0, 0x22c(r4)
stw r0, 0x40(r1)
stw r3, 0x44(r1)
lwz r0, 0x44(r5)
cmpwi r0, 1
beq lbl_801C1754
cmpwi r0, 3
bne lbl_801C1758
lbl_801C1754:
li r3, 1
lbl_801C1758:
clrlwi. r0, r3, 0x18
bne lbl_801C1774
addi r3, r1, 8
li r4, 0
li r5, 1
bl
setStageFlag__Q26PSGame9SceneInfoFQ36PSGame9SceneInfo7FlagDefQ36PSGame9SceneInfo12FlagBitShift
b lbl_801C1784
lbl_801C1774:
addi r3, r1, 8
li r4, 1
li r5, 1
bl
setStageFlag__Q26PSGame9SceneInfoFQ36PSGame9SceneInfo7FlagDefQ36PSGame9SceneInfo12FlagBitShift
lbl_801C1784:
mr r3, r30
addi r4, r1, 8
bl setDefaultPSSceneInfo__Q24Game15BaseGameSectionFRQ26PSGame9SceneInfo lwz
r0, spSceneMgr__8PSSystem@sda21(r13) cmplwi r0, 0 bne lbl_801C17B0 addi
r3, r31, 0x1c addi r5, r31, 0x28 li r4, 0x1d3 crclr 6 bl
panic_f__12JUTExceptionFPCciPCce
lbl_801C17B0:
lwz r3, spSceneMgr__8PSSystem@sda21(r13)
addi r4, r1, 8
lwz r12, 0(r3)
lwz r12, 0xc(r12)
mtctr r12
bctrl
lwz r0, spSceneMgr__8PSSystem@sda21(r13)
cmplwi r0, 0
bne lbl_801C17E8
addi r3, r31, 0x1c
addi r5, r31, 0x28
li r4, 0x1d3
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C17E8:
lwz r30, spSceneMgr__8PSSystem@sda21(r13)
lwz r0, 4(r30)
cmplwi r0, 0
bne lbl_801C180C
addi r3, r31, 0x34
addi r5, r31, 0x28
li r4, 0xc7
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C180C:
lwz r3, 4(r30)
lwz r3, 4(r3)
lwz r12, 0(r3)
lwz r12, 0x14(r12)
mtctr r12
bctrl
lwz r3, naviMgr__4Game@sda21(r13)
bl createPSMDirectorUpdator__Q24Game7NaviMgrFv
lwz r0, 0x64(r1)
lwz r31, 0x5c(r1)
lwz r30, 0x58(r1)
mtlr r0
addi r1, r1, 0x60
blr
*/
}
/*
* --INFO--
* Address: 801C1844
* Size: 00005C
*/
void VsGameSection::initPlayData(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r3, playData__4Game@sda21(r13)
bl reset__Q24Game8PlayDataFv
lwz r3, playData__4Game@sda21(r13)
li r4, 1
li r5, 1
bl setDevelopSetting__Q24Game8PlayDataFbb
lwz r4, naviMgr__4Game@sda21(r13)
lwz r3, playData__4Game@sda21(r13)
lwz r4, 0xc8(r4)
lfs f0, 0x9d0(r4)
stfs f0, 0x24(r3)
lwz r4, naviMgr__4Game@sda21(r13)
lwz r3, playData__4Game@sda21(r13)
lwz r4, 0xc8(r4)
lfs f0, 0x9d0(r4)
stfs f0, 0x28(r3)
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C18A0
* Size: 000168
*/
void VsGameSection::onSetupFloatMemory(void)
{
/*
stwu r1, -0x60(r1)
mflr r0
lis r4, lbl_8047FF98@ha
stw r0, 0x64(r1)
li r0, 0
stmw r26, 0x48(r1)
mr r26, r3
addi r31, r4, lbl_8047FF98@l
li r3, 0x28
stw r0, farmMgr__Q24Game4Farm@sda21(r13)
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C18DC
bl __ct__Q34Game6VsGame7TekiMgrFv
mr r0, r3
lbl_801C18DC:
stw r0, 0x32c(r26)
li r3, 0x114
bl __nw__FUl
or. r0, r3, r3
beq lbl_801C1900
lwz r5, 0x32c(r26)
mr r4, r26
bl
__ct__Q34Game6VsGame7CardMgrFPQ24Game13VsGameSectionPQ34Game6VsGame7TekiMgr mr
r0, r3
lbl_801C1900:
stw r0, 0x330(r26)
lwz r3, 0x330(r26)
bl loadResource__Q34Game6VsGame7CardMgrFv
lwz r6, 0x50(r31)
lis r4, __vt__Q24Game15CreatureInitArg@ha
lwz r5, 0x54(r31)
lis r3, __vt__Q24Game13PelletInitArg@ha
lwz r0, 0x58(r31)
addi r30, r1, 0xc
stw r6, 0xc(r1)
addi r27, r4, __vt__Q24Game15CreatureInitArg@l
lwz r4, cBedamaRed__13VsOtakaraName@sda21(r13)
addi r28, r3, __vt__Q24Game13PelletInitArg@l
stw r5, 0x10(r1)
li r26, 0
lwz r3, cBedamaBlue__13VsOtakaraName@sda21(r13)
stw r0, 0x14(r1)
lwz r0, cBedamaYellow__13VsOtakaraName@sda21(r13)
stw r4, 0xc(r1)
stw r3, 0x10(r1)
stw r0, 0x14(r1)
lbl_801C1954:
stw r27, 0x18(r1)
li r7, 0
li r0, -1
li r6, 0xff
li r5, 1
stw r28, 0x18(r1)
lwz r3, 0(r30)
addi r4, r1, 8
stb r7, 0x34(r1)
sth r7, 0x2c(r1)
stb r6, 0x2e(r1)
stw r7, 0x30(r1)
stb r7, 0x2f(r1)
stb r5, 0x1c(r1)
stb r7, 0x35(r1)
stw r0, 0x3c(r1)
stw r0, 0x38(r1)
stb r7, 0x36(r1)
stb r7, 0x37(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r29, r3, r3
bne lbl_801C19C0
addi r3, r31, 0x5c
addi r5, r31, 0x70
li r4, 0x388
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C19C0:
lha r3, 0x258(r29)
addi r4, r1, 0x18
lwz r0, 8(r1)
stw r3, 0x28(r1)
lwz r3, pelletMgr__4Game@sda21(r13)
lwz r5, 0x40(r29)
stw r5, 0x20(r1)
stb r0, 0x2e(r1)
bl setUse__Q24Game9PelletMgrFPQ24Game13PelletInitArg
addi r26, r26, 1
addi r30, r30, 4
cmpwi r26, 3
blt lbl_801C1954
lmw r26, 0x48(r1)
lwz r0, 0x64(r1)
mtlr r0
addi r1, r1, 0x60
blr
*/
}
/*
* --INFO--
* Address: 801C1A08
* Size: 0000A0
*/
void VsGameSection::postSetupFloatMemory(void)
{
/*
stwu r1, -0x20(r1)
mflr r0
stw r0, 0x24(r1)
stw r31, 0x1c(r1)
mr r31, r3
lwz r4, gameSystem__4Game@sda21(r13)
lwz r0, 0x44(r4)
cmpwi r0, 1
bne lbl_801C1A8C
lfs f0, lbl_805194A8@sda21(r2)
li r0, 0
addi r4, r1, 8
stfs f0, 0x35c(r31)
stfs f0, 0x358(r31)
stw r0, 0x384(r31)
stw r0, 0x380(r31)
stfs f0, 8(r1)
stfs f0, 0xc(r1)
stfs f0, 0x10(r1)
bl "createRedBlueBedamas__Q24Game13VsGameSectionFR10Vector3<f>"
li r0, 0
mr r3, r31
stw r0, 0x388(r31)
li r4, 7
stw r0, 0x38c(r31)
stw r0, 0x390(r31)
stw r0, 0x394(r31)
stw r0, 0x398(r31)
stw r0, 0x39c(r31)
stw r0, 0x3a0(r31)
bl createYellowBedamas__Q24Game13VsGameSectionFi
mr r3, r31
bl initCardPellets__Q24Game13VsGameSectionFv
lbl_801C1A8C:
mr r3, r31
bl postSetupFloatMemory__Q24Game15BaseGameSectionFv
lwz r0, 0x24(r1)
lwz r31, 0x1c(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 801C1AA8
* Size: 000020
*/
void VsGameSection::onClearHeap(void)
{
/*
lwz r4, gameSystem__4Game@sda21(r13)
lwz r0, 0x44(r4)
cmpwi r0, 1
bnelr
li r0, 0
stw r0, 0x3d0(r3)
stw r0, 0x3cc(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C1AC8
* Size: 0000B0
*/
void VsGameSection::loadChallengeStageList(void)
{
/*
stwu r1, -0x440(r1)
mflr r0
lis r4, gGameConfig__4Game@ha
stw r0, 0x444(r1)
addi r5, r4, gGameConfig__4Game@l
li r0, 0
lis r4, lbl_8048003C@ha
stw r31, 0x43c(r1)
mr r31, r3
addi r3, r4, lbl_8048003C@l
stw r0, 8(r1)
lwz r0, 0x228(r5)
cmpwi r0, 0
beq lbl_801C1B08
lis r3, lbl_80480014@ha
addi r3, r3, lbl_80480014@l
lbl_801C1B08:
li r4, 0
li r5, 0
li r6, 0
li r7, 0
li r8, 2
li r9, 0
li r10, 0
bl
loadToMainRAM__12JKRDvdRipperFPCcPUc15JKRExpandSwitchUlP7JKRHeapQ212JKRDvdRipper15EAllocDirectionUlPiPUl
cmplwi r3, 0
beq lbl_801C1B64
mr r4, r3
addi r3, r1, 0x10
li r5, -1
bl __ct__9RamStreamFPvi
li r0, 1
cmpwi r0, 1
stw r0, 0x1c(r1)
bne lbl_801C1B58
li r0, 0
stw r0, 0x424(r1)
lbl_801C1B58:
lwz r3, 0x20c(r31)
addi r4, r1, 0x10
bl read__Q34Game13ChallengeGame9StageListFR6Stream
lbl_801C1B64:
lwz r0, 0x444(r1)
lwz r31, 0x43c(r1)
mtlr r0
addi r1, r1, 0x440
blr
*/
}
/*
* --INFO--
* Address: 801C1B78
* Size: 000098
*/
void VsGameSection::loadVsStageList(void)
{
/*
stwu r1, -0x440(r1)
mflr r0
lis r4, lbl_80480060@ha
li r5, 0
stw r0, 0x444(r1)
li r0, 0
li r6, 0
li r7, 0
stw r31, 0x43c(r1)
mr r31, r3
li r8, 2
li r9, 0
stw r0, 8(r1)
addi r0, r4, lbl_80480060@l
li r4, 0
li r10, 0
mr r3, r0
bl
loadToMainRAM__12JKRDvdRipperFPCcPUc15JKRExpandSwitchUlP7JKRHeapQ212JKRDvdRipper15EAllocDirectionUlPiPUl
cmplwi r3, 0
beq lbl_801C1BFC
mr r4, r3
addi r3, r1, 0x10
li r5, -1
bl __ct__9RamStreamFPvi
li r0, 1
cmpwi r0, 1
stw r0, 0x1c(r1)
bne lbl_801C1BF0
li r0, 0
stw r0, 0x424(r1)
lbl_801C1BF0:
lwz r3, 0x210(r31)
addi r4, r1, 0x10
bl read__Q34Game6VsGame9StageListFR6Stream
lbl_801C1BFC:
lwz r0, 0x444(r1)
lwz r31, 0x43c(r1)
mtlr r0
addi r1, r1, 0x440
blr
*/
}
/*
* --INFO--
* Address: 801C1C10
* Size: 000044
*/
void VsGameSection::gmOrimaDown(int)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r6, r3
mr r5, r4
stw r0, 0x14(r1)
lwz r3, 0x180(r3)
cmplwi r3, 0
beq lbl_801C1C44
lwz r12, 0(r3)
mr r4, r6
lwz r12, 0x28(r12)
mtctr r12
bctrl
lbl_801C1C44:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1C54
* Size: 000004
*/
void VsGame::State::onOrimaDown(Game::VsGameSection*, int) { }
/*
* --INFO--
* Address: 801C1C58
* Size: 000004
*/
void VsGameSection::gmPikminZero(void) { }
/*
* --INFO--
* Address: 801C1C5C
* Size: 00003C
*/
void VsGameSection::goNextFloor(Game::ItemHole::Item*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r6, r3
mr r5, r4
stw r0, 0x14(r1)
mr r4, r6
lwz r3, 0x180(r3)
lwz r12, 0(r3)
lwz r12, 0x34(r12)
mtctr r12
bctrl
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C1C98
* Size: 000004
*/
void VsGame::State::onNextFloor(Game::VsGameSection*, Game::ItemHole::Item*) { }
/*
* --INFO--
* Address: 801C1C9C
* Size: 0001D8
*/
void VsGameSection::openCaveMoreMenu(Game::ItemHole::Item*, Controller*)
{
/*
stwu r1, -0x40(r1)
mflr r0
stw r0, 0x44(r1)
stw r31, 0x3c(r1)
mr r31, r4
stw r30, 0x38(r1)
mr r30, r3
mr r4, r30
stw r29, 0x34(r1)
mr r29, r5
lwz r3, 0x180(r3)
lwz r12, 0(r3)
lwz r12, 0x3c(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
bne lbl_801C1E58
lwz r4, gameSystem__4Game@sda21(r13)
li r3, 0
lwz r0, 0x44(r4)
cmpwi r0, 1
beq lbl_801C1CFC
cmpwi r0, 3
bne lbl_801C1D00
lbl_801C1CFC:
li r3, 1
lbl_801C1D00:
clrlwi. r0, r3, 0x18
beq lbl_801C1D20
cmplwi r29, 0
beq lbl_801C1D20
lwz r3, gGame2DMgr__6Screen@sda21(r13)
mr r4, r29
bl setGamePad__Q26Screen9Game2DMgrFP10Controller
b lbl_801C1D2C
lbl_801C1D20:
lwz r3, gGame2DMgr__6Screen@sda21(r13)
lwz r4, 0x10c(r30)
bl setGamePad__Q26Screen9Game2DMgrFP10Controller
lbl_801C1D2C:
lis r3, __vt__Q32og6Screen14DispMemberBase@ha
li r11, 0
addi r0, r3, __vt__Q32og6Screen14DispMemberBase@l
li r8, 1
lis r3, 0x745F3031@ha
lis r6, __vt__Q32og6Screen17DispMemberAnaDemo@ha
addi r7, r3, 0x745F3031@l
stw r0, 8(r1)
li r10, 0x18
li r9, 0x45
addi r0, r6, __vt__Q32og6Screen17DispMemberAnaDemo@l
stw r11, 0x28(r1)
lis r5, __vt__Q32og6Screen18DispMemberCaveMore@ha
lis r4, 0x32705F63@ha
stw r0, 8(r1)
addi r6, r5, __vt__Q32og6Screen18DispMemberCaveMore@l
addi r0, r4, 0x32705F63@l
li r5, 4
stw r10, 0x10(r1)
li r4, 0xa
lis r3, mePikis__Q24Game8GameStat@ha
stw r9, 0x14(r1)
stw r8, 0x18(r1)
stw r7, 0x20(r1)
stw r11, 0xc(r1)
stb r8, 0x27(r1)
stw r8, 0x1c(r1)
stb r11, 0x24(r1)
stb r11, 0x25(r1)
stw r6, 8(r1)
stb r11, 0x2c(r1)
stb r11, 0x2d(r1)
stw r11, 0x28(r1)
stw r5, 0x10(r1)
stw r5, 0x14(r1)
stw r4, 0x18(r1)
stw r0, 0x20(r1)
lwzu r12, mePikis__Q24Game8GameStat@l(r3)
lwz r12, 8(r12)
mtctr r12
bctrl
or. r29, r3, r3
ble lbl_801C1E08
li r0, 1
li r3, -1
stb r0, 0x2c(r1)
bl getMapPikmins__Q24Game8GameStatFi
cmpw r29, r3
bne lbl_801C1DFC
li r0, 1
stb r0, 0x2d(r1)
b lbl_801C1E14
lbl_801C1DFC:
li r0, 0
stb r0, 0x2d(r1)
b lbl_801C1E14
lbl_801C1E08:
li r0, 0
stb r0, 0x2d(r1)
stb r0, 0x2c(r1)
lbl_801C1E14:
lwz r3, gGame2DMgr__6Screen@sda21(r13)
addi r4, r1, 8
bl open_CaveMoreMenu__Q26Screen9Game2DMgrFRQ32og6Screen18DispMemberCaveMore
clrlwi. r0, r3, 0x18
beq lbl_801C1E58
stw r31, 0x1fc(r30)
lis r3, lbl_80480078@ha
addi r5, r3, lbl_80480078@l
li r4, 1
lwz r3, gameSystem__4Game@sda21(r13)
li r6, 3
bl setPause__Q24Game10GameSystemFbPci
lis r4, lbl_80480078@ha
lwz r3, gameSystem__4Game@sda21(r13)
addi r5, r4, lbl_80480078@l
li r4, 1
bl setMoviePause__Q24Game10GameSystemFbPc
lbl_801C1E58:
lwz r0, 0x44(r1)
lwz r31, 0x3c(r1)
lwz r30, 0x38(r1)
lwz r29, 0x34(r1)
mtlr r0
addi r1, r1, 0x40
blr
*/
}
/*
* --INFO--
* Address: 801C1E74
* Size: 000008
*/
u32 VsGame::State::goingToCave(Game::VsGameSection*) { return 0x0; }
/*
* --INFO--
* Address: 801C1E7C
* Size: 0001B0
*/
void VsGameSection::openKanketuMenu(Game::ItemBigFountain::Item*, Controller*)
{
/*
stwu r1, -0x40(r1)
mflr r0
stw r0, 0x44(r1)
stw r31, 0x3c(r1)
mr r31, r4
stw r30, 0x38(r1)
mr r30, r3
li r3, 0
stw r29, 0x34(r1)
lwz r6, gameSystem__4Game@sda21(r13)
lwz r0, 0x44(r6)
cmpwi r0, 1
beq lbl_801C1EB8
cmpwi r0, 3
bne lbl_801C1EBC
lbl_801C1EB8:
li r3, 1
lbl_801C1EBC:
clrlwi. r0, r3, 0x18
beq lbl_801C1EDC
cmplwi r5, 0
beq lbl_801C1EDC
lwz r3, gGame2DMgr__6Screen@sda21(r13)
mr r4, r5
bl setGamePad__Q26Screen9Game2DMgrFP10Controller
b lbl_801C1EE8
lbl_801C1EDC:
lwz r3, gGame2DMgr__6Screen@sda21(r13)
lwz r4, 0x10c(r30)
bl setGamePad__Q26Screen9Game2DMgrFP10Controller
lbl_801C1EE8:
lis r3, __vt__Q32og6Screen14DispMemberBase@ha
li r9, 0
addi r0, r3, __vt__Q32og6Screen14DispMemberBase@l
li r7, 1
lis r3, __vt__Q32og6Screen17DispMemberAnaDemo@ha
stw r0, 8(r1)
addi r5, r3, __vt__Q32og6Screen17DispMemberAnaDemo@l
li r0, 0x18
li r8, 0x45
stw r9, 0x28(r1)
lis r3, 0x745F3031@ha
lis r4, __vt__Q32og6Screen21DispMemberKanketuMenu@ha
addi r6, r3, 0x745F3031@l
stw r5, 8(r1)
addi r5, r4, __vt__Q32og6Screen21DispMemberKanketuMenu@l
li r4, 4
stw r0, 0x10(r1)
li r0, 0xa
lis r3, mePikis__Q24Game8GameStat@ha
stw r8, 0x14(r1)
stw r7, 0x18(r1)
stw r9, 0xc(r1)
stb r7, 0x27(r1)
stw r7, 0x1c(r1)
stw r6, 0x20(r1)
stb r9, 0x24(r1)
stb r9, 0x25(r1)
stw r5, 8(r1)
stb r9, 0x2c(r1)
stb r9, 0x2d(r1)
stb r9, 0x2e(r1)
stw r9, 0x28(r1)
stw r4, 0x10(r1)
stw r4, 0x14(r1)
stw r0, 0x18(r1)
lwzu r12, mePikis__Q24Game8GameStat@l(r3)
lwz r12, 8(r12)
mtctr r12
bctrl
or. r29, r3, r3
ble lbl_801C1FBC
li r0, 1
li r3, -1
stb r0, 0x2c(r1)
bl getMapPikmins__Q24Game8GameStatFi
cmpw r29, r3
bne lbl_801C1FB0
li r0, 1
stb r0, 0x2d(r1)
b lbl_801C1FC8
lbl_801C1FB0:
li r0, 0
stb r0, 0x2d(r1)
b lbl_801C1FC8
lbl_801C1FBC:
li r0, 0
stb r0, 0x2d(r1)
stb r0, 0x2c(r1)
lbl_801C1FC8:
lwz r3, gGame2DMgr__6Screen@sda21(r13)
addi r4, r1, 8
bl
open_ChallengeKanketuMenu__Q26Screen9Game2DMgrFRQ32og6Screen21DispMemberKanketuMenu
clrlwi. r0, r3, 0x18
beq lbl_801C2010
stw r31, 0x200(r30)
li r4, 1
addi r5, r2, lbl_805194D0@sda21
li r6, 3
lbz r0, 0x1f8(r30)
ori r0, r0, 4
stb r0, 0x1f8(r30)
lwz r3, gameSystem__4Game@sda21(r13)
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 1
addi r5, r2, lbl_805194D0@sda21
bl setMoviePause__Q24Game10GameSystemFbPc
lbl_801C2010:
lwz r0, 0x44(r1)
lwz r31, 0x3c(r1)
lwz r30, 0x38(r1)
lwz r29, 0x34(r1)
mtlr r0
addi r1, r1, 0x40
blr
*/
}
/*
* --INFO--
* Address: 801C202C
* Size: 000014
*/
void VsGameSection::clearCaveMenus(void)
{
/*
li r0, 0
stb r0, 0x1f8(r3)
stw r0, 0x1fc(r3)
stw r0, 0x200(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C2040
* Size: 0002A8
*/
void VsGameSection::updateCaveMenus(void)
{
/*
stwu r1, -0x50(r1)
mflr r0
stw r0, 0x54(r1)
stw r31, 0x4c(r1)
mr r31, r3
lis r3, lbl_8047FF98@ha
stw r30, 0x48(r1)
addi r30, r3, lbl_8047FF98@l
lbz r4, 0x1f8(r31)
rlwinm. r0, r4, 0, 0x1e, 0x1e
beq lbl_801C217C
lwz r3, gGame2DMgr__6Screen@sda21(r13)
bl check_CaveMoreMenu__Q26Screen9Game2DMgrFv
cmpwi r3, 2
beq lbl_801C2134
bge lbl_801C2090
cmpwi r3, 0
beq lbl_801C22CC
bge lbl_801C209C
b lbl_801C22CC
lbl_801C2090:
cmpwi r3, 4
bge lbl_801C22CC
b lbl_801C2168
lbl_801C209C:
lwz r3, naviMgr__4Game@sda21(r13)
li r4, 0
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lfs f0, 0x2a0(r3)
li r4, 1
lwz r3, playData__4Game@sda21(r13)
stfs f0, 0x24(r3)
lwz r3, naviMgr__4Game@sda21(r13)
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lfs f0, 0x2a0(r3)
addi r5, r30, 0xec
lwz r3, playData__4Game@sda21(r13)
li r4, 0
li r6, 3
stfs f0, 0x28(r3)
lwz r3, gameSystem__4Game@sda21(r13)
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
addi r5, r30, 0xec
li r4, 0
bl setMoviePause__Q24Game10GameSystemFbPc
lbz r0, 0x1f8(r31)
mr r3, r31
rlwinm r0, r0, 0, 0x1f, 0x1d
stb r0, 0x1f8(r31)
lwz r12, 0(r31)
lwz r4, 0x1fc(r31)
lwz r12, 0x6c(r12)
mtctr r12
bctrl
li r3, 1
b lbl_801C22D0
lbl_801C2134:
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194D8@sda21
li r6, 3
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194D8@sda21
bl setMoviePause__Q24Game10GameSystemFbPc
lbz r0, 0x1f8(r31)
rlwinm r0, r0, 0, 0x1f, 0x1d
stb r0, 0x1f8(r31)
b lbl_801C22CC
lbl_801C2168:
lwz r3, gameSystem__4Game@sda21(r13)
addi r5, r30, 0xf8
li r4, 0
bl setMoviePause__Q24Game10GameSystemFbPc
b lbl_801C22CC
lbl_801C217C:
rlwinm. r0, r4, 0, 0x1d, 0x1d
beq lbl_801C22CC
lwz r3, gGame2DMgr__6Screen@sda21(r13)
bl check_KanketuMenu__Q26Screen9Game2DMgrFv
cmpwi r3, 2
beq lbl_801C229C
bge lbl_801C22CC
cmpwi r3, 0
beq lbl_801C22CC
bge lbl_801C21AC
b lbl_801C22CC
b lbl_801C22CC
lbl_801C21AC:
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194E0@sda21
li r6, 3
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194E0@sda21
bl setMoviePause__Q24Game10GameSystemFbPc
lbz r3, 0x1f8(r31)
addi r4, r30, 0x104
lfs f0, lbl_805194A8@sda21(r2)
li r0, 0
rlwinm r5, r3, 0, 0x1e, 0x1c
addi r3, r1, 8
stb r5, 0x1f8(r31)
lwz r5, 0xc8(r31)
stw r4, 0x14(r1)
stw r0, 0x18(r1)
stw r5, 0x20(r1)
stfs f0, 0x2c(r1)
stfs f0, 0x30(r1)
stfs f0, 0x34(r1)
stfs f0, 0x38(r1)
stw r0, 0x3c(r1)
stw r0, 0x24(r1)
stw r0, 0x1c(r1)
stw r0, 0x40(r1)
stw r0, 0x28(r1)
stw r0, 0x44(r1)
lwz r4, 0x200(r31)
lwz r12, 0(r4)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f2, 8(r1)
lfs f1, 0xc(r1)
lfs f0, 0x10(r1)
stfs f2, 0x2c(r1)
stfs f1, 0x30(r1)
stfs f0, 0x34(r1)
lwz r3, 0x200(r31)
lwz r12, 0(r3)
lwz r12, 0x64(r12)
mtctr r12
bctrl
stfs f1, 0x38(r1)
li r4, 0
lwz r0, 0xcc(r31)
stw r0, 0x24(r1)
lwz r3, 0x200(r31)
bl movie_begin__Q24Game8CreatureFb
lwz r0, 0x200(r31)
addi r4, r1, 0x14
lwz r3, moviePlayer__4Game@sda21(r13)
stw r0, 0x194(r3)
lwz r3, moviePlayer__4Game@sda21(r13)
bl play__Q24Game11MoviePlayerFRQ24Game12MoviePlayArg
li r3, 1
b lbl_801C22D0
lbl_801C229C:
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194E8@sda21
li r6, 3
bl setPause__Q24Game10GameSystemFbPci
lwz r3, gameSystem__4Game@sda21(r13)
li r4, 0
addi r5, r2, lbl_805194E8@sda21
bl setMoviePause__Q24Game10GameSystemFbPc
lbz r0, 0x1f8(r31)
rlwinm r0, r0, 0, 0x1e, 0x1c
stb r0, 0x1f8(r31)
lbl_801C22CC:
li r3, 0
lbl_801C22D0:
lwz r0, 0x54(r1)
lwz r31, 0x4c(r1)
lwz r30, 0x48(r1)
mtlr r0
addi r1, r1, 0x50
blr
*/
}
/*
* --INFO--
* Address: 801C22E8
* Size: 000008
*/
void ItemBigFountain::Item::getFaceDir(void)
{
/*
lfs f1, 0x1ec(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C22F0
* Size: 0000DC
*/
void VsGameSection::onMovieStart(Game::MovieConfig*, unsigned long, unsigned long)
{
/*
.loc_0x0:
stwu r1, -0x20(r1)
mflr r0
lis r7, 0x8048
stw r0, 0x24(r1)
stw r31, 0x1C(r1)
mr r31, r6
stw r30, 0x18(r1)
mr r30, r5
stw r29, 0x14(r1)
mr r29, r4
addi r4, r7, 0xAC
stw r28, 0x10(r1)
mr r28, r3
mr r3, r29
bl 0x26F5A4
lwz r4, -0x6C18(r13)
li r3, 0
lwz r0, 0x44(r4)
cmpwi r0, 0x1
beq- .loc_0x58
cmpwi r0, 0x3
bne- .loc_0x5C
.loc_0x58:
li r3, 0x1
.loc_0x5C:
rlwinm. r0,r3,0,24,31
beq- .loc_0x88
cmplwi r31, 0x1
bne- .loc_0x7C
mr r3, r28
li r4, 0x1
bl -0x74A4C
b .loc_0x88
.loc_0x7C:
mr r3, r28
li r4, 0
bl -0x74A5C
.loc_0x88:
mr r3, r28
bl -0x745F4
lwz r3, 0x180(r28)
cmplwi r3, 0
beq- .loc_0xBC
lwz r12, 0x0(r3)
mr r4, r28
mr r5, r29
mr r6, r30
lwz r12, 0x2C(r12)
mr r7, r31
mtctr r12
bctrl
.loc_0xBC:
lwz r0, 0x24(r1)
lwz r31, 0x1C(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
lwz r28, 0x10(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 801C23CC
* Size: 000004
*/
void VsGame::State::onMovieStart(Game::VsGameSection*, Game::MovieConfig*, unsigned long, unsigned long) { }
/*
* --INFO--
* Address: 801C23D0
* Size: 000054
*/
void VsGameSection::onMovieDone(Game::MovieConfig*, unsigned long, unsigned long)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
mr r9, r3
mr r8, r4
stw r0, 0x14(r1)
mr r0, r5
mr r7, r6
lwz r3, 0x180(r3)
cmplwi r3, 0
beq- .loc_0x44
lwz r12, 0x0(r3)
mr r4, r9
mr r5, r8
mr r6, r0
lwz r12, 0x30(r12)
mtctr r12
bctrl
.loc_0x44:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2424
* Size: 000004
*/
void VsGame::State::onMovieDone(Game::VsGameSection*, Game::MovieConfig*, unsigned long, unsigned long) { }
/*
* --INFO--
* Address: 801C2428
* Size: 000434
*/
void VsGameSection::createFallPikmins(Game::PikiContainer&, int)
{
/*
stwu r1, -0x160(r1)
mflr r0
stw r0, 0x164(r1)
stfd f31, 0x150(r1)
psq_st f31, 344(r1), 0, qr0
stfd f30, 0x140(r1)
psq_st f30, 328(r1), 0, qr0
stfd f29, 0x130(r1)
psq_st f29, 312(r1), 0, qr0
stfd f28, 0x120(r1)
psq_st f28, 296(r1), 0, qr0
stfd f27, 0x110(r1)
psq_st f27, 280(r1), 0, qr0
stfd f26, 0x100(r1)
psq_st f26, 264(r1), 0, qr0
stfd f25, 0xf0(r1)
psq_st f25, 248(r1), 0, qr0
stfd f24, 0xe0(r1)
psq_st f24, 232(r1), 0, qr0
stfd f23, 0xd0(r1)
psq_st f23, 216(r1), 0, qr0
stfd f22, 0xc0(r1)
psq_st f22, 200(r1), 0, qr0
stfd f21, 0xb0(r1)
psq_st f21, 184(r1), 0, qr0
stfd f20, 0xa0(r1)
psq_st f20, 168(r1), 0, qr0
stmw r25, 0x84(r1)
lwz r3, mapMgr__4Game@sda21(r13)
mr r26, r4
addi r4, r1, 0x38
lwz r12, 4(r3)
lwz r12, 0x10(r12)
mtctr r12
bctrl
lis r4, lbl_804800BC@ha
mr r3, r26
addi r4, r4, lbl_804800BC@l
bl dump__Q24Game13PikiContainerFPc
lwz r3, naviMgr__4Game@sda21(r13)
li r4, 0
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
mr r0, r3
addi r3, r1, 8
mr r4, r0
lwz r12, 0(r4)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f2, 8(r1)
addi r4, r1, 0x38
lfs f1, 0xc(r1)
lfs f0, 0x10(r1)
stfs f2, 0x38(r1)
lwz r3, mapMgr__4Game@sda21(r13)
stfs f1, 0x3c(r1)
stfs f0, 0x40(r1)
lwz r12, 4(r3)
lwz r12, 0x28(r12)
mtctr r12
bctrl
lis r3, sincosTable___5JMath@ha
stfs f1, 0x3c(r1)
lfd f22, lbl_805194C8@sda21(r2)
addi r31, r3, sincosTable___5JMath@l
lfs f23, lbl_805194F0@sda21(r2)
li r29, 0
lfs f24, lbl_805194F8@sda21(r2)
lis r30, 0x4330
lfs f25, lbl_805194F4@sda21(r2)
lfs f26, lbl_805194FC@sda21(r2)
lfs f27, lbl_80519500@sda21(r2)
lfs f28, lbl_80519508@sda21(r2)
lfs f29, lbl_80519504@sda21(r2)
lfs f30, lbl_805194A8@sda21(r2)
lfs f31, lbl_8051950C@sda21(r2)
lbl_801C2564:
li r28, 0
lbl_801C2568:
li r27, 0
b lbl_801C27AC
lbl_801C2570:
bl rand
xoris r0, r3, 0x8000
stw r30, 0x48(r1)
stw r0, 0x4c(r1)
lfd f0, 0x48(r1)
fsubs f0, f0, f22
fdivs f0, f0, f23
fmadds f21, f24, f0, f25
bl rand
xoris r0, r3, 0x8000
stw r30, 0x50(r1)
stw r0, 0x54(r1)
lfd f0, 0x50(r1)
fsubs f0, f0, f22
fdivs f0, f0, f23
fmuls f20, f26, f0
bl rand
xoris r0, r3, 0x8000
stw r30, 0x58(r1)
fmr f1, f20
stw r0, 0x5c(r1)
fcmpo cr0, f20, f30
lfd f0, 0x58(r1)
fsubs f0, f0, f22
fdivs f0, f0, f23
fmadds f0, f28, f0, f29
fadds f2, f27, f0
bge lbl_801C25E4
fneg f1, f20
lbl_801C25E4:
fmuls f0, f1, f31
fcmpo cr0, f20, f30
fctiwz f0, f0
stfd f0, 0x60(r1)
lwz r0, 0x64(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
add r3, r31, r0
lfs f0, 4(r3)
fmuls f1, f21, f0
bge lbl_801C2638
lfs f0, lbl_80519510@sda21(r2)
lis r3, sincosTable___5JMath@ha
addi r3, r3, sincosTable___5JMath@l
fmuls f0, f20, f0
fctiwz f0, f0
stfd f0, 0x68(r1)
lwz r0, 0x6c(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r3, r0
fneg f0, f0
b lbl_801C2658
lbl_801C2638:
fmuls f0, f20, f31
lis r3, sincosTable___5JMath@ha
addi r3, r3, sincosTable___5JMath@l
fctiwz f0, f0
stfd f0, 0x70(r1)
lwz r0, 0x74(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r3, r0
lbl_801C2658:
fmuls f0, f21, f0
stfs f2, 0x30(r1)
lwz r3, pikiMgr__4Game@sda21(r13)
stfs f1, 0x34(r1)
stfs f0, 0x2c(r1)
lwz r12, 0(r3)
lwz r12, 0x7c(r12)
mtctr r12
bctrl
lfs f1, 0x2c(r1)
or. r25, r3, r3
lfs f0, 0x38(r1)
lfs f3, 0x30(r1)
fadds f4, f1, f0
lfs f2, 0x3c(r1)
lfs f1, 0x34(r1)
lfs f0, 0x40(r1)
fadds f2, f3, f2
stfs f4, 0x2c(r1)
fadds f0, f1, f0
stfs f2, 0x30(r1)
stfs f0, 0x34(r1)
beq lbl_801C27A8
lis r5, __vt__Q24Game15CreatureInitArg@ha
lis r4, __vt__Q24Game11PikiInitArg@ha
addi r0, r5, __vt__Q24Game15CreatureInitArg@l
li r5, 0xf
stw r0, 0x20(r1)
addi r6, r4, __vt__Q24Game11PikiInitArg@l
li r0, 0
addi r4, r1, 0x20
stw r6, 0x20(r1)
stw r5, 0x24(r1)
stw r0, 0x28(r1)
bl init__Q24Game8CreatureFPQ24Game15CreatureInitArg
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0x74(r1)
mr r3, r25
lfd f3, lbl_805194C8@sda21(r2)
addi r4, r1, 0x2c
stw r0, 0x70(r1)
li r5, 0
lfs f1, lbl_805194F0@sda21(r2)
lfd f2, 0x70(r1)
lfs f0, lbl_805194FC@sda21(r2)
fsubs f2, f2, f3
fdivs f1, f2, f1
fmuls f0, f0, f1
stfs f0, 0x1fc(r25)
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
mr r3, r25
mr r4, r29
bl changeShape__Q24Game4PikiFi
mr r3, r25
mr r4, r28
bl changeHappa__Q24Game4PikiFi
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0x6c(r1)
mr r3, r25
lfs f2, lbl_805194A8@sda21(r2)
addi r4, r1, 0x14
stw r0, 0x68(r1)
lfd f1, lbl_805194C8@sda21(r2)
lfd f0, 0x68(r1)
lfs f3, lbl_805194F0@sda21(r2)
fsubs f4, f0, f1
lfs f1, lbl_80519518@sda21(r2)
lfs f0, lbl_80519514@sda21(r2)
stfs f2, 0x14(r1)
fdivs f3, f4, f3
stfs f2, 0x1c(r1)
fnmadds f0, f1, f3, f0
stfs f0, 0x18(r1)
lwz r12, 0(r25)
lwz r12, 0x68(r12)
mtctr r12
bctrl
mr r3, r25
li r4, 0
bl movie_begin__Q24Game8CreatureFb
lbl_801C27A8:
addi r27, r27, 1
lbl_801C27AC:
mr r3, r26
mr r4, r29
mr r5, r28
bl getCount__Q24Game13PikiContainerFii
lwz r0, 0(r3)
cmpw r27, r0
blt lbl_801C2570
addi r28, r28, 1
cmpwi r28, 3
blt lbl_801C2568
addi r29, r29, 1
cmpwi r29, 7
blt lbl_801C2564
mr r3, r26
bl clear__Q24Game13PikiContainerFv
psq_l f31, 344(r1), 0, qr0
lfd f31, 0x150(r1)
psq_l f30, 328(r1), 0, qr0
lfd f30, 0x140(r1)
psq_l f29, 312(r1), 0, qr0
lfd f29, 0x130(r1)
psq_l f28, 296(r1), 0, qr0
lfd f28, 0x120(r1)
psq_l f27, 280(r1), 0, qr0
lfd f27, 0x110(r1)
psq_l f26, 264(r1), 0, qr0
lfd f26, 0x100(r1)
psq_l f25, 248(r1), 0, qr0
lfd f25, 0xf0(r1)
psq_l f24, 232(r1), 0, qr0
lfd f24, 0xe0(r1)
psq_l f23, 216(r1), 0, qr0
lfd f23, 0xd0(r1)
psq_l f22, 200(r1), 0, qr0
lfd f22, 0xc0(r1)
psq_l f21, 184(r1), 0, qr0
lfd f21, 0xb0(r1)
psq_l f20, 168(r1), 0, qr0
lfd f20, 0xa0(r1)
lmw r25, 0x84(r1)
lwz r0, 0x164(r1)
mtlr r0
addi r1, r1, 0x160
blr
*/
}
/*
* --INFO--
* Address: 801C285C
* Size: 000564
*/
void VsGameSection::createVsPikmins(void)
{
/*
stwu r1, -0x1b0(r1)
mflr r0
stw r0, 0x1b4(r1)
stfd f31, 0x1a0(r1)
psq_st f31, 424(r1), 0, qr0
stfd f30, 0x190(r1)
psq_st f30, 408(r1), 0, qr0
stfd f29, 0x180(r1)
psq_st f29, 392(r1), 0, qr0
stfd f28, 0x170(r1)
psq_st f28, 376(r1), 0, qr0
stfd f27, 0x160(r1)
psq_st f27, 360(r1), 0, qr0
stfd f26, 0x150(r1)
psq_st f26, 344(r1), 0, qr0
stfd f25, 0x140(r1)
psq_st f25, 328(r1), 0, qr0
stfd f24, 0x130(r1)
psq_st f24, 312(r1), 0, qr0
stfd f23, 0x120(r1)
psq_st f23, 296(r1), 0, qr0
stfd f22, 0x110(r1)
psq_st f22, 280(r1), 0, qr0
stfd f21, 0x100(r1)
psq_st f21, 264(r1), 0, qr0
stfd f20, 0xf0(r1)
psq_st f20, 248(r1), 0, qr0
stfd f19, 0xe0(r1)
psq_st f19, 232(r1), 0, qr0
stfd f18, 0xd0(r1)
psq_st f18, 216(r1), 0, qr0
stfd f17, 0xc0(r1)
psq_st f17, 200(r1), 0, qr0
stfd f16, 0xb0(r1)
psq_st f16, 184(r1), 0, qr0
stmw r24, 0x90(r1)
mr r25, r3
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
li r4, 1
bl getOnyon__Q34Game9ItemOnyon3MgrFi
or. r26, r3, r3
bne lbl_801C2920
lis r3, lbl_8047FFF4@ha
lis r5, lbl_8047FFC0@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x545
addi r5, r5, lbl_8047FFC0@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C2920:
mr r4, r26
addi r3, r1, 0x28
lwz r12, 0(r26)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f25, 0x28(r1)
li r4, 0
lfs f24, 0x2c(r1)
lfs f23, 0x30(r1)
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
bl getOnyon__Q34Game9ItemOnyon3MgrFi
or. r26, r3, r3
bne lbl_801C2974
lis r3, lbl_8047FFF4@ha
lis r5, lbl_8047FFC0@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x54a
addi r5, r5, lbl_8047FFC0@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C2974:
mr r4, r26
addi r3, r1, 0x1c
lwz r12, 0(r26)
lwz r12, 8(r12)
mtctr r12
bctrl
addi r29, r25, 0x214
lfs f22, 0x1c(r1)
lfs f21, 0x20(r1)
mr r3, r29
lfs f20, 0x24(r1)
bl clear__Q24Game13PikiContainerFv
mr r3, r29
li r4, 1
li r5, 0
bl getCount__Q24Game13PikiContainerFii
lwz r0, 0x344(r25)
li r4, 0
li r5, 0
mulli r0, r0, 5
stw r0, 0(r3)
mr r3, r29
bl getCount__Q24Game13PikiContainerFii
lwz r0, 0x348(r25)
li r28, 0
mulli r0, r0, 5
stw r0, 0(r3)
lbl_801C29E0:
cmpwi r28, 1
bne lbl_801C29F8
fmr f19, f25
fmr f18, f24
fmr f17, f23
b lbl_801C2A0C
lbl_801C29F8:
cmpwi r28, 0
bne lbl_801C2BD4
fmr f19, f22
fmr f18, f21
fmr f17, f20
lbl_801C2A0C:
lis r3, sincosTable___5JMath@ha
lfd f26, lbl_805194C8@sda21(r2)
lfs f27, lbl_805194F0@sda21(r2)
addi r31, r3, sincosTable___5JMath@l
lfs f28, lbl_8051951C@sda21(r2)
li r27, 0
lfs f29, lbl_805194FC@sda21(r2)
lis r30, 0x4330
lfs f30, lbl_805194A8@sda21(r2)
lfs f31, lbl_8051950C@sda21(r2)
lbl_801C2A34:
li r26, 0
b lbl_801C2BAC
lbl_801C2A3C:
bl rand
xoris r0, r3, 0x8000
stw r30, 0x68(r1)
stw r0, 0x6c(r1)
lfd f0, 0x68(r1)
fsubs f0, f0, f26
fdivs f0, f0, f27
fmuls f16, f28, f0
bl rand
xoris r0, r3, 0x8000
stw r30, 0x70(r1)
stw r0, 0x74(r1)
lfd f0, 0x70(r1)
fsubs f0, f0, f26
fdivs f0, f0, f27
fmuls f2, f29, f0
fmr f0, f2
fcmpo cr0, f2, f30
bge lbl_801C2A8C
fneg f0, f2
lbl_801C2A8C:
fmuls f0, f0, f31
fcmpo cr0, f2, f30
fctiwz f0, f0
stfd f0, 0x78(r1)
lwz r0, 0x7c(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
add r3, r31, r0
lfs f0, 4(r3)
fmuls f1, f16, f0
bge lbl_801C2AE0
lfs f0, lbl_80519510@sda21(r2)
lis r3, sincosTable___5JMath@ha
addi r3, r3, sincosTable___5JMath@l
fmuls f0, f2, f0
fctiwz f0, f0
stfd f0, 0x80(r1)
lwz r0, 0x84(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r3, r0
fneg f0, f0
b lbl_801C2B00
lbl_801C2AE0:
fmuls f0, f2, f31
lis r3, sincosTable___5JMath@ha
addi r3, r3, sincosTable___5JMath@l
fctiwz f0, f0
stfd f0, 0x88(r1)
lwz r0, 0x8c(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r3, r0
lbl_801C2B00:
fmuls f0, f16, f0
stfs f30, 0x60(r1)
lwz r3, pikiMgr__4Game@sda21(r13)
stfs f1, 0x64(r1)
stfs f0, 0x5c(r1)
lwz r12, 0(r3)
lwz r12, 0x7c(r12)
mtctr r12
bctrl
lfs f2, 0x5c(r1)
or. r24, r3, r3
lfs f1, 0x60(r1)
lfs f0, 0x64(r1)
fadds f2, f2, f19
fadds f1, f1, f18
fadds f0, f0, f17
stfs f2, 0x5c(r1)
stfs f1, 0x60(r1)
stfs f0, 0x64(r1)
beq lbl_801C2BA8
lis r5, __vt__Q24Game15CreatureInitArg@ha
lis r4, __vt__Q24Game11PikiInitArg@ha
addi r0, r5, __vt__Q24Game15CreatureInitArg@l
li r5, -1
stw r0, 0x50(r1)
addi r6, r4, __vt__Q24Game11PikiInitArg@l
li r0, 0
addi r4, r1, 0x50
stw r6, 0x50(r1)
stw r5, 0x54(r1)
stw r0, 0x58(r1)
bl init__Q24Game8CreatureFPQ24Game15CreatureInitArg
mr r3, r24
addi r4, r1, 0x5c
li r5, 0
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
mr r3, r24
mr r4, r28
bl changeShape__Q24Game4PikiFi
mr r3, r24
mr r4, r27
bl changeHappa__Q24Game4PikiFi
lbl_801C2BA8:
addi r26, r26, 1
lbl_801C2BAC:
mr r3, r29
mr r4, r28
mr r5, r27
bl getCount__Q24Game13PikiContainerFii
lwz r0, 0(r3)
cmpw r26, r0
blt lbl_801C2A3C
addi r27, r27, 1
cmpwi r27, 3
blt lbl_801C2A34
lbl_801C2BD4:
addi r28, r28, 1
cmpwi r28, 7
blt lbl_801C29E0
lwz r3, lbl_80520E68@sda21(r2)
addi r26, r1, 8
lwz r0, lbl_80520E6C@sda21(r2)
li r24, 0
stw r3, 8(r1)
lwz r3, cBedamaRed__13VsOtakaraName@sda21(r13)
stw r0, 0xc(r1)
lwz r0, cBedamaBlue__13VsOtakaraName@sda21(r13)
stw r3, 8(r1)
stw r0, 0xc(r1)
lbl_801C2C08:
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
subfic r4, r24, 1
bl getOnyon__Q34Game9ItemOnyon3MgrFi
mr r0, r3
addi r3, r1, 0x40
mr r27, r0
bl __ct__Q24Game14PelletIteratorFv
addi r3, r1, 0x40
bl first__Q24Game14PelletIteratorFv
b lbl_801C2CAC
lbl_801C2C30:
addi r3, r1, 0x40
bl __ml__Q24Game14PelletIteratorFv
mr r0, r3
lwz r3, 0(r26)
mr r28, r0
lwz r4, 0x35c(r28)
lwz r4, 0x40(r4)
bl strcmp
cmpwi r3, 0
bne lbl_801C2CA4
mr r4, r27
addi r3, r1, 0x10
bl getFlagSetPos__Q24Game5OnyonFv
lfs f2, 0x10(r1)
mr r3, r28
lfs f1, 0x14(r1)
lfs f0, 0x18(r1)
stfs f2, 0x34(r1)
stfs f1, 0x38(r1)
stfs f0, 0x3c(r1)
bl getCylinderHeight__Q24Game6PelletFv
lfs f2, lbl_805194AC@sda21(r2)
mr r3, r28
lfs f0, 0x38(r1)
addi r4, r1, 0x34
li r5, 0
fmadds f0, f2, f1, f0
stfs f0, 0x38(r1)
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
lbl_801C2CA4:
addi r3, r1, 0x40
bl next__Q24Game14PelletIteratorFv
lbl_801C2CAC:
addi r3, r1, 0x40
bl isDone__Q24Game14PelletIteratorFv
clrlwi. r0, r3, 0x18
beq lbl_801C2C30
addi r24, r24, 1
addi r26, r26, 4
cmpwi r24, 2
blt lbl_801C2C08
lwz r3, naviMgr__4Game@sda21(r13)
li r4, 0
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lwz r5, 0x33c(r25)
li r4, 1
lwz r0, 0x68(r5)
stw r0, 0x25c(r3)
lwz r5, 0x33c(r25)
lwz r0, 0x64(r5)
stw r0, 0x260(r3)
lwz r3, naviMgr__4Game@sda21(r13)
lwz r12, 0(r3)
lwz r12, 0x24(r12)
mtctr r12
bctrl
lwz r4, 0x33c(r25)
lwz r0, 0x68(r4)
stw r0, 0x25c(r3)
lwz r4, 0x33c(r25)
lwz r0, 0x64(r4)
stw r0, 0x260(r3)
psq_l f31, 424(r1), 0, qr0
lfd f31, 0x1a0(r1)
psq_l f30, 408(r1), 0, qr0
lfd f30, 0x190(r1)
psq_l f29, 392(r1), 0, qr0
lfd f29, 0x180(r1)
psq_l f28, 376(r1), 0, qr0
lfd f28, 0x170(r1)
psq_l f27, 360(r1), 0, qr0
lfd f27, 0x160(r1)
psq_l f26, 344(r1), 0, qr0
lfd f26, 0x150(r1)
psq_l f25, 328(r1), 0, qr0
lfd f25, 0x140(r1)
psq_l f24, 312(r1), 0, qr0
lfd f24, 0x130(r1)
psq_l f23, 296(r1), 0, qr0
lfd f23, 0x120(r1)
psq_l f22, 280(r1), 0, qr0
lfd f22, 0x110(r1)
psq_l f21, 264(r1), 0, qr0
lfd f21, 0x100(r1)
psq_l f20, 248(r1), 0, qr0
lfd f20, 0xf0(r1)
psq_l f19, 232(r1), 0, qr0
lfd f19, 0xe0(r1)
psq_l f18, 216(r1), 0, qr0
lfd f18, 0xd0(r1)
psq_l f17, 200(r1), 0, qr0
lfd f17, 0xc0(r1)
psq_l f16, 184(r1), 0, qr0
lfd f16, 0xb0(r1)
lmw r24, 0x90(r1)
lwz r0, 0x1b4(r1)
mtlr r0
addi r1, r1, 0x1b0
blr
*/
}
/*
* --INFO--
* Address: 801C2DC0
* Size: 000010
*/
void VsGameSection::addChallengeScore(int)
{
/*
lwz r0, 0x3bc(r3)
add r0, r0, r4
stw r0, 0x3bc(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C2DD0
* Size: 00006C
*/
void VsGameSection::sendMessage(Game::GameMessage&)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
mr r30, r3
mr r3, r31
lwz r12, 0(r31)
mr r4, r30
lwz r12, 8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C2E24
mr r3, r31
mr r4, r30
lwz r12, 0(r31)
lwz r12, 0x10(r12)
mtctr r12
bctrl
lbl_801C2E24:
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2E3C
* Size: 000040
*/
void GameMessageVsGetDoping::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r5, r3
mr r3, r4
stw r0, 0x14(r1)
lwz r4, 4(r5)
lwz r5, 8(r5)
bl getGetDopeCount__Q24Game13VsGameSectionFii
lwz r4, 0(r3)
addi r0, r4, 1
stw r0, 0(r3)
li r3, 1
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2E7C
* Size: 00004C
*/
void GameMessageVsBattleFinished::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r5, r3
stw r0, 0x14(r1)
lwz r0, 0x180(r4)
cmplwi r0, 0
beq lbl_801C2EB4
mr r3, r0
lwz r5, 4(r5)
lwz r12, 0(r3)
li r6, 0
lwz r12, 0x40(r12)
mtctr r12
bctrl
lbl_801C2EB4:
lwz r0, 0x14(r1)
li r3, 1
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2EC8
* Size: 000004
*/
void VsGame::State::onBattleFinished(Game::VsGameSection*, int, bool) { }
/*
* --INFO--
* Address: 801C2ECC
* Size: 00004C
*/
void GameMessageVsRedOrSuckStart::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r6, r3
stw r0, 0x14(r1)
lwz r0, 0x180(r4)
cmplwi r0, 0
beq lbl_801C2F04
mr r3, r0
lwz r5, 4(r6)
lwz r12, 0(r3)
lbz r6, 8(r6)
lwz r12, 0x44(r12)
mtctr r12
bctrl
lbl_801C2F04:
lwz r0, 0x14(r1)
li r3, 1
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2F18
* Size: 000004
*/
void VsGame::State::onRedOrBlueSuckStart(Game::VsGameSection*, int, bool) { }
/*
* --INFO--
* Address: 801C2F1C
* Size: 0000B8
*/
void GameMessageVsGetOtakara::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
mr r30, r3
lwz r0, 0x180(r4)
cmplwi r0, 0
beq lbl_801C2FB8
lwz r0, 4(r30)
slwi r0, r0, 2
add r4, r31, r0
lwz r3, 0x3d4(r4)
addi r0, r3, 1
stw r0, 0x3d4(r4)
lwz r3, 4(r30)
slwi r0, r3, 2
cntlzw r4, r3
add r3, r31, r0
lwz r0, 0x3d4(r3)
srwi r3, r4, 5
subfic r0, r0, 3
cntlzw r0, r0
srwi r4, r0, 5
bl PSSetLastBeedamaDirection__Fbb
lwz r5, 4(r30)
slwi r0, r5, 2
add r3, r31, r0
lwz r0, 0x3d4(r3)
cmpwi r0, 4
blt lbl_801C2FB8
lwz r3, 0x180(r31)
mr r4, r31
li r6, 1
lwz r12, 0(r3)
lwz r12, 0x40(r12)
mtctr r12
bctrl
lbl_801C2FB8:
lwz r0, 0x14(r1)
li r3, 1
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C2FD4
* Size: 000034
*/
void GameMessageVsAddEnemy::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
mr r5, r3
stw r0, 0x14(r1)
lwz r3, 0x32c(r4)
lwz r4, 4(r5)
lwz r5, 8(r5)
bl entry__Q34Game6VsGame7TekiMgrFQ34Game11EnemyTypeID12EEnemyTypeIDi
lwz r0, 0x14(r1)
li r3, 1
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: ........
* Size: 0000A4
*/
void GameMessageVsBirthTeki::actVs(Game::VsGameSection*)
{
// UNUSED FUNCTION
}
/*
* --INFO--
* Address: 801C3008
* Size: 000118
*/
void GameMessagePelletBorn::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r5, 4(r3)
lbz r0, 0x32c(r5)
cmplwi r0, 6
bne lbl_801C310C
lwz r0, 0x388(r4)
cmplw r0, r5
bne lbl_801C3038
li r3, 0
b lbl_801C3110
lbl_801C3038:
lwz r0, 0x38c(r4)
cmplw r0, r5
bne lbl_801C304C
li r3, 0
b lbl_801C3110
lbl_801C304C:
addi r3, r4, 8
lwz r0, 0x390(r4)
cmplw r0, r5
bne lbl_801C3064
li r3, 0
b lbl_801C3110
lbl_801C3064:
lwz r0, 0x38c(r3)
cmplw r0, r5
bne lbl_801C3078
li r3, 0
b lbl_801C3110
lbl_801C3078:
lwz r0, 0x390(r3)
cmplw r0, r5
bne lbl_801C308C
li r3, 0
b lbl_801C3110
lbl_801C308C:
lwz r0, 0x394(r3)
cmplw r0, r5
bne lbl_801C30A0
li r3, 0
b lbl_801C3110
lbl_801C30A0:
lwz r0, 0x398(r3)
cmplw r0, r5
bne lbl_801C30B4
li r3, 0
b lbl_801C3110
lbl_801C30B4:
li r0, 7
mr r3, r4
li r6, 0
mtctr r0
lbl_801C30C4:
lwz r0, 0x388(r3)
cmplwi r0, 0
bne lbl_801C30E4
slwi r0, r6, 2
li r3, 1
add r4, r4, r0
stw r5, 0x388(r4)
b lbl_801C3110
lbl_801C30E4:
addi r3, r3, 4
addi r6, r6, 1
bdnz lbl_801C30C4
lis r3, lbl_8047FFF4@ha
lis r5, lbl_804800D0@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x638
addi r5, r5, lbl_804800D0@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C310C:
li r3, 0
lbl_801C3110:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C3120
* Size: 00008C
*/
void GameMessagePelletDead::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r5, 4(r3)
lbz r0, 0x32c(r5)
cmplwi r0, 6
bne lbl_801C3198
li r0, 7
mr r3, r4
li r6, 0
mtctr r0
lbl_801C314C:
lwz r0, 0x388(r3)
cmplw r0, r5
bne lbl_801C3170
slwi r0, r6, 2
li r5, 0
add r4, r4, r0
li r3, 1
stw r5, 0x388(r4)
b lbl_801C319C
lbl_801C3170:
addi r3, r3, 4
addi r6, r6, 1
bdnz lbl_801C314C
lis r3, lbl_8047FFF4@ha
lis r5, lbl_804800EC@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x651
addi r5, r5, lbl_804800EC@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3198:
li r3, 0
lbl_801C319C:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C31AC
* Size: 000228
*/
void GameMessageVsBirthTekiTreasure::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0xb0(r1)
mflr r0
stw r0, 0xb4(r1)
stfd f31, 0xa0(r1)
psq_st f31, 168(r1), 0, qr0
stmw r26, 0x88(r1)
mr r30, r3
mr r31, r4
lfs f1, 4(r3)
addi r3, r1, 0x18
lfs f0, lbl_80519520@sda21(r2)
addi r4, r1, 8
stfs f1, 8(r1)
li r29, 0
li r28, 0
li r27, 0
lfs f1, 8(r30)
stfs f1, 0xc(r1)
lfs f1, 0xc(r30)
stfs f1, 0x10(r1)
stfs f0, 0x14(r1)
bl __ct__Q24Game15CellIteratorArgFRQ23Sys6Sphere
addi r3, r1, 0x38
addi r4, r1, 0x18
bl __ct__Q24Game12CellIteratorFRQ24Game15CellIteratorArg
addi r3, r1, 0x38
bl first__Q24Game12CellIteratorFv
b lbl_801C3284
lbl_801C321C:
addi r3, r1, 0x38
bl __ml__Q24Game12CellIteratorFv
lwz r12, 0(r3)
mr r26, r3
lwz r12, 0x18(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C327C
mr r3, r26
lwz r12, 0(r26)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C327C
lbz r0, 0x2b8(r26)
cmpwi r0, 1
bne lbl_801C3270
addi r28, r28, 1
b lbl_801C327C
lbl_801C3270:
cmpwi r0, 0
bne lbl_801C327C
addi r27, r27, 1
lbl_801C327C:
addi r3, r1, 0x38
bl next__Q24Game12CellIteratorFv
lbl_801C3284:
addi r3, r1, 0x38
bl isDone__Q24Game12CellIteratorFv
clrlwi. r0, r3, 0x18
beq lbl_801C321C
cmpw r27, r28
ble lbl_801C32A0
li r29, 1
lbl_801C32A0:
subfic r0, r29, 1
slwi r3, r29, 2
slwi r0, r0, 2
lfs f0, lbl_80519528@sda21(r2)
add r4, r31, r3
lfs f31, lbl_80519524@sda21(r2)
add r3, r31, r0
lfs f2, 0x370(r4)
lfs f1, 0x370(r3)
fsubs f2, f2, f1
fcmpo cr0, f2, f0
ble lbl_801C32E4
lwz r3, 0x10(r30)
fmr f31, f0
addi r0, r3, 2
stw r0, 0x10(r30)
b lbl_801C334C
lbl_801C32E4:
lfs f0, lbl_805194AC@sda21(r2)
fcmpo cr0, f2, f0
ble lbl_801C3304
lwz r3, 0x10(r30)
fmr f31, f0
addi r0, r3, 1
stw r0, 0x10(r30)
b lbl_801C334C
lbl_801C3304:
lfs f1, lbl_8051952C@sda21(r2)
fcmpo cr0, f2, f1
ble lbl_801C3314
b lbl_801C334C
lbl_801C3314:
lfs f0, lbl_80519530@sda21(r2)
fcmpo cr0, f2, f0
bgt lbl_801C334C
lfs f0, lbl_80519534@sda21(r2)
fcmpo cr0, f2, f0
ble lbl_801C3334
fmr f31, f1
b lbl_801C334C
lbl_801C3334:
lfs f0, lbl_80519538@sda21(r2)
fcmpo cr0, f2, f0
ble lbl_801C3348
lfs f31, lbl_8051953C@sda21(r2)
b lbl_801C334C
lbl_801C3348:
lfs f31, lbl_80519540@sda21(r2)
lbl_801C334C:
bl rand
xoris r4, r3, 0x8000
lis r0, 0x4330
stw r4, 0x84(r1)
lfd f2, lbl_805194C8@sda21(r2)
stw r0, 0x80(r1)
lfs f0, lbl_805194F0@sda21(r2)
lfd f1, 0x80(r1)
fsubs f1, f1, f2
fdivs f0, f1, f0
fcmpo cr0, f0, f31
bgt lbl_801C33B8
lwz r3, 0x32c(r31)
li r27, 0
lwz r3, 0x24(r3)
addi r26, r3, -1
b lbl_801C33A8
lbl_801C3390:
lwz r3, 0x32c(r31)
mr r4, r26
lbz r6, 0x14(r30)
addi r5, r30, 4
bl "birth__Q34Game6VsGame7TekiMgrFiR10Vector3<f>b"
addi r27, r27, 1
lbl_801C33A8:
lwz r0, 0x10(r30)
cmpw r27, r0
blt lbl_801C3390
li r3, 1
lbl_801C33B8:
psq_l f31, 168(r1), 0, qr0
lfd f31, 0xa0(r1)
lmw r26, 0x88(r1)
lwz r0, 0xb4(r1)
mtlr r0
addi r1, r1, 0xb0
blr
*/
}
/*
* --INFO--
* Address: 801C33D4
* Size: 00001C
*/
void GameMessageVsPikminDead::actVs(Game::VsGameSection*)
{
/*
li r0, 0
li r3, 1
stb r0, 0x205(r4)
lwz r5, 0x208(r4)
addi r0, r5, 1
stw r0, 0x208(r4)
blr
*/
}
/*
* --INFO--
* Address: 801C33F0
* Size: 00007C
*/
void GameMessageVsGotCard::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
mr r30, r3
lwz r0, 4(r3)
lwz r4, 0x330(r4)
mulli r3, r0, 0x70
addi r3, r3, 0x18
add r3, r4, r3
lbz r0, 0x18(r3)
cmplwi r0, 0
bne lbl_801C3444
lwz r3, 0x58(r3)
addis r0, r3, 0
cmplwi r0, 0xffff
beq lbl_801C3444
mr r3, r31
bl useCard__Q24Game13VsGameSectionFv
lbl_801C3444:
lwz r3, 0x330(r31)
lwz r4, 4(r30)
bl gotPlayerCard__Q34Game6VsGame7CardMgrFi
lwz r0, 0x14(r1)
li r3, 1
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C346C
* Size: 0000A8
*/
void GameMessageVsUseCard::actVs(Game::VsGameSection*)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r4
stw r30, 8(r1)
mr r30, r3
lwz r3, 0x180(r4)
cmplwi r3, 0
beq lbl_801C34B4
lwz r12, 0(r3)
lwz r12, 0x48(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
bne lbl_801C34B4
li r3, 0
b lbl_801C34FC
lbl_801C34B4:
lis r3, gGameConfig__4Game@ha
addi r3, r3, gGameConfig__4Game@l
lwz r0, 0x1b8(r3)
cmpwi r0, 0
bne lbl_801C34EC
lwz r3, 0x330(r31)
lwz r4, 4(r30)
lwz r5, 0x32c(r31)
bl usePlayerCard__Q34Game6VsGame7CardMgrFiPQ34Game6VsGame7TekiMgr
clrlwi. r0, r3, 0x18
beq lbl_801C34F8
mr r3, r31
bl useCard__Q24Game13VsGameSectionFv
b lbl_801C34F8
lbl_801C34EC:
lwz r3, 0x330(r31)
lwz r4, 4(r30)
bl stopSlot__Q34Game6VsGame7CardMgrFi
lbl_801C34F8:
li r3, 1
lbl_801C34FC:
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C3514
* Size: 000008
*/
u32 VsGame::State::isCardUsable(Game::VsGameSection*) { return 0x0; }
/*
* --INFO--
* Address: ........
* Size: 000170
*/
void VsGameSection::createCardPellet(void)
{
// UNUSED FUNCTION
}
/*
* --INFO--
* Address: 801C351C
* Size: 000010
*/
void setComeAlive__Q24Game49FixedSizePelletMgr<Game::PelletOtakara::Object> Fi(void)
{
/*
.loc_0x0:
lwz r3, 0x9C(r3)
li r0, 0
stbx r0, r3, r4
blr
*/
}
/*
* --INFO--
* Address: 801C352C
* Size: 000190
*/
void VsGameSection::initCardPellets(void)
{
/*
stwu r1, -0x60(r1)
mflr r0
stw r0, 0x64(r1)
li r0, 0xa
stmw r27, 0x4c(r1)
mr r30, r3
stw r0, 0x3cc(r3)
lis r3, lbl_8047FF98@ha
addi r31, r3, lbl_8047FF98@l
lwz r0, 0x3cc(r30)
slwi r3, r0, 2
bl __nwa__FUl
stw r3, 0x3d0(r30)
lis r3, __vt__Q24Game15CreatureInitArg@ha
addi r0, r3, __vt__Q24Game15CreatureInitArg@l
li r7, 0
lis r3, __vt__Q24Game13PelletInitArg@ha
stw r0, 0x18(r1)
li r0, -1
li r6, 0xff
addi r3, r3, __vt__Q24Game13PelletInitArg@l
li r5, 1
stw r3, 0x18(r1)
addi r4, r1, 8
lwz r3, cCoin__13VsOtakaraName@sda21(r13)
stb r7, 0x34(r1)
sth r7, 0x2c(r1)
stb r6, 0x2e(r1)
stw r7, 0x30(r1)
stb r7, 0x2f(r1)
stb r5, 0x1c(r1)
stb r7, 0x35(r1)
stw r0, 0x3c(r1)
stw r0, 0x38(r1)
stb r7, 0x36(r1)
stb r7, 0x37(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r29, r3, r3
bne lbl_801C35DC
addi r3, r31, 0x5c
addi r5, r31, 0x70
li r4, 0x704
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C35DC:
lha r4, 0x258(r29)
li r0, 1
lwz r3, 8(r1)
li r27, 0
stw r4, 0x28(r1)
li r28, 0
lwz r4, 0x40(r29)
stw r4, 0x20(r1)
stb r3, 0x2e(r1)
stw r0, 0x38(r1)
stw r0, 0x3c(r1)
b lbl_801C366C
lbl_801C360C:
lwz r3, pelletMgr__4Game@sda21(r13)
addi r4, r1, 0x18
bl birth__Q24Game9PelletMgrFPQ24Game13PelletInitArg
or. r29, r3, r3
beq lbl_801C3650
lfs f0, lbl_805194A8@sda21(r2)
addi r4, r1, 0xc
li r5, 0
stfs f0, 0xc(r1)
stfs f0, 0x10(r1)
stfs f0, 0x14(r1)
lwz r6, 0x3d0(r30)
stwx r29, r6, r28
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
lwz r3, 0x3d0(r30)
stwx r29, r3, r28
b lbl_801C3664
lbl_801C3650:
addi r3, r31, 0x5c
addi r5, r31, 0x16c
li r4, 0x715
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3664:
addi r28, r28, 4
addi r27, r27, 1
lbl_801C366C:
lwz r0, 0x3cc(r30)
cmpw r27, r0
blt lbl_801C360C
li r27, 0
li r28, 0
b lbl_801C369C
lbl_801C3684:
lwz r3, 0x3d0(r30)
li r4, 0
lwzx r3, r3, r28
bl kill__Q24Game8CreatureFPQ24Game15CreatureKillArg
addi r28, r28, 4
addi r27, r27, 1
lbl_801C369C:
lwz r0, 0x3cc(r30)
cmpw r27, r0
blt lbl_801C3684
lmw r27, 0x4c(r1)
lwz r0, 0x64(r1)
mtlr r0
addi r1, r1, 0x60
blr
*/
}
/*
* --INFO--
* Address: 801C36BC
* Size: 000014
*/
void VsGameSection::initCardGeneration(void)
{
/*
li r0, 0
lfs f0, lbl_80519544@sda21(r2)
stw r0, 0x3c4(r3)
stfs f0, 0x3c8(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C36D0
* Size: 0002D8
*/
void VsGameSection::updateCardGeneration(void)
{
/*
stwu r1, -0x50(r1)
mflr r0
stw r0, 0x54(r1)
stfd f31, 0x40(r1)
psq_st f31, 72(r1), 0, qr0
stfd f30, 0x30(r1)
psq_st f30, 56(r1), 0, qr0
stmw r27, 0x1c(r1)
mr r29, r3
lfs f4, lbl_80519524@sda21(r2)
lfs f3, 0x378(r3)
li r31, 0
lfs f2, 0x37c(r3)
li r30, 5
lfs f1, 0x370(r3)
lfs f0, 0x374(r3)
fsubs f2, f3, f2
lfs f31, lbl_80519548@sda21(r2)
fsubs f0, f1, f0
lfs f30, lbl_8051954C@sda21(r2)
fsubs f6, f2, f0
fabs f0, f6
frsp f5, f0
fcmpo cr0, f5, f4
blt lbl_801C37D8
fcmpo cr0, f4, f5
cror 2, 0, 2
mfcr r0
lis r3, 0x4330
rlwinm r0, r0, 3, 0x1f, 0x1f
stw r3, 0x10(r1)
lfd f3, lbl_80519568@sda21(r2)
stw r0, 0x14(r1)
lfd f0, 0x10(r1)
fsubs f0, f0, f3
fcmpo cr0, f0, f31
bge lbl_801C3778
lfs f31, lbl_80519550@sda21(r2)
li r30, 5
lfs f30, lbl_805194AC@sda21(r2)
li r31, 1
b lbl_801C37D8
lbl_801C3778:
fcmpo cr0, f31, f5
fmr f2, f31
cror 2, 0, 2
mfcr r0
stw r3, 0x10(r1)
rlwinm r0, r0, 3, 0x1f, 0x1f
lfs f0, lbl_80519528@sda21(r2)
stw r0, 0x14(r1)
lfd f1, 0x10(r1)
fsubs f1, f1, f3
fcmpo cr0, f1, f0
bge lbl_801C37BC
fmr f31, f4
li r30, 6
fmr f30, f2
li r31, 1
b lbl_801C37D8
lbl_801C37BC:
fcmpo cr0, f0, f5
cror 2, 0, 2
bne lbl_801C37D8
fmr f31, f4
li r30, 7
fmr f30, f2
li r31, 1
lbl_801C37D8:
lfs f0, lbl_805194A8@sda21(r2)
fcmpo cr0, f6, f0
bge lbl_801C37F4
fmr f1, f31
lfs f0, lbl_805194B8@sda21(r2)
fsubs f31, f0, f30
fsubs f30, f0, f1
lbl_801C37F4:
clrlwi. r0, r31, 0x18
bne lbl_801C3894
lfs f2, 0x364(r29)
lfs f0, 0x360(r29)
lfs f1, lbl_805194AC@sda21(r2)
fsubs f3, f2, f0
lfs f0, lbl_8051952C@sda21(r2)
fmuls f3, f3, f1
fabs f2, f3
frsp f2, f2
fcmpo cr0, f2, f0
cror 2, 0, 2
beq lbl_801C3894
lfs f0, lbl_80519524@sda21(r2)
fcmpo cr0, f2, f0
bge lbl_801C3840
lfs f31, lbl_80519548@sda21(r2)
lfs f30, lbl_80519554@sda21(r2)
b lbl_801C3878
lbl_801C3840:
fcmpo cr0, f2, f1
bge lbl_801C3854
fmr f30, f1
lfs f31, lbl_80519548@sda21(r2)
b lbl_801C3878
lbl_801C3854:
lfs f0, lbl_805194B8@sda21(r2)
fcmpo cr0, f2, f0
bge lbl_801C3878
lfs f0, lbl_80519558@sda21(r2)
fmr f30, f1
lfs f31, lbl_80519550@sda21(r2)
fcmpo cr0, f2, f0
ble lbl_801C3878
li r30, 5
lbl_801C3878:
lfs f0, lbl_805194A8@sda21(r2)
fcmpo cr0, f3, f0
bge lbl_801C3894
fmr f1, f31
lfs f0, lbl_805194B8@sda21(r2)
fsubs f31, f0, f30
fsubs f30, f0, f1
lbl_801C3894:
li r28, 0
li r27, 0
stw r28, 0x3c4(r29)
b lbl_801C38D8
lbl_801C38A4:
lwz r3, 0x3d0(r29)
lwzx r3, r3, r28
lwz r12, 0(r3)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C38D0
lwz r3, 0x3c4(r29)
addi r0, r3, 1
stw r0, 0x3c4(r29)
lbl_801C38D0:
addi r28, r28, 4
addi r27, r27, 1
lbl_801C38D8:
lwz r0, 0x3cc(r29)
cmpw r27, r0
blt lbl_801C38A4
lwz r3, 0x3c4(r29)
cmpwi r3, 4
blt lbl_801C3900
clrlwi. r0, r31, 0x18
beq lbl_801C3984
cmpw r3, r30
bge lbl_801C3984
lbl_801C3900:
lwz r3, sys@sda21(r13)
clrlwi. r0, r31, 0x18
lfs f2, 0x54(r3)
beq lbl_801C3918
lfs f0, lbl_8051955C@sda21(r2)
fmuls f2, f2, f0
lbl_801C3918:
lfs f1, 0x3c8(r29)
lfs f0, lbl_805194A8@sda21(r2)
fsubs f1, f1, f2
stfs f1, 0x3c8(r29)
lfs f1, 0x3c8(r29)
fcmpo cr0, f1, f0
cror 2, 0, 2
bne lbl_801C3984
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0x14(r1)
mr r3, r29
lfd f3, lbl_805194C8@sda21(r2)
addi r4, r1, 8
stw r0, 0x10(r1)
lfs f2, lbl_805194F0@sda21(r2)
lfd f0, 0x10(r1)
lfs f1, lbl_80519560@sda21(r2)
fsubs f3, f0, f3
lfs f0, lbl_8051951C@sda21(r2)
fdivs f2, f3, f2
fmadds f0, f1, f2, f0
stfs f0, 0x3c8(r29)
stfs f31, 8(r1)
stfs f30, 0xc(r1)
bl dropCard__Q24Game13VsGameSectionFRQ34Game13VsGameSection11DropCardArg
lbl_801C3984:
psq_l f31, 72(r1), 0, qr0
lfd f31, 0x40(r1)
psq_l f30, 56(r1), 0, qr0
lfd f30, 0x30(r1)
lmw r27, 0x1c(r1)
lwz r0, 0x54(r1)
mtlr r0
addi r1, r1, 0x50
blr
*/
}
/*
* --INFO--
* Address: 801C39A8
* Size: 000018
*/
void VsGameSection::useCard(void)
{
/*
lwz r4, 0x3c4(r3)
cmpwi r4, 0
blelr
addi r0, r4, -1
stw r0, 0x3c4(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C39C0
* Size: 0003F4
*/
void VsGameSection::dropCard(Game::VsGameSection::DropCardArg&)
{
/*
stwu r1, -0xf0(r1)
mflr r0
stw r0, 0xf4(r1)
stfd f31, 0xe0(r1)
psq_st f31, 232(r1), 0, qr0
stw r31, 0xdc(r1)
stw r30, 0xd8(r1)
stw r29, 0xd4(r1)
stw r28, 0xd0(r1)
mr r5, r4
mr r30, r3
lwz r3, randMapMgr__Q24Game4Cave@sda21(r13)
addi r4, r1, 0x28
lfs f1, 0(r5)
lfs f2, 4(r5)
bl "getItemDropPosition__Q34Game4Cave10RandMapMgrFR10Vector3<f>ff"
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0xac(r1)
lfd f3, lbl_805194C8@sda21(r2)
stw r0, 0xa8(r1)
lfs f1, lbl_805194F0@sda21(r2)
lfd f2, 0xa8(r1)
lfs f0, lbl_80519520@sda21(r2)
fsubs f2, f2, f3
fdivs f1, f2, f1
fmuls f31, f0, f1
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0xb4(r1)
lfd f3, lbl_805194C8@sda21(r2)
stw r0, 0xb0(r1)
lfs f2, lbl_805194F0@sda21(r2)
lfd f0, 0xb0(r1)
lfs f1, lbl_805194FC@sda21(r2)
fsubs f3, f0, f3
lfs f0, lbl_805194A8@sda21(r2)
fdivs f2, f3, f2
fmuls f3, f1, f2
fmr f1, f3
fcmpo cr0, f3, f0
bge lbl_801C3A74
fneg f1, f3
lbl_801C3A74:
lfs f2, lbl_8051950C@sda21(r2)
lis r3, sincosTable___5JMath@ha
lfs f0, lbl_805194A8@sda21(r2)
addi r4, r3, sincosTable___5JMath@l
fmuls f1, f1, f2
lfs f4, 0x28(r1)
fcmpo cr0, f3, f0
fctiwz f0, f1
stfd f0, 0xb8(r1)
lwz r0, 0xbc(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
add r3, r4, r0
lfs f0, 4(r3)
fmuls f5, f31, f0
bge lbl_801C3AD4
lfs f0, lbl_80519510@sda21(r2)
fmuls f0, f3, f0
fctiwz f0, f0
stfd f0, 0xc0(r1)
lwz r0, 0xc4(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r4, r0
fneg f0, f0
b lbl_801C3AEC
lbl_801C3AD4:
fmuls f0, f3, f2
fctiwz f0, f0
stfd f0, 0xc8(r1)
lwz r0, 0xcc(r1)
rlwinm r0, r0, 3, 0x12, 0x1c
lfsx f0, r4, r0
lbl_801C3AEC:
fmuls f3, f31, f0
li r7, 0
lfs f0, 0x30(r1)
li r0, -1
lis r3, __vt__Q24Game15CreatureInitArg@ha
lfs f2, 0x2c(r1)
lfs f1, lbl_805194A8@sda21(r2)
fadds f3, f4, f3
fadds f0, f0, f5
addi r4, r3, __vt__Q24Game15CreatureInitArg@l
fadds f1, f2, f1
lis r3, __vt__Q24Game13PelletInitArg@ha
li r6, 0xff
li r5, 1
stw r4, 0x4c(r1)
addi r8, r3, __vt__Q24Game13PelletInitArg@l
lwz r3, cCoin__13VsOtakaraName@sda21(r13)
addi r4, r1, 8
stfs f3, 0x28(r1)
stfs f1, 0x2c(r1)
stfs f0, 0x30(r1)
stw r8, 0x4c(r1)
stb r7, 0x68(r1)
sth r7, 0x60(r1)
stb r6, 0x62(r1)
stw r7, 0x64(r1)
stb r7, 0x63(r1)
stb r5, 0x50(r1)
stb r7, 0x69(r1)
stw r0, 0x70(r1)
stw r0, 0x6c(r1)
stb r7, 0x6a(r1)
stb r7, 0x6b(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r31, r3, r3
bne lbl_801C3B98
lis r3, lbl_8047FFF4@ha
lis r5, lbl_80480008@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x6df
addi r5, r5, lbl_80480008@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3B98:
lha r4, 0x258(r31)
li r29, 0
lwz r3, 8(r1)
li r0, 1
stw r4, 0x5c(r1)
mr r28, r29
lwz r4, 0x40(r31)
stw r4, 0x54(r1)
stb r3, 0x62(r1)
stb r0, 0x68(r1)
stw r0, 0x6c(r1)
stw r0, 0x70(r1)
b lbl_801C3C30
lbl_801C3BCC:
lwz r3, 0x3d0(r30)
lwzx r31, r3, r28
mr r3, r31
lwz r12, 0(r31)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
bne lbl_801C3C28
mr r3, r31
bl getStateID__Q24Game6PelletFv
cmpwi r3, 0
bne lbl_801C3C28
lwz r3, mgr__Q24Game13PelletOtakara@sda21(r13)
lwz r4, 0x440(r31)
lwz r12, 0(r3)
lwz r12, 0x4c(r12)
mtctr r12
bctrl
mr r3, r31
addi r4, r1, 0x4c
bl init__Q24Game8CreatureFPQ24Game15CreatureInitArg
b lbl_801C3C40
lbl_801C3C28:
addi r28, r28, 4
addi r29, r29, 1
lbl_801C3C30:
lwz r0, 0x3cc(r30)
cmpw r29, r0
blt lbl_801C3BCC
li r31, 0
lbl_801C3C40:
cmplwi r31, 0
beq lbl_801C3D54
lfs f1, 0x2c(r1)
mr r3, r31
lfs f0, lbl_80519570@sda21(r2)
addi r4, r1, 0x28
li r5, 0
fadds f0, f1, f0
stfs f0, 0x2c(r1)
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
lwz r5, 0x28(r1)
lis r6, __vt__Q23efx5TBase@ha
lwz r0, 0x2c(r1)
lis r3, __vt__Q23efx3Arg@ha
lwz r4, 0x30(r1)
addi r8, r6, __vt__Q23efx5TBase@l
stw r5, 0x10(r1)
addi r6, r3, __vt__Q23efx3Arg@l
lfs f0, lbl_805194B8@sda21(r2)
lis r5, __vt__Q23efx13TEnemyApsmoke@ha
stw r0, 0x14(r1)
lis r3, __vt__Q23efx12ArgEnemyType@ha
lfs f3, 0x10(r1)
li r0, 1
stw r4, 0x18(r1)
addi r7, r5, __vt__Q23efx13TEnemyApsmoke@l
lfs f2, 0x14(r1)
addi r5, r3, __vt__Q23efx12ArgEnemyType@l
stw r8, 0xc(r1)
addi r3, r1, 0xc
lfs f1, 0x18(r1)
addi r4, r1, 0x34
stw r6, 0x34(r1)
stw r7, 0xc(r1)
stfs f3, 0x38(r1)
stfs f2, 0x3c(r1)
stfs f1, 0x40(r1)
stw r5, 0x34(r1)
stw r0, 0x44(r1)
stfs f0, 0x48(r1)
bl create__Q23efx13TEnemyApsmokeFPQ23efx3Arg
bl rand
xoris r3, r3, 0x8000
lis r0, 0x4330
stw r3, 0xcc(r1)
lis r3, "zero__10Vector3<f>"@ha
lfs f1, lbl_805194A8@sda21(r2)
addi r4, r3, "zero__10Vector3<f>"@l
stw r0, 0xc8(r1)
addi r3, r1, 0x74
lfd f3, lbl_805194C8@sda21(r2)
addi r5, r1, 0x1c
lfd f0, 0xc8(r1)
lfs f2, lbl_805194F0@sda21(r2)
fsubs f3, f0, f3
lfs f0, lbl_805194FC@sda21(r2)
stfs f1, 0x1c(r1)
fdivs f2, f3, f2
stfs f1, 0x24(r1)
fmuls f0, f0, f2
stfs f0, 0x20(r1)
bl "makeTR__7MatrixfFR10Vector3<f>R10Vector3<f>"
mr r3, r31
addi r4, r1, 0x74
bl setOrientation__Q24Game6PelletFR7Matrixf
lwz r3, 0x3c4(r30)
addi r0, r3, 1
stw r0, 0x3c4(r30)
b lbl_801C3D8C
lbl_801C3D54:
li r29, 0
li r28, 0
b lbl_801C3D80
lbl_801C3D60:
lwz r3, 0x3d0(r30)
lwzx r3, r3, r28
lwz r12, 0(r3)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
addi r28, r28, 4
addi r29, r29, 1
lbl_801C3D80:
lwz r0, 0x3cc(r30)
cmpw r29, r0
blt lbl_801C3D60
lbl_801C3D8C:
psq_l f31, 232(r1), 0, qr0
lwz r0, 0xf4(r1)
lfd f31, 0xe0(r1)
lwz r31, 0xdc(r1)
lwz r30, 0xd8(r1)
lwz r29, 0xd4(r1)
lwz r28, 0xd0(r1)
mtlr r0
addi r1, r1, 0xf0
blr
*/
}
/*
* --INFO--
* Address: 801C3DB4
* Size: 0001AC
*/
void VsGameSection::createYellowBedamas(int)
{
/*
stwu r1, -0x2b0(r1)
mflr r0
stw r0, 0x2b4(r1)
stmw r27, 0x29c(r1)
mr r30, r3
lis r3, lbl_8047FF98@ha
mr r31, r4
addi r28, r3, lbl_8047FF98@l
lwz r5, 0x33c(r30)
cmplwi r5, 0
beq lbl_801C3DF8
lwz r31, 0xb0(r5)
cmpwi r31, 0
beq lbl_801C3F4C
cmpwi r31, 7
blt lbl_801C3DF8
li r31, 7
lbl_801C3DF8:
lis r3, __vt__Q24Game15CreatureInitArg@ha
li r7, 0
addi r4, r3, __vt__Q24Game15CreatureInitArg@l
li r0, -1
lis r3, __vt__Q24Game13PelletInitArg@ha
stw r4, 0x18(r1)
addi r3, r3, __vt__Q24Game13PelletInitArg@l
li r6, 0xff
li r5, 1
stw r3, 0x18(r1)
lwz r3, cBedamaYellow__13VsOtakaraName@sda21(r13)
addi r4, r1, 8
stb r7, 0x34(r1)
sth r7, 0x2c(r1)
stb r6, 0x2e(r1)
stw r7, 0x30(r1)
stb r7, 0x2f(r1)
stb r5, 0x1c(r1)
stb r7, 0x35(r1)
stw r0, 0x3c(r1)
stw r0, 0x38(r1)
stb r7, 0x36(r1)
stb r7, 0x37(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r29, r3, r3
bne lbl_801C3E74
addi r3, r28, 0x5c
addi r5, r28, 0x70
li r4, 0x86a
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3E74:
lha r0, 0x258(r29)
cmpwi r31, 0x32
lwz r4, 8(r1)
li r3, 1
stw r0, 0x28(r1)
li r0, 8
lwz r5, 0x40(r29)
stw r5, 0x20(r1)
stb r4, 0x2e(r1)
stw r3, 0x38(r1)
stw r0, 0x3c(r1)
ble lbl_801C3EBC
mr r6, r31
addi r3, r28, 0x5c
addi r5, r28, 0x17c
li r4, 0x873
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C3EBC:
lis r4, "__ct__10Vector3<f>Fv"@ha
addi r3, r1, 0x40
addi r4, r4, "__ct__10Vector3<f>Fv"@l
li r5, 0
li r6, 0xc
li r7, 0x32
bl __construct_array
lwz r3, randMapMgr__Q24Game4Cave@sda21(r13)
mr r5, r31
lfs f1, lbl_80519548@sda21(r2)
addi r4, r1, 0x40
lfs f2, lbl_8051954C@sda21(r2)
bl "getItemDropPosition__Q34Game4Cave10RandMapMgrFP10Vector3<f>iff"
mr r29, r30
addi r28, r1, 0x40
li r27, 0
b lbl_801C3F44
lbl_801C3F00:
lwz r3, pelletMgr__4Game@sda21(r13)
addi r4, r1, 0x18
bl birth__Q24Game9PelletMgrFPQ24Game13PelletInitArg
lfs f2, 0(r28)
mr r30, r3
lfs f1, 4(r28)
addi r4, r1, 0xc
lfs f0, 8(r28)
li r5, 0
stfs f2, 0xc(r1)
stfs f1, 0x10(r1)
stfs f0, 0x14(r1)
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
stw r30, 0x388(r29)
addi r28, r28, 0xc
addi r29, r29, 4
addi r27, r27, 1
lbl_801C3F44:
cmpw r27, r31
blt lbl_801C3F00
lbl_801C3F4C:
lmw r27, 0x29c(r1)
lwz r0, 0x2b4(r1)
mtlr r0
addi r1, r1, 0x2b0
blr
*/
}
} // namespace Game
/*
* --INFO--
* Address: 801C3F60
* Size: 00014C
*/
void createRedBlueBedamas__Q24Game13VsGameSectionFR10Vector3f(void)
{
/*
stwu r1, -0x60(r1)
mflr r0
lis r5, __vt__Q24Game15CreatureInitArg@ha
stw r0, 0x64(r1)
stmw r26, 0x48(r1)
mr r28, r3
addi r29, r1, 0xc
addi r30, r5, __vt__Q24Game15CreatureInitArg@l
li r27, 0
lwz r4, lbl_80520E70@sda21(r2)
lwz r0, lbl_80520E74@sda21(r2)
stw r4, 0xc(r1)
lis r4, __vt__Q24Game13PelletInitArg@ha
lwz r6, cBedamaRed__13VsOtakaraName@sda21(r13)
addi r31, r4, __vt__Q24Game13PelletInitArg@l
stw r0, 0x10(r1)
lwz r0, cBedamaBlue__13VsOtakaraName@sda21(r13)
stw r6, 0xc(r1)
stw r0, 0x10(r1)
lbl_801C3FAC:
stw r30, 0x20(r1)
li r7, 0
li r0, -1
li r6, 0xff
li r5, 1
stw r31, 0x20(r1)
lwz r3, 0(r29)
addi r4, r1, 8
stb r7, 0x3c(r1)
sth r7, 0x34(r1)
stb r6, 0x36(r1)
stw r7, 0x38(r1)
stb r7, 0x37(r1)
stb r5, 0x24(r1)
stb r7, 0x3d(r1)
stw r0, 0x44(r1)
stw r0, 0x40(r1)
stb r7, 0x3e(r1)
stb r7, 0x3f(r1)
bl getConfigAndKind__Q34Game10PelletList3MgrFPcRQ34Game10PelletList5cKind
or. r26, r3, r3
bne lbl_801C4020
lis r3, lbl_8047FFF4@ha
lis r5, lbl_80480008@ha
addi r3, r3, lbl_8047FFF4@l
li r4, 0x8a3
addi r5, r5, lbl_80480008@l
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C4020:
lha r3, 0x258(r26)
li r5, 1
lwz r6, 8(r1)
li r0, 8
stw r3, 0x30(r1)
addi r4, r1, 0x20
lwz r3, pelletMgr__4Game@sda21(r13)
lwz r7, 0x40(r26)
stw r7, 0x28(r1)
stb r6, 0x36(r1)
stw r5, 0x40(r1)
stw r0, 0x44(r1)
bl birth__Q24Game9PelletMgrFPQ24Game13PelletInitArg
mr r0, r3
lwz r3, randMapMgr__Q24Game4Cave@sda21(r13)
lfs f1, lbl_80519524@sda21(r2)
mr r26, r0
lfs f2, lbl_80519528@sda21(r2)
addi r4, r1, 0x14
bl "getItemDropPosition__Q34Game4Cave10RandMapMgrFR10Vector3<f>ff"
mr r3, r26
addi r4, r1, 0x14
li r5, 0
bl "setPosition__Q24Game8CreatureFR10Vector3<f>b"
addi r27, r27, 1
stw r26, 0x380(r28)
cmpwi r27, 2
addi r29, r29, 4
addi r28, r28, 4
blt lbl_801C3FAC
lmw r26, 0x48(r1)
lwz r0, 0x64(r1)
mtlr r0
addi r1, r1, 0x60
blr
*/
}
namespace Game {
/*
* --INFO--
* Address: 801C40AC
* Size: 000814
*/
void VsGameSection::calcVsScores(void)
{
/*
stwu r1, -0x180(r1)
mflr r0
stw r0, 0x184(r1)
stfd f31, 0x170(r1)
psq_st f31, 376(r1), 0, qr0
stfd f30, 0x160(r1)
psq_st f30, 360(r1), 0, qr0
stfd f29, 0x150(r1)
psq_st f29, 344(r1), 0, qr0
stmw r22, 0x128(r1)
mr r29, r3
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
li r4, 1
bl getOnyon__Q34Game9ItemOnyon3MgrFi
stw r3, 0x18(r1)
li r4, 0
lwz r3, mgr__Q24Game9ItemOnyon@sda21(r13)
bl getOnyon__Q34Game9ItemOnyon3MgrFi
addi r31, r1, 0xa8
addi r30, r1, 0x8c
stw r3, 0x1c(r1)
mr r28, r29
mr r27, r31
mr r26, r30
mr r25, r3
li r24, 0
lbl_801C4114:
lwz r23, 0x388(r28)
cmplwi r23, 0
beq lbl_801C4308
mr r3, r23
lwz r12, 0(r23)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C4308
mr r3, r23
bl getStateID__Q24Game6PelletFv
cmpwi r3, 0
bne lbl_801C4308
mr r3, r23
li r22, -1
lwz r12, 0(r23)
lwz r12, 0x204(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C4194
lwz r0, 0x3d4(r23)
cmpwi r0, 1
beq lbl_801C4188
bge lbl_801C4194
cmpwi r0, 0
bge lbl_801C4190
b lbl_801C4194
lbl_801C4188:
li r22, 0
b lbl_801C4194
lbl_801C4190:
li r22, 1
lbl_801C4194:
mr r4, r23
addi r3, r1, 0x80
lwz r12, 0(r23)
lwz r12, 8(r12)
mtctr r12
bctrl
lwz r4, 0x18(r1)
addi r3, r1, 0x74
lfs f30, 0x80(r1)
lwz r12, 0(r4)
lfs f29, 0x88(r1)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x7c(r1)
lfs f1, 0x74(r1)
fsubs f3, f29, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f30, f1
fmuls f1, f3, f3
fmadds f31, f2, f2, f1
fcmpo cr0, f31, f0
ble lbl_801C4200
ble lbl_801C4204
frsqrte f0, f31
fmuls f31, f0, f31
b lbl_801C4204
lbl_801C4200:
fmr f31, f0
lbl_801C4204:
mr r4, r25
addi r3, r1, 0x68
lwz r12, 0(r25)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x70(r1)
lfs f1, 0x68(r1)
fsubs f3, f29, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f30, f1
fmuls f1, f3, f3
fmadds f3, f2, f2, f1
fcmpo cr0, f3, f0
ble lbl_801C4250
ble lbl_801C4254
frsqrte f0, f3
fmuls f3, f0, f3
b lbl_801C4254
lbl_801C4250:
fmr f3, f0
lbl_801C4254:
fadds f1, f31, f3
lfs f0, lbl_805194AC@sda21(r2)
lfs f2, lbl_80519574@sda21(r2)
fdivs f1, f3, f1
fsubs f0, f1, f0
fmuls f1, f2, f0
bl exp
frsp f0, f1
lfs f1, lbl_805194B8@sda21(r2)
lwz r0, 0xb8(r23)
li r3, 0
fadds f0, f1, f0
cmplwi r0, 0
fdivs f3, f1, f0
beq lbl_801C4294
li r3, 1
lbl_801C4294:
clrlwi. r0, r3, 0x18
bne lbl_801C42E8
cmpwi r22, -1
bne lbl_801C42B8
lfs f0, lbl_805194B8@sda21(r2)
stfs f3, 0(r27)
fsubs f0, f0, f3
stfs f0, 0(r26)
b lbl_801C4314
lbl_801C42B8:
cmpwi r22, 0
bne lbl_801C42D0
lfs f0, lbl_805194A8@sda21(r2)
stfs f3, 0(r27)
stfs f0, 0(r26)
b lbl_801C4314
lbl_801C42D0:
lfs f0, lbl_805194B8@sda21(r2)
lfs f1, lbl_805194A8@sda21(r2)
fsubs f0, f0, f3
stfs f1, 0(r27)
stfs f0, 0(r26)
b lbl_801C4314
lbl_801C42E8:
lfs f0, lbl_805194B8@sda21(r2)
lfs f2, lbl_8051952C@sda21(r2)
fsubs f0, f0, f3
fmuls f1, f2, f3
fmuls f0, f2, f0
stfs f1, 0(r27)
stfs f0, 0(r26)
b lbl_801C4314
lbl_801C4308:
lfs f0, lbl_80519578@sda21(r2)
stfs f0, 0(r27)
stfs f0, 0(r26)
lbl_801C4314:
addi r24, r24, 1
addi r27, r27, 4
cmpwi r24, 7
addi r26, r26, 4
addi r28, r28, 4
blt lbl_801C4114
lfs f3, lbl_805194A8@sda21(r2)
mr r7, r29
lfd f4, lbl_805194C8@sda21(r2)
addi r8, r1, 0x10
lfs f2, lbl_8051957C@sda21(r2)
li r9, 0
lfs f1, lbl_80519580@sda21(r2)
lis r3, 0x4330
lbl_801C434C:
lwz r4, 0x3dc(r7)
li r0, 7
stw r3, 0x118(r1)
mr r5, r31
xoris r4, r4, 0x8000
mr r6, r30
stw r4, 0x11c(r1)
lfd f0, 0x118(r1)
fsubs f5, f0, f4
mtctr r0
lbl_801C4374:
cmpwi r9, 0
bne lbl_801C4390
lfs f0, 0(r5)
fcmpo cr0, f0, f3
cror 2, 1, 2
bne lbl_801C4390
fadds f5, f5, f0
lbl_801C4390:
cmpwi r9, 1
bne lbl_801C43AC
lfs f0, 0(r6)
fcmpo cr0, f0, f3
cror 2, 1, 2
bne lbl_801C43AC
fadds f5, f5, f0
lbl_801C43AC:
addi r5, r5, 4
addi r6, r6, 4
bdnz lbl_801C4374
fcmpo cr0, f5, f2
cror 2, 1, 2
bne lbl_801C43C8
fmr f5, f2
lbl_801C43C8:
fmuls f5, f5, f1
addi r9, r9, 1
cmpwi r9, 2
stfs f5, 0(r8)
lfs f0, 0(r8)
addi r8, r8, 4
stfs f0, 0x370(r7)
addi r7, r7, 4
blt lbl_801C434C
lwz r3, lbl_80520E78@sda21(r2)
mr r25, r29
lwz r0, lbl_80520E7C@sda21(r2)
addi r26, r1, 0x18
stw r3, 8(r1)
addi r27, r1, 8
li r22, 0
stw r0, 0xc(r1)
lbl_801C440C:
lwz r4, 0x380(r25)
lwz r23, 0(r26)
cmplwi r4, 0
beq lbl_801C451C
lwz r12, 0(r4)
addi r3, r1, 0x5c
lwz r12, 8(r12)
mtctr r12
bctrl
mr r4, r23
addi r3, r1, 0x50
lwz r12, 0(r23)
lfs f29, 0x5c(r1)
lwz r12, 8(r12)
lfs f30, 0x64(r1)
mtctr r12
bctrl
lfs f0, 0x58(r1)
lfs f1, 0x50(r1)
fsubs f3, f30, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f29, f1
fmuls f1, f3, f3
fmadds f31, f2, f2, f1
fcmpo cr0, f31, f0
ble lbl_801C4484
ble lbl_801C4488
frsqrte f0, f31
fmuls f31, f0, f31
b lbl_801C4488
lbl_801C4484:
fmr f31, f0
lbl_801C4488:
subfic r0, r22, 1
addi r4, r1, 0x18
slwi r0, r0, 2
addi r3, r1, 0x44
lwzx r4, r4, r0
lwz r12, 0(r4)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x4c(r1)
lfs f1, 0x44(r1)
fsubs f3, f30, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f29, f1
fmuls f1, f3, f3
fmadds f1, f2, f2, f1
fcmpo cr0, f1, f0
ble lbl_801C44E0
ble lbl_801C44E4
frsqrte f0, f1
fmuls f1, f0, f1
b lbl_801C44E4
lbl_801C44E0:
fmr f1, f0
lbl_801C44E4:
fadds f1, f31, f1
lfs f0, lbl_805194AC@sda21(r2)
lfs f2, lbl_80519574@sda21(r2)
fdivs f1, f31, f1
fsubs f0, f1, f0
fmuls f1, f2, f0
bl exp
frsp f0, f1
lfs f1, lbl_805194B8@sda21(r2)
fadds f0, f1, f0
fdivs f0, f1, f0
stfs f0, 0(r27)
lfs f0, 0(r27)
stfs f0, 0x378(r25)
lbl_801C451C:
addi r22, r22, 1
addi r26, r26, 4
cmpwi r22, 2
addi r27, r27, 4
addi r25, r25, 4
blt lbl_801C440C
lfs f3, 0x10(r1)
addi r28, r1, 0xec
lfs f0, 0x14(r1)
addi r30, r1, 0xc4
lfs f2, 8(r1)
mr r26, r28
fsubs f1, f3, f0
lfs f4, 0xc(r1)
fsubs f0, f0, f3
mr r27, r30
li r22, 0
li r25, 0
fsubs f1, f1, f2
fsubs f0, f0, f4
fadds f1, f4, f1
fadds f0, f2, f0
stfs f1, 0x358(r29)
stfs f0, 0x35c(r29)
lbl_801C457C:
lwz r3, 0x3d0(r29)
lwzx r23, r3, r25
mr r3, r23
lwz r12, 0(r23)
lwz r12, 0xa8(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C476C
mr r3, r23
bl getStateID__Q24Game6PelletFv
cmpwi r3, 0
bne lbl_801C476C
mr r3, r23
li r24, -1
lwz r12, 0(r23)
lwz r12, 0x204(r12)
mtctr r12
bctrl
clrlwi. r0, r3, 0x18
beq lbl_801C45F8
lwz r0, 0x3d4(r23)
cmpwi r0, 1
beq lbl_801C45EC
bge lbl_801C45F8
cmpwi r0, 0
bge lbl_801C45F4
b lbl_801C45F8
lbl_801C45EC:
li r24, 0
b lbl_801C45F8
lbl_801C45F4:
li r24, 1
lbl_801C45F8:
mr r4, r23
addi r3, r1, 0x38
lwz r12, 0(r23)
lwz r12, 8(r12)
mtctr r12
bctrl
lwz r4, 0x18(r1)
addi r3, r1, 0x2c
lfs f29, 0x38(r1)
lwz r12, 0(r4)
lfs f30, 0x40(r1)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x34(r1)
lfs f1, 0x2c(r1)
fsubs f3, f30, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f29, f1
fmuls f1, f3, f3
fmadds f31, f2, f2, f1
fcmpo cr0, f31, f0
ble lbl_801C4664
ble lbl_801C4668
frsqrte f0, f31
fmuls f31, f0, f31
b lbl_801C4668
lbl_801C4664:
fmr f31, f0
lbl_801C4668:
lwz r4, 0x1c(r1)
addi r3, r1, 0x20
lwz r12, 0(r4)
lwz r12, 8(r12)
mtctr r12
bctrl
lfs f0, 0x28(r1)
lfs f1, 0x20(r1)
fsubs f3, f30, f0
lfs f0, lbl_805194A8@sda21(r2)
fsubs f2, f29, f1
fmuls f1, f3, f3
fmadds f3, f2, f2, f1
fcmpo cr0, f3, f0
ble lbl_801C46B4
ble lbl_801C46B8
frsqrte f0, f3
fmuls f3, f0, f3
b lbl_801C46B8
lbl_801C46B4:
fmr f3, f0
lbl_801C46B8:
fadds f1, f31, f3
lfs f0, lbl_805194AC@sda21(r2)
lfs f2, lbl_80519574@sda21(r2)
fdivs f1, f3, f1
fsubs f0, f1, f0
fmuls f1, f2, f0
bl exp
frsp f0, f1
lfs f1, lbl_805194B8@sda21(r2)
lwz r0, 0xb8(r23)
li r3, 0
fadds f0, f1, f0
cmplwi r0, 0
fdivs f3, f1, f0
beq lbl_801C46F8
li r3, 1
lbl_801C46F8:
clrlwi. r0, r3, 0x18
bne lbl_801C474C
cmpwi r24, -1
bne lbl_801C471C
lfs f0, lbl_805194B8@sda21(r2)
stfs f3, 0(r26)
fsubs f0, f0, f3
stfs f0, 0(r27)
b lbl_801C4778
lbl_801C471C:
cmpwi r24, 0
bne lbl_801C4734
lfs f0, lbl_805194A8@sda21(r2)
stfs f3, 0(r26)
stfs f0, 0(r27)
b lbl_801C4778
lbl_801C4734:
lfs f0, lbl_805194B8@sda21(r2)
lfs f1, lbl_805194A8@sda21(r2)
fsubs f0, f0, f3
stfs f1, 0(r26)
stfs f0, 0(r27)
b lbl_801C4778
lbl_801C474C:
lfs f0, lbl_805194B8@sda21(r2)
lfs f2, lbl_8051952C@sda21(r2)
fsubs f0, f0, f3
fmuls f1, f2, f3
fmuls f0, f2, f0
stfs f1, 0(r26)
stfs f0, 0(r27)
b lbl_801C4778
lbl_801C476C:
lfs f0, lbl_80519578@sda21(r2)
stfs f0, 0(r26)
stfs f0, 0(r27)
lbl_801C4778:
addi r22, r22, 1
addi r26, r26, 4
cmpwi r22, 0xa
addi r27, r27, 4
addi r25, r25, 4
blt lbl_801C457C
lfs f1, lbl_805194A8@sda21(r2)
mr r5, r29
li r6, 0
lbl_801C479C:
fmr f3, f1
li r0, 5
mr r3, r28
mr r4, r30
stfs f1, 0x368(r5)
li r7, 0
mtctr r0
lbl_801C47B8:
cmpwi r6, 0
lfs f4, lbl_805194A8@sda21(r2)
bne lbl_801C47DC
lfs f0, 0(r3)
fcmpo cr0, f0, f4
cror 2, 1, 2
bne lbl_801C47DC
fadds f3, f3, f0
fmr f4, f0
lbl_801C47DC:
cmpwi r6, 1
bne lbl_801C4800
lfs f2, 0(r4)
lfs f0, lbl_805194A8@sda21(r2)
fcmpo cr0, f2, f0
cror 2, 1, 2
bne lbl_801C4800
fadds f3, f3, f2
fmr f4, f2
lbl_801C4800:
lfs f0, 0x368(r5)
fcmpo cr0, f0, f4
cror 2, 0, 2
bne lbl_801C4814
stfs f4, 0x368(r5)
lbl_801C4814:
cmpwi r6, 0
lfs f4, lbl_805194A8@sda21(r2)
bne lbl_801C4838
lfs f0, 4(r3)
fcmpo cr0, f0, f4
cror 2, 1, 2
bne lbl_801C4838
fadds f3, f3, f0
fmr f4, f0
lbl_801C4838:
cmpwi r6, 1
bne lbl_801C485C
lfs f2, 4(r4)
lfs f0, lbl_805194A8@sda21(r2)
fcmpo cr0, f2, f0
cror 2, 1, 2
bne lbl_801C485C
fadds f3, f3, f2
fmr f4, f2
lbl_801C485C:
lfs f0, 0x368(r5)
fcmpo cr0, f0, f4
cror 2, 0, 2
bne lbl_801C4870
stfs f4, 0x368(r5)
lbl_801C4870:
addi r3, r3, 8
addi r4, r4, 8
addi r7, r7, 1
bdnz lbl_801C47B8
addi r6, r6, 1
stfs f3, 0x360(r5)
cmpwi r6, 2
addi r5, r5, 4
blt lbl_801C479C
psq_l f31, 376(r1), 0, qr0
lfd f31, 0x170(r1)
psq_l f30, 360(r1), 0, qr0
lfd f30, 0x160(r1)
psq_l f29, 344(r1), 0, qr0
lfd f29, 0x150(r1)
lmw r22, 0x128(r1)
lwz r0, 0x184(r1)
mtlr r0
addi r1, r1, 0x180
blr
*/
}
/*
* --INFO--
* Address: 801C48C0
* Size: 000018
*/
void VsGameSection::clearGetDopeCount(void)
{
/*
li r0, 0
stw r0, 0x3b0(r3)
stw r0, 0x3ac(r3)
stw r0, 0x3a8(r3)
stw r0, 0x3a4(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C48D8
* Size: 0000D0
*/
void VsGameSection::getGetDopeCount(int, int)
{
/*
stwu r1, -0x20(r1)
mflr r0
stw r0, 0x24(r1)
li r0, 0
stw r31, 0x1c(r1)
stw r30, 0x18(r1)
mr r30, r5
stw r29, 0x14(r1)
or. r29, r4, r4
lis r4, lbl_8047FF98@ha
stw r28, 0x10(r1)
mr r28, r3
addi r31, r4, lbl_8047FF98@l
blt lbl_801C491C
cmpwi r29, 1
bgt lbl_801C491C
li r0, 1
lbl_801C491C:
clrlwi. r0, r0, 0x18
bne lbl_801C493C
mr r6, r29
addi r3, r31, 0x5c
addi r5, r31, 0x188
li r4, 0xa07
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C493C:
cmpwi r30, 0
li r0, 0
blt lbl_801C4954
cmpwi r30, 1
bgt lbl_801C4954
li r0, 1
lbl_801C4954:
clrlwi. r0, r0, 0x18
bne lbl_801C4974
mr r6, r30
addi r3, r31, 0x5c
addi r5, r31, 0x198
li r4, 0xa08
crclr 6
bl panic_f__12JUTExceptionFPCciPCce
lbl_801C4974:
slwi r3, r29, 3
slwi r0, r30, 2
add r3, r3, r0
addi r3, r3, 0x3a4
add r3, r28, r3
lwz r31, 0x1c(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
lwz r28, 0x10(r1)
lwz r0, 0x24(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 801C49A8
* Size: 000010
*/
void VsGameSection::clearGetCherryCount(void)
{
/*
li r0, 0
stw r0, 0x3b8(r3)
stw r0, 0x3b4(r3)
blr
*/
}
/*
* --INFO--
* Address: ........
* Size: 00007C
*/
u32 VsGameSection::getGetCherryCount(int playerIndex)
{
// UNUSED FUNCTION
}
/*
* --INFO--
* Address: 801C49B8
* Size: 000008
*/
bool VsGameSection::challengeDisablePelplant(void) { return false; }
/*
* --INFO--
* Address: 801C49C0
* Size: 000008
*/
bool VsGameSection::player2enabled(void) { return true; }
/*
* --INFO--
* Address: 801C49C8
* Size: 000008
*/
char* VsGameSection::getCaveFilename(void)
{
/*
addi r3, r3, 0x224
blr
*/
}
/*
* --INFO--
* Address: 801C49D0
* Size: 000008
*/
void VsGameSection::getEditorFilename(void)
{
/*
addi r3, r3, 0x2a4
blr
*/
}
/*
* --INFO--
* Address: 801C49D8
* Size: 000008
*/
void VsGameSection::getVsEditNumber(void)
{
/*
lwz r3, 0x328(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C49E0
* Size: 000004
*/
void init__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game13VsGameSection(void) { }
} // namespace Game
/*
* --INFO--
* Address: 801C49E4
* Size: 000064
*/
void create__Q24Game36StateMachine<Game::VsGameSection> Fi(void)
{
/*
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
li r0, 0
stw r31, 0xc(r1)
mr r31, r3
stw r4, 0xc(r3)
stw r0, 8(r3)
lwz r0, 0xc(r3)
slwi r3, r0, 2
bl __nwa__FUl
stw r3, 4(r31)
lwz r0, 0xc(r31)
slwi r3, r0, 2
bl __nwa__FUl
stw r3, 0x10(r31)
lwz r0, 0xc(r31)
slwi r3, r0, 2
bl __nwa__FUl
stw r3, 0x14(r31)
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C4A48
* Size: 00009C
*/
void transit__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game13VsGameSectioniPQ24Game8StateArg(void)
{
/*
.loc_0x0:
stwu r1, -0x20(r1)
mflr r0
stw r0, 0x24(r1)
rlwinm r0,r5,2,0,29
stmw r27, 0xC(r1)
mr r27, r3
mr r28, r4
mr r29, r6
lwz r30, 0x180(r4)
lwz r3, 0x14(r3)
cmplwi r30, 0
lwzx r31, r3, r0
beq- .loc_0x50
mr r3, r30
lwz r12, 0x0(r30)
lwz r12, 0x10(r12)
mtctr r12
bctrl
lwz r0, 0x4(r30)
stw r0, 0x18(r27)
.loc_0x50:
lwz r0, 0xC(r27)
cmpw r31, r0
blt- .loc_0x60
.loc_0x5C:
b .loc_0x5C
.loc_0x60:
lwz r3, 0x4(r27)
rlwinm r0,r31,2,0,29
mr r4, r28
mr r5, r29
lwzx r3, r3, r0
stw r3, 0x180(r28)
lwz r12, 0x0(r3)
lwz r12, 0x8(r12)
mtctr r12
bctrl
lmw r27, 0xC(r1)
lwz r0, 0x24(r1)
mtlr r0
addi r1, r1, 0x20
blr
*/
}
/*
* --INFO--
* Address: 801C4AE4
* Size: 000004
*/
void init__Q24Game32FSMState<Game::VsGameSection> FPQ24Game13VsGameSectionPQ24Game8StateArg(void) { }
/*
* --INFO--
* Address: 801C4AE8
* Size: 000004
*/
void cleanup__Q24Game32FSMState<Game::VsGameSection> FPQ24Game13VsGameSection(void) { }
/*
* --INFO--
* Address: 801C4AEC
* Size: 000084
*/
void registerState__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game32FSMState<Game::VsGameSection>(void)
{
/*
.loc_0x0:
lwz r6, 0x8(r3)
lwz r0, 0xC(r3)
cmpw r6, r0
bgelr-
lwz r5, 0x4(r3)
rlwinm r0,r6,2,0,29
stwx r4, r5, r0
lwz r5, 0x4(r4)
cmpwi r5, 0
blt- .loc_0x34
lwz r0, 0xC(r3)
cmpw r5, r0
blt- .loc_0x3C
.loc_0x34:
li r0, 0
b .loc_0x40
.loc_0x3C:
li r0, 0x1
.loc_0x40:
rlwinm. r0,r0,0,24,31
beqlr-
stw r3, 0x8(r4)
lwz r0, 0x8(r3)
lwz r6, 0x4(r4)
lwz r5, 0x10(r3)
rlwinm r0,r0,2,0,29
stwx r6, r5, r0
lwz r0, 0x4(r4)
lwz r5, 0x8(r3)
lwz r4, 0x14(r3)
rlwinm r0,r0,2,0,29
stwx r5, r4, r0
lwz r4, 0x8(r3)
addi r0, r4, 0x1
stw r0, 0x8(r3)
blr
*/
}
/*
* --INFO--
* Address: 801C4B70
* Size: 000038
*/
void exec__Q24Game36StateMachine<Game::VsGameSection> FPQ24Game13VsGameSection(void)
{
/*
.loc_0x0:
stwu r1, -0x10(r1)
mflr r0
stw r0, 0x14(r1)
lwz r3, 0x180(r4)
cmplwi r3, 0
beq- .loc_0x28
lwz r12, 0x0(r3)
lwz r12, 0xC(r12)
mtctr r12
bctrl
.loc_0x28:
lwz r0, 0x14(r1)
mtlr r0
addi r1, r1, 0x10
blr
*/
}
/*
* --INFO--
* Address: 801C4BA8
* Size: 000004
*/
void exec__Q24Game32FSMState<Game::VsGameSection> FPQ24Game13VsGameSection(void) { }
/*
* --INFO--
* Address: 801C4BAC
* Size: 000028
*/
void __sinit_vsGameSection_cpp(void)
{
/*
lis r4, __float_nan@ha
li r0, -1
lfs f0, __float_nan@l(r4)
lis r3, lbl_804B60E8@ha
stw r0, lbl_80515A88@sda21(r13)
stfsu f0, lbl_804B60E8@l(r3)
stfs f0, lbl_80515A8C@sda21(r13)
stfs f0, 4(r3)
stfs f0, 8(r3)
blr
*/
}
| 21.726418
| 109
| 0.596313
|
projectPiki
|
de6d3617beacfb1559a28d796d311db01954a766
| 687
|
cpp
|
C++
|
CastleDoctrine/gameSource/sharedServerSecret.cpp
|
PhilipLudington/CastleDoctrine
|
443f2b6b0215a6d71515c8887c99b4322965622e
|
[
"Unlicense"
] | 1
|
2020-01-16T00:07:11.000Z
|
2020-01-16T00:07:11.000Z
|
CastleDoctrine/gameSource/sharedServerSecret.cpp
|
PhilipLudington/CastleDoctrine
|
443f2b6b0215a6d71515c8887c99b4322965622e
|
[
"Unlicense"
] | null | null | null |
CastleDoctrine/gameSource/sharedServerSecret.cpp
|
PhilipLudington/CastleDoctrine
|
443f2b6b0215a6d71515c8887c99b4322965622e
|
[
"Unlicense"
] | 2
|
2019-09-17T12:08:20.000Z
|
2020-09-26T00:54:48.000Z
|
// you can replace this string before building the client in order to
// match the shared secret that the server is expecting.
// Please don't abuse your power to do this.
// Remember that this is an indie game made entirely by one guy and being
// run on a shoestring budget server. Making a truly "secure" game, where
// every move happens on the server, would exceed the resources that I had
// available.
// If any mod that you're building might give you a questionable advantage,
// please don't connect to the main server with that mod.
const char *sharedServerSecret = "This is an example secret. You probably cannot connect to the main server without replacing this.";
| 36.157895
| 134
| 0.755459
|
PhilipLudington
|
de70f85d4eeb1240a8026a6a5965668e45e018c7
| 4,633
|
cpp
|
C++
|
Samples/Simple.cpp
|
QtExcel/QSimpleXlsxWriter
|
da96975bfd089fcb779fd871c9075e097a8373c0
|
[
"MIT"
] | 13
|
2019-02-15T06:16:30.000Z
|
2022-02-17T04:58:49.000Z
|
Samples/Simple.cpp
|
umaysahan/QSimpleXlsxWriter
|
da96975bfd089fcb779fd871c9075e097a8373c0
|
[
"MIT"
] | 1
|
2019-01-13T07:12:26.000Z
|
2019-01-13T09:58:27.000Z
|
Samples/Simple.cpp
|
umaysahan/QSimpleXlsxWriter
|
da96975bfd089fcb779fd871c9075e097a8373c0
|
[
"MIT"
] | 6
|
2019-07-19T01:45:48.000Z
|
2021-03-17T09:57:59.000Z
|
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <vector>
#include <Xlsx/Workbook.h>
#ifdef _WIN32
#include <windows.h>
#endif
#ifdef QT_CORE_LIB
#include <QDateTime>
#endif
using namespace SimpleXlsx;
int main()
{
setlocale( LC_ALL, "" );
time_t CurTime = time( NULL );
CWorkbook book( "Incognito" );
std::vector<ColumnWidth> ColWidth;
ColWidth.push_back( ColumnWidth( 0, 3, 25 ) );
CWorksheet & Sheet = book.AddSheet( "Unicode", ColWidth );
Style style;
style.horizAlign = ALIGN_H_CENTER;
style.font.attributes = FONT_BOLD;
const size_t CenterStyleIndex = book.AddStyle( style );
Sheet.BeginRow();
Sheet.AddCell( "Common test of Unicode support", CenterStyleIndex );
Sheet.MergeCells( CellCoord( 1, 0 ), CellCoord( 1, 3 ) );
Sheet.EndRow();
Font TmpFont = book.GetFonts().front();
TmpFont.attributes = FONT_ITALIC;
Comment Com;
Com.x = 300;
Com.y = 100;
Com.width = 100;
Com.height = 30;
Com.cellRef = CellCoord( 8, 1 );
Com.isHidden = false;
Com.AddContent( TmpFont, "Comment with custom style" );
Sheet.AddComment( Com );
Sheet.BeginRow().AddCell( "English language" ).AddCell( "English language" ).EndRow();
Sheet.BeginRow().AddCell( "Russian language" ).AddCell( L"Русский язык" ).EndRow();
Sheet.BeginRow().AddCell( "Chinese language" ).AddCell( L"中文" ).EndRow();
Sheet.BeginRow().AddCell( "French language" ).AddCell( L"le français" ).EndRow();
Sheet.BeginRow().AddCell( "Arabic language" ).AddCell( L"العَرَبِيَّة" ).EndRow();
Sheet.AddEmptyRow();
style.fill.patternType = PATTERN_NONE;
style.font.theme = true;
style.horizAlign = ALIGN_H_RIGHT;
style.vertAlign = ALIGN_V_CENTER;
style.numFormat.numberStyle = NUMSTYLE_MONEY;
const size_t MoneyStyleIndex = book.AddStyle( style );
Sheet.BeginRow().AddCell( "Money symbol" ).AddCell( 123.45, MoneyStyleIndex ).EndRow();
Style stPanel;
stPanel.border.top.style = BORDER_THIN;
stPanel.border.bottom.color = "FF000000";
stPanel.fill.patternType = PATTERN_SOLID;
stPanel.fill.fgColor = "FFCCCCFF";
const size_t PanelStyleIndex = book.AddStyle( stPanel );
Sheet.AddEmptyRow().BeginRow();
Sheet.AddCell( "Cells with border", PanelStyleIndex );
Sheet.AddCell( "", PanelStyleIndex ).AddCell( "", PanelStyleIndex ).AddCell( "", PanelStyleIndex );
Sheet.EndRow();
style.numFormat.numberStyle = NUMSTYLE_DATETIME;
style.font.attributes = FONT_NORMAL;
style.horizAlign = ALIGN_H_LEFT;
const size_t DateTimeStyleIndex = book.AddStyle( style );
Sheet.AddEmptyRow().AddSimpleRow( "time_t", CenterStyleIndex );
Sheet.AddSimpleRow( CellDataTime( CurTime, DateTimeStyleIndex ) );
Style stRotated;
stRotated.horizAlign = EAlignHoriz::ALIGN_H_CENTER;
stRotated.vertAlign = EAlignVert::ALIGN_V_CENTER;
stRotated.textRotation = 45;
const size_t RotatedStyleIndex = book.AddStyle( stRotated );
Sheet.AddSimpleRow( "Rotated text", RotatedStyleIndex, 3, 20 );
Sheet.MergeCells( CellCoord( 14, 3 ), CellCoord( 19, 3 ) );
/* Be careful with the style of date and time.
* If milliseconds are specified, then the style used should take them into account.
* Otherwise, Excel will round milliseconds and may change seconds.
* See example below. */
style.numFormat.formatString = "yyyy.mm.dd hh:mm:ss.000";
const size_t CustomDateTimeStyleIndex = book.AddStyle( style );
Sheet.AddSimpleRow( "Direct date and time", CenterStyleIndex );
Sheet.AddSimpleRow( CellDataTime( 2020, 1, 1, 0, 0, 0, 500, CustomDateTimeStyleIndex ) );
Sheet.AddSimpleRow( CellDataTime( 2020, 1, 1, 0, 0, 0, 500, DateTimeStyleIndex ) );
Sheet.AddSimpleRow( CellDataTime( 2020, 1, 1, 0, 0, 0, 499, CustomDateTimeStyleIndex ) );
Sheet.AddSimpleRow( CellDataTime( 2020, 1, 1, 0, 0, 0, 499, DateTimeStyleIndex ) );
#ifdef _WIN32
Sheet.AddEmptyRow().AddSimpleRow( "Windows SYSTEMTIME", CenterStyleIndex );
SYSTEMTIME lt;
GetLocalTime( & lt );
Sheet.AddSimpleRow( CellDataTime( lt, CustomDateTimeStyleIndex ) );
#endif
#if defined( QT_VERSION ) && ( QT_VERSION >= 0x040000 )
Sheet.AddEmptyRow().AddSimpleRow( "Qt QDateTime", CenterStyleIndex );
const QDateTime CurDT = QDateTime::currentDateTime();
Sheet.AddSimpleRow( CellDataTime( CurDT, CustomDateTimeStyleIndex ) );
#endif
if( book.Save( "Simple.xlsx" ) ) std::cout << "The book has been saved successfully" << std::endl;
else std::cout << "The book saving has been failed" << std::endl;
return 0;
}
| 37.666667
| 103
| 0.690481
|
QtExcel
|
de73b5485234ba8ed43297cd580bd6f40f60d4bd
| 572
|
cc
|
C++
|
atcoder/arc/007/b_maigo_no_cd_case.cc
|
boobam0618/competitive-programming
|
0341bd8bb240b1ed0d84cc60db91508242fc867b
|
[
"MIT"
] | null | null | null |
atcoder/arc/007/b_maigo_no_cd_case.cc
|
boobam0618/competitive-programming
|
0341bd8bb240b1ed0d84cc60db91508242fc867b
|
[
"MIT"
] | 32
|
2019-08-15T09:16:48.000Z
|
2020-02-09T16:23:30.000Z
|
atcoder/arc/007/b_maigo_no_cd_case.cc
|
boobam0618/competitive-programming
|
0341bd8bb240b1ed0d84cc60db91508242fc867b
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <vector>
int main() {
int cd_case_num, listen_cd_num;
std::cin >> cd_case_num >> listen_cd_num;
std::vector<int> cds(cd_case_num);
for (int i = 0; i < cd_case_num; ++i) {
cds.at(i) = i + 1;
}
int current = 0;
for (int i = 0; i < listen_cd_num; ++i) {
int listen_cd;
std::cin >> listen_cd;
for (int j = 0; j < cd_case_num; ++j) {
if (cds.at(j) == listen_cd) {
std::swap(current, cds.at(j));
}
}
}
for (int i = 0; i < cd_case_num; ++i) {
std::cout << cds.at(i) << std::endl;
}
}
| 22
| 43
| 0.536713
|
boobam0618
|
de742378fbcc59e333009e743335a1b22585d443
| 2,594
|
cpp
|
C++
|
outdated/tests/io_copy.cpp
|
pjsaksa/x0
|
96b69e5a54b006e3d929b9934c2708f7967371bb
|
[
"MIT"
] | 24
|
2016-07-10T08:05:11.000Z
|
2021-11-16T10:53:48.000Z
|
outdated/tests/io_copy.cpp
|
pjsaksa/x0
|
96b69e5a54b006e3d929b9934c2708f7967371bb
|
[
"MIT"
] | 14
|
2015-04-12T10:45:26.000Z
|
2016-06-28T22:27:50.000Z
|
outdated/tests/io_copy.cpp
|
pjsaksa/x0
|
96b69e5a54b006e3d929b9934c2708f7967371bb
|
[
"MIT"
] | 4
|
2016-10-05T17:51:38.000Z
|
2020-04-20T07:45:23.000Z
|
// This file is part of the "x0" project, http://xzero.io/
// (c) 2009-2018 Christian Parpart <christian@parpart.family>
//
// Licensed under the MIT License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of
// the License at: http://opensource.org/licenses/MIT
#include <x0/io/source.hpp>
#include <x0/io/fd_source.hpp>
#include <x0/io/file_source.hpp>
#include <x0/io/sink.hpp>
#include <x0/io/file_sink.hpp>
#include <x0/io/filter.hpp>
#include <x0/io/null_filter.hpp>
#include <x0/io/uppercase_filter.hpp>
#include <x0/io/CompressFilter.h>
#include <x0/io/chain_filter.hpp>
#include <x0/io/pump.hpp>
#include <iostream>
#include <memory>
#include <getopt.h>
inline x0::file_ptr getfile(const std::string ifname) {
return x0::file_ptr(new x0::File(x0::FileInfoPtr(new x0::FileInfo(ifname))));
}
int main(int argc, char *argv[]) {
struct option options[] = {{"input", required_argument, 0, 'i'},
{"output", required_argument, 0, 'o'},
{"gzip", no_argument, 0, 'c'},
{"uppercase", no_argument, 0, 'U'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}};
std::string ifname("-");
std::string ofname("-");
x0::chain_filter cf;
for (bool done = false; !done;) {
int index = 0;
int rv = (getopt_long(argc, argv, "i:o:hUc", options, &index));
switch (rv) {
case 'i':
ifname = optarg;
break;
case 'o':
ofname = optarg;
break;
case 'U':
cf.push_back(x0::filter_ptr(new x0::uppercase_filter()));
break;
case 'c':
cf.push_back(x0::filter_ptr(new x0::CompressFilter()));
break;
case 'h':
std::cerr << "usage: " << argv[0] << " INPUT OUTPUT [-u]" << std::endl
<< " where INPUT and OUTPUT can be '-' to be interpreted as "
"stdin/stdout respectively." << std::endl;
return 0;
case 0:
break;
case -1:
done = true;
break;
default:
std::cerr << "syntax error: "
<< "(" << rv << ")" << std::endl;
return 1;
}
}
x0::source_ptr input(ifname == "-" ? new x0::fd_source(STDIN_FILENO)
: new x0::file_source(getfile(ifname)));
x0::sink_ptr output(ofname == "-" ? new x0::fd_sink(STDOUT_FILENO)
: new x0::file_sink(ofname));
pump(*input, *output, cf);
return 0;
}
| 30.162791
| 80
| 0.543562
|
pjsaksa
|
de77a51807f0b0b0d4e3577cd24d13557acf9458
| 324
|
cpp
|
C++
|
pgf+/src/reader/Expr.cpp
|
egladil/mscthesis
|
d6f0c9b1b1e73b749894405372f2edf01e746920
|
[
"BSD-2-Clause"
] | 1
|
2019-05-03T18:00:39.000Z
|
2019-05-03T18:00:39.000Z
|
pgf+/src/reader/Expr.cpp
|
egladil/mscthesis
|
d6f0c9b1b1e73b749894405372f2edf01e746920
|
[
"BSD-2-Clause"
] | null | null | null |
pgf+/src/reader/Expr.cpp
|
egladil/mscthesis
|
d6f0c9b1b1e73b749894405372f2edf01e746920
|
[
"BSD-2-Clause"
] | null | null | null |
//
// Expr.cpp
// pgf+
//
// Created by Emil Djupfeldt on 2012-06-26.
// Copyright (c) 2012 Chalmers University of Technology. All rights reserved.
//
#include <gf/reader/Expr.h>
namespace gf {
namespace reader {
Expr::Expr() {
}
Expr::~Expr() {
}
}
}
| 15.428571
| 78
| 0.509259
|
egladil
|
de7b08cf91b5e5aaed7f68e56832ea58dac9d4de
| 6,995
|
cpp
|
C++
|
src/Ainur/AinurState1.cpp
|
g1257/PsimagLite
|
1cdeb4530c66cd41bd0c59af9ad2ecb1069ca010
|
[
"Unlicense"
] | 8
|
2015-08-19T16:06:52.000Z
|
2021-12-05T02:37:47.000Z
|
src/Ainur/AinurState1.cpp
|
g1257/PsimagLite
|
1cdeb4530c66cd41bd0c59af9ad2ecb1069ca010
|
[
"Unlicense"
] | 5
|
2016-02-02T20:28:21.000Z
|
2019-07-08T22:56:12.000Z
|
src/Ainur/AinurState1.cpp
|
g1257/PsimagLite
|
1cdeb4530c66cd41bd0c59af9ad2ecb1069ca010
|
[
"Unlicense"
] | 5
|
2016-04-29T17:28:00.000Z
|
2019-11-22T03:33:19.000Z
|
#include "AinurState.h"
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include "AinurDoubleOrFloat.h"
namespace PsimagLite {
struct MyProxyFor {
static void convert(long unsigned int& t, std::string str)
{
t = PsimagLite::atoi(str);
}
static void convert(unsigned int& t, std::string str)
{
t = PsimagLite::atoi(str);
}
static void convert(long int& t, std::string str)
{
t = PsimagLite::atoi(str);
}
static void convert(int& t, std::string str)
{
t = PsimagLite::atoi(str);
}
static void convert(double& t, std::string str)
{
t = PsimagLite::atof(str);
}
static void convert(float& t, std::string str)
{
t = PsimagLite::atof(str);
}
template<typename T>
static void convert(std::complex<T>& t, std::string str)
{
t = toComplex<T>(str);
}
static void convert(String& t, std::string str)
{
t = str;
}
template<typename T>
static void convert(T& t, std::string str)
{
String msg("Unknown type ");
throw RuntimeError("convert(): " + msg + typeid(t).name() + " for " + str + "\n");
}
private:
template<typename RealType>
static std::complex<RealType> toComplex(std::string str)
{
typedef std::complex<RealType> ComplexType;
String buffer;
bool flag = false;
const SizeType n = str.length();
RealType real1 = 0;
for (SizeType i = 0; i < n; ++i) {
bool isSqrtMinus1 = (str[i] == 'i');
if (isSqrtMinus1 && flag)
throw RuntimeError("Error parsing number " + str + "\n");
if (isSqrtMinus1) {
flag = true;
real1 = atof(buffer.c_str());
buffer = "";
continue;
}
buffer += str[i];
}
return (flag) ? ComplexType(real1, atof(buffer.c_str())) :
ComplexType(atof(buffer.c_str()), 0);
}
};
//---------
boost::spirit::qi::rule<std::string::iterator,
std::vector<std::string>(),
boost::spirit::qi::space_type>
ruleRows()
{
boost::spirit::qi::rule<std::string::iterator,
std::vector<std::string>(),
boost::spirit::qi::space_type> myrule = "[" >> (+~boost::spirit::qi::char_(",[]"))
% ',' >> "]";
return myrule;
}
//---------
void AinurState::assign(String k, String v)
{
int x = storageIndexByName(k);
if (x < 0)
err(errLabel(ERR_PARSE_UNDECLARED, k));
assert(static_cast<SizeType>(x) < values_.size());
//if (values_[x] != "")
// std::cerr<<"Overwriting label "<<k<<" with "<<v<<"\n";
values_[x] = v;
}
//---------
template <typename T>
template <typename A, typename ContextType>
void AinurState::ActionMatrix<T>::operator()(A& attr,
ContextType&,
bool&) const
{
SizeType rows = attr.size();
if (rows == 0) return;
SizeType cols = attr[0].size();
t_.resize(rows, cols);
for (SizeType i = 0; i < rows; ++i) {
if (attr[i].size() != cols)
err("Ainur: Problem reading matrix\n");
for (SizeType j = 0; j < cols; ++j)
MyProxyFor::convert(t_(i, j), attr[i][j]);
}
}
//---------
template <typename T>
template <typename A, typename ContextType>
void AinurState::Action<T>::operator()(A& attr,
ContextType&,
bool&) const
{
const SizeType n = attr.size();
if (n == 2 && attr[1] == "...") {
const SizeType m = t_.size();
if (m == 0)
err("Cannot use ellipsis for vector of unknown size\n");
MyProxyFor::convert(t_[0], attr[0]);
for (SizeType i = 1; i < m; ++i)
t_[i] = t_[0];
return;
}
if (n == 2 && attr[1].length() > 4 && attr[1].substr(0, 4) == "...x") {
const SizeType m = t_.size();
const SizeType l = attr[1].length();
const SizeType mm = PsimagLite::atoi(attr[1].substr(4, l - 4));
if (m != 0)
std::cout<<"Resizing vector to "<<mm<<"\n";
t_.resize(mm);
MyProxyFor::convert(t_[0], attr[0]);
for (SizeType i = 1; i < mm; ++i)
t_[i] = t_[0];
return;
}
t_.resize(n);
for (SizeType i = 0; i < n; ++i)
MyProxyFor::convert(t_[i], attr[i]);
}
//---------
template<typename T>
void AinurState::convertInternal(Matrix<T>& t,
String value) const
{
namespace qi = boost::spirit::qi;
typedef std::string::iterator IteratorType;
typedef std::vector<std::string> VectorStringType;
typedef std::vector<VectorStringType> VectorVectorVectorType;
IteratorType it = value.begin();
qi::rule<IteratorType, VectorStringType(), qi::space_type> ruRows = ruleRows();
qi::rule<IteratorType, VectorVectorVectorType(), qi::space_type> full =
"[" >> -(ruRows % ",") >> "]";
ActionMatrix<T> actionMatrix("matrix", t);
bool r = qi::phrase_parse(it,
value.end(),
full [actionMatrix],
qi::space);
//check if we have a match
if (!r) {
err("matrix parsing failed near " +
stringContext(it, value.begin(), value.end())
+ "\n");
}
if (it != value.end())
std::cerr << "matrix parsing: unmatched part exists\n";
}
template<typename T>
void AinurState::convertInternal(std::vector<T>& t,
String value,
typename EnableIf<Loki::TypeTraits<T>::isArith ||
IsComplexNumber<T>::True ||
TypesEqual<T, String>::True,
int>::Type) const
{
namespace qi = boost::spirit::qi;
typedef std::string::iterator IteratorType;
typedef std::vector<std::string> VectorStringType;
IteratorType it = value.begin();
qi::rule<IteratorType, VectorStringType(), qi::space_type> ruRows = ruleRows();
Action<T> actionRows("rows", t);
bool r = qi::phrase_parse(it,
value.end(),
ruRows [actionRows],
qi::space);
//check if we have a match
if (!r)
err("vector parsing failed near " + stringContext(it, value.begin(), value.end()) + "\n");
if (it != value.end()) {
std::cerr << "vector parsing: unmatched part exists near ";
std::cerr << stringContext(it, value.begin(), value.end())<<"\n";
}
}
//---------
template void AinurState::convertInternal(Matrix<DoubleOrFloatType>&,String) const;
template void AinurState::convertInternal(Matrix<std::complex<DoubleOrFloatType> >&,
String) const;
template void AinurState::convertInternal(Matrix<String>&, String) const;
template void AinurState::convertInternal(std::vector<DoubleOrFloatType>&, String, int) const;
template void AinurState::convertInternal(std::vector<std::complex<DoubleOrFloatType> >&,
String,
int) const;
template void AinurState::convertInternal(std::vector<SizeType>&, String, int) const;
template void AinurState::convertInternal(std::vector<int>&, String, int) const;
template void AinurState::convertInternal(std::vector<String>&, String, int) const;
} // namespace PsimagLite
| 26.396226
| 94
| 0.59371
|
g1257
|
de7e28964c63dffd7045225e1a0544cf61653e85
| 1,539
|
cpp
|
C++
|
Algorithms/Search/SherlockandArray/Solution.cpp
|
4ngelica/HackerRank
|
61c4269168a9b35c98840e40637fe87c9735356c
|
[
"MIT"
] | 1,122
|
2017-03-22T03:52:28.000Z
|
2022-03-31T06:01:39.000Z
|
Algorithms/Search/SherlockandArray/Solution.cpp
|
4ngelica/HackerRank
|
61c4269168a9b35c98840e40637fe87c9735356c
|
[
"MIT"
] | 100
|
2017-03-15T20:01:28.000Z
|
2021-07-12T14:42:21.000Z
|
Algorithms/Search/SherlockandArray/Solution.cpp
|
4ngelica/HackerRank
|
61c4269168a9b35c98840e40637fe87c9735356c
|
[
"MIT"
] | 799
|
2017-03-19T21:28:30.000Z
|
2022-03-26T16:58:54.000Z
|
/*
Problem : https://www.hackerrank.com/challenges/sherlock-and-array
C++ 14
Approach :
This is quite a straight forward problem. All elements of the input array is
set to the sum of all the elements upto that point of the input array, i.e.
arr[i] = Sum(arr[j]) for 0 <= j <=i < n
Then in an other loop we compare arr[i] and arr[n-1] - arr[i] , which will
turn the answer to be YES, otherwise it is NO.
Time Complexity : O( n ) for each test case.
Overall Time Complexity : O( t*n ) for entire input file.
Space Complextiy : O( n ) for entire input file.
*/
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int test; cin>>test;
int n=100000, i=0, temp=0;
unsigned long long arr[n], sum=0;
while(test--){
for(i=0; i<=100000; i++){
arr[i]=0;
}
cin>>n;
for(i=0; i<n; i++){
cin>>temp;
sum+=temp;
arr[i]=sum;
temp=0;
}
if(n==1){
cout<<"YES\n";
sum=0;
continue;
}
for(i=1; i<n; i++){
if(arr[i-1]==(arr[n-1]-arr[i])){
cout<<"YES\n";
break;
}
else
continue;
}
if(i==n)
cout<<"NO\n";
sum=0;
}
return 0;
}
| 27
| 84
| 0.492528
|
4ngelica
|
de80f917f17f259dc54dffe14f6d3605eb249fb5
| 17,753
|
cpp
|
C++
|
src/drivers/liberatr.cpp
|
gameblabla/mame_nspire
|
83dfe1606aba906bd28608f2cb8f0754492ac3da
|
[
"Unlicense"
] | 33
|
2015-08-10T11:13:47.000Z
|
2021-08-30T10:00:46.000Z
|
src/drivers/liberatr.cpp
|
gameblabla/mame_nspire
|
83dfe1606aba906bd28608f2cb8f0754492ac3da
|
[
"Unlicense"
] | 13
|
2015-08-25T03:53:08.000Z
|
2022-03-30T18:02:35.000Z
|
src/drivers/liberatr.cpp
|
gameblabla/mame_nspire
|
83dfe1606aba906bd28608f2cb8f0754492ac3da
|
[
"Unlicense"
] | 40
|
2015-08-25T05:09:21.000Z
|
2022-02-08T05:02:30.000Z
|
#include "../vidhrdw/liberatr.cpp"
/***************************************************************************
Liberator Memory Map (for the main set, the other one is rearranged)
(from the schematics/manual)
HEX R/W D7 D6 D5 D4 D3 D2 D2 D0 function
---------+-----+------------------------+------------------------
0000 D D D D D D D D XCOORD
0001 D D D D D D D D YCOORD
0002 D D D BIT MODE DATA
---------+-----+------------------------+------------------------
0003-033F D D D D D D D D Working RAM
0340-3D3F D D D D D D D D Screen RAM
3D40-3FFF D D D D D D D D Working RAM
---------+-----+------------------------+------------------------
4000-403F R D D D D D D D D EARD* read from non-volatile memory
---------+-----+------------------------+------------------------
5000 R D coin AUX (CTRLD* set low)
5000 R D coin LEFT (CTRLD* set low)
5000 R D coin RIGHT (CTRLD* set low)
5000 R D SLAM (CTRLD* set low)
5000 R D SPARE (CTRLD* set low)
5000 R D SPARE (CTRLD* set low)
5000 R D COCKTAIL (CTRLD* set low)
5000 R D SELF-TEST (CTRLD* set low)
5000 R D D D D HDIR (CTRLD* set high)
5000 R D D D D VDIR (CTRLD* set high)
---------+-----+------------------------+------------------------
5001 R D SHIELD 2
5001 R D SHIELD 1
5001 R D FIRE 2
5001 R D FIRE 1
5001 R D SPARE (CTRLD* set low)
5001 R D START 2
5001 R D START 1
5001 R D VBLANK
---------+-----+------------------------+------------------------
6000-600F W D D D D base_ram*
6200-621F W D D D D D D D D COLORAM*
6400 W INTACK*
6600 W D D D D EARCON
6800 W D D D D D D D D STARTLG (planet frame)
6A00 W WDOG*
---------+-----+------------------------+------------------------
6C00 W D START LED 1
6C01 W D START LED 2
6C02 W D TBSWP*
6C03 W D SPARE
6C04 W D CTRLD*
6C05 W D COINCNTRR
6C06 W D COINCNTRL
6C07 W D PLANET
---------+-----+------------------------+------------------------
6E00-6E3F W D D D D D D D D EARWR*
7000-701F D D D D D D D D IOS2* (Pokey 2)
7800-781F D D D D D D D D IOS1* (Pokey 1)
8000-EFFF R D D D D D D D D ROM
-----------------------------------------------------------------
Dip switches at D4 on the PCB for play options: (IN2)
LSB D1 D2 D3 D4 D5 D6 MSB
SW8 SW7 SW6 SW5 SW4 SW3 SW2 SW1 Option
-------------------------------------------------------------------------------------
Off Off 4 ships per game <-
On Off 5 ships per game
Off On 6 ships per game
On On 8 ships per game
-------------------------------------------------------------------------------------
Off Off Bonus ship every 15000 points
On Off Bonus ship every 20000 points <-
Off On Bonus ship every 25000 points
On On Bonus ship every 30000 points
-------------------------------------------------------------------------------------
On Off Easy game play
Off Off Normal game play <-
Off On Hard game play
-------------------------------------------------------------------------------------
X X Not used
-------------------------------------------------------------------------------------
Dip switches at A4 on the PCB for price options: (IN3)
LSB D1 D2 D3 D4 D5 D6 MSB
SW8 SW7 SW6 SW5 SW4 SW3 SW2 SW1 Option
-------------------------------------------------------------------------------------
Off Off Free play
On Off 1 coin for 2 credits
Off On 1 coin for 1 credit <-
On On 2 coins for 1 credit
-------------------------------------------------------------------------------------
Off Off Right coin mech X 1 <-
On Off Right coin mech X 4
Off On Right coin mech X 5
On On Right coin mech X 6
-------------------------------------------------------------------------------------
Off Left coin mech X 1 <-
On Left coin mech X 2
-------------------------------------------------------------------------------------
Off Off Off No bonus coins <-
Off On Off For every 4 coins inserted, game logic
adds 1 more coin
On On Off For every 4 coins inserted, game logic
adds 2 more coin
Off Off On For every 5 coins inserted, game logic
adds 1 more coin
On Off On For every 3 coins inserted, game logic
adds 1 more coin
X On On No bonus coins
-------------------------------------------------------------------------------------
<- = Manufacturer's suggested settings
Note:
----
The loop at $cf60 should count down from Y=0 instead of Y=0xff. Because of this the first
four leftmost pixels of each row are not cleared. This bug is masked by the visible area
covering up the offending pixels.
******************************************************************************************/
#include "driver.h"
#include "machine/atari_vg.h"
extern UINT8 *liberatr_base_ram;
extern UINT8 *liberatr_planet_frame;
extern UINT8 *liberatr_planet_select;
extern UINT8 *liberatr_x;
extern UINT8 *liberatr_y;
/* in vidhrdw */
extern unsigned char *liberatr_bitmapram;
int liberatr_vh_start(void);
void liberatr_vh_stop(void);
void liberatr_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
WRITE_HANDLER( liberatr_colorram_w ) ;
WRITE_HANDLER( liberatr_bitmap_w );
READ_HANDLER( liberatr_bitmap_xy_r );
WRITE_HANDLER( liberatr_bitmap_xy_w );
static UINT8 *liberatr_ctrld;
static WRITE_HANDLER( liberatr_led_w )
{
osd_led_w(offset, (data >> 4) & 0x01);
}
static WRITE_HANDLER( liberatr_coin_counter_w )
{
coin_counter_w(offset ^ 0x01, data);
}
static READ_HANDLER( liberatr_input_port_0_r )
{
int res ;
int xdelta, ydelta;
/* CTRLD selects whether we're reading the stick or the coins,
see memory map */
if(*liberatr_ctrld)
{
/* mouse support */
xdelta = input_port_4_r(0);
ydelta = input_port_5_r(0);
res = ( ((ydelta << 4) & 0xf0) | (xdelta & 0x0f) );
}
else
{
res = input_port_0_r(offset);
}
return res;
}
static struct MemoryReadAddress liberatr_readmem[] =
{
{ 0x0002, 0x0002, liberatr_bitmap_xy_r },
{ 0x0000, 0x3fff, MRA_RAM }, /* overlapping for my convenience */
{ 0x4000, 0x403f, atari_vg_earom_r },
{ 0x5000, 0x5000, liberatr_input_port_0_r },
{ 0x5001, 0x5001, input_port_1_r },
{ 0x7000, 0x701f, pokey2_r },
{ 0x7800, 0x781f, pokey1_r },
{ 0x8000, 0xefff, MRA_ROM },
{ 0xfffa, 0xffff, MRA_ROM },
{ -1 } /* end of table */
};
static struct MemoryReadAddress liberat2_readmem[] =
{
{ 0x0002, 0x0002, liberatr_bitmap_xy_r },
{ 0x0000, 0x3fff, MRA_RAM }, /* overlapping for my convenience */
{ 0x4000, 0x4000, liberatr_input_port_0_r },
{ 0x4001, 0x4001, input_port_1_r },
{ 0x4800, 0x483f, atari_vg_earom_r },
{ 0x5000, 0x501f, pokey2_r },
{ 0x5800, 0x581f, pokey1_r },
{ 0x6000, 0xbfff, MRA_ROM },
{ 0xfffa, 0xffff, MRA_ROM },
{ -1 } /* end of table */
};
static struct MemoryWriteAddress liberatr_writemem[] =
{
{ 0x0002, 0x0002, liberatr_bitmap_xy_w },
{ 0x0000, 0x3fff, liberatr_bitmap_w, &liberatr_bitmapram }, /* overlapping for my convenience */
{ 0x6000, 0x600f, MWA_RAM, &liberatr_base_ram },
{ 0x6200, 0x621f, liberatr_colorram_w },
{ 0x6400, 0x6400, MWA_NOP },
{ 0x6600, 0x6600, atari_vg_earom_ctrl_w },
{ 0x6800, 0x6800, MWA_RAM, &liberatr_planet_frame },
{ 0x6a00, 0x6a00, watchdog_reset_w },
{ 0x6c00, 0x6c01, liberatr_led_w },
{ 0x6c04, 0x6c04, MWA_RAM, &liberatr_ctrld },
{ 0x6c05, 0x6c06, liberatr_coin_counter_w },
{ 0x6c07, 0x6c07, MWA_RAM, &liberatr_planet_select },
{ 0x6e00, 0x6e3f, atari_vg_earom_w },
{ 0x7000, 0x701f, pokey2_w },
{ 0x7800, 0x781f, pokey1_w },
{ 0x8000, 0xefff, MWA_ROM },
{ 0xfffa, 0xffff, MWA_ROM },
{ 0x0000, 0x0000, MWA_RAM, &liberatr_x }, /* just here to assign pointer */
{ 0x0001, 0x0001, MWA_RAM, &liberatr_y }, /* just here to assign pointer */
{ -1 } /* end of table */
};
static struct MemoryWriteAddress liberat2_writemem[] =
{
{ 0x0002, 0x0002, liberatr_bitmap_xy_w },
{ 0x0000, 0x3fff, liberatr_bitmap_w, &liberatr_bitmapram }, /* overlapping for my convenience */
{ 0x4000, 0x400f, MWA_RAM, &liberatr_base_ram },
{ 0x4200, 0x421f, liberatr_colorram_w },
{ 0x4400, 0x4400, MWA_NOP },
{ 0x4600, 0x4600, atari_vg_earom_ctrl_w },
{ 0x4800, 0x4800, MWA_RAM, &liberatr_planet_frame },
{ 0x4a00, 0x4a00, watchdog_reset_w },
{ 0x4c00, 0x4c01, liberatr_led_w },
{ 0x4c04, 0x4c04, MWA_RAM, &liberatr_ctrld },
{ 0x4c05, 0x4c06, liberatr_coin_counter_w },
{ 0x4c07, 0x4c07, MWA_RAM, &liberatr_planet_select },
{ 0x4e00, 0x4e3f, atari_vg_earom_w },
{ 0x5000, 0x501f, pokey2_w },
{ 0x5800, 0x581f, pokey1_w },
//{ 0x6000, 0x601f, pokey1_w }, /* bug ??? */
{ 0x6000, 0xbfff, MWA_ROM },
{ 0xfffa, 0xffff, MWA_ROM },
{ 0x0000, 0x0000, MWA_RAM, &liberatr_x }, /* just here to assign pointer */
{ 0x0001, 0x0001, MWA_RAM, &liberatr_y }, /* just here to assign pointer */
{ -1 } /* end of table */
};
INPUT_PORTS_START( liberatr )
PORT_START /* IN0 - $5000 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN3 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_TILT )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Cabinet ) )
PORT_DIPSETTING( 0x40, DEF_STR( Upright ) )
PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) )
PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
PORT_START /* IN1 - $5001 */
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 )
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 )
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x80, IP_ACTIVE_HIGH,IPT_VBLANK )
PORT_START /* IN2 - Game Option switches DSW @ D4 on PCB */
PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )
PORT_DIPSETTING( 0x00, "4" )
PORT_DIPSETTING( 0x01, "5" )
PORT_DIPSETTING( 0x02, "6" )
PORT_DIPSETTING( 0x03, "8" )
PORT_DIPNAME( 0x0C, 0x04, DEF_STR( Bonus_Life ) )
PORT_DIPSETTING( 0x00, "15000" )
PORT_DIPSETTING( 0x04, "20000" )
PORT_DIPSETTING( 0x08, "25000" )
PORT_DIPSETTING( 0x0C, "30000" )
PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty ) )
PORT_DIPSETTING( 0x10, "Easy" )
PORT_DIPSETTING( 0x00, "Normal" )
PORT_DIPSETTING( 0x20, "Hard" )
PORT_DIPSETTING( 0x30, "???" )
PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_START /* IN3 - Pricing Option switches DSW @ A4 on PCB */
PORT_DIPNAME( 0x03, 0x02, DEF_STR( Coinage ) )
PORT_DIPSETTING( 0x03, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x02, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) )
PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) )
PORT_DIPNAME( 0x0c, 0x00, "Right Coin" )
PORT_DIPSETTING ( 0x00, "*1" )
PORT_DIPSETTING ( 0x04, "*4" )
PORT_DIPSETTING ( 0x08, "*5" )
PORT_DIPSETTING ( 0x0c, "*6" )
PORT_DIPNAME( 0x10, 0x00, "Left Coin" )
PORT_DIPSETTING ( 0x00, "*1" )
PORT_DIPSETTING ( 0x10, "*2" )
/* TODO: verify the following settings */
PORT_DIPNAME( 0xe0, 0x00, "Bonus Coins" )
PORT_DIPSETTING ( 0x00, "None" )
PORT_DIPSETTING ( 0x80, "1 each 5" )
PORT_DIPSETTING ( 0x40, "1 each 4 (+Demo)" )
PORT_DIPSETTING ( 0xa0, "1 each 3" )
PORT_DIPSETTING ( 0x60, "2 each 4 (+Demo)" )
PORT_DIPSETTING ( 0x20, "1 each 2" )
PORT_DIPSETTING ( 0xc0, "Freeze Mode" )
PORT_DIPSETTING ( 0xe0, "Freeze Mode" )
PORT_START /* IN4 - FAKE - overlaps IN0 in the HW */
PORT_ANALOG( 0x0f, 0x0, IPT_TRACKBALL_X, 30, 10, 0, 0 )
PORT_START /* IN5 - FAKE - overlaps IN0 in the HW */
PORT_ANALOG( 0x0f, 0x0, IPT_TRACKBALL_Y, 30, 10, 0, 0 )
INPUT_PORTS_END
static struct POKEYinterface pokey_interface =
{
2, /* 2 chips */
FREQ_17_APPROX, /* 1.7 Mhz */
{ 50, 50 },
/* The 8 pot handlers */
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
/* The allpot handler */
{ input_port_3_r, input_port_2_r }
};
#define MACHINE_DRIVER(NAME) \
static struct MachineDriver machine_driver_##NAME = \
{ \
/* basic machine hardware */ \
{ \
{ \
CPU_M6502, \
1250000, /* 1.25 Mhz */ \
NAME##_readmem,NAME##_writemem,0,0, \
interrupt, 4 \
} \
}, \
60, DEFAULT_REAL_60HZ_VBLANK_DURATION, /* frames per second, vblank duration */ \
1, /* single CPU, no need for interleaving */ \
0, \
\
/* video hardware */ \
256, 256, { 8, 247, 13, 244 }, \
0, /* no gfxdecodeinfo - bitmapped display */ \
32, 0, \
0, \
\
VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE, \
0, \
liberatr_vh_start, \
liberatr_vh_stop, \
liberatr_vh_screenrefresh, \
\
/* sound hardware */ \
0,0,0,0, \
{ \
{ \
SOUND_POKEY, \
&pokey_interface \
} \
}, \
\
atari_vg_earom_handler \
};
MACHINE_DRIVER(liberatr)
MACHINE_DRIVER(liberat2)
/***************************************************************************
Game driver(s)
***************************************************************************/
ROM_START( liberatr )
ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code and data */
ROM_LOAD( "136012.206", 0x8000, 0x1000, 0x1a0cb4a0 )
ROM_LOAD( "136012.205", 0x9000, 0x1000, 0x2f071920 )
ROM_LOAD( "136012.204", 0xa000, 0x1000, 0xbcc91827 )
ROM_LOAD( "136012.203", 0xb000, 0x1000, 0xb558c3d4 )
ROM_LOAD( "136012.202", 0xc000, 0x1000, 0x569ba7ea )
ROM_LOAD( "136012.201", 0xd000, 0x1000, 0xd12cd6d0 )
ROM_LOAD( "136012.200", 0xe000, 0x1000, 0x1e98d21a )
ROM_RELOAD( 0xf000, 0x1000 ) /* for interrupt/reset vectors */
ROM_REGION( 0x4000, REGION_GFX1 ) /* planet image, used at runtime */
ROM_LOAD( "136012.110", 0x0000, 0x1000, 0x6eb11221 )
ROM_LOAD( "136012.107", 0x1000, 0x1000, 0x8a616a63 )
ROM_LOAD( "136012.108", 0x2000, 0x1000, 0x3f8e4cf6 )
ROM_LOAD( "136012.109", 0x3000, 0x1000, 0xdda0c0ef )
ROM_END
ROM_START( liberat2 )
ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code and data */
ROM_LOAD( "l6.bin", 0x6000, 0x1000, 0x78093d06 )
ROM_LOAD( "l5.bin", 0x7000, 0x1000, 0x988db636 )
ROM_LOAD( "l4.bin", 0x8000, 0x1000, 0xec114540 )
ROM_LOAD( "l3.bin", 0x9000, 0x1000, 0x184c751f )
ROM_LOAD( "l2.bin", 0xa000, 0x1000, 0xc3f61f88 )
ROM_LOAD( "l1.bin", 0xb000, 0x1000, 0xef6e9f9e )
ROM_RELOAD( 0xf000, 0x1000 ) /* for interrupt/reset vectors */
ROM_REGION( 0x4000, REGION_GFX1 ) /* planet image, used at runtime */
ROM_LOAD( "136012.110", 0x0000, 0x1000, 0x6eb11221 )
ROM_LOAD( "136012.107", 0x1000, 0x1000, 0x8a616a63 )
ROM_LOAD( "136012.108", 0x2000, 0x1000, 0x3f8e4cf6 )
ROM_LOAD( "136012.109", 0x3000, 0x1000, 0xdda0c0ef )
ROM_END
GAMEX( 1982, liberatr, 0, liberatr, liberatr, 0, ROT0, "Atari", "Liberator (set 1)", GAME_NO_COCKTAIL )
GAMEX( 1982, liberat2, liberatr, liberat2, liberatr, 0, ROT0, "Atari", "Liberator (set 2)", GAME_NOT_WORKING | GAME_NO_COCKTAIL )
| 38.260776
| 129
| 0.506788
|
gameblabla
|
de8502cf617a9e2c2736d3751817269a7292a8a9
| 12,174
|
cpp
|
C++
|
PeerIOSerialControl.cpp
|
TGit-Tech/PeerIOSerialControl
|
cdb79f906e359fbc7fab934b918cb54dc61b1810
|
[
"MIT"
] | null | null | null |
PeerIOSerialControl.cpp
|
TGit-Tech/PeerIOSerialControl
|
cdb79f906e359fbc7fab934b918cb54dc61b1810
|
[
"MIT"
] | null | null | null |
PeerIOSerialControl.cpp
|
TGit-Tech/PeerIOSerialControl
|
cdb79f906e359fbc7fab934b918cb54dc61b1810
|
[
"MIT"
] | null | null | null |
/************************************************************************//**
* @file PeerIOSerialControl.cpp
* @brief Arduino Peer IO-Control through Serial Port Communications.
* @authors
* tgit23 1/2017 Original
******************************************************************************/
#include "PeerIOSerialControl.h"
#define ID_MASK 0x0F // Bytes[0] [0000 1111] ArduinoID ( 0-15 )
#define REPLY_BIT 4 // Bytes[0] [0001 0000] Reply-1, Send-0
#define RW_BIT 5 // Bytes[0] [0010 0000] Read-1, Write-0
#define DA_BIT 6 // Bytes[0] [0100 0000] Digital-1, Analog-0
#define DPIN_MASK 0x3F // Bytes[1] [0011 1111] Digital Pins ( 0 - 63 )
#define APIN_MASK 0x7F // Bytes[1] [0111 1111] Analog Pins ( 0 - 127 )
#define HL_BIT 6 // Bytes[1] [0100 0000] High-1, Low-0
#define END_BIT 7 // Bytes[?} [1000 0000] Any set 8th bit flags END-OF-PACKET
//-----------------------------------------------------------------------------------------------------
// Initializer
//-----------------------------------------------------------------------------------------------------
PeerIOSerialControl::PeerIOSerialControl(int ThisArduinoID, Stream &CommunicationPort, Stream &DebugPort) {
ArduinoID = ThisArduinoID;
COMPort = &CommunicationPort;
DBPort = &DebugPort;
}
void PeerIOSerialControl::digitalWriteB(uint8_t Pin, uint8_t Value) {
int packetID = SendPacket(DIGITAL,WRITE,Pin,Value);
unsigned long Start = millis();
do {
if ( Available() ) break;
} while ( (millis() - Start) < BlockingTimeoutMS );
}
int PeerIOSerialControl::digitalReadB(uint8_t Pin) {
int packetID = SendPacket(DIGITAL,READ,Pin);
unsigned long Start = millis();
do {
if ( Available() ) return GetReply(packetID);
} while ( (millis() - Start) < BlockingTimeoutMS );
return -1;
}
int PeerIOSerialControl::analogReadB(uint8_t Pin) {
int packetID = SendPacket(ANALOG,READ,Pin);
unsigned long Start = millis();
do {
if ( Available() ) return GetReply(packetID);
} while ( (millis() - Start) < BlockingTimeoutMS );
return -1;
}
void PeerIOSerialControl::analogWriteB(uint8_t Pin, int Value) {
int packetID = SendPacket(ANALOG,WRITE,Pin,Value);
unsigned long Start = millis();
do {
if ( Available() ) break;
} while ( (millis() - Start) < BlockingTimeoutMS );
}
int PeerIOSerialControl::digitalWriteNB(uint8_t Pin, uint8_t Value) {
return SendPacket(DIGITAL,WRITE,Pin,Value);
}
int PeerIOSerialControl::digitalReadNB(uint8_t Pin) {
return SendPacket(DIGITAL,READ,Pin);
}
int PeerIOSerialControl::analogReadNB(uint8_t Pin) {
return SendPacket(ANALOG,READ,Pin);
}
int PeerIOSerialControl::analogWriteNB(uint8_t Pin, int Value) {
return SendPacket(ANALOG,WRITE,Pin,Value);
}
void PeerIOSerialControl::TargetArduinoID(int ID) {
iTargetArduinoID = ID;
}
int PeerIOSerialControl::TargetArduinoID() {
return iTargetArduinoID;
}
void PeerIOSerialControl::Timeout(int milliseconds) {
BlockingTimeoutMS = milliseconds;
}
int PeerIOSerialControl::Timeout() {
return BlockingTimeoutMS;
}
void PeerIOSerialControl::VirtualPin(int Pin, int Value) {
if ( Pin > 63 && Pin < 128 ) iVirtualPin[Pin-64] = Value;
}
int PeerIOSerialControl::VirtualPin(int Pin) {
if ( Pin > 63 && Pin < 128 ) return iVirtualPin[Pin-64];
}
//-----------------------------------------------------------------------------------------------------
// SendPacket()
//-----------------------------------------------------------------------------------------------------
int PeerIOSerialControl::SendPacket(bool DA, bool RW, byte Pin, int Value) {
DBL(("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"));
DBL(("SendPacket()"));
byte SBytes[4] = { 0,0,0,0 };
if ( DA ) bitSet(SBytes[0],DA_BIT);
if ( RW ) bitSet(SBytes[0],RW_BIT);
SBytes[0] = SBytes[0] | (iTargetArduinoID & ID_MASK);
if ( DA == DIGITAL ) {
SBytes[1] = (Pin & DPIN_MASK); // 6-bit Pin for Digital
if ( RW != READ ) bitWrite(SBytes[1],HL_BIT,(Value>0)); // Digital Write - Set H/L Bit
bitSet(SBytes[1],END_BIT); // Digital only uses 2-Bytes
} else {
SBytes[1] = (Pin & APIN_MASK); // 7-bit Pin for Analog
if ( Value > -1 ) {
Value = ValueTo7bits(Value); // Conversion marks the END_BIT
SBytes[2] = lowByte(Value);
SBytes[3] = highByte(Value);
} else {
bitSet(SBytes[1],END_BIT); // Set END_BIT if not sending Value
}
}
DB(("SendBytes( "));
COMPort->write(SBytes[0]);
COMPort->write(SBytes[1]);
if ( SBytes[2] != 0 ) COMPort->write(SBytes[2]);
if ( SBytes[3] != 0 ) COMPort->write(SBytes[3]);
DB((SBytes[0],HEX));DBC;DB((SBytes[1],HEX));DBC;DB((SBytes[2],HEX));DBC;DB((SBytes[3],HEX));DBL((" )"));
return ( SBytes[1] << 8 ) | SBytes[0]; // Return Bytes 0, 1 for tracking
}
//-----------------------------------------------------------------------------------------------------
// GetReply()
//-----------------------------------------------------------------------------------------------------
int PeerIOSerialControl::GetReply(int packetID) {
DB(("GetReply("));DB((packetID,HEX));DBL((")"));
int UseRBI = RBI - 1;
if ( UseRBI < 1 ) UseRBI = 0;
// Find the Reply for this Command
if ( packetID != -1 ) {
byte Byte0 = lowByte(packetID);
byte Byte1 = highByte(packetID);
int i = UseRBI; UseRBI = -1;
do {
DB(("\tRBytes["));DB((i));DB(("][0] = "));DBL((RBytes[i][0],HEX));
DB(("\tRBytes["));DB((i));DB(("][1] = "));DBL((RBytes[i][1],HEX));
if ( (Byte0 & 0xEF) == (RBytes[i][0] & 0xEF) &&
(Byte1 & 0x3F) == (RBytes[i][1] & 0x3F) ) {
UseRBI = i;
break;
}
i--; if ( i < 0 ) i = 9;
} while ( i != RBI );
}
if ( UseRBI < 0 ) return -1;
if ( bitRead(RBytes[UseRBI][0],RW_BIT) == WRITE ) {
return 0; // Okay Status for a WRITE COMMAND
} else {
if ( bitRead(RBytes[UseRBI][0],DA_BIT) == DIGITAL ) { // Value of the Reply
return bitRead(RBytes[UseRBI][1],HL_BIT);
} else {
return ValueTo8bits(RBytes[UseRBI][2],RBytes[UseRBI][3]);
}
}
}
//-----------------------------------------------------------------------------------------------------
// ValueTo8bits() ValueTo7bits()
// - Encodes / Decodes numeric values into (2)7-bit bytes for the 14-bit 'AV' (Analog Value) Bytes
// - This function automatically attaches the END_BIT at the appropriate location.
//-----------------------------------------------------------------------------------------------------
int PeerIOSerialControl::ValueTo8bits(byte lByte, byte hByte) {
bitClear(hByte,7); // Clear any End-Of-Packet flag
bitWrite(lByte,7,bitRead(hByte,0)); // Transfer hByte<0> onto lByte<7>
return (hByte<<7) | lByte; // Left shift 7 overwrites lByte<7>
}
int PeerIOSerialControl::ValueTo7bits(int From8BitValue) {
byte lByte = lowByte(From8BitValue);
byte hByte = highByte(From8BitValue);
if ( From8BitValue > 0x3FFF ) return -1; // Value is too big for a 14-bit Value
hByte = hByte << 1; // Make Room on hByte for bit-7 of lByte
bitWrite(hByte,0,bitRead(lByte,7)); // Transfer lByte<7> onto hByte<0>
if ( From8BitValue > 0x7F ) {
bitSet(hByte,7); // Value > 7-bits so Set 'END_BIT' @ hByte
bitClear(lByte,7);
} else {
bitSet(lByte,7); // Value <= 7-bits so Set 'END_BIT' @ lByte
bitClear(hByte,7);
}
return (hByte<<8) | lByte;
}
//-----------------------------------------------------------------------------------------------------
// DecodePacket()
//-----------------------------------------------------------------------------------------------------
void PeerIOSerialControl::DecodePacket(long lPacket) {
byte Byte0; byte Byte1; byte Byte2; byte Byte3;
if ( lPacket = -1 ) {
Byte0=Bytes[0];Byte1=Bytes[1];Byte2=Bytes[2];Byte3=Bytes[3];
} else {
Byte0 = ( lPacket >> 24 ) & 0xFF;
Byte1 = ( lPacket >> 16 ) & 0xFF;
Byte2 = ( lPacket >> 8 ) & 0xFF;
Byte3 = lPacket & 0xFF;
}
DB(("D/A Flag = "));if ( bitRead(Byte0,DA_BIT) ) { DBL(("DIGITAL")); } else { DBL(("ANALOG")); }
DB(("R/W Flag = "));if ( bitRead(Byte0,RW_BIT) ) { DBL(("READ")); } else { DBL(("WRITE")); }
DB(("S/R Flag = "));if ( bitRead(Byte0,REPLY_BIT) ) { DBL(("REPLY")); } else { DBL(("SEND")); }
DB(("Arduino ID = "));DBL(( (Byte0 & ID_MASK) ));
if ( bitRead(Byte0,DA_BIT) ) {
DB(("H/L Flag = "));
if ( bitRead(Byte0,HL_BIT) ) { DBL(("HIGH")); } else { DBL(("LOW")); }
DB(("PIN = "));DBL(( (Byte1 & DPIN_MASK) ));
} else {
DB(("Value = "));DBL(( ValueTo8bits(Byte2, Byte3) ));
DB(("PIN = "));DBL(( (Byte1 & APIN_MASK) ));
}
}
//-----------------------------------------------------------------------------------------------------
// ProcessPacket()
//-----------------------------------------------------------------------------------------------------
void PeerIOSerialControl::ProcessPacket() {
DB(("ProcessPacket( "));
DB((Bytes[0],HEX));DBC;DB((Bytes[1],HEX));DBC;DB((Bytes[2],HEX));DBC;DB((Bytes[3],HEX));
DB((" ) - "));
// REPLY PACKET RECEIVED
if ( bitRead(Bytes[0],REPLY_BIT) ) {
DBL(("Packet Type REPLY"));
for ( int i=0;i<4;i++ ) RBytes[RBI][i] = Bytes[i]; // Put Replies in RBytes Buffer
#if defined(DEBUG)
#if DEBUG>0
DecodePacket();
#endif
#endif
// COMMAND PACKET RECEIVED
} else if ( (Bytes[0] & ID_MASK) == ArduinoID ) {
DBL(("Packet Type SEND"));
// DIGITAL
if ( bitRead(Bytes[0],DA_BIT) == DIGITAL ) {
int pin = Bytes[1] & DPIN_MASK;
if ( bitRead(Bytes[0],RW_BIT) == READ ) {
DB(("digitalRead("));DB((pin));DBL((")"));
bitWrite(Bytes[1],HL_BIT,digitalRead(pin));
} else {
DB(("digitalWrite("));DB((pin));DB((","));DB((bitRead(Bytes[1],HL_BIT)));DBL((")"));
digitalWrite(pin,bitRead(Bytes[1],HL_BIT));
}
bitSet(Bytes[1],END_BIT);
// ANALOG
} else {
int pin = Bytes[1] & APIN_MASK;
int val = 0;
if ( bitRead(Bytes[0],RW_BIT) == READ ) {
DB(("analogRead("));DB((pin));DBL((")"));
if ( pin > 63 && pin < 128 ) {
val = ValueTo7bits(iVirtualPin[pin-64]);
} else {
val = ValueTo7bits(analogRead(pin));
}
Bytes[2] = lowByte(val);
Bytes[3] = highByte(val);
} else {
DB(("analogWrite("));DB((pin));DB((","));DB((ValueTo8bits(Bytes[2],Bytes[3])));DBL((")"));
if ( pin > 63 && pin < 128 ) {
iVirtualPin[pin-64] = ValueTo8bits(Bytes[2],Bytes[3]);
} else {
analogWrite(pin,ValueTo8bits(Bytes[2],Bytes[3]));
}
}
}
// Send out the Reply Packet
bitSet(Bytes[0],REPLY_BIT); // Set the Reply Bit
DB(("SendBytes( "));
COMPort->write(Bytes[0]);
COMPort->write(Bytes[1]);
if ( Bytes[2] != 0 ) COMPort->write(Bytes[2]);
if ( Bytes[3] != 0 ) COMPort->write(Bytes[3]);
DB((Bytes[0],HEX));DBC;DB((Bytes[1],HEX));DBC;DB((Bytes[2],HEX));DBC;DB((Bytes[3],HEX));DBL((" )"));
}
}
//-----------------------------------------------------------------------------------------------------
// Available()
//-----------------------------------------------------------------------------------------------------
bool PeerIOSerialControl::Available() {
// Receive Bytes
while(COMPort->available() > 0) {
Bytes[idx] = COMPort->read();
if ( Bytes[idx] != -1 ) {
//DBL((Bytes[idx],HEX));
if ( bitRead(Bytes[idx],END_BIT) ) {
DBL(("-----------------------------------------------------------"));
DB(("Packet Received @ Size: "));DBL((idx+1));
bitClear(Bytes[idx],END_BIT); // Clear the END_BIT
for(int i=(idx+1);i<4;i++) Bytes[i]=0; // Clear unused bytes
idx = 0;
ProcessPacket();
return true;
} else {
idx++;
}
}
}
}
| 38.894569
| 107
| 0.496632
|
TGit-Tech
|
de8726d230ba89163f05f0b03924340a6d8bb824
| 23,188
|
cc
|
C++
|
Source/Util/sort.cc
|
AryaFaramarzi/CS220-dmfb-synthesis-skeleton
|
6b592516025f6c2838f269dcf2ca1696d9de5ab8
|
[
"MIT"
] | 3
|
2018-11-03T06:17:08.000Z
|
2020-08-12T05:26:47.000Z
|
Source/Util/sort.cc
|
AryaFaramarzi/CS220-dmfb-synthesis-skeleton
|
6b592516025f6c2838f269dcf2ca1696d9de5ab8
|
[
"MIT"
] | null | null | null |
Source/Util/sort.cc
|
AryaFaramarzi/CS220-dmfb-synthesis-skeleton
|
6b592516025f6c2838f269dcf2ca1696d9de5ab8
|
[
"MIT"
] | 6
|
2019-09-03T23:58:04.000Z
|
2021-07-09T02:33:47.000Z
|
/*------------------------------------------------------------------------------*
* (c)2016, All Rights Reserved. *
* ___ ___ ___ *
* /__/\ / /\ / /\ *
* \ \:\ / /:/ / /::\ *
* \ \:\ / /:/ / /:/\:\ *
* ___ \ \:\ / /:/ ___ / /:/~/:/ *
* /__/\ \__\:\ /__/:/ / /\ /__/:/ /:/___ UCR DMFB Synthesis Framework *
* \ \:\ / /:/ \ \:\ / /:/ \ \:\/:::::/ www.microfluidics.cs.ucr.edu *
* \ \:\ /:/ \ \:\ /:/ \ \::/~~~~ *
* \ \:\/:/ \ \:\/:/ \ \:\ *
* \ \::/ \ \::/ \ \:\ *
* \__\/ \__\/ \__\/ *
*-----------------------------------------------------------------------------*/
/*---------------------------Implementation Details-----------------------------*
* Source: sort.cc *
* Original Code Author(s): Dan Grissom *
* Original Completion/Release Date: October 7, 2012 *
* *
* Details: N/A *
* *
* Revision History: *
* WHO WHEN WHAT *
* --- ---- ---- *
* FML MM/DD/YY One-line description *
*-----------------------------------------------------------------------------*/
#include "sort.h"
#include "wire_router.h" // DTG
///////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////
Sort::Sort() {}
///////////////////////////////////////////////////////////////////////////////////
// Deconstructor
///////////////////////////////////////////////////////////////////////////////////
Sort::~Sort(){}
/////////////////////////////////////////////////////////////////
// Sorts nodes by starting time-step, from least to greatest
/////////////////////////////////////////////////////////////////
bool sNodesByStartTS(AssayNode *a1, AssayNode *a2) { return (a1->GetStartTS() < a2->GetStartTS()); }
bool sNodesByStartThenEndTS(AssayNode *a1, AssayNode *a2)
{
if (a1->GetStartTS() == a2->GetStartTS())
return (a1->GetEndTS() < a2->GetEndTS());
else
return (a1->GetStartTS() < a2->GetStartTS());
}
bool sPathNodesByStartTS(AssayPathNode *a1, AssayPathNode *a2) { return (a1->startTS < a2->startTS); }
/////////////////////////////////////////////////////////////////
// Sorts nodes by length, from shortest to longest
/////////////////////////////////////////////////////////////////
bool sNodesByLength(AssayNode *a1, AssayNode *a2) { return (a1->GetEndTS() - a1->GetStartTS() < a2->GetEndTS() - a2->GetStartTS()); }
/////////////////////////////////////////////////////////////////
// Sorts integers at derefrenced address in decreasing order
/////////////////////////////////////////////////////////////////
bool sDecreasingInts(int *i1, int *i2) { return ((*i1) > (*i2)); }
/////////////////////////////////////////////////////////////////
// Sorts by starting TS. If a tie, puts the storage-holders
// first.
/////////////////////////////////////////////////////////////////
bool sNodesByStartTSThenStorageFirst(AssayNode *a1, AssayNode *a2)
{
if (a1->GetStartTS() == a2->GetStartTS())
{
if (a1->GetType() == STORAGE_HOLDER && a2->GetType() != STORAGE_HOLDER)
return true;
else
return false;
}
else
return (a1->GetStartTS() < a2->GetStartTS());
}
/////////////////////////////////////////////////////////////////
// Sorts nodes by reconfig. module, and then by starting time-step,
// from least to greatest
/////////////////////////////////////////////////////////////////
bool sNodesByModuleThenStartTS(AssayNode *a1, AssayNode *a2)
{
//if (a1->GetReconfigMod() != a2->GetReconfigMod())
// return (a1->GetReconfigMod() < a2->GetReconfigMod());
//else
// return (a1->GetStartTS() < a2->GetStartTS());
//;return true;
if (a1->GetReconfigMod()->getId() == a2->GetReconfigMod()->getId())
return (a1->GetStartTS() < a2->GetStartTS());
else
return (a1->GetReconfigMod()->getId() < a2->GetReconfigMod()->getId());
}
/////////////////////////////////////////////////////////////////
// Sorts nodes by priority, but puts outputs at the very front
// b/c they can ALWAYS go and free up system resources...not matter
// what their priority is. HiFirst puts the higher numbers in front,
// while LoFirst puts the lower numbers first
/////////////////////////////////////////////////////////////////
bool sNodesByPriorityHiFirst(AssayNode *a1, AssayNode *a2)
{
if (a1->GetType() == OUTPUT && a2->GetType() != OUTPUT)
return true;
else if (a1->GetType() != OUTPUT && a2->GetType() == OUTPUT)
return false;
return (a1->GetPriority() > a2->GetPriority());
}
bool sNodesByPriorityLoFirst(AssayNode *a1, AssayNode *a2)
{
if (a1->GetType() == OUTPUT && a2->GetType() != OUTPUT)
return true;
else if (a1->GetType() != OUTPUT && a2->GetType() == OUTPUT)
return false;
return (a1->GetPriority() < a2->GetPriority());
}
///////////////////////////////////////////////////////////////
// Sort heat and detects to front of list b/c they have more
// stringent resource demands and should be processed first
///////////////////////////////////////////////////////////////
bool sNodesByLimitedResources(AssayNode *a1, AssayNode *a2)
{
if ((a1->GetType() == HEAT || a1->GetType() == DETECT) && !(a2->GetType() == HEAT || a2->GetType() == DETECT))
return true;
else
return false;
}
///////////////////////////////////////////////////////////////
// Shortest id first
///////////////////////////////////////////////////////////////
bool sNodesById(AssayNode *a1, AssayNode *a2) { return (a1->getId() < a2->getId()); }
///////////////////////////////////////////////////////////////
// Longest routes first
///////////////////////////////////////////////////////////////
bool sRoutesByLength(vector<RoutePoint *> *r1, vector<RoutePoint *> *r2)
{
return r1->size() > r2->size();
}
///////////////////////////////////////////////////////////////
// Latest ending time-steps first, then sort the storage nodes
// to the end.
// ***** original latestTS then storage copy
///////////////////////////////////////////////////////////////
bool sNodesByLatestTSAndStorage(AssayNode *a1, AssayNode *a2)
{
if (a1->GetType() == STORAGE && a2->GetType() != STORAGE)
return true;
else if ((a1->GetType() == DETECT || a1->GetType() == HEAT) && !(a2->GetType() == DETECT || a2->GetType() == HEAT))
return true;
else if (a1->GetEndTS() != a2->GetEndTS())
return a1->GetEndTS() > a2->GetEndTS();
else
return true;
}
///////////////////////////////////////////////////////////////
// Latest ending time-steps first, then sort the storage nodes
// to the end.
// *****Changed to:
// If is a storage node and not changing modules from parent
// node's module, then sorted to front
///////////////////////////////////////////////////////////////
bool sNodesByLatestTSThenStorage(AssayNode *a1, AssayNode *a2)
{
if (a1->GetType() == STORAGE && a2->GetType() != STORAGE)
return true;
else if (a1->GetType() != STORAGE && a2->GetType() == STORAGE)
return false;
else if (a1->GetType() == STORAGE && a2->GetType() == STORAGE)
{
ReconfigModule *rm1 = a1->GetReconfigMod();
ReconfigModule *rm2 = a2->GetReconfigMod();
if (rm1->getTY() == rm2->getTY() && rm1->getLX() == rm2->getLX())
return true;
else
return false;
}
else // Non-storage nodes
return false;
/*if (a1->GetEndTS() != a2->GetEndTS())
return a1->GetEndTS() > a2->GetEndTS();
else if (a1->GetType() == STORAGE && a2->GetType() != STORAGE)
return false;
else
return true;*/
}
/////////////////////////////////////////////////////////////////
// Sorts reconfigurable modules by starting time-step, and then
// by ending time-step, from least to greatest
/////////////////////////////////////////////////////////////////
bool sReconfigModsByStartThenEndTS(ReconfigModule *r1, ReconfigModule *r2)
{
if (r1->getStartTS() == r2->getStartTS())
return (r1->getEndTS() < r2->getEndTS());
else
return (r1->getStartTS() < r2->getStartTS());
}
///////////////////////////////////////////////////////////////////////////////////
// Sorts paths based on shared pin size...least to greatest.
///////////////////////////////////////////////////////////////////////////////////
bool sPathsBySharedPinSize(Path *p1, Path *p2)
{
return p1->sharedPinsSize() < p2->sharedPinsSize();
}
///////////////////////////////////////////////////////////////////////////////////
// Sorts pin groups based on their average minimum distance to an edge of the DMFB.
///////////////////////////////////////////////////////////////////////////////////
bool sPinGroupsByAvgMinDistToEdge(vector<WireRouteNode *> *pg1, vector<WireRouteNode *> *pg2)
{
// Get arch and return if either group is empty
DmfbArch *a = NULL;
if (!pg1->empty() && !pg2->empty())
a = pg1->front()->arch;
else if (pg1->empty())
return true;
else
return false;
// Get edge extremes
int wgXMax = a->getWireRouter()->getModel()->getWireGridXSize()-1;
int wgYMax = a->getWireRouter()->getModel()->getWireGridYSize()-1;
// Compute Averages
double avg1 = 0;
for (unsigned i = 0; i < pg1->size(); i++)
{
WireRouteNode *p = pg1->at(i);
avg1 += min( min(p->wgX, p->wgY), min(wgXMax - p->wgX, wgYMax - p->wgY) );
}
avg1 = avg1 / (double)pg1->size();
double avg2 = 0;
for (unsigned i = 0; i < pg2->size(); i++)
{
WireRouteNode *p = pg2->at(i);
avg2 += min( min(p->wgX, p->wgY), min(wgXMax - p->wgX, wgYMax - p->wgY) );
}
avg2 = avg2 / (double)pg2->size();
// Output comparison
if (avg1 == avg2)
return pg1->front()->originalPinNum < pg2->front()->originalPinNum; // If same, order by pin number
return (avg1 < avg2); // Else, order by smallest distance first
}
///////////////////////////////////////////////////////////////////////////////////
// Sorts pin groups based on their number of pins being shared. Least number of
// pins in a group is sorted toward the front.
///////////////////////////////////////////////////////////////////////////////////
bool sPinGroupsByPinGroupSize(vector<WireRouteNode *> *pg1, vector<WireRouteNode *> *pg2)
{
return pg1->size() < pg2->size();
}
///////////////////////////////////////////////////////////////////////////////////
// Sort pin groups based on their area (bounding box).
///////////////////////////////////////////////////////////////////////////////////
bool sPinGroupsByPinGroupArea(vector<WireRouteNode *> *pg1, vector<WireRouteNode *> *pg2)
{
// Get arch and return if either group is empty
DmfbArch *a = NULL;
if (!pg1->empty() && !pg2->empty())
a = pg1->front()->arch;
else if (pg1->empty())
return true;
else
return false;
// Get edge extremes
int wgXMax = a->getWireRouter()->getModel()->getWireGridXSize()-1;
int wgYMax = a->getWireRouter()->getModel()->getWireGridYSize()-1;
int xMin1 = -1;
int xMax1 = -1;
int yMin1 = -1;
int yMax1 = -1;
int xMin2 = -1;
int xMax2 = -1;
int yMin2 = -1;
int yMax2 = -1;
int area1 = -1;
int area2 = -1;
// Compute Averages and extreme points
double avg1 = 0;
for (unsigned i = 0; i < pg1->size(); i++)
{
WireRouteNode *p = pg1->at(i);
avg1 += min( min(p->wgX, p->wgY), min(wgXMax - p->wgX, wgYMax - p->wgY) );
if (xMin1 == -1 || p->wgX < xMin1)
xMin1 = p->wgX;
if (xMax1 == -1 || p->wgX > xMax1)
xMax1 = p->wgX;
if (yMin1 == -1 || p->wgY < yMin1)
yMin1 = p->wgX;
if (yMax1 == -1 || p->wgY > yMax1)
yMax1 = p->wgX;
}
avg1 = avg1 / (double)pg1->size();
area1 = (xMax1 - xMin1 + 1) * (yMax1 - yMin1 + 1);
double avg2 = 0;
for (unsigned i = 0; i < pg2->size(); i++)
{
WireRouteNode *p = pg2->at(i);
avg2 += min( min(p->wgX, p->wgY), min(wgXMax - p->wgX, wgYMax - p->wgY) );
if (xMin2 == -1 || p->wgX < xMin2)
xMin2 = p->wgX;
if (xMax2 == -1 || p->wgX > xMax2)
xMax2 = p->wgX;
if (yMin2 == -1 || p->wgY < yMin2)
yMin2 = p->wgX;
if (yMax2 == -1 || p->wgY > yMax2)
yMax2 = p->wgX;
}
avg2 = avg2 / (double)pg2->size();
area2 = (xMax2 - xMin2 + 1) * (yMax2 - yMin2 + 1);
// Output comparison
if (area1 == area2)
return (avg1 < avg2); // If same area, order by smallest distance first
else
return area1 < area2; // Do ones that take up least amount of space first
//if (avg1 == avg2)
// return pg1->front()->originalPinNum < pg2->front()->originalPinNum; // If same, order by pin number
//return (avg1 < avg2); // Else, order by smallest distance first
}
///////////////////////////////////////////////////////////////////////////////////
// Sorts the fixed modules based on their location on the DMFB, from top to bottom.
// In event of tie (same height), choose one of left.
///////////////////////////////////////////////////////////////////////////////////
bool sFixedModulesFromTopToBottom(FixedModule *fm1, FixedModule *fm2)
{
if (fm1->getTY() == fm2->getTY())
return fm1->getLX() < fm2->getLX();
else
return fm1->getTY() < fm2->getTY();
}
///////////////////////////////////////////////////////////////////////////////////
// Sorts the modules based on their location on the DMFB, from top to bottom.
// In event of tie (same height), choose one of left.
///////////////////////////////////////////////////////////////////////////////////
bool sModulesFromTopToBot(ReconfigModule *rm1, ReconfigModule *rm2)
{
if (rm1->getTY() == rm2->getTY())
return rm1->getLX() < rm2->getLX();
else
return rm1->getTY() < rm2->getTY();
}
bool sModulesFromBotToTop(ReconfigModule *rm1, ReconfigModule *rm2)
{
if (rm1->getTY() == rm2->getTY())
return rm1->getLX() < rm2->getLX();
else
return rm1->getTY() > rm2->getTY();
}
///////////////////////////////////////////////////////////////////////////////////
// Sorts the ports by DMFB side and then position.
///////////////////////////////////////////////////////////////////////////////////
bool sPortsNtoSthenPos(IoPort *p1, IoPort *p2)
{
if (p1->getSide() == p2->getSide())
return p1->getPosXY() < p2->getPosXY();
else
return p1->getSide() < p2->getSide();
}
bool sPortsStoNthenPos(IoPort *p1, IoPort *p2)
{
if (p1->getSide() == p2->getSide())
return p1->getPosXY() < p2->getPosXY();
else
return p1->getSide() > p2->getSide();
}
///////////////////////////////////////////////////////////////////////////////////
// This function assumes an FPPC architecture is being used sorts nodes in
// decreasing routing distance from source. This is specifically designed for the
// FPPC2 (and it's a quick, non-comprehensive optimization), but shouldn't break
// on the original FPPC layout.
///////////////////////////////////////////////////////////////////////////////////
bool sFppcNodesInIncreasingRouteDistance(AssayNode *n1, AssayNode *n2)
{
// Get a reconfigurable module....
ReconfigModule *rm;
if (n1->GetReconfigMod())
rm = n1->GetReconfigMod();
else if (n2->GetReconfigMod())
rm = n2->GetReconfigMod();
else if (n1->GetChildren().at(0)->GetReconfigMod())
rm = n1->GetChildren().at(0)->GetReconfigMod();
else if (n2->GetChildren().at(0)->GetReconfigMod())
rm = n2->GetChildren().at(0)->GetReconfigMod();
else
claim(false, "Could not find a suitable module in sFppcNodesInDecreasingRouteDistance to compute the central routing column index.");
//...and then compute the central routing channel location
int crcIndex = 0; // central routing column index
if (rm->getResourceType() == SSD_RES)
crcIndex = rm->getLX() - 2;
else if (rm->getResourceType() == BASIC_RES)
crcIndex = rm->getRX() + 2;
else
claim(false, "Unknown module type in sFppcNodesInDecreasingRouteDistance.");
int d1 = 0;
int d2 = 0;
int x = 0;
int y = 0;
int ioPenalty = 500; // I/Os should be routed last, let things in modules be routed first
// Only looking at N/S...E/W for original FPPC not supported
if (n1->GetType() == DISPENSE)
{
AssayNode *c = n1->GetChildren().front();
if (n1->GetIoPort()->getSide() == NORTH || n1->GetIoPort()->getSide() == SOUTH)
x = n1->GetIoPort()->getPosXY();
d1 = abs(crcIndex-x) + ioPenalty;
}
else
{
rm = n1->GetReconfigMod();
AssayNode *c = n1->GetChildren().front();
ReconfigModule *crm = c->GetReconfigMod();
d1 = abs(crm->getBY());
}
if (n2->GetType() == DISPENSE)
{
AssayNode *c = n2->GetChildren().front();
if (n2->GetIoPort()->getSide() == NORTH || n2->GetIoPort()->getSide() == SOUTH)
x = n2->GetIoPort()->getPosXY();
d2 = abs(crcIndex-x) + ioPenalty;
}
else
{
rm = n2->GetReconfigMod();
AssayNode *c = n2->GetChildren().front();
ReconfigModule *crm = c->GetReconfigMod();
d2 = abs(crm->getBY());
}
return d1 < d2;
}
/////////////////////////////////////////////////////////////////
// Sorts Conditions by their internal order
/////////////////////////////////////////////////////////////////
bool sConditionsByOrder(Condition *c1, Condition *c2) { return (c1->order < c2->order); }
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Wrapper functions for sorts
/////////////////////////////////////////////////////////////////
void Sort::sortNodesByStartTS(list<AssayNode*>* l) { l->sort(sNodesByStartTS); }
void Sort::sortNodesByStartTS(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByStartTS); }
void Sort::sortNodesByStartTSThenStorageFirst(list<AssayNode*>* l) { l->sort(sNodesByStartTSThenStorageFirst); }
void Sort::sortNodesByStartTSThenStorageFirst(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByStartTSThenStorageFirst); }
void Sort::sortNodesByPriorityHiFirst(list<AssayNode*>* l) { l->sort(sNodesByPriorityHiFirst); }
void Sort::sortNodesByPriorityHiFirst(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByPriorityHiFirst); }
void Sort::sortNodesByPriorityLoFirst(list<AssayNode*>* l) { l->sort(sNodesByPriorityLoFirst); }
void Sort::sortNodesByPriorityLoFirst(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByPriorityLoFirst); }
void Sort::sortNodesByLimitedResources(list<AssayNode*>* l) { l->sort(sNodesByLimitedResources); }
void Sort::sortNodesByLimitedResources(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByLimitedResources); }
void Sort::sortNodesById(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesById); }
void Sort::sortNodesByModuleThenStartTS(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByModuleThenStartTS); }
void Sort::sortNodesByStartThenEndTS(vector<AssayNode *>* v) { sort(v->begin(), v->end(), sNodesByStartThenEndTS); }
void Sort::sortNodesByLatestTSThenStorage(vector<AssayNode *> *v) { sort(v->begin(), v->end(), sNodesByLatestTSThenStorage); }
void Sort::sortNodesByLatestTSAndStorage(vector<AssayNode *> *v) { sort(v->begin(), v->end(), sNodesByLatestTSAndStorage); }
void Sort::sortPathNodesByStartTS(list<AssayPathNode*>* l) { l->sort(sPathNodesByStartTS); }
void Sort::sortNodesByLength(vector<AssayNode*>* v) { sort(v->begin(), v->end(), sNodesByLength); }
void Sort::sortReconfigModsByStartThenEndTS(vector<ReconfigModule *>* v) { sort(v->begin(), v->end(), sReconfigModsByStartThenEndTS); }
void Sort::sortPathsBySharedPinSize(vector<Path *> *v) { sort(v->begin(), v->end(), sPathsBySharedPinSize); }
void Sort::sortPinGroupsByAvgMinDistToEdge(vector<vector<WireRouteNode*>* > *v) { sort(v->begin(), v->end(), sPinGroupsByAvgMinDistToEdge); }
void Sort::sortPinGroupsByPinGroupSize(vector<vector<WireRouteNode*>* > *v) { sort(v->begin(), v->end(), sPinGroupsByPinGroupSize); }
void Sort::sortPinGroupsByPinGroupArea(vector<vector<WireRouteNode*>* > *v) { sort(v->begin(), v->end(), sPinGroupsByPinGroupArea); }
void Sort::sortFixedModulesFromTopToBottom(vector<FixedModule*> *v) { sort(v->begin(), v->end(), sFixedModulesFromTopToBottom); }
void Sort::sortPortsNtoSthenPos(vector<IoPort *> *v) { sort(v->begin(), v->end(), sPortsNtoSthenPos); }
void Sort::sortPortsStoNthenPos(vector<IoPort *> *v) { sort(v->begin(), v->end(), sPortsStoNthenPos); }
void Sort::sortModulesFromTopToBot(vector<ReconfigModule *> *v) { sort(v->begin(), v->end(), sModulesFromTopToBot); }
void Sort::sortModulesFromBotToTop(vector<ReconfigModule *> *v) { sort(v->begin(), v->end(), sModulesFromTopToBot); }
void Sort::sortFppcNodesInIncreasingRouteDistance(vector<AssayNode *> *v) { sort(v->begin(), v->end(), sFppcNodesInIncreasingRouteDistance); }
void Sort::sortConditionsByOrder(vector<Condition*>* v) { sort(v->begin(), v->end(), sConditionsByOrder); }
void Sort::sortRoutesByLength(vector<vector<RoutePoint *> *> * v, vector<Droplet *> *vd)
{
map<vector<RoutePoint *> *, Droplet *> link;
for (unsigned i = 0; i < v->size(); i++)
link[v->at(i)] = vd->at(i);
sort(v->begin(), v->end(), sRoutesByLength);
vd->clear();
for (unsigned i = 0; i < v->size(); i++)
vd->push_back(link[v->at(i)]);
}
void Sort::sortPopBySchedTimes(vector< map<AssayNode*, unsigned> *> *pop, vector<unsigned> * times)
{
map<unsigned *, map<AssayNode*, unsigned> *> link;
for (unsigned i = 0; i < pop->size(); i++)
link[&(times->at(i))] = pop->at(i);
for (unsigned i = 0; i < times->size(); i++)
cout << times->at(i) << "(" << pop->at(i) << ")-";
cout << endl;
sort(times->begin(), times->end());
pop->clear();
for (unsigned i = 0; i < times->size(); i++)
pop->push_back(link[&(times->at(i))]);
for (unsigned i = 0; i < times->size(); i++)
cout << times->at(i) << "(" << pop->at(i) << ")-";
cout << endl;
exit(1);
}
///////////////////////////////////////////////////////////////////////////////////////
// Sorts routingThisTS in decreasing order, based on the manhattan distance between
// the corresponding source and target cells.
///////////////////////////////////////////////////////////////////////////////////////
void Sort::sortDropletsInDecManhattanDist(vector<Droplet *> *routingThisTS, map<Droplet *, SoukupCell *> *sourceCells, map<Droplet *, SoukupCell *> *targetCells)
{
vector<int *> distances;
map<int *, Droplet *> link;
for (unsigned i = 0; i < routingThisTS->size(); i++)
{
SoukupCell *s = sourceCells->at(routingThisTS->at(i));
SoukupCell *t = targetCells->at(routingThisTS->at(i));
int *manhattanDist = new int();
*manhattanDist = abs(s->x - t->x) + abs(s->y - t->y);
distances.push_back(manhattanDist);
link[manhattanDist] = routingThisTS->at(i);
}
//for (int i = 0; i < routingThisTS->size(); i++)
// cout << "D" << routingThisTS->at(i)->getId() << ": " << *distances.at(i) << endl;
sort(distances.begin(), distances.end(), sDecreasingInts);
routingThisTS->clear();
for (unsigned i = 0; i < distances.size(); i++)
routingThisTS->push_back(link[distances.at(i)]);
//for (int i = 0; i < routingThisTS->size(); i++)
// cout << "D" << routingThisTS->at(i)->getId() << ": " << *distances.at(i) << endl;
while (!distances.empty())
{
int *i = distances.back();
distances.pop_back();
delete i;
}
}
| 40.048359
| 161
| 0.522684
|
AryaFaramarzi
|
de881f7d037ca8a76ffc7fc942e14eab26df3e32
| 1,996
|
hpp
|
C++
|
src/backend/vm/value_type.hpp
|
korelang/kore
|
9fc06176406c2de2524382dff7e0d7d8e619c457
|
[
"BSD-3-Clause"
] | null | null | null |
src/backend/vm/value_type.hpp
|
korelang/kore
|
9fc06176406c2de2524382dff7e0d7d8e619c457
|
[
"BSD-3-Clause"
] | null | null | null |
src/backend/vm/value_type.hpp
|
korelang/kore
|
9fc06176406c2de2524382dff7e0d7d8e619c457
|
[
"BSD-3-Clause"
] | null | null | null |
#ifndef KORE_VALUE_TYPE_HPP
#define KORE_VALUE_TYPE_HPP
#include <ostream>
#include "frontend/internal_value_types.hpp"
namespace kore {
enum class ValueTag {
Bool,
I32,
I64,
F32,
F64,
Str,
};
/// The types for the vm's runtime values implemented
/// as a tagged union
struct Value {
ValueTag tag;
union _Value {
bool _bool;
i32 _i32;
i64 _i64;
f32 _f32;
f64 _f64;
} value;
inline bool as_bool() {
#if KORE_VM_DEBUG
if (tag != ValueTag::Bool) {
throw std::runtime_error("Not a boolean value");
}
#endif
return value._bool;
}
inline i32 as_i32() {
#if KORE_VM_DEBUG
if (tag != ValueTag::I32) {
throw std::runtime_error("Not an i32 value");
}
#endif
return value._i32;
}
inline i64 as_i64() {
#if KORE_VM_DEBUG
if (tag != ValueTag::I64) {
throw std::runtime_error("Not an i64 value");
}
#endif
return value._i64;
}
inline f32 as_f32() {
#if KORE_VM_DEBUG
if (tag != ValueTag::f32) {
throw std::runtime_error("Not an f32 value");
}
#endif
return value._f32;
}
inline f64 as_f64() {
#if KORE_VM_DEBUG
if (tag != ValueTag::f64) {
throw std::runtime_error("Not an f64 value");
}
#endif
return value._f64;
}
};
Value from_bool(bool value);
Value from_i32(i32 value);
Value from_i64(i64 value);
Value from_f32(f32 value);
Value from_f64(f64 value);
std::ostream& operator<<(std::ostream& out, const Value& value);
}
#endif // KORE_VALUE_TYPE_HPP
| 21.695652
| 68
| 0.483467
|
korelang
|
de8c886e2035c324bea7a1866f17e9a904d69b14
| 1,252
|
cpp
|
C++
|
Sources/Plugins/RenderSystem_GL/GLSLShaderSystem.cpp
|
jdelezenne/Sonata
|
fb1b1b64a78874a0ab2809995be4b6f14f9e4d56
|
[
"MIT"
] | null | null | null |
Sources/Plugins/RenderSystem_GL/GLSLShaderSystem.cpp
|
jdelezenne/Sonata
|
fb1b1b64a78874a0ab2809995be4b6f14f9e4d56
|
[
"MIT"
] | null | null | null |
Sources/Plugins/RenderSystem_GL/GLSLShaderSystem.cpp
|
jdelezenne/Sonata
|
fb1b1b64a78874a0ab2809995be4b6f14f9e4d56
|
[
"MIT"
] | null | null | null |
/*=============================================================================
GLSLShaderSystem.cpp
Project: Sonata Engine
Author: Julien Delezenne
=============================================================================*/
#include "GLSLShaderSystem.h"
#include "GLSLShaderProgram.h"
namespace SE_GL
{
GLSLShaderSystem::GLSLShaderSystem() :
ShaderSystem()
{
}
GLSLShaderSystem::~GLSLShaderSystem()
{
}
bool GLSLShaderSystem::Create()
{
return true;
}
void GLSLShaderSystem::Destroy()
{
}
void GLSLShaderSystem::Update(real64 elapsed)
{
}
ShaderProgram* GLSLShaderSystem::CreateShaderProgram(ShaderProgramType type)
{
ShaderProgram* program;
if (type == ShaderProgramType_Vertex)
{
program = new GLSLVertexShaderProgram(this);
}
else if (type == ShaderProgramType_Pixel)
{
program = new GLSLPixelShaderProgram(this);
}
else
{
return NULL;
}
return program;
}
void GLSLShaderSystem::DestroyShaderProgram(ShaderProgram* program)
{
if (program == NULL)
return;
delete program;
}
bool GLSLShaderSystem::SetShaderProgram(ShaderProgram* program)
{
if (program == NULL)
return false;
return program->Bind();
}
bool GLSLShaderSystem::DisableShaderProgram(ShaderProgram* program)
{
return program->Unbind();
}
}
| 16.25974
| 79
| 0.654952
|
jdelezenne
|
de8e04438ca08bec9df7cb3a061fa0504539a8dc
| 166
|
hxx
|
C++
|
src/Providers/UNIXProviders/PolicyRepositoryInPolicyRepository/UNIX_PolicyRepositoryInPolicyRepository_FREEBSD.hxx
|
brunolauze/openpegasus-providers-old
|
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
|
[
"MIT"
] | 1
|
2020-10-12T09:00:09.000Z
|
2020-10-12T09:00:09.000Z
|
src/Providers/UNIXProviders/PolicyRepositoryInPolicyRepository/UNIX_PolicyRepositoryInPolicyRepository_FREEBSD.hxx
|
brunolauze/openpegasus-providers-old
|
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
|
[
"MIT"
] | null | null | null |
src/Providers/UNIXProviders/PolicyRepositoryInPolicyRepository/UNIX_PolicyRepositoryInPolicyRepository_FREEBSD.hxx
|
brunolauze/openpegasus-providers-old
|
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
|
[
"MIT"
] | null | null | null |
#ifdef PEGASUS_OS_FREEBSD
#ifndef __UNIX_POLICYREPOSITORYINPOLICYREPOSITORY_PRIVATE_H
#define __UNIX_POLICYREPOSITORYINPOLICYREPOSITORY_PRIVATE_H
#endif
#endif
| 13.833333
| 59
| 0.885542
|
brunolauze
|
de8eef4f62e1f6780b1848fb0668b12182336276
| 2,211
|
hpp
|
C++
|
source/LibFgBase/src/FgPlatform.hpp
|
denim2x/FaceGenBaseLibrary
|
52317cf96984a47d7f2d0c5471230d689404101c
|
[
"MIT"
] | null | null | null |
source/LibFgBase/src/FgPlatform.hpp
|
denim2x/FaceGenBaseLibrary
|
52317cf96984a47d7f2d0c5471230d689404101c
|
[
"MIT"
] | null | null | null |
source/LibFgBase/src/FgPlatform.hpp
|
denim2x/FaceGenBaseLibrary
|
52317cf96984a47d7f2d0c5471230d689404101c
|
[
"MIT"
] | null | null | null |
//
// Copyright (c) 2019 Singular Inversions Inc. (facegen.com)
// Use, modification and distribution is subject to the MIT License,
// see accompanying file LICENSE.txt or facegen.com/base_library_license.txt
//
// Compile target platform and compiler specific definitions.
//
// ANSI defines:
// _DATE_
// _FILE_
// _LINE_
// _TIMESTAMP_
// NDEBUG Controls expression of ANSI 'assert'.
//
// MSVC defines:
// _WIN32 Compiling for windows (32 or 64 bit)
// _WIN64 Targeting 64-bit ISA
// _DEBUG Defined automatically by MSVC (/MTd or /MDd). We define for gcc/clang.
// _MSC_VER :
// 1800 : VS2013 12.0
// 1900 : VS2015 14.0
// 1910-1916 : VS2017 14.1
// 1920-1923 : VS2019 16
// _M_AMD64 Targeting Intel/AMD 64-bit ISA
// gcc,clang,icpc defines:
// __GNUC__ Compiler is gcc, clang or icpc
// __clang__ clang compiler
// __INTEL_COMPILER Intel's icc and icpc compilers
// _LP64 LP64 paradigm
// __x86_64__ Intel/AMD 64 bit ISA
// __ppc64__ PowerPC 64 bit ISA
// __APPLE__ Defined on all apple platform compilers (along with __MACH__)
// __ANDROID__
//
#ifndef FGPLATFORM_HPP
#define FGPLATFORM_HPP
#include "FgStdLibs.hpp"
// FaceGen defines:
// FG_64 Targeting 64-bit ISA (there is no cross-compiler standard for this)
#ifdef _WIN64
#define FG_64
#elif __x86_64__
#define FG_64
#endif
// FG_SANDBOX Targeting a sandboxed platform (eg. Android, iOS, WebAssembly). No system() calls etc.
#ifdef __ANDROID__
#define FG_SANDBOX
#endif
#if defined(__APPLE__) && defined(ENABLE_BITCODE)
// Including "TargetConditionals.h" and testing TARGET_OS_IPHONE does not work because this file
// is in sysroot/usr/include/ which doesn't compile with C++ (C only):
#define FG_SANDBOX
#endif
namespace Fg {
// Is current binary 64 bit (avoid 'conditional expression is constant') ?
bool
fgIs64bit();
// As above
bool
fgIsDebug();
// Returns "32 if the current executable is 32-bit, "64" if 64-bit.
std::string
fgBitsString();
}
#endif
| 28.346154
| 107
| 0.645862
|
denim2x
|
de93720a3eeb3d97501c06306f636429ddda6bfa
| 1,743
|
cpp
|
C++
|
utils/logging.cpp
|
XMrVertigoX/xXx_CPP
|
550f04ccb2ff772e5c8cd632c9a748a001533077
|
[
"MIT"
] | null | null | null |
utils/logging.cpp
|
XMrVertigoX/xXx_CPP
|
550f04ccb2ff772e5c8cd632c9a748a001533077
|
[
"MIT"
] | null | null | null |
utils/logging.cpp
|
XMrVertigoX/xXx_CPP
|
550f04ccb2ff772e5c8cd632c9a748a001533077
|
[
"MIT"
] | null | null | null |
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <FreeRTOS.h>
#include <task.h>
#include "logging.hpp"
static const size_t bytesPerLine = 16;
static inline uint32_t ticks2ms(TickType_t ticks) {
return (ticks * portTICK_PERIOD_MS);
}
static inline uint32_t getSeconds(TickType_t ticks) {
return (ticks2ms(ticks) / 1000);
}
static inline uint32_t getMilliseconds(TickType_t ticks) {
return (ticks2ms(ticks) % 1000);
}
static inline void printTime() {
TickType_t ticks = xTaskGetTickCount();
uint32_t seconds = getSeconds(ticks);
uint32_t milliseconds = getMilliseconds(ticks);
printf("[%5lu.%03lu] ", seconds, milliseconds);
}
namespace xXx {
void hexdump(const void *bytes, size_t numBytes) {
for (size_t i = 0; i < numBytes; i += bytesPerLine) {
printf("0x%08x:", i);
for (size_t j = i; j < (i + bytesPerLine); j++) {
char c;
if (j < numBytes) {
c = static_cast<const char *>(bytes)[j];
printf(" %02x", c);
} else {
printf(" ");
}
}
putchar(' ');
for (size_t j = i; j < (i + bytesPerLine); j++) {
char c;
if (j < numBytes) {
c = static_cast<const char *>(bytes)[j];
if (not isprint(c)) {
c = '.';
}
} else {
c = ' ';
}
putchar(c);
}
putchar('\n');
}
}
void log(const char *format, ...) {
printTime();
va_list arguments;
va_start(arguments, format);
vprintf(format, arguments);
va_end(arguments);
}
} /* namespace xXx */
| 21.256098
| 58
| 0.526104
|
XMrVertigoX
|
de9e74434fd6c5d27832ea6734411238fe56fa67
| 3,741
|
cpp
|
C++
|
src/lib/adatafield.cpp
|
leaderit/ananas-qt4
|
6830bf5074b316582a38f6bed147a1186dd7cc95
|
[
"MIT"
] | 1
|
2021-03-16T21:47:41.000Z
|
2021-03-16T21:47:41.000Z
|
src/lib/adatafield.cpp
|
leaderit/ananas-qt4
|
6830bf5074b316582a38f6bed147a1186dd7cc95
|
[
"MIT"
] | null | null | null |
src/lib/adatafield.cpp
|
leaderit/ananas-qt4
|
6830bf5074b316582a38f6bed147a1186dd7cc95
|
[
"MIT"
] | null | null | null |
/****************************************************************************
** $Id: adatafield.cpp,v 1.1 2008/11/05 21:16:28 leader Exp $
**
** Code file of the Ananas database field of Ananas
** Designer and Engine applications
**
** Created : 20031201
**
** Copyright (C) 2003-2004 Leader InfoTech. All rights reserved.
**
** This file is part of the Library of the Ananas
** automation accounting system.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.leaderit.ru/page=ananas or email sales@leaderit.ru
** See http://www.leaderit.ru/gpl/ for GPL licensing information.
**
** Contact org@leaderit.ru if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
//#include <qobject.h>
//#include "acfg.h"
#include "adatafield.h"
/*!
Create Ananas database field contaner.
*/
/*
aDataField::aDataField(aCfg *newmd, aCfgItem newcontext )
:QObject( 0, "aField" ) // name )
{
md = newmd;
context = newcontext;
// fType = type;
fTName = "";
// field = new QSqlField( fTName );
fSys = false;
}
*/
/*!
* Create Ananas field contaner.
*/
aDataField::aDataField( QObject *parent, const QString &name, const QString &type )
:QObject( parent, "aField" )
{
init( name, type );
}
/*!
* Create Ananas field contaner.
*/
aDataField::aDataField(const QString &name, const QString &type )
:QObject( 0, "aField" )
{
init( name, type );
}
aDataField::aDataField( const aDataField &field )
:QObject( 0, "aField" )
{
init( field.fieldName(), field.fType );
}
/*!
* Destroy object.
*/
aDataField::~aDataField()
{
// delete field;
}
aDataField&
aDataField::operator=( const aDataField& other )
{
Type = other.Type;
context = other.context;
id = other.id;;
md = other.md;
fSys = other.fSys;
Width = other.Width;
Dec = other.Dec;
Name = other.Name;
fType = other.fType;
aType = other.aType;
fieldData = other.fieldData;
return *this;
}
bool
aDataField::operator==( const aDataField& other ) const
{
return (
fSys == other.fSys &&
Name == other.Name &&
fType == other.fType &&
id == other.id &&
context == other.context
);
}
bool
aDataField::operator!=( const aDataField& other ) const
{
return !( other == *this );
}
void
aDataField::init( const QString &name, const QString &type )
{
QString t;
fSys = true;
Name = name;
fType = type;
Type = QVariant::Invalid;
if ( !type.isNull() ) {
aType = ( (const char *) type.section(" ",0,0).upper() )[0];
Width = type.section(" ",1,1).toInt();
Dec = type.section(" ",2,2).toInt();
switch ( aType ){
case 'C':
Type = QVariant::String;
fieldData = QString("");
break;
case 'N':
Type = QVariant::Double;
fieldData = ( double ) 0.0;
default:
Type = QVariant::Invalid;
}
}
}
/*!
Return pointer to asociated sql field.
*/
//QSqlField *
//aField::sqlField(){
// return field;
//}
/*!
*
*/
QVariant
aDataField::internalValue()
{
return fieldData;
}
/*!
*
*/
void
aDataField::setInternalValue( const QVariant &value)
{
fieldData = value;
}
/*!
* Возвращает значение поля данных.
*/
QVariant
aDataField::value()
{
return fieldData;
}
/*!
* Устанавливает значение поля данных.
*/
void
aDataField::setValue( const QVariant &value)
{
fieldData = value;
}
/*!
*
*/
int
aDataField::ObjectType()
{
return oType;
}
QString
aDataField::fieldName() const
{
return Name;
}
| 17.481308
| 83
| 0.636995
|
leaderit
|
dea3383bbe1211dcd2b00cfdb3f8141f81f6f04d
| 1,841
|
cpp
|
C++
|
src/r3.endlesss/endlesss/toolkit.exchange.cpp
|
Unbundlesss/OUROVEON
|
34dda511eda2a28b8522a724cfc9500a7914ea03
|
[
"MIT"
] | 6
|
2022-01-27T20:33:17.000Z
|
2022-02-16T18:29:43.000Z
|
src/r3.endlesss/endlesss/toolkit.exchange.cpp
|
Unbundlesss/OUROVEON
|
34dda511eda2a28b8522a724cfc9500a7914ea03
|
[
"MIT"
] | 4
|
2022-01-30T16:16:53.000Z
|
2022-02-20T20:07:25.000Z
|
src/r3.endlesss/endlesss/toolkit.exchange.cpp
|
Unbundlesss/OUROVEON
|
34dda511eda2a28b8522a724cfc9500a7914ea03
|
[
"MIT"
] | null | null | null |
// _______ _______ ______ _______ ___ ___ _______ _______ _______
// | | | | __ \ | | | ___| | | |
// | - | | | < - | | | ___| - | |
// |_______|_______|___|__|_______|\_____/|_______|_______|__|____|
// ishani.org 2022 e.t.c. MIT License
//
//
//
#include "pch.h"
#include "endlesss/toolkit.exchange.h"
#include "endlesss/live.riff.h"
#include "endlesss/live.stem.h"
namespace endlesss {
void Exchange::fillDetailsFromRiff( Exchange& data, const live::RiffPtr& riff, const char* jamName )
{
const auto* currentRiff = riff.get();
if ( currentRiff != nullptr )
{
data.m_dataflags |= DataFlags_Riff;
}
else
{
data.m_dataflags = DataFlags_Empty;
return;
}
strncpy(
data.m_jamName,
jamName,
endlesss::Exchange::MaxJamName - 1 );
const uint64_t currentRiffHash = currentRiff->getCIDHash().getID();
data.m_riffHash = currentRiffHash;
{
data.m_riffTimestamp = currentRiff->m_stTimestamp.time_since_epoch().count();
data.m_riffRoot = currentRiff->m_riffData.riff.root;
data.m_riffScale = currentRiff->m_riffData.riff.scale;
data.m_riffBPM = currentRiff->m_timingDetails.m_bpm;
data.m_riffBeatSegmentCount = currentRiff->m_timingDetails.m_quarterBeats;
}
for ( size_t sI = 0; sI < 8; sI++ )
{
const endlesss::live::Stem* stem = currentRiff->m_stemPtrs[sI];
if ( stem != nullptr )
{
data.m_stemColour[sI] = stem->m_colourU32;
data.m_stemGain[sI] = currentRiff->m_stemGains[sI];
data.setJammerName( sI, stem->m_data.user.c_str() );
}
}
}
} // namespace endlesss
| 30.180328
| 100
| 0.568169
|
Unbundlesss
|
dea4093891cf1c0ad10fac75f2675e11f486d4f5
| 596
|
cpp
|
C++
|
src/src/clonetest.cpp
|
yangkaioppen/imgpp
|
2212e8c80fc770a9bb24fed396ca43031de9e10f
|
[
"MIT"
] | 1
|
2020-05-12T07:35:39.000Z
|
2020-05-12T07:35:39.000Z
|
src/src/clonetest.cpp
|
yangkaioppen/imgpp
|
2212e8c80fc770a9bb24fed396ca43031de9e10f
|
[
"MIT"
] | 2
|
2020-04-22T05:27:47.000Z
|
2020-12-26T07:38:45.000Z
|
src/src/clonetest.cpp
|
yangkaioppen/imgpp
|
2212e8c80fc770a9bb24fed396ca43031de9e10f
|
[
"MIT"
] | 2
|
2020-04-20T05:55:12.000Z
|
2020-05-25T16:41:16.000Z
|
#include <imgpp/imgpp.hpp>
int main() {
// Test clone
{
imgpp::Img image(2, 2, 1, 1, 32, true, true, 1);
image.ROI().At<float>(0, 0) = 1.0f;
image.ROI().At<float>(0, 1) = 2.0f;
image.ROI().At<float>(1, 0) = 3.0f;
image.ROI().At<float>(1, 1) = 4.0f;
imgpp::Img clone = image.Clone();
// Make sure this is a deep copy.
if (image.Data().GetBuffer() == clone.Data().GetBuffer()) {
return 1;
}
// Check data.
if (std::memcmp(image.Data().GetBuffer(), clone.Data().GetBuffer(), image.Data().GetLength())) {
return 1;
}
}
return 0;
}
| 25.913043
| 100
| 0.541946
|
yangkaioppen
|
dea7bc77e719900abb506b3e47c937bd055b51e0
| 791
|
cpp
|
C++
|
9/969. Pancake Sorting.cpp
|
eagleoflqj/LeetCode
|
ca5dd06cad4c7fe5bf679cca7ee60f4348b316e9
|
[
"MIT"
] | null | null | null |
9/969. Pancake Sorting.cpp
|
eagleoflqj/LeetCode
|
ca5dd06cad4c7fe5bf679cca7ee60f4348b316e9
|
[
"MIT"
] | 1
|
2021-12-25T10:33:23.000Z
|
2022-02-16T00:34:05.000Z
|
9/969. Pancake Sorting.cpp
|
eagleoflqj/LeetCode
|
ca5dd06cad4c7fe5bf679cca7ee60f4348b316e9
|
[
"MIT"
] | null | null | null |
class Solution {
public:
vector<int> pancakeSort(vector<int>& arr) {
int n = arr.size();
vector<int> index(n), ret;
for(int i = 0; i < n; ++i)
index[arr[i] - 1] = i;
for(int i = n - 1; i > 0; --i)
if(index[i] != i) { // AxBy
ret.push_back(index[i] + 1); // xA'By
ret.push_back(i + 1); // yB'Ax
int d = i - index[i];
ret.push_back(d--); // ByAx
if(d)
ret.push_back(d); // B'yAx
ret.push_back(i); // A'yBx
if(index[i])
ret.push_back(index[i]); // AyBx
arr[index[i]] = arr[i];
index[arr[i] - 1] = index[i];
}
return ret;
}
};
| 31.64
| 53
| 0.380531
|
eagleoflqj
|
deacc28df8e4bcbba836c34c03bcf73c69eb7f6c
| 12,706
|
cpp
|
C++
|
src/Device/VertexProcessor.cpp
|
opersys/bbb-platform_external_swiftshader
|
54561baf5b7bd68e572326bf99a0c7ae1ecd76a2
|
[
"Apache-2.0"
] | null | null | null |
src/Device/VertexProcessor.cpp
|
opersys/bbb-platform_external_swiftshader
|
54561baf5b7bd68e572326bf99a0c7ae1ecd76a2
|
[
"Apache-2.0"
] | null | null | null |
src/Device/VertexProcessor.cpp
|
opersys/bbb-platform_external_swiftshader
|
54561baf5b7bd68e572326bf99a0c7ae1ecd76a2
|
[
"Apache-2.0"
] | null | null | null |
// Copyright 2016 The SwiftShader Authors. 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 "VertexProcessor.hpp"
#include "Pipeline/VertexProgram.hpp"
#include "Pipeline/VertexShader.hpp"
#include "Pipeline/PixelShader.hpp"
#include "Pipeline/Constants.hpp"
#include "System/Math.hpp"
#include "Vulkan/VkDebug.hpp"
#include <string.h>
namespace sw
{
bool precacheVertex = false;
void VertexCache::clear()
{
for(int i = 0; i < 16; i++)
{
tag[i] = 0x80000000;
}
}
unsigned int VertexProcessor::States::computeHash()
{
unsigned int *state = (unsigned int*)this;
unsigned int hash = 0;
for(unsigned int i = 0; i < sizeof(States) / 4; i++)
{
hash ^= state[i];
}
return hash;
}
VertexProcessor::State::State()
{
memset(this, 0, sizeof(State));
}
bool VertexProcessor::State::operator==(const State &state) const
{
if(hash != state.hash)
{
return false;
}
return memcmp(static_cast<const States*>(this), static_cast<const States*>(&state), sizeof(States)) == 0;
}
VertexProcessor::TransformFeedbackInfo::TransformFeedbackInfo()
{
buffer = nullptr;
offset = 0;
reg = 0;
row = 0;
col = 0;
stride = 0;
}
VertexProcessor::UniformBufferInfo::UniformBufferInfo()
{
buffer = nullptr;
offset = 0;
}
VertexProcessor::VertexProcessor(Context *context) : context(context)
{
routineCache = nullptr;
setRoutineCacheSize(1024);
}
VertexProcessor::~VertexProcessor()
{
delete routineCache;
routineCache = nullptr;
}
void VertexProcessor::setInputStream(int index, const Stream &stream)
{
context->input[index] = stream;
}
void VertexProcessor::resetInputStreams()
{
for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{
context->input[i].defaults();
}
}
void VertexProcessor::setFloatConstant(unsigned int index, const float value[4])
{
if(index < VERTEX_UNIFORM_VECTORS)
{
c[index][0] = value[0];
c[index][1] = value[1];
c[index][2] = value[2];
c[index][3] = value[3];
}
else ASSERT(false);
}
void VertexProcessor::setIntegerConstant(unsigned int index, const int integer[4])
{
if(index < 16)
{
i[index][0] = integer[0];
i[index][1] = integer[1];
i[index][2] = integer[2];
i[index][3] = integer[3];
}
else ASSERT(false);
}
void VertexProcessor::setBooleanConstant(unsigned int index, int boolean)
{
if(index < 16)
{
b[index] = boolean != 0;
}
else ASSERT(false);
}
void VertexProcessor::setUniformBuffer(int index, sw::Resource* buffer, int offset)
{
uniformBufferInfo[index].buffer = buffer;
uniformBufferInfo[index].offset = offset;
}
void VertexProcessor::lockUniformBuffers(byte** u, sw::Resource* uniformBuffers[])
{
for(int i = 0; i < MAX_UNIFORM_BUFFER_BINDINGS; ++i)
{
u[i] = uniformBufferInfo[i].buffer ? static_cast<byte*>(uniformBufferInfo[i].buffer->lock(PUBLIC, PRIVATE)) + uniformBufferInfo[i].offset : nullptr;
uniformBuffers[i] = uniformBufferInfo[i].buffer;
}
}
void VertexProcessor::setTransformFeedbackBuffer(int index, sw::Resource* buffer, int offset, unsigned int reg, unsigned int row, unsigned int col, unsigned int stride)
{
transformFeedbackInfo[index].buffer = buffer;
transformFeedbackInfo[index].offset = offset;
transformFeedbackInfo[index].reg = reg;
transformFeedbackInfo[index].row = row;
transformFeedbackInfo[index].col = col;
transformFeedbackInfo[index].stride = stride;
}
void VertexProcessor::lockTransformFeedbackBuffers(byte** t, unsigned int* v, unsigned int* r, unsigned int* c, unsigned int* s, sw::Resource* transformFeedbackBuffers[])
{
for(int i = 0; i < MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS; ++i)
{
t[i] = transformFeedbackInfo[i].buffer ? static_cast<byte*>(transformFeedbackInfo[i].buffer->lock(PUBLIC, PRIVATE)) + transformFeedbackInfo[i].offset : nullptr;
transformFeedbackBuffers[i] = transformFeedbackInfo[i].buffer;
v[i] = transformFeedbackInfo[i].reg;
r[i] = transformFeedbackInfo[i].row;
c[i] = transformFeedbackInfo[i].col;
s[i] = transformFeedbackInfo[i].stride;
}
}
void VertexProcessor::setInstanceID(int instanceID)
{
context->instanceID = instanceID;
}
void VertexProcessor::setTextureFilter(unsigned int sampler, FilterType textureFilter)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setTextureFilter(textureFilter);
}
else ASSERT(false);
}
void VertexProcessor::setMipmapFilter(unsigned int sampler, MipmapType mipmapFilter)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMipmapFilter(mipmapFilter);
}
else ASSERT(false);
}
void VertexProcessor::setGatherEnable(unsigned int sampler, bool enable)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setGatherEnable(enable);
}
else ASSERT(false);
}
void VertexProcessor::setAddressingModeU(unsigned int sampler, AddressingMode addressMode)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setAddressingModeU(addressMode);
}
else ASSERT(false);
}
void VertexProcessor::setAddressingModeV(unsigned int sampler, AddressingMode addressMode)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setAddressingModeV(addressMode);
}
else ASSERT(false);
}
void VertexProcessor::setAddressingModeW(unsigned int sampler, AddressingMode addressMode)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setAddressingModeW(addressMode);
}
else ASSERT(false);
}
void VertexProcessor::setReadSRGB(unsigned int sampler, bool sRGB)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setReadSRGB(sRGB);
}
else ASSERT(false);
}
void VertexProcessor::setMipmapLOD(unsigned int sampler, float bias)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMipmapLOD(bias);
}
else ASSERT(false);
}
void VertexProcessor::setBorderColor(unsigned int sampler, const Color<float> &borderColor)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setBorderColor(borderColor);
}
else ASSERT(false);
}
void VertexProcessor::setMaxAnisotropy(unsigned int sampler, float maxAnisotropy)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMaxAnisotropy(maxAnisotropy);
}
else ASSERT(false);
}
void VertexProcessor::setHighPrecisionFiltering(unsigned int sampler, bool highPrecisionFiltering)
{
if(sampler < TEXTURE_IMAGE_UNITS)
{
context->sampler[sampler].setHighPrecisionFiltering(highPrecisionFiltering);
}
else ASSERT(false);
}
void VertexProcessor::setSwizzleR(unsigned int sampler, SwizzleType swizzleR)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setSwizzleR(swizzleR);
}
else ASSERT(false);
}
void VertexProcessor::setSwizzleG(unsigned int sampler, SwizzleType swizzleG)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setSwizzleG(swizzleG);
}
else ASSERT(false);
}
void VertexProcessor::setSwizzleB(unsigned int sampler, SwizzleType swizzleB)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setSwizzleB(swizzleB);
}
else ASSERT(false);
}
void VertexProcessor::setSwizzleA(unsigned int sampler, SwizzleType swizzleA)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setSwizzleA(swizzleA);
}
else ASSERT(false);
}
void VertexProcessor::setCompareFunc(unsigned int sampler, CompareFunc compFunc)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setCompareFunc(compFunc);
}
else ASSERT(false);
}
void VertexProcessor::setBaseLevel(unsigned int sampler, int baseLevel)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setBaseLevel(baseLevel);
}
else ASSERT(false);
}
void VertexProcessor::setMaxLevel(unsigned int sampler, int maxLevel)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMaxLevel(maxLevel);
}
else ASSERT(false);
}
void VertexProcessor::setMinLod(unsigned int sampler, float minLod)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMinLod(minLod);
}
else ASSERT(false);
}
void VertexProcessor::setMaxLod(unsigned int sampler, float maxLod)
{
if(sampler < VERTEX_TEXTURE_IMAGE_UNITS)
{
context->sampler[TEXTURE_IMAGE_UNITS + sampler].setMaxLod(maxLod);
}
else ASSERT(false);
}
void VertexProcessor::setPointSizeMin(float pointSizeMin)
{
this->pointSizeMin = pointSizeMin;
}
void VertexProcessor::setPointSizeMax(float pointSizeMax)
{
this->pointSizeMax = pointSizeMax;
}
void VertexProcessor::setTransformFeedbackQueryEnabled(bool enable)
{
context->transformFeedbackQueryEnabled = enable;
}
void VertexProcessor::enableTransformFeedback(uint64_t enable)
{
context->transformFeedbackEnabled = enable;
}
void VertexProcessor::setRoutineCacheSize(int cacheSize)
{
delete routineCache;
routineCache = new RoutineCache<State>(clamp(cacheSize, 1, 65536), precacheVertex ? "sw-vertex" : 0);
}
const VertexProcessor::State VertexProcessor::update(DrawType drawType)
{
State state;
state.shaderID = context->vertexShader->getSerialID();
state.fixedFunction = !context->vertexShader && context->pixelShaderModel() < 0x0300;
state.textureSampling = context->vertexShader ? context->vertexShader->containsTextureSampling() : false;
state.positionRegister = context->vertexShader ? context->vertexShader->getPositionRegister() : Pos;
state.pointSizeRegister = context->vertexShader ? context->vertexShader->getPointSizeRegister() : Pts;
state.multiSampling = context->getMultiSampleCount() > 1;
state.transformFeedbackQueryEnabled = context->transformFeedbackQueryEnabled;
state.transformFeedbackEnabled = context->transformFeedbackEnabled;
// Note: Quads aren't handled for verticesPerPrimitive, but verticesPerPrimitive is used for transform feedback,
// which is an OpenGL ES 3.0 feature, and OpenGL ES 3.0 doesn't support quads as a primitive type.
DrawType type = static_cast<DrawType>(static_cast<unsigned int>(drawType) & 0xF);
state.verticesPerPrimitive = 1 + (type >= DRAW_LINELIST) + (type >= DRAW_TRIANGLELIST);
for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{
state.input[i].type = context->input[i].type;
state.input[i].count = context->input[i].count;
state.input[i].normalized = context->input[i].normalized;
state.input[i].attribType = context->vertexShader ? context->vertexShader->getAttribType(i) : SpirvShader::ATTRIBTYPE_FLOAT;
}
for(unsigned int i = 0; i < VERTEX_TEXTURE_IMAGE_UNITS; i++)
{
if(context->vertexShader->usesSampler(i))
{
state.sampler[i] = context->sampler[TEXTURE_IMAGE_UNITS + i].samplerState();
}
}
if(context->vertexShader) // FIXME: Also when pre-transformed?
{
for(int i = 0; i < MAX_VERTEX_OUTPUTS; i++)
{
state.output[i].xWrite = context->vertexShader->getOutput(i, 0).active();
state.output[i].yWrite = context->vertexShader->getOutput(i, 1).active();
state.output[i].zWrite = context->vertexShader->getOutput(i, 2).active();
state.output[i].wWrite = context->vertexShader->getOutput(i, 3).active();
}
}
state.hash = state.computeHash();
return state;
}
Routine *VertexProcessor::routine(const State &state)
{
Routine *routine = routineCache->query(state);
if(!routine) // Create one
{
VertexRoutine *generator = new VertexProgram(state, context->vertexShader);
generator->generate();
routine = (*generator)("VertexRoutine_%0.8X", state.shaderID);
delete generator;
routineCache->add(state, routine);
}
return routine;
}
}
| 27.681917
| 171
| 0.730364
|
opersys
|
deb01d3a6b355ab470ed94ce35a2df080e5f3df1
| 160
|
cpp
|
C++
|
system/system.cpp
|
firngrod/firnlibs
|
a8fbdd22ec3b0a9497b809e8b86092e0affea995
|
[
"MIT"
] | null | null | null |
system/system.cpp
|
firngrod/firnlibs
|
a8fbdd22ec3b0a9497b809e8b86092e0affea995
|
[
"MIT"
] | null | null | null |
system/system.cpp
|
firngrod/firnlibs
|
a8fbdd22ec3b0a9497b809e8b86092e0affea995
|
[
"MIT"
] | null | null | null |
#include "system.hpp"
#include <thread>
namespace FirnLibs{ namespace System{
int GetProcessorCount()
{
return std::thread::hardware_concurrency();
}
}}
| 11.428571
| 45
| 0.725
|
firngrod
|
deb21c7ff38d279093e60fc31fdf79e46e950c16
| 7,714
|
cpp
|
C++
|
media_driver/agnostic/common/codec/hal/codechal_mmc_decode_vp8.cpp
|
xinfengz/media-driver
|
310104a4693c476a215de13e7e9fabdf2afbad0a
|
[
"Intel",
"BSD-3-Clause",
"MIT"
] | 1
|
2019-09-26T23:48:34.000Z
|
2019-09-26T23:48:34.000Z
|
media_driver/agnostic/common/codec/hal/codechal_mmc_decode_vp8.cpp
|
xinfengz/media-driver
|
310104a4693c476a215de13e7e9fabdf2afbad0a
|
[
"Intel",
"BSD-3-Clause",
"MIT"
] | null | null | null |
media_driver/agnostic/common/codec/hal/codechal_mmc_decode_vp8.cpp
|
xinfengz/media-driver
|
310104a4693c476a215de13e7e9fabdf2afbad0a
|
[
"Intel",
"BSD-3-Clause",
"MIT"
] | 1
|
2017-12-11T03:28:35.000Z
|
2017-12-11T03:28:35.000Z
|
/*
* Copyright (c) 2017, Intel Corporation
*
* 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.
*/
//!
//! \file codechal_mmc_decode_vp8.cpp
//! \brief Impelements the public interface for CodecHal Media Memory Compression
//!
#include "codechal_mmc_decode_vp8.h"
CodechalMmcDecodeVp8::CodechalMmcDecodeVp8(
CodechalHwInterface *hwInterface,
void *standardState):
CodecHalMmcState(hwInterface)
{
CODECHAL_DECODE_FUNCTION_ENTER;
m_vp8State = (CodechalDecodeVp8 *)standardState;
CODECHAL_HW_ASSERT(m_vp8State);
CODECHAL_HW_ASSERT(hwInterface);
CODECHAL_HW_ASSERT(hwInterface->GetSkuTable());
if (MEDIA_IS_SKU(hwInterface->GetSkuTable(), FtrMemoryCompression))
{
MOS_USER_FEATURE_VALUE_DATA userFeatureData;
MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData));
userFeatureData.i32Data = m_mmcEnabled;
userFeatureData.i32DataFlag = MOS_USER_FEATURE_VALUE_DATA_FLAG_CUSTOM_DEFAULT_VALUE_TYPE;
CodecHal_UserFeature_ReadValue(
nullptr,
__MEDIA_USER_FEATURE_VALUE_DECODE_MMC_ENABLE_ID,
&userFeatureData);
m_mmcEnabled = (userFeatureData.i32Data) ? true : false;
MOS_USER_FEATURE_VALUE_WRITE_DATA userFeatureWriteData;
MOS_ZeroMemory(&userFeatureWriteData, sizeof(userFeatureWriteData));
userFeatureWriteData.Value.i32Data = m_mmcEnabled;
userFeatureWriteData.ValueID = __MEDIA_USER_FEATURE_VALUE_DECODE_MMC_IN_USE_ID;
CodecHal_UserFeature_WriteValue(nullptr, &userFeatureWriteData);
}
#if (_DEBUG || _RELEASE_INTERNAL)
m_compressibleId = __MEDIA_USER_FEATURE_VALUE_MMC_DEC_RT_COMPRESSIBLE_ID;
m_compressModeId = __MEDIA_USER_FEATURE_VALUE_MMC_DEC_RT_COMPRESSMODE_ID;
#endif
}
MOS_STATUS CodechalMmcDecodeVp8::SetPipeBufAddr(
PMHW_VDBOX_PIPE_BUF_ADDR_PARAMS pipeBufAddrParams,
PMOS_COMMAND_BUFFER cmdBuffer)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
CODECHAL_DECODE_FUNCTION_ENTER;
// MMC is only enabled for frame decoding and no interlaced support in VP8
// So no need to check frame/field type here.
if (m_mmcEnabled && m_vp8State->sDestSurface.bCompressible)
{
if (m_vp8State->bDeblockingEnabled)
{
pipeBufAddrParams->PostDeblockSurfMmcState = MOS_MEMCOMP_HORIZONTAL;
}
else
{
pipeBufAddrParams->PreDeblockSurfMmcState = MOS_MEMCOMP_VERTICAL;
}
}
CODECHAL_DEBUG_TOOL(
m_vp8State->sDestSurface.MmcState = m_vp8State->bDeblockingEnabled ?
pipeBufAddrParams->PostDeblockSurfMmcState : pipeBufAddrParams->PreDeblockSurfMmcState;
)
return eStatus;
}
MOS_STATUS CodechalMmcDecodeVp8::SetRefrenceSync(
bool disableDecodeSyncLock,
bool disableLockForTranscode)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
CODECHAL_DECODE_FUNCTION_ENTER;
// Check if reference surface needs to be synchronized in MMC case
if (m_mmcEnabled)
{
MOS_SYNC_PARAMS syncParams = g_cInitSyncParams;
syncParams.GpuContext = m_vp8State->GetVideoContext();
syncParams.bDisableDecodeSyncLock = disableDecodeSyncLock;
syncParams.bDisableLockForTranscode = disableLockForTranscode;
if (m_vp8State->presLastRefSurface)
{
syncParams.presSyncResource = m_vp8State->presLastRefSurface;
syncParams.bReadOnly = true;
CODECHAL_DECODE_CHK_STATUS_RETURN(m_osInterface->pfnPerformOverlaySync(m_osInterface, &syncParams));
CODECHAL_DECODE_CHK_STATUS_RETURN(m_osInterface->pfnResourceWait(m_osInterface, &syncParams));
m_osInterface->pfnSetResourceSyncTag(m_osInterface, &syncParams);
}
if (m_vp8State->presGoldenRefSurface)
{
syncParams.presSyncResource = m_vp8State->presGoldenRefSurface;
syncParams.bReadOnly = true;
CODECHAL_DECODE_CHK_STATUS_RETURN(m_osInterface->pfnPerformOverlaySync(m_osInterface, &syncParams));
CODECHAL_DECODE_CHK_STATUS_RETURN(m_osInterface->pfnResourceWait(m_osInterface, &syncParams));
m_osInterface->pfnSetResourceSyncTag(m_osInterface, &syncParams);
}
if (m_vp8State->presAltRefSurface)
{
syncParams.presSyncResource = m_vp8State->presAltRefSurface;
syncParams.bReadOnly = true;
CODECHAL_DECODE_CHK_STATUS_RETURN(m_osInterface->pfnPerformOverlaySync(m_osInterface, &syncParams));
CODECHAL_DECODE_CHK_STATUS_RETURN(m_osInterface->pfnResourceWait(m_osInterface, &syncParams));
m_osInterface->pfnSetResourceSyncTag(m_osInterface, &syncParams);
}
}
return eStatus;
}
MOS_STATUS CodechalMmcDecodeVp8::CheckReferenceList(
PMHW_VDBOX_PIPE_BUF_ADDR_PARAMS pipeBufAddrParams)
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
CODECHAL_DECODE_FUNCTION_ENTER;
CODECHAL_DECODE_CHK_NULL_RETURN(pipeBufAddrParams);
CODECHAL_DECODE_CHK_NULL_RETURN(m_vp8State->pVp8PicParams);
// Disable MMC if self-reference is dectected for P/B frames (mainly for error concealment)
if ((pipeBufAddrParams->PostDeblockSurfMmcState != MOS_MEMCOMP_DISABLED ||
pipeBufAddrParams->PreDeblockSurfMmcState != MOS_MEMCOMP_DISABLED) &&
m_vp8State->pVp8PicParams->key_frame != I_TYPE)
{
bool selfReference = false;
if ((m_vp8State->pVp8PicParams->ucCurrPicIndex == m_vp8State->pVp8PicParams->ucLastRefPicIndex) ||
(m_vp8State->pVp8PicParams->ucCurrPicIndex == m_vp8State->pVp8PicParams->ucGoldenRefPicIndex) ||
(m_vp8State->pVp8PicParams->ucCurrPicIndex == m_vp8State->pVp8PicParams->ucAltRefPicIndex)
)
{
selfReference = true;
}
if (selfReference)
{
pipeBufAddrParams->PostDeblockSurfMmcState = MOS_MEMCOMP_DISABLED;
pipeBufAddrParams->PreDeblockSurfMmcState = MOS_MEMCOMP_DISABLED;
CODECHAL_DECODE_ASSERTMESSAGE("Self-reference is detected for P/B frames!");
// Decompress current frame to avoid green corruptions in this error handling case
MOS_MEMCOMP_STATE mmcMode;
CODECHAL_DECODE_CHK_STATUS_RETURN(
m_osInterface->pfnGetMemoryCompressionMode(
m_osInterface,
&m_vp8State->sDestSurface.OsResource,
&mmcMode));
if (mmcMode != MOS_MEMCOMP_DISABLED)
{
m_osInterface->pfnDecompResource(
m_osInterface,
&m_vp8State->sDestSurface.OsResource);
}
}
}
return eStatus;
}
| 39.558974
| 112
| 0.717267
|
xinfengz
|
deb2487da9f4648a10b685865133c036e41c6b66
| 2,191
|
cpp
|
C++
|
src/application_item.cpp
|
haiziyan/mayo
|
330099948bb8626a56d138c62509d85f7f0e1d94
|
[
"BSD-2-Clause"
] | null | null | null |
src/application_item.cpp
|
haiziyan/mayo
|
330099948bb8626a56d138c62509d85f7f0e1d94
|
[
"BSD-2-Clause"
] | null | null | null |
src/application_item.cpp
|
haiziyan/mayo
|
330099948bb8626a56d138c62509d85f7f0e1d94
|
[
"BSD-2-Clause"
] | 1
|
2022-03-10T03:28:53.000Z
|
2022-03-10T03:28:53.000Z
|
/****************************************************************************
** Copyright (c) 2019, Fougue Ltd. <http://www.fougue.pro>
** All rights reserved.
** See license at https://github.com/fougue/mayo/blob/master/LICENSE.txt
****************************************************************************/
#include "application_item.h"
namespace Mayo {
ApplicationItem::ApplicationItem(Document *doc)
: m_doc(doc),
m_docItem(nullptr),
m_docItemNode(DocumentItemNode::null())
{ }
ApplicationItem::ApplicationItem(DocumentItem *docItem)
: m_doc(nullptr),
m_docItem(docItem),
m_docItemNode(DocumentItemNode::null())
{ }
ApplicationItem::ApplicationItem(const DocumentItemNode &node)
: m_doc(nullptr),
m_docItem(nullptr),
m_docItemNode(node)
{ }
bool ApplicationItem::isValid() const {
return this->isDocument()
|| this->isDocumentItem()
|| this->isDocumentItemNode();
}
bool ApplicationItem::isDocument() const {
return m_doc != nullptr;
}
bool ApplicationItem::isDocumentItem() const {
return m_docItem != nullptr;
}
bool ApplicationItem::isDocumentItemNode() const {
return m_docItemNode.isValid();
}
Document* ApplicationItem::document() const
{
if (this->isDocument())
return m_doc;
else if (this->isDocumentItem())
return m_docItem->document();
else if (this->isDocumentItemNode())
return m_docItemNode.documentItem->document();
return nullptr;
}
DocumentItem* ApplicationItem::documentItem() const
{
if (this->isDocumentItem())
return m_docItem;
else if (this->isDocumentItemNode())
return m_docItemNode.documentItem;
return nullptr;
}
const DocumentItemNode& ApplicationItem::documentItemNode() const
{
return this->isDocumentItemNode() ?
m_docItemNode : DocumentItemNode::null();
}
bool ApplicationItem::operator==(const ApplicationItem &other) const
{
return m_doc == other.m_doc
&& m_docItem == other.m_docItem
&& m_docItemNode.documentItem == other.m_docItemNode.documentItem
&& m_docItemNode.id == other.m_docItemNode.id;
}
} // namespace Mayo
| 26.083333
| 77
| 0.63487
|
haiziyan
|
deb3f64aa62ff8b78015a35cd2871c9c185f0ac7
| 250
|
inl
|
C++
|
node_modules/lzz-gyp/lzz-source/util_GetIdent.inl
|
SuperDizor/dizornator
|
9f57dbb3f6af80283b4d977612c95190a3d47900
|
[
"ISC"
] | 3
|
2019-09-18T16:44:33.000Z
|
2021-03-29T13:45:27.000Z
|
node_modules/lzz-gyp/lzz-source/util_GetIdent.inl
|
SuperDizor/dizornator
|
9f57dbb3f6af80283b4d977612c95190a3d47900
|
[
"ISC"
] | null | null | null |
node_modules/lzz-gyp/lzz-source/util_GetIdent.inl
|
SuperDizor/dizornator
|
9f57dbb3f6af80283b4d977612c95190a3d47900
|
[
"ISC"
] | 2
|
2019-03-29T01:06:38.000Z
|
2019-09-18T16:44:34.000Z
|
// util_GetIdent.inl
//
#ifdef LZZ_ENABLE_INLINE
#define LZZ_INLINE inline
#else
#define LZZ_INLINE
#endif
namespace util
{
LZZ_INLINE util::Ident getIdent (util::String const & str)
{
return getIdent (str.c_str ());
}
}
#undef LZZ_INLINE
| 14.705882
| 60
| 0.72
|
SuperDizor
|
630c2a572b4cfece5fbe93d893400196dc33c44d
| 870
|
cpp
|
C++
|
Chapter10/chapter10-7.cpp
|
kozborn/programing-principles-and-practise-using-cpp
|
7fefba8765e26af83f138e660861fe5b90adcda4
|
[
"MIT"
] | null | null | null |
Chapter10/chapter10-7.cpp
|
kozborn/programing-principles-and-practise-using-cpp
|
7fefba8765e26af83f138e660861fe5b90adcda4
|
[
"MIT"
] | null | null | null |
Chapter10/chapter10-7.cpp
|
kozborn/programing-principles-and-practise-using-cpp
|
7fefba8765e26af83f138e660861fe5b90adcda4
|
[
"MIT"
] | null | null | null |
#include "../std_lib_facilities.h"
void skip_to_int() {
if (cin.fail())
{
cin.clear();
char ch;
while (cin >> ch && !isdigit(ch));
if (!cin) error("Brak danych");
cin.unget();
}
}
int get_int() {
int n = 0;
while(true) {
if(cin >> n) return n;
cout << "That was not a number, please try again" << endl;
skip_to_int();
}
}
int get_int(int min, int max) {
int i = 0;
while(true) {
i = get_int();
if(min <= i && i <= max) return i;
cout << "Sorry, but " << i << " doesn't belong to [" << min << ", " << max << "]" << endl;
}
}
int main() {
try {
int i = 0;
cout << "Provide a number between 1 and 10" << endl;
while(true) {
i = get_int(1, 10);
}
} catch(...) {
cerr << "Something went wrong" << endl;
return 1;
}
return 0;
}
| 19.333333
| 95
| 0.472414
|
kozborn
|
630c477e15b064e58df18997b45b2ffc5d52c4b4
| 5,703
|
cpp
|
C++
|
main.cpp
|
SirDifferential/minimal_movidius
|
73dc436c6151c022963108fb82b9262a838b0d95
|
[
"MIT"
] | 1
|
2017-10-02T17:32:32.000Z
|
2017-10-02T17:32:32.000Z
|
main.cpp
|
SirDifferential/minimal_movidius
|
73dc436c6151c022963108fb82b9262a838b0d95
|
[
"MIT"
] | null | null | null |
main.cpp
|
SirDifferential/minimal_movidius
|
73dc436c6151c022963108fb82b9262a838b0d95
|
[
"MIT"
] | null | null | null |
#include <mvnc.h>
#include <vector>
#include <stdio.h>
#include <string>
#include <chrono>
#include <unistd.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#include "movidiusdevice.h"
const int req_width = 227;
const int req_height = 227;
const bool show_perfs = false;
const bool show_results = false;
int runNetwork(const std::vector<std::string>& fnames,
const std::vector<unsigned char*>& images,
movidius_device* movidius_dev,
const std::string& networkPath)
{
std::chrono::high_resolution_clock::time_point t1;
std::chrono::high_resolution_clock::time_point t2;
std::chrono::high_resolution_clock::time_point t3;
strcpy(movidius_dev->networkPath, networkPath.c_str());
int ret = movidius_uploadNetwork(movidius_dev);
if (ret != 0)
{
fprintf(stderr, "Failed allocating graph: %d\n", ret);
return 1;
}
float* results = NULL;
if (movidius_dev->numCategories == 0)
{
fprintf(stderr, "no categories after loading network\n");
return 1;
}
results = new float[movidius_dev->numCategories];
memset(results, 0, sizeof(float) * movidius_dev->numCategories);
for (int c = 0; c < fnames.size(); c++)
{
t1 = std::chrono::high_resolution_clock::now();
if (movidius_convertImage((movidius_RGB*)images.at(c), req_width,req_height, movidius_dev) != 0)
{
fprintf(stderr, "failed converting image to 16bit float format\n");
return 1;
}
t2 = std::chrono::high_resolution_clock::now();
int ret = movidius_runInference(movidius_dev, results);
t3 = std::chrono::high_resolution_clock::now();
if (ret != 0)
{
fprintf(stderr, "runinference failure: %d for image %s\n", ret, fnames.at(c).c_str());
return 1;
}
auto dur1 = std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1).count();
auto dur2 = std::chrono::duration_cast<std::chrono::microseconds>(t3 - t2).count();
if (show_perfs)
{
fprintf(stderr, "convertImage(): %d us\n", dur1);
fprintf(stderr, "runInference(): %d us\n", dur2);
}
if (show_results)
{
for (int cat = 0; cat < movidius_dev->numCategories; cat++)
{
fprintf(stderr, "category %d (%s): %f\n", cat, movidius_dev->categories[cat], results[cat]);
}
}
}
ret = movidius_deallocateGraph(movidius_dev);
if (ret != 0)
{
fprintf(stderr, "Failed deallocating graph: %d\n", ret);
return 1;
}
delete[] results;
results = NULL;
return 0;
}
int main(int argc, char** argv)
{
movidius_device movidius_dev;
memset(&movidius_dev, 0, sizeof(movidius_device));
if (movidius_openDevice(&movidius_dev) != 0)
return 1;
std::vector<unsigned char*> images;
std::vector<std::string> fnames;
fnames.push_back("./sample_1505732941144.png");
fnames.push_back("./sample_1505732942167.png");
fnames.push_back("./sample_1505732945220.png");
fnames.push_back("./sample_1505732946240.png");
fnames.push_back("./sample_1505732947259.png");
fnames.push_back("./sample_1505732948277.png");
fnames.push_back("./sample_1505732949297.png");
fnames.push_back("./sample_1505732952353.png");
// load images from disk
for (int c = 0; c < fnames.size(); c++)
{
int width, height, cp;
width = height = cp = 0;
unsigned char* img = stbi_load(fnames.at(c).c_str(), &width, &height, &cp, 3);
if (img == NULL)
{
fprintf(stderr, "The image %s could not be loaded\n", fnames.at(c).c_str());
return 1;
}
if (width != req_width || height != req_height)
{
fprintf(stderr, "Invalid size for image %s. Expected %d x %d, got %d x %d\n",
fnames.at(c).c_str(), width, height, req_width, req_height);
return 1;
}
images.push_back(img);
}
int loops = 0;
int loops_total = 4;
int ret = 0;
// run networks a few times
while (loops < loops_total)
{
loops++;
ret = runNetwork(fnames, images, &movidius_dev, "./network/Age");
if (ret != 0)
{
fprintf(stderr, "Age network failed: %d\n", ret);
break;
}
ret = runNetwork(fnames, images, &movidius_dev, "./network/Gender");
if (ret != 0)
{
fprintf(stderr, "Gender network failed: %d\n", ret);
break;
}
ret = runNetwork(fnames, images, &movidius_dev, "./network/Age");
if (ret != 0)
{
fprintf(stderr, "Age network failed: %d\n", ret);
break;
}
ret = runNetwork(fnames, images, &movidius_dev, "./network/Gender");
if (ret != 0)
{
fprintf(stderr, "Gender network failed: %d\n", ret);
break;
}
ret = runNetwork(fnames, images, &movidius_dev, "./network/Age");
if (ret != 0)
{
fprintf(stderr, "Age network failed: %d\n", ret);
break;
}
ret = runNetwork(fnames, images, &movidius_dev, "./network/Gender");
if (ret != 0)
{
fprintf(stderr, "Gender network failed: %d\n", ret);
break;
}
fprintf(stderr, "Done with loop %d / %d\n", loops, loops_total);
}
for (int c = 0; c < images.size(); c++)
free(images.at(c));
images.clear();
movidius_closeDevice(&movidius_dev, false);
return ret;
}
| 28.373134
| 108
| 0.568122
|
SirDifferential
|
63167cdbb65ffc9ba73e31706bb4da5db6ed509d
| 360
|
hpp
|
C++
|
include/uitsl/mpi/MpiGuard.hpp
|
perryk12/conduit
|
3ea055312598353afd465536c8e04cdec1111c8c
|
[
"MIT"
] | null | null | null |
include/uitsl/mpi/MpiGuard.hpp
|
perryk12/conduit
|
3ea055312598353afd465536c8e04cdec1111c8c
|
[
"MIT"
] | 1
|
2020-10-22T20:41:05.000Z
|
2020-10-22T20:41:05.000Z
|
include/uitsl/mpi/MpiGuard.hpp
|
perryk12/conduit
|
3ea055312598353afd465536c8e04cdec1111c8c
|
[
"MIT"
] | null | null | null |
#pragma once
#ifndef UITSL_MPI_MPIGUARD_HPP_INCLUDE
#define UITSL_MPI_MPIGUARD_HPP_INCLUDE
#include <functional>
#include "audited_routines.hpp"
#include "mpi_utils.hpp"
namespace uitsl {
struct MpiGuard {
MpiGuard() { uitsl::mpi_init(); }
~MpiGuard() { UITSL_Finalize(); }
};
} // namespace uitsl
#endif // #ifndef UITSL_MPI_MPIGUARD_HPP_INCLUDE
| 15.652174
| 48
| 0.75
|
perryk12
|
6322f86fbb23198e86f7584e107ffe8c1f1ca165
| 807
|
cpp
|
C++
|
talent/talent.cpp
|
chenhongqiao/OI-Solutions
|
009a3c4b713b62658b835b52e0f61f882b5a6ffe
|
[
"MIT"
] | 1
|
2020-12-15T20:25:21.000Z
|
2020-12-15T20:25:21.000Z
|
talent/talent.cpp
|
chenhongqiao/OI-Solutions
|
009a3c4b713b62658b835b52e0f61f882b5a6ffe
|
[
"MIT"
] | null | null | null |
talent/talent.cpp
|
chenhongqiao/OI-Solutions
|
009a3c4b713b62658b835b52e0f61f882b5a6ffe
|
[
"MIT"
] | null | null | null |
#include <bits/stdc++.h>
using namespace std;
struct cow
{
long long w, t;
};
cow c[255];
long long dp[1000005];
int main()
{
//freopen("talent.in", "r", stdin);
//freopen("talent.out", "w", stdout);
int n, wl;
cin >> n >> wl;
for (int i = 1; i <= n; i++)
{
long long w, t;
cin >> w >> t;
c[i] = {w, t * 1000};
}
for (int i = 1; i <= 1000000; i++)
{
dp[i] = -10000000000;
}
for (int i = 1; i <= n; i++)
{
for (int j = 1000000; j >= c[i].w; j--)
{
dp[j] = max(dp[j], dp[j - c[i].w] + c[i].t);
}
}
int ans = 0;
for (int i = wl; i <= 1000000; i++)
{
if (dp[i] / i > ans)
{
ans = dp[i] / i;
}
}
cout << ans << endl;
return 0;
}
| 19.214286
| 56
| 0.385378
|
chenhongqiao
|
632dee063f996faac35d807afc63239a68a815dc
| 4,867
|
hpp
|
C++
|
src/gui/src/core/interfaces/impl/iota-wallet.hpp
|
MatthewDarnell/iota-simplewallet
|
aa3449bae3023e292ad47a9fa72213e279367b7a
|
[
"MIT"
] | 1
|
2020-11-19T07:18:44.000Z
|
2020-11-19T07:18:44.000Z
|
src/gui/src/core/interfaces/impl/iota-wallet.hpp
|
MatthewDarnell/iota-simplewallet
|
aa3449bae3023e292ad47a9fa72213e279367b7a
|
[
"MIT"
] | null | null | null |
src/gui/src/core/interfaces/impl/iota-wallet.hpp
|
MatthewDarnell/iota-simplewallet
|
aa3449bae3023e292ad47a9fa72213e279367b7a
|
[
"MIT"
] | null | null | null |
// Copyright (c) 2018-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef IOTAWALLET_HPP
#define IOTAWALLET_HPP
#include <interfaces/wallet.h>
#include <interfaces/handler.h>
#include <QObject>
#include <QJsonObject>
#include <QDateTime>
struct FreeCStringDeleter
{
void operator()(char *ptr)
{
free(ptr);
}
};
using c_string_unique_ptr = std::unique_ptr<char, FreeCStringDeleter>;
namespace interfaces {
struct UserAccount
{
int index { -1 };
QString username;
QString balance;
bool synced;
QDateTime createdAt;
static UserAccount FromJson(QJsonObject obj);
};
class IotaWallet : public QObject, public Wallet
{
// Wallet interface
Q_OBJECT
public:
explicit IotaWallet(UserAccount account,
QObject *parent = nullptr);
bool encryptWallet(const SecureString &wallet_passphrase) override;
bool isCrypted() override;
bool lock() override;
bool unlock(const SecureString &wallet_passphrase) override;
bool isLocked() override;
bool changeWalletPassphrase(const SecureString &old_wallet_passphrase, const SecureString &new_wallet_passphrase) override;
void abortRescan() override;
bool backupWallet(const std::string &filename) override;
std::string getWalletName() override;
bool getNewDestination(const std::string label, std::string &dest) override;
bool getPubKey(const std::string &address, std::string &pub_key) override;
bool getPrivKey(const std::string &address, std::string &key) override;
bool isSpendable(const std::string &dest) override;
bool setAddressBook(const std::string &dest, const std::string &name, const std::string &purpose) override;
bool delAddressBook(const std::string &dest) override;
bool getAddress(const std::string &dest, std::string *name, isminetype *is_mine, std::string *purpose) override;
std::vector<WalletAddress> getAddresses() override;
bool addDestData(const std::string &dest, const std::string &key, const std::string &value) override;
bool eraseDestData(const std::string &dest, const std::string &key) override;
std::vector<std::string> getDestValues(const std::string &prefix) override;
bool generateAddresses(int count, std::string &fail_reason) override;
WalletMutableTransaction createTransaction(const std::vector<CRecipient>& recipients, std::string& fail_reason) override;
bool commitTransaction(WalletMutableTransaction tx, WalletOrderForm order_form, std::string &fail_reason) override;
WalletTx getWalletTx(const std::string &txid) override;
std::vector<WalletTx> getWalletTxs() override;
uint32_t numberOfAddresses() override;
bool tryGetTxStatus(const std::string &txid, WalletTxStatus &tx_status, int &num_blocks, int64_t &block_time) override;
WalletTx getWalletTxDetails(const std::string &txid, WalletTxStatus &tx_status, WalletOrderForm &order_form, bool &in_mempool, int &num_blocks) override;
WalletBalances getBalances() override;
bool tryGetBalances(WalletBalances &balances, int &num_blocks) override;
CAmount getBalance() override;
CAmount getAvailableBalance() override;
CAmount getRequiredFee(unsigned int tx_bytes) override;
CAmount getMinimumFee(unsigned int tx_bytes, const CCoinControl &coin_control, int *returned_target, FeeReason *reason) override;
unsigned int getConfirmTarget() override;
bool hdEnabled() override;
bool canGetAddresses() override;
bool IsWalletFlagSet(uint64_t flag) override;
void remove() override;
std::unique_ptr<Handler> handleUnload(UnloadFn fn) override;
std::unique_ptr<Handler> handleShowProgress(ShowProgressFn fn) override;
std::unique_ptr<Handler> handleStatusChanged(StatusChangedFn fn) override;
std::unique_ptr<Handler> handleAddressBookChanged(AddressBookChangedFn fn) override;
std::unique_ptr<Handler> handleTransactionChanged(TransactionChangedFn fn) override;
std::unique_ptr<Handler> handleBalanceChanged(BalanceChangedFn fn) override;
std::unique_ptr<Handler> handleCanGetAddressesChanged(CanGetAddressesChangedFn fn) override;
signals:
void transactionAdded(QString txid);
void transactionUpdated(QString txid);
void balanceChanged();
public slots:
void onAccountUpdated(UserAccount account, int milestoneIndex);
void onAccountBalanceUpdated(QString balance);
void onTransactionChanged(QJsonObject payload);
private:
void updateTransactions();
void updateUnconfirmedBalance();
private:
UserAccount _account;
SecureString _unlockPassword;
std::map<std::string, WalletTx> _transactions;
CAmount _uncofirmedBalance { 0 };
int _latestMilestoneIndex { 0 };
};
} // namespace interfaces
#endif
| 41.598291
| 157
| 0.757345
|
MatthewDarnell
|
632e3acbee7d6ebcf18f3270d5b4b6e42b4da882
| 24
|
hpp
|
C++
|
modules/renderer/include/texture.hpp
|
hpnrep6/3DModelViewer
|
4437d9b798fe75f3f6eae33488edc73dda4aaca0
|
[
"MIT"
] | null | null | null |
modules/renderer/include/texture.hpp
|
hpnrep6/3DModelViewer
|
4437d9b798fe75f3f6eae33488edc73dda4aaca0
|
[
"MIT"
] | null | null | null |
modules/renderer/include/texture.hpp
|
hpnrep6/3DModelViewer
|
4437d9b798fe75f3f6eae33488edc73dda4aaca0
|
[
"MIT"
] | null | null | null |
namespace JRenderer {
}
| 8
| 21
| 0.75
|
hpnrep6
|
633d51fd67d2c7625b3d1550c471b3612264fa25
| 5,646
|
cpp
|
C++
|
src/Kernel/ResourceImageData.cpp
|
irov/Mengine
|
b76e9f8037325dd826d4f2f17893ac2b236edad8
|
[
"MIT"
] | 39
|
2016-04-21T03:25:26.000Z
|
2022-01-19T14:16:38.000Z
|
src/Kernel/ResourceImageData.cpp
|
irov/Mengine
|
b76e9f8037325dd826d4f2f17893ac2b236edad8
|
[
"MIT"
] | 23
|
2016-06-28T13:03:17.000Z
|
2022-02-02T10:11:54.000Z
|
src/Kernel/ResourceImageData.cpp
|
irov/Mengine
|
b76e9f8037325dd826d4f2f17893ac2b236edad8
|
[
"MIT"
] | 14
|
2016-06-22T20:45:37.000Z
|
2021-07-05T12:25:19.000Z
|
#include "ResourceImageData.h"
#include "Interface/ImageCodecInterface.h"
#include "Interface/CodecServiceInterface.h"
#include "Interface/ConfigServiceInterface.h"
#include "Kernel/Logger.h"
#include "Kernel/DocumentHelper.h"
#include "Kernel/ConstString.h"
#include "Kernel/AssertionMemoryPanic.h"
#include "Kernel/FileStreamHelper.h"
#include "Kernel/PixelFormatHelper.h"
#include "Kernel/FileGroupHelper.h"
namespace Mengine
{
//////////////////////////////////////////////////////////////////////////
ResourceImageData::ResourceImageData()
: m_width( 0 )
, m_height( 0 )
, m_widthF( 0.f )
, m_heightF( 0.f )
, m_maxSize( 0.f, 0.f )
, m_buffer( nullptr )
{
}
//////////////////////////////////////////////////////////////////////////
ResourceImageData::~ResourceImageData()
{
}
//////////////////////////////////////////////////////////////////////////
bool ResourceImageData::_compile()
{
const ContentInterfacePtr & content = this->getContent();
const FileGroupInterfacePtr & fileGroup = content->getFileGroup();
const FilePath & filePath = content->getFilePath();
InputStreamInterfacePtr stream = Helper::openInputStreamFile( fileGroup, filePath, false, false, MENGINE_DOCUMENT_FACTORABLE );
MENGINE_ASSERTION_MEMORY_PANIC( stream, "image file '%s' was not found"
, Helper::getFileGroupFullPath( this->getContent()->getFileGroup(), this->getContent()->getFilePath() )
);
MENGINE_ASSERTION_FATAL( stream->size() != 0, "empty file '%s' codec '%s'"
, Helper::getFileGroupFullPath( this->getContent()->getFileGroup(), this->getContent()->getFilePath() )
, this->getContent()->getCodecType().c_str()
);
const ConstString & codecType = content->getCodecType();
ImageDecoderInterfacePtr imageDecoder = CODEC_SERVICE()
->createDecoder( codecType, MENGINE_DOCUMENT_FACTORABLE );
MENGINE_ASSERTION_MEMORY_PANIC( imageDecoder, "image decoder '%s' for file '%s' was not found"
, this->getContent()->getCodecType().c_str()
, Helper::getFileGroupFullPath( this->getContent()->getFileGroup(), this->getContent()->getFilePath() )
);
if( imageDecoder->prepareData( stream ) == false )
{
LOGGER_ERROR( "image decoder '%s' for file '%s' was not found"
, this->getContent()->getCodecType().c_str()
, Helper::getFileGroupFullPath( this->getContent()->getFileGroup(), this->getContent()->getFilePath() )
);
return false;
}
const ImageCodecDataInfo * dataInfo = imageDecoder->getCodecDataInfo();
uint32_t width = dataInfo->width;
uint32_t height = dataInfo->height;
EPixelFormat format = dataInfo->format;
uint32_t memorySize = Helper::getTextureMemorySize( width, height, format );
m_buffer = Helper::allocateMemoryNT<uint8_t>( memorySize, "image_data" );
uint32_t channels = Helper::getPixelFormatChannels( format );
ImageDecoderData data;
data.buffer = m_buffer;
data.size = memorySize;
data.pitch = width * channels;
data.format = format;
if( imageDecoder->decode( &data ) == 0 )
{
LOGGER_ERROR( "image decoder '%s' for file '%s' invalid decode"
, this->getContent()->getCodecType().c_str()
, Helper::getFileGroupFullPath( this->getContent()->getFileGroup(), this->getContent()->getFilePath() )
);
return false;
}
return true;
}
//////////////////////////////////////////////////////////////////////////
void ResourceImageData::_release()
{
Helper::deallocateMemory( m_buffer, "image_data" );
m_buffer = nullptr;
}
//////////////////////////////////////////////////////////////////////////
void ResourceImageData::setImageMaxSize( const mt::vec2f & _maxSize )
{
m_maxSize = _maxSize;
}
//////////////////////////////////////////////////////////////////////////
const mt::vec2f & ResourceImageData::getImageMaxSize() const
{
return m_maxSize;
}
//////////////////////////////////////////////////////////////////////////
void ResourceImageData::setImageWidth( uint32_t _width )
{
m_width = _width;
m_widthF = (float)_width;
}
//////////////////////////////////////////////////////////////////////////
uint32_t ResourceImageData::getImageWidth() const
{
return m_width;
}
//////////////////////////////////////////////////////////////////////////
void ResourceImageData::setImageHeight( uint32_t _height )
{
m_height = _height;
m_heightF = (float)_height;
}
//////////////////////////////////////////////////////////////////////////
uint32_t ResourceImageData::getImageHeight() const
{
return m_height;
}
//////////////////////////////////////////////////////////////////////////
float ResourceImageData::getImageWidthF() const
{
return m_widthF;
}
//////////////////////////////////////////////////////////////////////////
float ResourceImageData::getImageHeightF() const
{
return m_heightF;
}
//////////////////////////////////////////////////////////////////////////
Pointer ResourceImageData::getImageBuffer() const
{
return m_buffer;
}
//////////////////////////////////////////////////////////////////////////
}
| 35.961783
| 135
| 0.505136
|
irov
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.