blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
9bd9a47cb6539e55cdd2c08c0954ee2811a00209
f057542364beb7f6e362463ce08a356d8622c893
/src/planets/Planet.cpp
ed17986baf93fe770241c62efd50279b937685e5
[]
no_license
TWilson023/Aquarius
bcf49868de601b7e854f181e66812dd0f4f626e5
c24034e88f0a04e032e17f64760f7701008abf8d
refs/heads/master
2021-07-06T20:05:58.918619
2017-12-31T01:28:25
2017-12-31T01:28:25
48,939,663
1
1
null
2021-05-24T17:42:51
2016-01-03T08:49:33
C++
UTF-8
C++
false
false
1,788
cpp
Planet.cpp
#include "planets/Planet.h" #include <iostream> Planet::Planet(int radius) : radius(radius), Geometry(new ShaderProgram("shaders/simple.vert", "shaders/simple.frag")) { create(); } void Planet::create() { chunk = new Chunk(1, ); GLuint vertexArrayID; glGenVertexArrays(1, &vertexArrayID); glBindVertexArray(vertexArrayID); // Generate vertex buffer glGenBuffers(1, &vertexBuffer); glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); glBufferData(GL_ARRAY_BUFFER, voxelObject->vertexCount * sizeof(glm::vec3), &voxelObject->vertices[0], GL_DYNAMIC_DRAW); GLint size = 0; glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size); std::cout << "Triangle Vertices: " << voxelObject->vertexCount << std::endl; std::cout << "Buffer Size: " << size << std::endl; glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0); glEnableVertexAttribArray(0); glGenBuffers(1, &normalBuffer); glBindBuffer(GL_ARRAY_BUFFER, normalBuffer); glBufferData(GL_ARRAY_BUFFER, voxelObject->vertexCount * sizeof(glm::vec3), &voxelObject->normals[0], GL_DYNAMIC_DRAW); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0); glEnableVertexAttribArray(1); } void Planet::render(glm::mat4 mvp) { shaderProgram->use(); shaderProgram->mvp(mvp); glUniform3fv(colorID, 1, glm::value_ptr(color)); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*) 0); glEnableVertexAttribArray(2); glBindBuffer(GL_ARRAY_BUFFER, normalBuffer); glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, (void*) 0); glDrawArrays(drawMode, 0, voxelObject->vertexCount); glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glDisableVertexAttribArray(2); }
a8752872932cee7b2a3e85059bca2c696d1a055d
bfa3b192288ceed44ed30792d8857c3c1d72b4b2
/FTL_ALL/ColorQuantizer/ColorQuantizerBase.cpp
dc304eaa9234f994e6a8efee51ee86ed55ad8c1f
[]
no_license
Crawping/fishjam-template-library
a886ac50f807c4386ce37a89563b8da23024220f
46b4b3048a38034772d7c8a654d372907d7e024d
refs/heads/master
2020-12-24T09:44:22.596675
2015-03-18T10:50:43
2015-03-18T10:50:43
null
0
0
null
null
null
null
GB18030
C++
false
false
5,230
cpp
ColorQuantizerBase.cpp
#include "stdafx.h" #include "ColorQuantizerBase.h" #include <ftlGdi.h> namespace FTL { CFColorQuantizerBase::CFColorQuantizerBase(){ m_nWidth = 0; m_nHeight = 0; m_nBpp = 0; m_nBmpDataSize = 0; m_nBmpLineBytes = 0; m_nPaletteItemCount = 0; m_nBmpPixelCount = 0; m_bCopyMem = FALSE; m_pBmpData = NULL; m_pResultPalette = NULL; m_pPixelClrList = NULL; } CFColorQuantizerBase::~CFColorQuantizerBase() { FUNCTION_BLOCK_TRACE(100); SAFE_DELETE_ARRAY(m_pResultPalette); SAFE_DELETE_ARRAY(m_pPixelClrList); if (m_bCopyMem) { SAFE_DELETE_ARRAY(m_pBmpData); } else { m_pBmpData = NULL; } } BOOL CFColorQuantizerBase::SetBmpInfo(UINT nWidth, UINT nHeight, UINT nBpp, BYTE* pBmpData, UINT nBmpDataSize, BOOL bCopyMem) { BOOL bRet = FALSE; UINT nBmpLineBytes = CALC_BMP_ALLIGNMENT_WIDTH_COUNT(nWidth, nBpp); UINT nBmpDataSizeCheck = nBmpLineBytes * nHeight; FTLASSERT(nBmpDataSizeCheck == nBmpDataSize && TEXT("BMP图片的大小需要四字节对齐")); if (nBmpDataSizeCheck != nBmpDataSize) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } if (m_bCopyMem) { if (m_nBmpDataSize != nBmpDataSize) { //当旧的数据是拷贝出来的,且大小不一样时,清除旧的 SAFE_DELETE_ARRAY(m_pBmpData); } } else { m_pBmpData = NULL; } if (nBmpDataSize > 0) { if (bCopyMem) { if(!m_pBmpData){ m_pBmpData = new BYTE[nBmpDataSize]; } if (m_pBmpData) { CopyMemory(m_pBmpData, pBmpData, nBmpDataSize); } else{ SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } } else { m_pBmpData = pBmpData; } } m_nWidth = nWidth; m_nHeight = nHeight; m_nBpp = nBpp; m_nBmpLineBytes = nBmpLineBytes; m_nBmpDataSize = nBmpDataSize; m_bCopyMem = bCopyMem; m_nBmpPixelCount = nWidth * nHeight; return TRUE; } BOOL CFColorQuantizerBase::ProcessQuantizer(UINT nWantClrCount, UINT *pResultClrCount) { FUNCTION_BLOCK_TRACE(500); BOOL bRet = FALSE; API_VERIFY(OnPrepare()); if (bRet) { API_VERIFY(OnProcessQuantizer(nWantClrCount, pResultClrCount)); OnFinish(); } return bRet; } BOOL CFColorQuantizerBase::OnPrepare() { return TRUE; } void CFColorQuantizerBase::OnFinish() { } COLORREF* CFColorQuantizerBase::GetPalette(UINT* pResultCount) { if (pResultCount) { if (m_pResultPalette){ *pResultCount = m_nPaletteItemCount; } else{ *pResultCount = 0; } } return m_pResultPalette; } UCHAR* CFColorQuantizerBase::GetQuantizerResult(UINT* pBufferSize) { FTLASSERT(m_QuantizerResultIndexes.size() == m_nWidth * m_nHeight); if (pBufferSize) { *pBufferSize = m_QuantizerResultIndexes.size(); } return &m_QuantizerResultIndexes[0]; } BOOL CFColorQuantizerBase::_AnalyzeColorMeta() { FTLASSERT(24 == m_nBpp || 32 == m_nBpp); if (24 != m_nBpp && 32 != m_nBpp) { return FALSE; } SAFE_DELETE_ARRAY(m_pPixelClrList); m_pPixelClrList = new COLORREF[m_nBmpPixelCount]; ZeroMemory(m_pPixelClrList, sizeof(COLORREF) * m_nBmpPixelCount); //UINT nColorCount = m_nWidth * m_nHeight; UINT nPixOffset = (m_nBpp / 8); UINT nRowBytes = CALC_BMP_ALLIGNMENT_WIDTH_COUNT(m_nWidth, m_nBpp); //4字节对齐,计算每行的字节数 UINT nPixelIndex = 0; for (UINT h = 0; h < m_nHeight; h++) { BYTE* pBuf = m_pBmpData + (nRowBytes * h); for (UINT w = 0; w < m_nWidth; w++) { UCHAR Alpha = 0xFF; UCHAR Red = *(pBuf + 2); UCHAR Green = *(pBuf+1); UCHAR Blue = *(pBuf); if (32 == m_nBpp) { Alpha = *(pBuf + 3); } //COLORREF clr = MAKE_RGBA(Red, Green, Blue, Alpha); //m_clrList.push_back(clr); m_pPixelClrList[nPixelIndex++] = MAKE_RGBA(Red, Green, Blue, Alpha); pBuf += nPixOffset; } } FTLASSERT(nPixelIndex == m_nBmpPixelCount); return TRUE; } }
335c7e9d8f2529a5ca33ab60be1ca6c6175e52d4
60a15a584b00895e47628c5a485bd1f14cfeebbe
/comps/misc/input/NewDoc/InputDriverManager.h
b62e69eb7bec96ceff302280c2b605efe438db55
[]
no_license
fcccode/vt5
ce4c1d8fe819715f2580586c8113cfedf2ab44ac
c88049949ebb999304f0fc7648f3d03f6501c65b
refs/heads/master
2020-09-27T22:56:55.348501
2019-06-17T20:39:46
2019-06-17T20:39:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,785
h
InputDriverManager.h
#if !defined(AFX_INPUTDRIVERMANAGER_H__530DE72D_608F_4218_991A_C393B4FB1283__INCLUDED_) #define AFX_INPUTDRIVERMANAGER_H__530DE72D_608F_4218_991A_C393B4FB1283__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // InputDriverManager.h : header file // class CDeviceInfo; ///////////////////////////////////////////////////////////////////////////// // CInputDriverManager command target class CInputDriverManager : public CCmdTargetEx, public CNamedObjectImpl, public CCompManagerImpl, public CRootedObjectImpl { DECLARE_DYNCREATE(CInputDriverManager) ENABLE_MULTYINTERFACE() CInputDriverManager(); // protected constructor used by dynamic creation CTypedPtrArray<CPtrArray, CDeviceInfo*> m_Devices; bool m_bInited; protected: void RebuildDevices(); // Attributes public: CString m_sSectName; // Operations public: CString OnGetCurrentDeviceName(); void OnSetCurrentDeviceName(CString s); IUnknown *GetDriver(int nNum); BOOL FindDriver(CString sDevName, IUnknown **ppunkDriver, int *pnDevice); int OnGetDevicesCount(); void OnGetDeviceInfo(int nDevice, CString &sShortName, CString &sLongName, CString &sCategory, int *pnDriver, int *pnDeviceInDriver); bool OnExecuteSettings(HWND hwndParent, IUnknown *pTarget, int nSelectDriver, int nDialogMode, BOOL bFirst, BOOL bFromSettings, BSTR bstrConf); bool SelectDriver(HWND hwndParent, int nMode); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CInputDriverManager) public: virtual void OnFinalRelease(); //}}AFX_VIRTUAL // Implementation protected: virtual ~CInputDriverManager(); // Generated message map functions //{{AFX_MSG(CInputDriverManager) // NOTE - the ClassWizard will add and remove member functions here. //}}AFX_MSG DECLARE_MESSAGE_MAP() GUARD_DECLARE_OLECREATE(CInputDriverManager) // Generated OLE dispatch map functions //{{AFX_DISPATCH(CInputDriverManager) afx_msg BSTR GetCurrentDriver1(); afx_msg void SetCurrentDriver(LPCTSTR lpszNewValue); afx_msg BSTR GetCurrentDevice(); afx_msg void SetCurrentDevice(LPCTSTR lpszNewValue); afx_msg BSTR GetCurrentDeviceName(); afx_msg void SetCurrentDeviceName(LPCTSTR lpszNewValue); afx_msg void SetValue(LPCTSTR Name, const VARIANT FAR& Value); afx_msg VARIANT GetValue(LPCTSTR Name); afx_msg long GetDevicesNum(); afx_msg BSTR GetDeviceName(long iDev); afx_msg BSTR GetDeviceCategory(long iDev); afx_msg BSTR GetDeviceFullName(long iDev); afx_msg void ExecuteDriverDialog(LPCTSTR strName); //}}AFX_DISPATCH DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() BEGIN_INTERFACE_PART(DrvMan, IDriverManager2) com_call GetCurrentDeviceName(BSTR *pbstrShortName); com_call SetCurrentDeviceName(BSTR bstrShortName); com_call IsInputAvailable(BOOL *pbAvail); com_call ExecuteSettings(HWND hwndParent, IUnknown *pTarget, int nSelectDriver, int nDialogMode, BOOL bFirst, BOOL bFromSettings); com_call GetCurrentDeviceAndDriver(BOOL *pbFound, IUnknown **ppunkDriver, int *pnDeviceInDriver); com_call GetSectionName(BSTR *pbstrSecName); com_call GetDevicesCount(int *pnDeviceCount); com_call GetDeviceInfo(int nDevice, BSTR *pbstrDevShortName, BSTR *pbstrDevLongName, BSTR *pbstrCategory, int *pnDeviceDriver, int *pnDeviceInDriver); com_call ExecuteSettings2(HWND hwndParent, IUnknown *pTarget, int nSelectDriver, int nDialogMode, BOOL bFirst, BOOL bFromSettings, BSTR bstrConfName); END_INTERFACE_PART(DrvMan); }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_INPUTDRIVERMANAGER_H__530DE72D_608F_4218_991A_C393B4FB1283__INCLUDED_)
a9fb499614fccccca4312ecb9baa8b2cb05c1e09
a8d7099048b36126f5faf56b373cc970b601f745
/Famouso/include/VREPActuator.h
61531f7f014c6de42cb4ab783397481ae1cec17a
[]
no_license
dtbinh/VREP-Plugins
3fd944c5b23d3c450098ccb9a51ebf9723f10d74
1371edbf68a78c2dacbfadeba6bca528bbcaa26a
refs/heads/master
2021-01-22T15:22:22.251798
2014-11-07T19:03:07
2014-11-07T19:03:07
63,950,209
1
0
null
2016-07-22T12:02:42
2016-07-22T12:02:42
null
UTF-8
C++
false
false
621
h
VREPActuator.h
#pragma once #include <config.h> #include <VREPObject.h> class VREPActuator : public VREPObject{ private: config::Famouso::Subscriber sub; void init(); void trampoline(const famouso::mw::api::SECCallBackData& e); protected: typedef famouso::mw::api::SECCallBackData Event; virtual void print(std::ostream& out) const; virtual void callback(const Event& e) = 0; public: typedef famouso::mw::Subject Subject; VREPActuator(simInt id, const Subject& subject); VREPActuator(const VREPActuator& copy); virtual ~VREPActuator(); const famouso::mw::Subject& subject() const; };
6f60f3833d0ca4002443228ab7130ed683db8772
88005007184d47119b299152101abd5e67d638e6
/EMS_Controller/EMS_Controller.ino
506d9c06f8e71078737ef791acd61d40ef7a47ed
[]
no_license
christianstenderup/MasterThesis
f9dc8c5a656f5a1abb6fc96b38026cc13ab193f2
83ee41ed889938920d88f96dea8d46e3cf56fdc2
refs/heads/master
2021-01-20T00:14:59.607507
2017-04-22T22:26:33
2017-04-22T22:26:33
89,101,237
0
0
null
null
null
null
UTF-8
C++
false
false
2,309
ino
EMS_Controller.ino
#include <DS1803.h> #include <Wire.h> DS1803 pot_pulse(0x28); DS1803 pot_amplitude(0x2C); int amp; int width; int rate; int amp2; int FstSource = 0; int SndSource = 1; int PulseWidth = 0; int PulseRate = 1; bool turnOnSndSource; void setup() { Serial.begin(9600); //Initialize amplitude potentiometers. pot_amplitude.setPot(0, FstSource); pot_amplitude.setPot(0, SndSource); //Initialize pulse potentiometers. pot_pulse.setPot(0,PulseWidth); pot_pulse.setPot(0,PulseRate); //Initialize channels. pinMode(4,OUTPUT); pinMode(5,OUTPUT); pinMode(6,OUTPUT); pinMode(7,OUTPUT); pinMode(8,OUTPUT); pinMode(9,OUTPUT); digitalWrite(4,LOW); digitalWrite(5,LOW); digitalWrite(6,LOW); digitalWrite(7,LOW); digitalWrite(8,LOW); digitalWrite(9,LOW); int amp = 0; int amp2 = 0; int width = 0; int rate = 0; bool turnOnSndSource = false; } void loop() { readInput(); } //Read control signals from serial void readInput(){ if (Serial.available() > 0) { int commandValue = Serial.parseInt(); char labelValue = Serial.read(); switch (labelValue) { //amplitude case 'a' : amp = int(commandValue); break; //amplitude 2 case 'v' : amp2 = int(commandValue); break; //pulse width case 'w' : width = int(commandValue); break; //pulse rate case 'r' : rate = int(commandValue); break; //channels/relays to open case 'c' : digitalWrite(int(commandValue), HIGH); break; case 's' : pot_amplitude.setPot(amp2,SndSource); pot_amplitude.setPot(amp,FstSource); pot_pulse.setPot(width,PulseWidth); pot_pulse.setPot(rate,PulseRate); break; case 'e' : //turn everything off turnOnSndSource = false; pot_amplitude.setPot(0, FstSource); pot_amplitude.setPot(0, SndSource); pot_pulse.setPot(0,PulseWidth); pot_pulse.setPot(0,PulseRate); digitalWrite(4,LOW); digitalWrite(5,LOW); digitalWrite(6,LOW); digitalWrite(7,LOW); digitalWrite(8,LOW); digitalWrite(9,LOW); break; default: break; } } }
3c93ec73e1ee6e29c76dee1ed909e559f302e7f6
0f35399b2d6a9e7ff5e57efcc9048f2216f41618
/modem3g.cpp
4fad3b0d69333b57983daa957d64fecb6d9b6438
[]
no_license
electrobas94/UMController
a9de6b6e5dd36c1a7b175870a1891b8bdfcb7e7d
beca5a3beb4e2dee997679f63c0d4764140cbae6
refs/heads/master
2021-01-19T19:46:26.831685
2017-06-25T14:59:45
2017-06-25T14:59:45
84,476,503
0
0
null
null
null
null
UTF-8
C++
false
false
46
cpp
modem3g.cpp
#include "modem3g.h" Modem3G::Modem3G() { }
54d24a159b1ba928e5e7a80f4c9db8943ee67ea8
3ef492e4ceddcc487ef73ddd1befee2f0dd34777
/Algorithms/Implementation/Drawing Book.cpp
8d875f735bb705a958ecb4dfaaabd7430660c4d4
[]
no_license
PhoenixDD/HackerRank
23c9079e5b31657bc68f1709b5550be403f958ce
044c39619ce535f5a247c7407b0f7793ca04719d
refs/heads/master
2021-01-15T16:47:47.124935
2018-06-28T00:17:12
2018-06-28T00:17:12
99,726,089
0
0
null
null
null
null
UTF-8
C++
false
false
294
cpp
Drawing Book.cpp
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int N,p; cin>>N>>p; if(p==N-1&&N%2==0&&N!=2) cout<<1; else if(p>N/2) cout<<(N-p)/2; else cout<<p/2; return 0; }
33d651b6dab6028575cdb103bcf634809f6960de
ce29683da092c8aa5a9ce222f080042071d575fb
/viewmenulistedestaches.cpp
56a6689d858a9f84745f61b36ceb11ef3c8e9c57
[]
no_license
piratebreizh/DockAuto
58dcab1829459194bd60a00f1badb6180bc1bebb
ed182d139f528e3fd9d2cafd911d60115a12c811
refs/heads/master
2016-09-08T02:37:59.146140
2014-07-21T12:05:54
2014-07-21T12:05:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,981
cpp
viewmenulistedestaches.cpp
#include "viewmenulistedestaches.h" #include <gestiondb.h> ViewMenuListeDesTaches::ViewMenuListeDesTaches(ViewMenuSimulation * _viewMenuSimulation) { viewMenuSimulation = &* _viewMenuSimulation; initialisationComposant(); definitonLayout(); } void ViewMenuListeDesTaches::initialisationComposant() { mainLayout = new QVBoxLayout(this); layout1 = new QGridLayout(); labelNomTacheListe = new QLabel("Nom liste"); champNomTacheListe = new QLineEdit(); labelNomTacheListe = new QLabel("Liste des tâches"); model= new QStandardItemModel(); tableListeTache = new QTableView(); tableListeTache->setFixedWidth(400); QStringList list; list.append("Nom robot"); list.append("Poids"); list.append("Départ"); list.append("Arrivée"); confirmationEnregistrement = new QLabel(); confirmationEnregistrement->hide(); model->setHorizontalHeaderLabels(list); tableListeTache->setModel(model); listeTache = new Listetache(); pushAjouterTache = new QPushButton("Nouvelle tâche"); pushSauvegarder = new QPushButton("Sauvegarder"); pushAnnuler = new QPushButton("Retour"); } void ViewMenuListeDesTaches::definitonLayout() { layout1->addWidget(confirmationEnregistrement,0,0,1,2); layout1->addWidget(labelNomTacheListe,1,0); layout1->addWidget(champNomTacheListe,2,0); layout1->addWidget(labelNomTacheListe,3,0); layout1->addWidget(tableListeTache,4,0); layout1->addWidget(pushAjouterTache,5,0); layout1->addWidget(pushSauvegarder,6,0); layout1->addWidget(pushAnnuler,7,0); QWidget::connect(pushAjouterTache, SIGNAL(clicked()), this, SLOT(executerViewDefinirTache())); QWidget::connect(pushSauvegarder, SIGNAL(clicked()), this, SLOT(CliqueSauvegarder())); QWidget::connect(pushAnnuler, SIGNAL(clicked()), this, SLOT(close())); mainLayout->addLayout(layout1); this->setLayout(mainLayout); } void ViewMenuListeDesTaches::executerViewDefinirTache() { nouvelleTacheTemp = new Tache(); nouveauRobotTemp = new Robot(); viewDefinirTache = new ViewDefinirTache(this); viewDefinirTache->exec(); } void ViewMenuListeDesTaches::ajouterTacheDansListe() { QList <QStandardItem*> listItem; listItem.append(new QStandardItem (this->nouveauRobotTemp->nomRobot)); listItem.append(new QStandardItem (QString::number(this->nouvelleTacheTemp->getPoids()))); QString champDepart(QString::number(this->nouvelleTacheTemp->depart->getX())); champDepart.append(" : "); champDepart.append(QString::number(this->nouvelleTacheTemp->depart->getY())); QString champArrive(QString::number(this->nouvelleTacheTemp->arrivee->getX())); champArrive.append(" : "); champArrive.append(QString::number(this->nouvelleTacheTemp->arrivee->getY())); listItem.append(new QStandardItem(champDepart)); listItem.append(new QStandardItem(champArrive)); model->appendRow(listItem); } void ViewMenuListeDesTaches::CliqueSauvegarder() { if(!champNomTacheListe->text().isEmpty() && (listeTache->getListeDesTaches()->size() >0)){ enregistrementDansLaTableListetache(); enregistrementDansLaTableTache(); this->viewMenuSimulation->setConfirmationTache(true); this->viewMenuSimulation->verificationLabelConfirmation(); confirmationEnregistrement->setText("La liste de tâches a été enregistrée"); confirmationEnregistrement->setStyleSheet("QLabel { color : green; }"); confirmationEnregistrement->show(); this->close(); }else{ confirmationEnregistrement->setText("Tous les champs doivent être remplis"); confirmationEnregistrement->setStyleSheet("QLabel { color : red; }"); confirmationEnregistrement->show(); } } void ViewMenuListeDesTaches::enregistrementDansLaTableListetache() { QString insertListeTable = "INSERT INTO liste_taches (Nom_Liste_Taches) VALUES ('"; insertListeTable.append(this->champNomTacheListe->text()); insertListeTable.append("');"); GestionDB * db = GestionDB::getInstance(); db->Requete(insertListeTable); initialisationIDListeTache(); } void ViewMenuListeDesTaches::initialisationIDListeTache() { GestionDB * db = GestionDB::getInstance(); db->selectMultiLignes("SELECT MAX(ID_Liste_Taches) FROM liste_taches ;"); this->listeTache->IDListeTache = db->resultatSelectMultiLignes.at(0).at(0).toInt(); } void ViewMenuListeDesTaches::enregistrementDansLaTableTache() { QString insertDansTache ("INSERT INTO tache (Poids_Tache,Depart_X,Depart_Y,Arrive_X, Arrive_Y, ID_Liste_Taches, ID_Robot) VALUES ("); bool firstVirgule = true; if(this->listeTache->getListeDesTaches()->size()>0){ for(int i = 0;i<listeTache->getListeDesTaches()->size();i++){ if(!firstVirgule){ insertDansTache.append(" ),( "); } Tache tacheTemp = *listeTache->getListeDesTaches()->at(i); insertDansTache.append("'"); insertDansTache.append(QString::number(tacheTemp.getPoids())); insertDansTache.append("',"); insertDansTache.append(QString::number(tacheTemp.depart->getX())); insertDansTache.append( ","); insertDansTache.append(QString::number(tacheTemp.depart->getY())); insertDansTache .append(","); insertDansTache.append(QString::number(tacheTemp.arrivee->getX())); insertDansTache .append( ","); insertDansTache.append(QString::number(tacheTemp.arrivee->getY())); insertDansTache .append(","); insertDansTache.append(QString::number(this->listeTache->IDListeTache)); insertDansTache .append(","); insertDansTache.append(QString::number(tacheTemp.idRobot)); firstVirgule = false; } insertDansTache.append("); "); GestionDB * db = GestionDB::getInstance(); db->Requete(insertDansTache); } }
6205be3a9d392f64f1aea486dbaf83ada7c244c7
5c9777049a5af6fb2400578ba6214ea8b8249b59
/practices/Q18.cpp
a43ad44eed430696d14a0a33d203a59371624532
[]
no_license
brucelee503jo3/F611700
092e0233dbc2037fcd1fae06fecd37191e59d426
de4d00cc4ba05576b19a919d0707f082b2b5ebb2
refs/heads/main
2023-06-20T02:48:58.920659
2021-07-20T05:51:13
2021-07-20T05:51:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
268
cpp
Q18.cpp
#include<iostream> #include<cstdlib> using namespace std; #define MAX(a,b,c) (a>b?a:b)>c?(a>b?a:b):c int main() { int a; cin>>a; for(int b=0;b<a;b++) { int i,j,k,n; cin>>i>>j>>k; n=MAX(i,j,k); cout<<n<<endl; } return 0; }
f2c2b1c9bdad1a81de59693f0f85e8de4b6fcfe6
ba33e7cc50972aa4affe70397da85cff61a15ea2
/include/ponder/qt/qtsimpleproperty.hpp
2b866403068a4410c1cc4948df8475ee3582dce9
[ "MIT" ]
permissive
billyquith/ponder
246fcd0b5a4b1c0c1a1e53760977b834c0a47e78
aff8843efa8069b272bad49df2d820a9b4d88171
refs/heads/master
2023-08-22T13:08:52.616858
2020-12-03T16:56:58
2020-12-03T16:56:58
48,850,177
634
116
NOASSERTION
2022-10-31T03:52:31
2015-12-31T13:22:02
C++
UTF-8
C++
false
false
3,689
hpp
qtsimpleproperty.hpp
/**************************************************************************** ** ** This file is part of the Ponder library, formerly CAMP. ** ** The MIT License (MIT) ** ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. ** Copyright (C) 2015-2020 Nick Trout. ** ** 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. ** ****************************************************************************/ #ifndef PONDER_QT_QTSIMPLEPROPERTY_HPP #define PONDER_QT_QTSIMPLEPROPERTY_HPP #include <ponder/qt/qthelper.hpp> #include <ponder/simpleproperty.hpp> #include <ponder/userobject.hpp> #include <ponder/value.hpp> #include <QMetaProperty> #include <QVariant> namespace ponder_ext { /** * \brief Specialization of ponder::SimpleProperty implemented using a Qt property * * This class is instantiated and returned by QtMapper<T>. * * \sa QtMapper */ template <typename T> class QtSimpleProperty : public ponder::SimpleProperty { public: /** * \brief Construct the property from a QMetaProperty * * \param metaProperty Qt meta property */ QtSimpleProperty(const QMetaProperty& metaProperty) : ponder::SimpleProperty(metaProperty.name(), metaProperty.isEnumType() ? ponder::ValueKind::Enum : QtHelper::type(metaProperty.kind())) , m_metaProperty(metaProperty) { } /** * \brief Get the value of the property for the given object * * \param object Object to read * * \return Current value of the property */ ponder::Value getValue(const ponder::UserObject& object) const override { return QtHelper::variantToValue(m_metaProperty.read(object.get<T*>())); } /** * \brief Set the value of the property for the given object * * \param object Object to write * \param value New value of the property */ void setValue(const ponder::UserObject& object, const ponder::Value& value) const override { m_metaProperty.write(object.get<T*>(), QtHelper::valueToVariant(value)); } /** * \brief Check if the property is readable * * \return True if the property is readable, false otherwise */ bool isReadable() const override { return m_metaProperty.isReadable(); } /** * \brief Check if the property is writable * * \return True if the property is writable, false otherwise */ bool isWritable() const override { return m_metaProperty.isWritable(); } private: QMetaProperty m_metaProperty; ///< Internal Qt property }; } // namespace ponder_ext #endif // PONDER_QT_QTSIMPLEPROPERTY_HPP
a6d8bb39d7fed926d01aacce149770a56b2bfaa5
103848bd4ee0922daf953a9933d85fbb41d01f3a
/ch3/ex3_40.cpp
0f89ca823b85d5f4c6f418ba66b9d032c3d3afbd
[]
no_license
geekbutton/Cpp-Primer
9db5f16685dfb8d847ad523da065e0418a9b353a
f192f2c023d3b673ad5dfac49962c4d7cad79c30
refs/heads/master
2021-01-12T13:52:24.741118
2016-10-07T07:55:15
2016-10-07T07:55:15
69,074,708
0
0
null
null
null
null
UTF-8
C++
false
false
637
cpp
ex3_40.cpp
//============================================================================ // Name : HW.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include<iostream> #include<iomanip> #include<string> #include<vector> #include<iterator>//beign(),end() #include<cstring> //#include<algorithm> //#include<stdio.h> using namespace std; int main(){ char c1[]="hello "; char c2[]="world"; char c3[100]={}; strcat(c1,c2); strcpy(c3,c1); for(auto c:c3) cout<<c; return 0; }
c108592dfae6a23b23f5f95b39e47222b846dba9
33f10f127eb15300065fc652825fbac90d7ac69a
/cvsnt/tortoiseCVS/TortoiseCVS/src/DialogsWxw/CheckoutOptionsPage.cpp
138ae6b7ee38ff40b71ed4502f9b1090cce417e1
[]
no_license
todace/G-CVSNT
aa4a7d075bb30303b373fda1041c486072d9c957
d13506abb904c61e6d031d97a23fde1a14ba4ba0
refs/heads/master
2021-03-12T20:45:33.618315
2021-01-15T12:07:19
2021-01-15T12:19:06
4,526,593
2
1
null
null
null
null
UTF-8
C++
false
false
7,463
cpp
CheckoutOptionsPage.cpp
// TortoiseCVS - a Windows shell extension for easy version control // Checkout options page // Copyright (C) 2002 - Ben Campbell // <ben.campbell@ntlworld.com> - Jan 2002 // This program 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 2 // of the License, or (at your option) any later version. // This program 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 this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "StdAfx.h" #include "CheckoutOptionsPage.h" #include "ModuleBasicsPage.h" #include "WxwHelpers.h" #include <wx/textctrl.h> #include "../Utils/Translate.h" enum { CHECKOUTOPTIONSPAGE_ID_CHECKOUT = 10001, CHECKOUTOPTIONSPAGE_ID_EXPORT, CHECKOUTOPTIONSPAGE_ID_MODULEDIR, CHECKOUTOPTIONSPAGE_ID_MODULETAGDIR, CHECKOUTOPTIONSPAGE_ID_ALTDIR }; BEGIN_EVENT_TABLE(CheckoutOptionsPage, wxPanel) EVT_COMMAND(CHECKOUTOPTIONSPAGE_ID_CHECKOUT, wxEVT_COMMAND_RADIOBUTTON_SELECTED, CheckoutOptionsPage::OnExport) EVT_COMMAND(CHECKOUTOPTIONSPAGE_ID_EXPORT, wxEVT_COMMAND_RADIOBUTTON_SELECTED, CheckoutOptionsPage::OnExport) EVT_COMMAND(CHECKOUTOPTIONSPAGE_ID_MODULEDIR, wxEVT_COMMAND_RADIOBUTTON_SELECTED, CheckoutOptionsPage::Refresh) EVT_COMMAND(CHECKOUTOPTIONSPAGE_ID_MODULETAGDIR, wxEVT_COMMAND_RADIOBUTTON_SELECTED, CheckoutOptionsPage::Refresh) EVT_COMMAND(CHECKOUTOPTIONSPAGE_ID_ALTDIR, wxEVT_COMMAND_RADIOBUTTON_SELECTED, CheckoutOptionsPage::RefreshAltDir) END_EVENT_TABLE() CheckoutOptionsPage::CheckoutOptionsPage(wxWindow* parent, ModuleBasicsPage* moduleBasicsPage) : wxPanel(parent), myModuleBasicsPage(moduleBasicsPage) { wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); SetAutoLayout(TRUE); SetSizer(sizer); // Input widgets sizer->Add(0, 4); wxStaticBox* staticBox = new wxStaticBox(this, -1, _("Purpose of checkout")); wxStaticBoxSizer* sizerStaticBox = new wxStaticBoxSizer(staticBox, wxVERTICAL); const wxChar* tip3 = _("Prevents creation of CVS admin folders"); myCheckoutRadioButton = new wxRadioButton(this, CHECKOUTOPTIONSPAGE_ID_CHECKOUT, _("&Checkout - for working on the module"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); myCheckoutRadioButton->SetValue(true); myExportRadioButton = new wxRadioButton(this, CHECKOUTOPTIONSPAGE_ID_EXPORT, _("&Export - for making a software release") ); sizerStaticBox->Add( myCheckoutRadioButton, 0, wxGROW | wxALL, 4); sizerStaticBox->Add( myExportRadioButton, 0, wxGROW | wxALL, 4); myExportRadioButton->SetToolTip(tip3); sizer->Add(sizerStaticBox, 0, wxGROW | wxALL, 4); sizer->Add(0, 10); #ifdef MARCH_HARE_BUILD const wxChar* tip5 = _( "Normally TortoiseCVS will checkout files so they can be modified. \ If you check this, TortoiseCVS will set the files to read-only and you can use the Edit option to make them changeable."); myReadOnlyCheck = new wxCheckBox(this, -1, _("Check out read only")); myReadOnlyCheck->SetToolTip(tip5); sizer->Add(myReadOnlyCheck, 0, wxGROW | wxALL, 4); #endif wxStaticBox* staticBox2 = new wxStaticBox(this, -1, _("Name of folder to create") ); wxStaticBoxSizer* sizerStaticBox2 = new wxStaticBoxSizer(staticBox2, wxVERTICAL); const wxChar* tip1 = _("Use this name instead of module name for the new folder"); myModuleDirRadioButton = new wxRadioButton(this, CHECKOUTOPTIONSPAGE_ID_MODULEDIR, _("Use &default folder name"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); myModuleDirRadioButton->SetValue(true); myModuleTagDirRadioButton = new wxRadioButton(this, CHECKOUTOPTIONSPAGE_ID_MODULETAGDIR, _("Use &module name and tag/branch/revision as folder name")); myAltDirRadioButton = new wxRadioButton(this, CHECKOUTOPTIONSPAGE_ID_ALTDIR, _("Enter your own &folder name")); sizerStaticBox2->Add( myModuleDirRadioButton, 0, wxGROW | wxALL, 4); sizerStaticBox2->Add( myModuleTagDirRadioButton, 0, wxGROW | wxALL, 4); sizerStaticBox2->Add( myAltDirRadioButton, 0, wxGROW | wxALL, 4); myAltDirRadioButton->SetToolTip(tip1); wxBoxSizer *horzSizer = new wxBoxSizer(wxHORIZONTAL); myAltDirLabel = new wxStaticText(this, -1, _("Custom folder name:")); horzSizer->Add( myAltDirLabel, 0, wxALL | wxALIGN_CENTER_VERTICAL, 4); myAltDirEntry = new wxTextCtrl(this, -1, wxT("")); horzSizer->Add( myAltDirEntry, 1, wxGROW | wxALL | wxALIGN_CENTER_VERTICAL, 4); myAltDirEntry->SetToolTip(tip1); myAltDirLabel->SetToolTip(tip1); sizerStaticBox2->Add( horzSizer, 0, wxGROW | wxALL, 2); sizer->Add( sizerStaticBox2, 0, wxGROW | wxALL, 4); sizer->Add(0, 10); const wxChar* tip4 = _( "Normally, text files checked out on Windows will use CRLF as the line ending. \ If you check this, TortoiseCVS will use UNIX line endings (LF only)."); myUnixLinesCheck = new wxCheckBox(this, -1, _("Use UNIX &line endings")); myUnixLinesCheck->SetToolTip(tip4); sizer->Add(myUnixLinesCheck, 0, wxGROW | wxALL, 4); wxCommandEvent event; Refresh(event); } void CheckoutOptionsPage::Update() { wxCommandEvent event; Refresh(event); } void CheckoutOptionsPage::Refresh(wxCommandEvent&) { myExportFlag = myExportRadioButton->GetValue(); bool enableTagDir = myModuleTagDirRadioButton->GetValue(); bool enableAltDir = myAltDirRadioButton->GetValue(); myAltDirEntry->Enable(enableAltDir); myAltDirLabel->Enable(enableAltDir); if (enableAltDir) { myAlternateDirectory = wxAscii(myAltDirEntry->GetValue().c_str()); myAltDirEntry->SetSelection(-1, -1); } else if (enableTagDir) { std::string dir = myModuleBasicsPage->GetModule(); std::string tag = myModuleBasicsPage->GetRevOptions()->GetTag(); std::string date = myModuleBasicsPage->GetRevOptions()->GetDate(); if (!tag.empty() || !date.empty()) { dir += '-'; dir += (date.empty() ? tag : date); } // Replace characters that cannot be in a filename FindAndReplace<std::string>(dir, ":", "."); FindAndReplace<std::string>(dir, "/", "-"); myAltDirEntry->SetValue(wxText(dir)); myAlternateDirectory = dir; } else { myAlternateDirectory = ""; myAltDirEntry->SetValue(wxText(myAlternateDirectory)); } myUnixLinesFlag = myUnixLinesCheck->GetValue(); #ifdef MARCH_HARE_BUILD myReadOnlyFlag = myReadOnlyCheck->GetValue(); #endif } void CheckoutOptionsPage::RefreshAltDir(wxCommandEvent& event) { Refresh(event); myAltDirEntry->SetFocus(); } void CheckoutOptionsPage::OnExport(wxCommandEvent& event) { myModuleBasicsPage->ExportEnabled(myExportRadioButton->GetValue()); Refresh(event); } void CheckoutOptionsPage::OKClicked() { wxCommandEvent event; Refresh(event); }
6a44fd6d950497d9143a3427ee05b43eb57692b4
588166c7cce8fd6d7a05d7bb246888948184f910
/archive/plot_2016-12-02_full_status_pies_1d.cxx
c0e6ace7f0151e9e905e0a6296169081310049bc
[]
no_license
ald77/ra4_draw
d9668844fa2c9c648a7af3b289805a4c00ef6469
5f4f6998516d5913ae899636ba39652bd9a79a52
refs/heads/master
2021-01-23T19:35:55.392641
2017-11-15T14:44:12
2017-11-15T14:44:12
49,285,571
5
2
null
null
null
null
UTF-8
C++
false
false
5,907
cxx
plot_2016-12-02_full_status_pies_1d.cxx
#include <cmath> #include <stdio.h> #include <chrono> #include "TError.h" #include "TVector2.h" #include "core/plot_maker.hpp" #include "core/plot_opt.hpp" #include "core/palette.hpp" #include "core/hist1d.hpp" #include "core/event_scan.hpp" #include "core/utilities.hpp" #include "core/table.hpp" #include "core/slide_maker.hpp" using namespace std; using namespace PlotOptTypes; NamedFunc max_b_pt("max_b_pt",[](const Baby &b) -> NamedFunc::ScalarType{ float maxPt=-999.; for (unsigned i(0); i<b.mc_pt()->size(); i++){ if (abs(b.mc_id()->at(i))!=5) continue; if(b.mc_pt()->at(i) > maxPt) maxPt = b.mc_pt()->at(i); } return maxPt; }); NamedFunc max_t_pt("max_t_pt",[](const Baby &b) -> NamedFunc::ScalarType{ float maxPt=-999.; for (unsigned i(0); i<b.mc_pt()->size(); i++){ if (abs(b.mc_id()->at(i))!=6) continue; if(b.mc_pt()->at(i) > maxPt) maxPt = b.mc_pt()->at(i); } return maxPt; }); int main(){ gErrorIgnoreLevel = 6000; chrono::high_resolution_clock::time_point begTime; begTime = chrono::high_resolution_clock::now(); double lumi = 32.2; string bfolder(""); string hostname(execute("echo $HOSTNAME")); if(Contains(hostname, "cms") || Contains(hostname, "compute-")) bfolder = "/net/cms2"; // In laptops, you can't create a /net folder string folder(bfolder+"/cms2r0/babymaker/babies/2016_08_10/mc/merged_mcbase_met100_stdnj5/"); Palette colors("txt/colors.txt", "default"); string ntupletag = "metG200"; ntupletag = ""; set<string>t1ncfiles({"*T1tttt*1500*"+ntupletag+"*.root"}); set<string>t1cfiles({"*T1tttt*1200*"+ntupletag+"*.root"}); set<string>ttfiles({"*_TTJets*Lept*"+ntupletag+"*.root", "*_TTJets_HT*"+ntupletag+"*.root"}); set<string>wfiles({"*_WJetsToLNu*"+ntupletag+"*.root"}); set<string>stfiles({"*_ST_*"+ntupletag+"*.root"}); set<string>ofiles({"*_WH_HToBB*"+ntupletag+"*.root", "*_ZH_HToBB*"+ntupletag+"*.root","*_WWTo*"+ntupletag+"*.root", "*_WZ*"+ntupletag+"*.root", "*_ZZ_*"+ntupletag+"*.root", "*_TTZ*"+ntupletag+"*.root", "*_TTW*"+ntupletag+"*.root","*_TTGJets*"+ntupletag+"*.root", "*_ttHJetTobb*"+ntupletag+"*.root","*_TTTT*"+ntupletag+"*.root", "*QCD_HT*0_Tune*"+ntupletag+"*.root", "*QCD_HT*Inf_Tune*"+ntupletag+"*.root", "*_ZJet*"+ntupletag+"*.root", "*DYJetsToLL*"+ntupletag+"*.root"}); string pscuts = "pass&&stitch"; vector<shared_ptr<Process> > procs; procs.push_back(Process::MakeShared<Baby_full>("t#bar{t}(1l), m_{T}<140", Process::Type::background, colors("tt_1l"), attach_folder(folder,ttfiles), pscuts+"&& ntruleps==1&&mt<140&&mj14<850")); procs.push_back(Process::MakeShared<Baby_full>("t#bar{t}(2l), m_{T}>140", Process::Type::background, colors("tt_2l"), attach_folder(folder,ttfiles), pscuts+"&& ntruleps==2&&mt>140&&mj14<850")); procs.push_back(Process::MakeShared<Baby_full>("T1tttt(1500,100)", Process::Type::background, 2, attach_folder(folder,t1ncfiles), pscuts+"&& mj14<850")); // procs.push_back(Process::MakeShared<Baby_full>("T1tttt(1200,800)", Process::Type::background, kGreen+1, // attach_folder(folder,t1cfiles), pscuts+"&& mj14<850")); vector<shared_ptr<Process> > proc_pies; proc_pies.push_back(Process::MakeShared<Baby_full>("t#bar{t}(1l)", Process::Type::background, colors("tt_1l"), attach_folder(folder,ttfiles), pscuts+"&& ntruleps==1")); proc_pies.push_back(Process::MakeShared<Baby_full>("t#bar{t}(2l)", Process::Type::background, colors("tt_2l"), attach_folder(folder,ttfiles), pscuts+"&& ntruleps==2")); proc_pies.push_back(Process::MakeShared<Baby_full>("W+jets", Process::Type::background, colors("wjets"), attach_folder(folder,wfiles), pscuts)); proc_pies.push_back(Process::MakeShared<Baby_full>("Single t", Process::Type::background, colors("single_t"), attach_folder(folder,stfiles), pscuts)); proc_pies.push_back(Process::MakeShared<Baby_full>("Other", Process::Type::background, colors("other"), attach_folder(folder,ofiles), pscuts)); PlotOpt linear_shapes("txt/plot_styles.txt", "CMSPaper"); linear_shapes.Title(TitleType::info) .YAxis(YAxisType::linear) .Bottom(BottomType::ratio) .Stack(StackType::shapes) .RatioMaximum(2.8); vector<PlotOpt> plot_types = {linear_shapes}; PlotMaker pm; ///// Plotting 1D pm.Push<Hist1D>(Axis(15,100.,850.,"mj14","M_{J} [GeV]",{250, 400}),"nleps==1&&st>500&&met>200&&njets>=6&&nbm>=1", procs, plot_types); ///// Plotting pies vector<TString> metcuts; metcuts.push_back("met>100 && met<=150"); metcuts.push_back("met>150 && met<=200"); metcuts.push_back("met>200 && met<=350"); metcuts.push_back("met>350 && met<=500"); metcuts.push_back("met>500"); metcuts.push_back("met>200"); vector<TString> nbcuts; nbcuts.push_back("nbm>=1"); //nbcuts.push_back("nbm>=2"); vector<TString> njcuts; njcuts.push_back("njets>=6"); vector<TString> mtcuts({"mt<=140", "mt>140"}); vector<TString> mjcuts({"mj14>250", "mj14>250&&mj14<=400", "mj14>400"}); vector<TString> cuts; vector<TableRow> table_cuts; //// nleps = 1 for(auto &imet: metcuts) for(auto &inb: nbcuts) for(auto &inj: njcuts) for(auto &imj: mjcuts) for(auto &imt: mtcuts) { cuts.push_back("nleps==1 && nveto==0 && "+imet+"&&"+inb+"&&"+inj+"&&"+imt+"&&"+imj); } for(size_t icut=0; icut<cuts.size(); icut++) table_cuts.push_back(TableRow("$"+CodeToLatex(cuts[icut].Data())+"$", cuts[icut].Data())); pm.Push<Table>("chart_full", table_cuts, proc_pies, true, true, true, false); pm.min_print_ = true; pm.MakePlots(lumi); double seconds = (chrono::duration<double>(chrono::high_resolution_clock::now() - begTime)).count(); TString hhmmss = HoursMinSec(seconds); cout<<endl<<"Making "<<pm.Figures().size()<<" plots took "<<round(seconds)<<" seconds ("<<hhmmss<<")"<<endl<<endl; }
b54fd1fde868d526b553aee064aa6bebab0ce163
07c3e4c4f82056e76285c81f14ea0fbb263ed906
/Re-Abyss/app/components/UI/SaveSelect/Main/ModeCtrl.hpp
5bbc60fd8f50044a8a1bb0d1f8f076848265409b
[]
no_license
tyanmahou/Re-Abyss
f030841ca395c6b7ca6f9debe4d0de8a8c0036b5
bd36687ddabad0627941dbe9b299b3c715114240
refs/heads/master
2023-08-02T22:23:43.867123
2023-08-02T14:20:26
2023-08-02T14:20:26
199,132,051
9
1
null
2021-11-22T20:46:39
2019-07-27T07:28:34
C++
UTF-8
C++
false
false
856
hpp
ModeCtrl.hpp
#pragma once #include <abyss/modules/GameObject/IComponent.hpp> #include <abyss/modules/UI/base/IDraw.hpp> #include <abyss/components/UI/SaveSelect/Main/Mode.hpp> namespace abyss::UI::SaveSelect::Main { class ModeCtrl : public IComponent, public IDraw { public: ModeCtrl(UIObj* pUi); void set(Mode mode) { m_mode = mode; } Mode get() const { return m_mode; } bool is(Mode mode) const { return m_mode == mode; } void onDraw() const override; private: UIObj* m_pUi; Mode m_mode = Mode::GameStart; }; } namespace abyss { template<> struct ComponentTree<UI::SaveSelect::Main::ModeCtrl> { using Base = MultiComponents< UI::IDraw >; }; }
e9350841fb4d51a393b050c2998f5e29ee566b04
bf437a984f4176f99ff1a8c6a7f60a64259b2415
/src/ansa/routing/eigrp/pdms/EigrpPrint.cc
63f0ac5285ab49e41f9755d645d2e929ce2bf649
[]
no_license
kvetak/ANSA
b8bcd25c9c04a09d5764177e7929f6d2de304e57
fa0f011b248eacf25f97987172d99b39663e44ce
refs/heads/ansainet-3.3.0
2021-04-09T16:36:26.173317
2017-02-16T12:43:17
2017-02-16T12:43:17
3,823,817
10
16
null
2017-02-16T12:43:17
2012-03-25T11:25:51
C++
UTF-8
C++
false
false
2,714
cc
EigrpPrint.cc
// // Copyright (C) 2009 - today Brno University of Technology, Czech Republic // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program 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 Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see http://www.gnu.org/licenses/. // /** * @file EigrpPrint.cc * @author Vit Rek (rek@kn.vutbr.cz) * @author Vladimir Vesely (ivesely@fit.vutbr.cz) * @copyright Brno University of Technology (www.fit.vutbr.cz) under GPLv3 * @date 6. 11. 2014 * @brief EIGRP Print functions * @detail File contains useful functions for printing EIGRP informations (CUT + PASTE from EigrpIpv4Pdm.cc) */ #include "ansa/routing/eigrp/pdms/EigrpPrint.h" namespace inet { namespace eigrp { // User messages const char *UserMsgs[] = { // M_OK "OK", // M_UPDATE_SEND "Update", // M_REQUEST_SEND "Request", // M_QUERY_SEND "Query", // M_REPLY_SEND "Reply", // M_HELLO_SEND "Hello", // M_DISABLED_ON_IF "EIGRP process isn't enabled on interface", // M_NEIGH_BAD_AS "AS number is different", // M_NEIGH_BAD_KVALUES "K-value mismatch", // M_NEIGH_BAD_SUBNET "Not on the common subnet", // M_SIAQUERY_SEND "Send SIA Query message", // M_SIAREPLY_SEND "Send SIA Reply message", }; }; // end of namespace eigrp std::ostream& operator<<(std::ostream& os, const EigrpNetwork<IPv4Address>& network) { os << "Address:" << network.getAddress() << " Mask:" << network.getMask(); return os; } std::ostream& operator<<(std::ostream& os, const EigrpNetwork<IPv6Address>& network) { os << "Address:" << network.getAddress() << " Mask: /" << getNetmaskLength(network.getMask()); return os; } std::ostream& operator<<(std::ostream& os, const EigrpKValues& kval) { os << "K1:" << kval.K1 << " K2:" << kval.K2 << " K3:" << kval.K3; os << "K4:" << kval.K4 << " K5:" << kval.K5 << " K6:" << kval.K6; return os; } std::ostream& operator<<(std::ostream& os, const EigrpStub& stub) { if (stub.connectedRt) os << "connected "; if (stub.leakMapRt) os << "leak-map "; if (stub.recvOnlyRt) os << "recv-only "; if (stub.redistributedRt) os << "redistrib "; if (stub.staticRt) os << "static "; if (stub.summaryRt) os << "summary"; return os; } }
9e6ae0f7420b2b790bd1710a07b07fb0976c3512
33d9639d0c994721ef62e6e423c89a7164d1b867
/tractor/FuelTank.h
ba87114a7e52a9bf3a471fe563323166c61e00c2
[]
no_license
elohhim/gkom-optimus
af7fa6e554ba5df34433320117f25b5fb5946ebd
c4150503dc4369e7614b7f77ddf27122607917cd
refs/heads/master
2021-06-02T14:01:53.321092
2018-01-25T13:57:38
2018-01-25T13:57:38
28,600,840
0
0
null
2015-01-08T23:15:09
2014-12-29T17:55:36
C++
UTF-8
C++
false
false
284
h
FuelTank.h
/* * FuelTank.h * * Created on: Jan 2, 2015 * Author: elohhim */ #ifndef FUELTANK_H_ #define FUELTANK_H_ #include "../Part.h" class FuelTank: public Part { public: FuelTank( float x, float y, float z); virtual ~FuelTank(); void draw(); }; #endif /* FUELTANK_H_ */
d8dc6b45f6206aee833c7f277866ad2f0fdb86ab
3926445e634886772189bf0ab5db05c211b817e4
/gameOverState.cpp
bd9d94a7ce1171e99d2a2c9967953aae67af3aba
[]
no_license
Samuelfournier/Projet-TrenteEtUn
172cdaf1d42176449be904ee6df2222e98b12255
f31b9a1d594e2ba07547eaa37629922f3159d8ff
refs/heads/main
2023-03-02T16:43:58.579278
2021-02-13T21:35:22
2021-02-13T21:35:22
338,672,708
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
2,348
cpp
gameOverState.cpp
/* Auteur : Samuel Fournier, Olivier Vigneault, William Goupil Date : 18 Décembre 2020 Programme : Définition des méthodes de gameOverState */ #include "gameOverState.h" //le constructeur utilise les : pour initialiser _data avant même l’exécution du contenu{} gameOverState::gameOverState(gameDataRef data, int winner) : _data(data), _winner(winner) { } //destructeur par default gameOverState::~gameOverState() { } //load l’image du background et tous les sprites/text associer a cette fenetre void gameOverState::init() { //load la texture pour le background _background.setTexture(_data->assets.getTexture("logo main menu background")); //load la texture pour le play button et le positionne dans la fenetre _playButton.setTexture(_data->assets.getTexture("play button")); _playButton.setTexture(_data->assets.getTexture("play button")); _playButton.setPosition((SCREEN_WIDTH / 2) - _playButton.getGlobalBounds().width / 2, (SCREEN_HEIGHT / 2) - _playButton.getGlobalBounds().height / 2); _winnerText.setFont(_data->assets.getFont("arial font")); //Set tout les parametres du text if (_winner == 0) _winnerText.setString("Vous avez perdu la partie !"); else _winnerText.setString("Vous avez gagné la partie !"); _winnerText.setCharacterSize(45); _winnerText.setFillColor(Color::White); _winnerText.setOrigin(_winnerText.getGlobalBounds().width / 2, _winnerText.getGlobalBounds().height / 2); _winnerText.setPosition((_data->window.getSize().x / 2), (_data->window.getSize().y / 2) - (_winnerText.getGlobalBounds().height / 2) - 200); } //fenêtre qui reste ouverte tant qu’elle n’est pas fermée void gameOverState::handleInput() { Event event; while (_data->window.pollEvent(event)) { if (event.type == Event::Closed) _data->window.close(); else if (_data->input.isSpriteClicked(_playButton, Mouse::Left, _data->window)) { //retourne au main menu _data->machine.addState(stateRef(new mainMenuState(_data)), true); } } } //ne fait rien pour cette fenetre void gameOverState::update(float dt) { } //clear, dessine le background et display la fenêtre avec tous ses sprites void gameOverState::draw(float dt) const { _data->window.clear(); _data->window.draw(_background); _data->window.draw(_playButton); _data->window.draw(_winnerText); _data->window.display(); }
1d67ee11c8a56815798bc7c61224522738faa1f9
53104373fb21335329b6a68ac24cef41300ae230
/A/1042.cpp
e5524842e3edbd63ba624b522ba50dbd626a630b
[]
no_license
LykeeKylee/PAT
fdcc64f009c557b08b56f1e7a17889b7ce3cdcb4
2cc460b7cfdce5ef129cca91ff3f4d5a741eae00
refs/heads/master
2022-11-22T11:19:02.441663
2020-07-25T09:03:57
2020-07-25T09:03:57
239,987,525
0
0
null
2020-03-19T09:55:52
2020-02-12T10:39:44
C++
UTF-8
C++
false
false
695
cpp
1042.cpp
#include<bits/stdc++.h> using namespace std; vector<string> card(60), tmp(60); int shuffles[60]; int main() { int k, i, j, cnt = 1; string color[] = {"S", "H", "C", "D", "J"}; scanf("%d", &k); for(i = 0; i < 5; ++i) { if(color[i] != "J") { for(j = 1; j <= 13; ++j) { card[cnt++] = color[i] + to_string(j); } } else { for(j = 1; j <= 2; ++j) { card[cnt++] = color[i] + to_string(j); } } } for(i = 1; i <= 54; ++i) scanf("%d", shuffles + i); for(i = 0; i < k; ++i) { for(j = 1; j <= 54; ++j) tmp[shuffles[j]] = card[j]; card = tmp; } for(i = 1; i <= 54; ++i) printf("%s%s", card[i].c_str(), i == 54 ? "\n" : " "); return 0; }
c5b0af6ef9d54029211b882732814fe9f84e52e6
9c8bf3ca7f70243c35c998916f6e402581b55f43
/Classes/ArrowNode.h
92aaddb7882ec86e76892b2dd2d632e96bb2f6ee
[]
no_license
agiantwhale/segments
aced26c936f6c7d5dce9d417316dec11023eafce
2fec42032d374078702268f6f04034f2d017da7d
refs/heads/master
2016-09-15T22:38:58.786295
2013-10-20T23:53:26
2013-10-20T23:53:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
581
h
ArrowNode.h
// // ArrowNode.h // CutGame // // Created by 이일재 on 13. 7. 5.. // // #ifndef __CutGame__ArrowNode__ #define __CutGame__ArrowNode__ #include <cocos2d.h> #include "GameLayer.h" using namespace cocos2d; class ArrowNode : public CCNode { CC_SYNTHESIZE_PASS_BY_REF(std::vector<SliceInfo>, m_sliceInfoStack, SliceInfoStack); public: static ArrowNode* create(const ccColor4B& color); virtual bool initWithColor(const ccColor4B& color); virtual void draw(); private: ccColor4B m_arrowColor; }; #endif /* defined(__CutGame__ArrowNode__) */
91f79f56bd005930c4c6f210a1939b663ea26edf
1b08ce242cf532a0af1378735a153a0cac172b85
/Ubung1/Header/Mul.h
d80c2b21318bf9b7979cd151fc784f64d5281a0a
[]
no_license
Martinay/PraktikumDesignPatterns
70dd43fc3c3dd16c71bc52ecf54796c06de74e06
0d5d7f6954993ccf6f7ac3445cdb7605335a6670
refs/heads/master
2021-04-30T22:06:49.422389
2017-01-20T11:08:10
2017-01-20T11:08:10
71,438,734
0
0
null
null
null
null
UTF-8
C++
false
false
188
h
Mul.h
#include "Term.h" class Mul : public Term{ public: Mul(Term* links, Term*rechts); void Print(); int Calc(); private: Term *_links; Term *_rechts; };
471a600a8f6cabe3fcf55e00586ff688f5d1bd9b
acc968826c90c46ecbb3f3c9fe839fbb98116124
/src/model/Term.h
90640b2b92202a2e478b0153c2031b4937c98a95
[ "MIT" ]
permissive
lucasnr/autocomplete
eeca8dec424981886597b06ecad7586824fbc980
7480711f9d908ef5f44d38b1dd8332e5cea71874
refs/heads/main
2023-07-06T20:02:15.908968
2021-08-22T20:24:54
2021-08-22T20:24:54
360,253,365
0
0
null
null
null
null
UTF-8
C++
false
false
89
h
Term.h
#include <string> using namespace std; struct Term { long weight; string value; };
f82c8942dbca950b1be89cd1ba70299cd632e983
a92e370fa5b4adc2b8ebd081ee2ac7a49283c7a4
/src/laneft_ocv.hpp
2f6935ddb213fec775d95f1f5e5ff1e836c72323
[ "MIT" ]
permissive
jamesljlster/laneft
66c03b076d0694489ba4abb1b288c3f41eb1a72a
6dfc0984d038b0c4b7fa13b6244b6f104a426584
refs/heads/master
2020-04-14T23:44:44.126728
2018-12-09T08:29:03
2018-12-09T08:29:07
164,214,203
0
0
null
null
null
null
UTF-8
C++
false
false
435
hpp
laneft_ocv.hpp
#ifndef LANEFT_OCV_HPP_INCLUDED #define LANEFT_OCV_HPP_INCLUDED #include <opencv2/opencv.hpp> #include "laneft.hpp" class laneft_ocv : public laneft { public: laneft_ocv() : laneft() {} laneft_ocv(laneft::LANE_TYPE laneType) : laneft(laneType) {} double get_feature(cv::Mat src); void draw_line_onto(cv::Mat& dst); protected: cv::Scalar get_order_color(int order); }; #endif // LANEFT_OCV_HPP_INCLUDED
6c7ef769bd6df4471d5e270d7429e0ce253c184a
6dccb3185a93e45b0992dfdf5938b5e3ab9d46de
/src/ParaGraphTest/src/main.cpp
142dfd0876e087fe83b13c4e21054871a327c5cf
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
appu226/ParaGraph
7a16f40424879a4aac5c8f1e264fc63dd9fa6c02
82604a286b50d414515f22521882115980f2ee80
refs/heads/master
2020-03-07T15:25:38.515538
2018-09-02T12:39:57
2018-09-02T12:39:57
127,554,552
1
0
Apache-2.0
2018-08-04T15:11:58
2018-03-31T17:22:32
C++
UTF-8
C++
false
false
2,048
cpp
main.cpp
/** * Copyright 2018 Parakram Majumdar * * 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 "math_test.h" #include "graph_test.h" #include "ml_graph_builder_test.h" #include "tensor_function_factory_test.h" namespace { template<typename t_test> void register_test(para::graph::unit_test_collection& uts) { uts.push_back(para::graph::unit_test_uptr(new t_test)); } } // end anonymous namespace int main(int argc, char** argv) { using namespace para::graph; unit_test_collection uts; register_test<tensor_construction_test>(uts); register_test<tensor_zero_test>(uts); register_test<tensor_zero_derivative_test>(uts); register_test<tensor_scalar_test>(uts); register_test<tensor_identity_derivative_test>(uts); register_test<tensor_chain_multiplication_test>(uts); register_test<tensor_add_test>(uts); register_test<tensor_iterator_test>(uts); register_test<graph_scalar_test>(uts); register_test<graph_tensor_test>(uts); register_test<tensor_function_factory_add_test>(uts); register_test<tensor_function_factory_chain_multiplication_test>(uts); register_test<tensor_function_factory_sigmoid_test>(uts); register_test<tensor_function_factory_reduce_sum_test>(uts); register_test<tensor_function_factory_log_test>(uts); register_test<tensor_function_factory_element_wise_multiplication_test>(uts); register_test<tensor_function_factory_negative_test>(uts); register_test<ml_graph_builder_test>(uts); run_unit_tests(uts); return 0; }
10d7be5a2fd15f30fc20aa455231e6a9d8720c6e
862b98241a8a7207237467829b6e54d67865c1d4
/cpp/Test/12_CO_en_case.cpp
225d1e0be5614a9bfcc71297ab218788c1038271
[]
no_license
eglrp/PublicSpace
fa6889f410e11ccebffac6730ee5c1b063d73217
e5d31339a316ffdbfedc8f3cb750ef942c47412a
refs/heads/master
2022-11-12T17:49:34.531240
2020-06-30T00:10:30
2020-06-30T00:10:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,947
cpp
12_CO_en_case.cpp
// // 12_CO_2case.cpp // cpp // // Created by kabun on 2020/4/21. // Copyright © 2020 kabun . All rights reserved. // #include <stdio.h> #include <iostream> #include <string> #include "Point.hpp" #include "Circle.hpp" using namespace std; /* //====================================================立方体案例======================================================= //1:创建立方体类 class Cube { //3:设计行为,获取立方体的面积和体积 public: //设置长 void setL(int l) { clong = l; } //获取长 int getL() { return clong; } //设置宽 void setW(int w) { cwide = w; } //获取宽 int getW() { return cwide; } //设置高 void setH(int h) { chigh = h; } //获取高 int getH() { return chigh; } //获取面积 int calculaterS() { return 2*clong*cwide + 2*clong*chigh + 2*cwide*chigh; } //获取体积 int calculaterV() { return clong*cwide*chigh; } //利用成员函数判断是否相等 bool IsSameClass(Cube& c) { if(chigh==c.getH()&&clong==c.getL()&&cwide==c.getW()) { return true; } else { return false; } } //2:设计属性 private: int clong; int cwide; int chigh; }; //4:分别用全局函数和成员函数,判断两个立方体是否相等 bool isSame(Cube& c1,Cube& c2) { if(c1.getH()==c2.getH()&&c1.getL()==c2.getL()&&c1.getW()==c2.getW()) { return true; } else { return false; } } int main() { //创建立方体的对象 Cube c1; c1.setL(10); c1.setH(2); c1.setW(3); cout << "面积就是::" << c1.calculaterS() << endl; cout << "体积就是::" << c1.calculaterV() << endl; //4:分别用全局函数和成员函数,判断两个立方体是否相等 //创建第二个立方体 Cube c2; c2.setL(10); c2.setH(2); c2.setW(6); bool reasult = isSame(c1, c2); if(reasult) { cout << "相等" << endl; } else { cout << "不相等" << endl; } //利用成员函数判断 reasult = c1.IsSameClass(c2); if(reasult) { cout << "成员相等" << endl; } else { cout << "成员不相等" << endl; } } */ //====================================================点和圆的关系案例======================================================= //创建点类 /* class Point { public: void setX(int x) { o_x = x; } int getX() { return o_x; } void setY(int y) { o_y = y; } int getY() { return o_y; } private: int o_x; int o_y; }; */ //创建圆 /* class Circle { public: void setR(int r) { o_r = r; } int getR() { return o_r; } void setCenter(Point center) { o_center = center; } Point getCenter() { return o_center; } private: int o_r; //在类中可以让另一个类 作为本类中的成员 Point o_center; }; */ //判断圆和点的关系 //void IsInCircle(Circle& c,Point& p) //{ // //计算两点之间距离的平方 // int distance = // (c.getCenter().getX() - p.getX())*(c.getCenter().getX() - p.getX()) + // (c.getCenter().getY() - p.getY())*(c.getCenter().getY() - p.getY()); // //计算半径的平方 // int rdintance = c.getR()*c.getR(); // // //判断关系 // if(distance == rdintance) // { // cout <<"点在原上"<< endl; // } // else if (distance > rdintance) // { // cout <<"在圆外"<< endl; // } // else // { // cout <<"在圆内"<< endl; // } // //} // // //int main() //{ // //创建一个圆 // Circle c; // c.setR(10); // Point center; // center.setX(10); // center.setY(0); // c.setCenter(center); // //创建一个点 // Point p; // p.setX(10); // p.setY(9); // // //判断关系 // IsInCircle(c, p); // return 0; //} // //==========================================类内更改私有属性========================================== // //class bb //{ // //public: // string name; // int age; // void func() // { // cout << "咩有const" << name << age << endl; // } // // void setni(string name,int age) // { // m_age = age; // m_name = name; // } // // string getname() // { // return m_name; // } // // int getage() // { // return m_age; // } // //private: // string m_name; // int m_age; //}; // // //int main() //{ // int b = 10; // bb b1; // b1.setni("李小龙", 26); // b1.func(); // // return 0; //}
779772437b7234380368d4d6b1d47b428f7449ff
547a0e37998c836be10ee00f13b1cf201a381de5
/3.2小节——入门模拟->查找元素/ProblemB.cpp
a40cd0c617619cf0b2801ea2256ddea530f0ee84
[]
no_license
hegongshan/algorithm-notes
7232c3b3868f1a6ca4603756adc92edb3facbf6d
59e1ab7146858e5a4b4b11c9b7459289e2a93f16
refs/heads/master
2020-04-29T11:41:02.881872
2019-08-06T15:35:39
2019-08-06T15:35:39
176,108,059
0
0
null
null
null
null
UTF-8
C++
false
false
366
cpp
ProblemB.cpp
#include <cstdio> int main() { int n; while (scanf("%d", &n) != EOF) { int arr[n]; for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } int x; scanf("%d", &x); bool flag = false; for (int i = 0; i < n; i++) { if (x == arr[i]) { printf("%d\n", i); flag = true; break; } } if (!flag) { printf("-1\n"); } } return 0; }
e7492987bbeb8c12c58d99184c22b073ba380c25
096387465560b8f226733ee807358b4c99ea0a3d
/BlobWorld/source/src/animatedsprite.cpp
7612ef742e7b0233225c7e9694e6760761f8f91b
[]
no_license
jezwin10/BlobWorld
57aaa210ca2756a39d216f316616dd6c8e48a23e
6f55bc62f042d114e0fa21754a053d88fb93731b
refs/heads/master
2020-03-12T23:34:46.315448
2018-04-24T14:42:40
2018-04-24T14:42:40
130,749,886
0
0
null
null
null
null
UTF-8
C++
false
false
3,371
cpp
animatedsprite.cpp
/* AnimatedSprite Class * Used to animate the sprites */ #include "animatedsprite.h" #include "graphics.h" AnimatedSprite::AnimatedSprite() { } AnimatedSprite::AnimatedSprite(Graphics &graphics, const std::string &filePath, int sourceX, int sourceY, int width, int height, float posX, float posY, float timeToUpdate) : Sprite(graphics, filePath, sourceX, sourceY, width, height, posX, posY), _frameIndex(0), _timeToUpdate(timeToUpdate), _visible(true), _currentAnimationOnce(false), _currentAnimation("") {} void AnimatedSprite::addAnimation(int frames, int x, int y, std::string name, int width, int height, Vector2 offset) { std::vector<SDL_Rect> rectangles; for (int i = 0; i < frames; i++) { // i goes from 0 to 2 from 3 frames per animation SDL_Rect newRect = { (i + x) * width, y, width, height}; // (i + x) * width grabs which ever sprite corresponds to x. rectangles.push_back(newRect); } _animations.insert(std::pair<std::string, std::vector<SDL_Rect> >(name, rectangles)); _offsets.insert(std::pair<std::string, Vector2>(name, offset)); } // This function clears the maps of both animations and offsets void AnimatedSprite::resetAnimation() { _animations.clear(); _offsets.clear(); } void AnimatedSprite::playAnimation(std::string animation, bool once) { _currentAnimationOnce = once; // Check if the animation that is trying to play is already playing if (_currentAnimation != animation) { _currentAnimation = animation; _frameIndex = 0; } } void AnimatedSprite::setVisible(bool visible) { _visible = visible; } void AnimatedSprite::stopAnimation() { _frameIndex = 0; animationDone(_currentAnimation); } // This function has a timer that checks when to go the next frame in the animation void AnimatedSprite::update(int elapsedTime) { Sprite::update(); // adding onto the timer every new frame _timeElapsed += elapsedTime; // if timeElapsed > _timeToUpdate then its time to change frames if (_timeElapsed > _timeToUpdate) { _timeElapsed -= _timeToUpdate; if (_frameIndex < _animations[_currentAnimation].size() -1) { // if frameIndex is not at the last one in the animation, then increase frameIndex by 1 _frameIndex++; } else { if (_currentAnimationOnce == true) { // if you are on the last one however, then stop, sending it back to the start setVisible(false); } _frameIndex = 0; animationDone(_currentAnimation); } // end else {} } // end if() statement } //end function void AnimatedSprite::draw(Graphics &graphics, int x, int y) { if (_visible) { // if its visible, then create a temporary destinationRectangle which is where it'll be drawn SDL_Rect destinationRectangle; destinationRectangle.x = x + _offsets[_currentAnimation].x; destinationRectangle.y = y + _offsets[_currentAnimation].y; destinationRectangle.w = _sourceRect.w * globals::SPRITE_SCALE; destinationRectangle.h = _sourceRect.h * globals::SPRITE_SCALE; SDL_Rect sourceRect = _animations[_currentAnimation][_frameIndex]; // get the correct rectangle to draw by using what's passed into _currentAnimation and _frameIndex // the map is indexed using _animations[_currentAnimation] to get the correct vector and _frameIndex then indexes the vector to get the correct rectangle from the vector itself graphics.blitSurface(_spriteSheet, &sourceRect, &destinationRectangle); } }
d8c70dfb97b36a84a314d54127e5179bf5e1eaec
78637020449753a82e219cd7e750a166a2a01533
/noiseField/src/ofApp.cpp
bcd8e25e1086023416c2ed93528ff4fe1b215c02
[]
no_license
jakeelwes/OF_work_old
f4550a56092f0a830809ba95fc29c4983c1e9faa
72d983c1e2508e10ffd26350146713c985c3c531
refs/heads/master
2021-01-15T13:23:22.375579
2015-10-24T06:48:17
2015-10-24T06:48:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,804
cpp
ofApp.cpp
#include "ofApp.h" float phase = TWO_PI; // separate u-noise from v-noise float complexity = 3; // wind complexity int step = 10; // spatial sampling rate float timeSpeed = .02; // wind variation speed ofPoint ofApp::getField(ofPoint position) { float normx = ofNormalize(position.x, 0, ofGetWidth()); float normy = ofNormalize(position.y, 0, ofGetHeight()); float u = ofNoise(t + phase, normx * complexity + phase, normy * complexity + phase); float v = ofNoise(t - phase, normx * complexity - phase, normy * complexity + phase); return ofVec2f(u, v); } void ofApp::setup(){ ofSetVerticalSync(true); // don't go too fast ofEnableAlphaBlending(); windSpeed = 500; // wind vector magnitude gui = new ofxDatGui( ofxDatGuiAnchor::TOP_LEFT ); gui->addSlider("Complexity", 0, 20); gui->addSlider("Length", 1, 800); gui->addSlider("Speed", 0, .1); gui->onSliderEvent(this, &ofApp::onSliderEvent); gui->setOpacity(0.2); gui->addFooter(); } void ofApp::update(){ t = ofGetFrameNum() * timeSpeed; } void ofApp::draw(){ ofBackgroundGradient(255, 100); for(int i = 0; i < ofGetWidth(); i += step) { for(int j = 0; j < ofGetHeight(); j += step) { ofVec2f field = getField(ofVec2f(i, j)); ofPushMatrix(); ofTranslate(i, j); ofSetColor(0,60); ofDrawLine(0, 0, ofLerp(-windSpeed, windSpeed, field.x), ofLerp(-windSpeed, windSpeed, field.y)); ofPopMatrix(); } } } void ofApp::onSliderEvent(ofxDatGuiSliderEvent e){ if (e.target->is("Complexity")) complexity = e.target->getValue(); if (e.target->is("Length")) windSpeed = e.target->getValue(); if (e.target->is("Speed")) timeSpeed = e.target->getValue(); }
2e0ee7c0f2259bbe3232c0f4cc93feface9e3358
fe561727a6b4337965c046019a2d412ef178540d
/apprenticevideo/yaePlaylistViewStyle.cpp
19b6123a6af38e402f836e23f7cbeac7575c6404
[]
no_license
pkoshevoy/aeyae
7a22eeac3afe58326b613233eb3df0abd11b1d67
f7e0d23c85bed7f223c1b7fe9e0a3d52eab88d67
refs/heads/master
2023-08-31T00:41:59.258498
2023-08-19T18:28:33
2023-08-19T18:28:33
40,034,857
16
6
null
2018-05-16T03:39:13
2015-08-01T04:10:12
C++
UTF-8
C++
false
false
1,895
cpp
yaePlaylistViewStyle.cpp
// -*- Mode: c++; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil -*- // NOTE: the first line of this file sets up source code indentation rules // for Emacs; it is also a hint to anyone modifying this file. // Created : Sat Jan 2 16:32:55 PST 2016 // Copyright : Pavel Koshevoy // License : MIT -- http://www.opensource.org/licenses/mit-license.php // standard C++ library: #include <algorithm> #include <cmath> // local interfaces: #include "yaePlaylistViewStyle.h" #include "yaeText.h" #include "yaeTexture.h" namespace yae { //---------------------------------------------------------------- // PlaylistViewStyle::PlaylistViewStyle // PlaylistViewStyle::PlaylistViewStyle(const char * id, PlaylistView & playlist): ItemViewStyle(id, playlist), playlist_(playlist), now_playing_(Item::addNewHidden<Text>("now_playing")), eyetv_badge_(Item::addNewHidden<Text>("eyetv_badge")) { xbutton_ = Item::addHidden<Texture> (new Texture("xbutton", QImage())).sharedPtr<Texture>(); collapsed_ = Item::addHidden<Texture> (new Texture("collapsed", QImage())).sharedPtr<Texture>(); expanded_ = Item::addHidden<Texture> (new Texture("expanded", QImage())).sharedPtr<Texture>(); } //---------------------------------------------------------------- // PlaylistViewStyle::uncache // void PlaylistViewStyle::uncache() { bg_xbutton_.uncache(); fg_xbutton_.uncache(); bg_hint_.uncache(); fg_hint_.uncache(); bg_badge_.uncache(); fg_badge_.uncache(); bg_label_.uncache(); fg_label_.uncache(); bg_label_selected_.uncache(); fg_label_selected_.uncache(); bg_group_.uncache(); fg_group_.uncache(); bg_item_.uncache(); bg_item_playing_.uncache(); bg_item_selected_.uncache(); ItemViewStyle::uncache(); } }
17f4fea6ed232d72f067f68f4e1fe1d1b0245fd7
8a4597aeb1a9dfdc91139a1f1f3aa8bb9f87718d
/src_cpp/Bench/Thread.h
55f067330893d7d4fd9bc0e55df2cbd90b51f15b
[]
no_license
kimleeju/JellyFishDB
62ece2f6bff085f545d69393f8b09130a632cb9e
9a737c72ba4faa08f7e4929275f1397c0dc198b2
refs/heads/master
2022-12-10T03:22:19.656333
2020-09-22T01:13:13
2020-09-22T01:13:13
297,499,528
0
0
null
null
null
null
UTF-8
C++
false
false
660
h
Thread.h
#ifndef THREAD_H #define THREAD_H #include <iostream> #include <pthread.h> #include <assert.h> #include <stdio.h> //#include <Windows.h> using namespace std; // 라이브러리 내부 클래스 class Thread{ public: pthread_t tid; pid_t pid; private: static void *_entry_func(void* arg) { assert(arg); ((Thread *)arg)->entry(); return NULL; } protected: virtual void *entry() = 0; void _join() { int rv = pthread_join(tid, NULL); assert(rv == 0); } void _create(){ int rv = pthread_create(&tid, NULL, _entry_func, (void *)this); assert(rv == 0); } Thread() : tid(0), pid(0){}; ~Thread(){}; }; #endif
768d85496756bc15d6b9c1353747372a7482b171
368dac6c28dc44bd28288bce651c32f1f640dc91
/virtual/client/include/csutil/csevent.h
3c99c7352ba5c42021df7b9f08a4f7fa25fbbdef
[]
no_license
Programming-Systems-Lab/archived-memento
8fbaa9387329d1d11ae4e8c1c20a92aeadeb86e0
084c56a679585c60b5fc418cd69b98c00cf2c81e
refs/heads/master
2020-12-02T12:21:04.667537
2003-11-04T17:08:35
2003-11-04T17:08:35
67,139,953
0
0
null
null
null
null
UTF-8
C++
false
false
1,905
h
csevent.h
/* Crystal Space 3D engine: Event class interface Written by Andrew Zabolotny <bit@eltech.ru> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __CS_CSEVENT_H__ #define __CS_CSEVENT_H__ #include "iutil/event.h" /** * This class represents a system event.<p> * Events can be generated by hardware (keyboard, mouse) * as well as by software. There are so much constructors of * this class as much different types of events exists. */ class csEvent : public iEvent { public: /// Empty initializer csEvent (); /** * Cloning constructor. Note that for command style events, this performs * only a shallow copy of the `Info' attribute. */ csEvent (csEvent const&); /// Create a keyboard event object csEvent (csTicks, int type, int kcode, int kchar, int modifiers); /// Create a mouse event object csEvent (csTicks, int type, int x, int y, int button, int modifiers); /// Create a joystick event object csEvent (csTicks, int type, int n, int x, int y, int button, int modifiers); /// Create a command event object csEvent (csTicks, int type, int code, void* info = NULL); /// Destructor virtual ~csEvent (); SCF_DECLARE_IBASE; }; #endif // __CS_CSEVENT_H__
ace714a2c1fe63fa668886936bc2ea77606c9cbf
d3cf897a9ba0f624da78ea59091237f54a9ff402
/686 Div3 E.cpp
454a56d7c20d402976523805c102fbd41b137f0e
[]
no_license
divyanshTyagi/ProblemsSolving
6caa70fc68cf5983b8f41b142ec9361e89b045e5
8ac1c71c32bc87956bf49e16fabafa57c91d1a10
refs/heads/master
2023-04-06T05:28:40.302645
2021-04-18T03:48:48
2021-04-18T03:48:48
293,764,751
0
0
null
null
null
null
UTF-8
C++
false
false
2,420
cpp
686 Div3 E.cpp
#include <bits/stdc++.h> #define int long long #define float double #define sz 100005 #define mod 1000000007 using namespace std; #define vi vector<int> #define vvi vector<vector<int>> #define debug cout << "here" << endl; #define rep(i,n) for(int i = 0 ; i<n ; ++i) #define pb push_back #define ff first #define ss second #define pi pair<int,int> using namespace std; int answer =0 ; int cycleLength = 0; void enumerateSubmasks(int m){ // visits submasks without repetition and in descending order for(int s = m ; ; s = (s-1)&m){ if(s == 0) { //... break; } } } map<int,list<int>> adj; map<int,bool> inCycle; void findCyclePath(int node,int par,map<int,bool> &visited,stack<int> &s,bool &flag){ //cout << " AT " << node << endl; s.push(node); visited[node] = true; for(auto child : adj[node]){ if(!flag) break; if(child == par) continue; if(visited[child] == true){ cycleLength+=1; while(s.top()!=child){ cycleLength+=1; inCycle[s.top()] = true; s.pop(); } inCycle[child] = true; flag = false; return ; } else{ if(flag) findCyclePath(child,node,visited,s,flag); } } if(flag) s.pop(); } void solvePerNode(int node,int par,map<int,bool> &visited,int &cnt){ //cout << " at " << node << endl; visited[node] = true; for(auto child : adj[node]){ if(child == par || inCycle[child]) continue; solvePerNode(child,node,visited,cnt); } cnt+=1; return ; } int32_t main(){ int tc; cin >> tc; while(tc--){ adj.clear(); inCycle.clear(); answer =0 ; cycleLength = 0; int n; cin >> n ; rep(i,n){ int u,v; cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } bool flag = true; stack<int> s; map<int,bool> visited; findCyclePath(1,1,visited,s,flag); visited.clear(); // non cycle paths for(int i = 1 ; i <= n ; i++){ if(inCycle[i] == false) continue; int cnt = 0; solvePerNode(i,i,visited,cnt); answer += (cnt*(cnt-1))/2 + (n-cnt)*(cnt); } cout << answer << endl; } }
b0c922124fc74ccd78e669e7ef6208612680ac5d
322056cae401f1bbd9a7336f636a29e4ffa6ffa9
/General/MRR_Dir/mrr.cpp
bb425a5884abc9a456c15d7cc843c9f02d89dcb9
[ "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
dariasor/ag_scripts
64987144f15e25f2df603525900c19401f8d1786
430af8e2c24ec803853fd7c66d981c469001ab83
refs/heads/master
2021-04-24T17:54:27.159922
2021-03-24T19:45:53
2021-03-24T19:45:53
18,821,093
1
4
null
null
null
null
UTF-8
C++
false
false
4,898
cpp
mrr.cpp
//mrr.cpp: main function of executable ndcg //Calculates MRR from predictions and group and target values. Reciprocal rank (RR) is calculated separately //for each group, then averaged. #pragma warning(disable : 4996) #include <fstream> #include <iostream> #include <errno.h> #include <vector> #include <string> #include <set> #include <algorithm> #include <string.h> #include "math.h" using namespace std; typedef vector<double> doublev; typedef pair<double, double> ddpair; typedef vector<ddpair> ddpairv; typedef set<int> intset; typedef vector<int> intv; typedef pair<string, int> sipair; typedef vector<sipair> sipairv; typedef vector<string> stringv; #define LINE_LEN 20000 //maximum length of line in the input file //extends fstream::getline with check on exceeding the buffer size void getLineExt(fstream& fin, char* buf) { fin.getline(buf, LINE_LEN); if(fin.gcount() == LINE_LEN - 1) throw string("Erros: lines in an input file exceed current limit."); } double atofExt(string str) { char *end; double value = strtod(str.c_str(), &end); if((end == str) || (*end != '\0')) throw string("Error: non-numeric value \"") + string(str) + string("\""); return value; } bool greater1(const ddpair& d1, const ddpair& d2) { return (d1.first > d2.first); } double rr(doublev::iterator preds, doublev::iterator tars, int itemN) { ddpairv data(itemN); for(int i = 0; i < itemN; i++) { data[i].first = preds[i]; data[i].second = tars[i]; } sort(data.begin(), data.end(), greater1); int firstRank = -1; for(int i = 0; (i < itemN) && (firstRank == -1); i++) { if(data[i].second > 0.0) //relevant firstRank = i + 1; } return (firstRank == -1) ? 0 : (1.0 / firstRank); } //rr averaged across groups double mrr(doublev& preds_in, doublev& tars_in, stringv& groups_in, bool sorted) { //if the data is not sorted by group, create sorted copies of all input arrays int itemN = (int)preds_in.size(); doublev preds_s, tars_s; stringv groups_s; if(!sorted) { sipairv groupids; groupids.resize(itemN); for(int itemNo = 0; itemNo < itemN; itemNo++) { groupids[itemNo].first = groups_in[itemNo]; groupids[itemNo].second = itemNo; } sort(groupids.begin(), groupids.end()); preds_s.resize(itemN); tars_s.resize(itemN); groups_s.resize(itemN); for(int itemNo = 0; itemNo < itemN; itemNo++) { preds_s[itemNo] = preds_in[groupids[itemNo].second]; tars_s[itemNo] = tars_in[groupids[itemNo].second]; groups_s[itemNo] = groups_in[groupids[itemNo].second]; } } doublev& preds = sorted ? preds_in : preds_s; doublev& tars = sorted ? tars_in : tars_s; stringv& groups = sorted ? groups_in : groups_s; //now calculate rr for every group double meanVal = 0; int groupN = 0; int curBegins = 0; string curGr = groups[0]; for(int itemNo = 0; itemNo < itemN; itemNo++) { if((itemNo == itemN - 1) || (groups[itemNo + 1].compare(curGr) != 0)) { groupN++; meanVal += rr(preds.begin() + curBegins, tars.begin() + curBegins, itemNo + 1 - curBegins); if(itemNo != itemN - 1) { curGr = groups[itemNo + 1]; curBegins = itemNo + 1; } } } return meanVal / groupN; } //mrr _targets_ _predictions_ _groups_ int main(int argc, char* argv[]) { try{ //check presence of input arguments if(argc != 4) throw string("Usage: mrr _targets_ _predictions_ _groups_"); fstream ftar(argv[1], ios_base::in); if(!ftar) throw string("Error: failed to open file ") + string(argv[1]); fstream fpred(argv[2], ios_base::in); if(!fpred) throw string("Error: failed to open file ") + string(argv[2]); fstream fgroup(argv[3], ios_base::in); if(!fgroup) throw string("Error: failed to open file ") + string(argv[3]); //load target and prediction values; doublev tars, preds; stringv groups; char buf[LINE_LEN]; //buffer for reading strings from input files double hold_d; string hold_s; fpred >> hold_s; try { hold_d = atofExt(hold_s); } catch(...) { //header present, remove it form all columns ftar >> hold_s; getLineExt(fgroup, buf); fpred >> hold_s; hold_d = atofExt(hold_s); } while(!fpred.fail()) { preds.push_back(hold_d); fpred >> hold_s; hold_d = atofExt(hold_s); } ftar >> hold_d; while(!ftar.fail()) { tars.push_back(hold_d); ftar >> hold_d; } getLineExt(fgroup, buf); while(fgroup.gcount()) { groups.push_back((string)buf); getLineExt(fgroup, buf); } if(tars.size() != preds.size()) throw string("Error: different number of values in targets and predictions files"); if(tars.size() != groups.size()) throw string("Error: different number of values in targets and groups files"); double retVal = mrr(preds, tars, groups, false); cout << "MRR: " << retVal << endl; }catch(string err){ cerr << err << endl; return 1; }catch(...){ string errstr = strerror(errno); cerr << "Error: " << errstr << endl; return 1; } return 0; }
2ce4294294e1248047821e54cc8845b5f38ee11b
4fd632c1daad7f351cdbc87e81a0f8f600d34337
/main.cpp
c30b0a108ce01867db43dd4b5c18d1affcc2ca65
[]
no_license
airyai/avalon
27992e65183d802d4859bde0310b3c4928c93e82
20b82c56ed72928084b2192d8282b9a46b252a4d
refs/heads/master
2016-09-06T11:00:29.099178
2012-03-27T17:47:11
2012-03-27T17:47:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
611
cpp
main.cpp
#include <iostream> #include <boost/asio/io_service.hpp> #include <boost/shared_ptr.hpp> #include <boost/thread.hpp> #include <boost/bind.hpp> void f(boost::shared_ptr<boost::asio::io_service::work> w) { boost::this_thread::sleep(boost::posix_time::seconds(2)); w.reset(); } int main(int argc, char **argv) { std::cout << "Hello, world!" << std::endl; boost::asio::io_service service; boost::shared_ptr<boost::asio::io_service::work> work; work.reset(new boost::asio::io_service::work(service)); service.post(boost::bind(f, work)); service.run_one(); return 0; }
0838bc21da3849e92e17274dd332f3623bcf93c7
da645441cfa22bb38fe55c90f0d83091fa7b636b
/src/net/src/TrantorEPoll.cc
ae54209d0a4245e9b5b4c29a27baf9a6a1a8f588
[ "BSD-2-Clause" ]
permissive
hdzz/TrantorNet
fc0a6a09930c5cbb9763afa1473ca505db40fa1c
df437ad698e8eb88d949e5c8053705068d511df1
refs/heads/master
2021-01-16T18:51:30.239858
2017-06-20T12:42:35
2017-06-20T12:42:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,115
cc
TrantorEPoll.cc
#include "TrantorEPoll.h" #include <sys/eventfd.h> TrantorEPoll::TrantorEPoll(uint32_t max_fd_num) :max_fd_num_(max_fd_num), events_vec(100) { epfd_ = epoll_create(max_fd_num_); if(epfd_ < 0) { //LOG_ERROR<<"epfd create error"; abort(); } } void TrantorEPoll::startEPoll(map<uint32_t, uint32_t>* event_map) { int nfds = epoll_wait(epfd_, &(*events_vec.begin()), events_vec.size(), -1); for(int i = 0; i < nfds; i++) { uint32_t fd = events_vec[i].data.fd; uint32_t revent = events_vec[i].events; event_map->insert(std::make_pair(fd, revent)); } if(nfds == events_vec.size()) { events_vec.resize(2 * events_vec.size()); } } void TrantorEPoll::registerFd(uint32_t fd, uint32_t events) { epoll_event event_st; event_st.data.fd = fd; event_st.events = events; epoll_ctl(epfd_, EPOLL_CTL_ADD, fd, &event_st); } void TrantorEPoll::updateFd(uint32_t fd, uint32_t events) { epoll_event event_st; event_st.data.fd = fd; event_st.events = events; epoll_ctl(epfd_, EPOLL_CTL_MOD, fd, &event_st); } void TrantorEPoll::removeFd(uint32_t fd) { epoll_ctl(epfd_, EPOLL_CTL_DEL, fd, NULL); }
e6e3d6f8fe77e436d8446c70cf9bc0e8f3967b3c
c5ae27716b79c1cdb0b7f6c980dee928e379976a
/library/src/main/cpp/CryptoHelper.h
244b4be5e5ab467fb74b30bc3a45021f71444421
[ "MIT", "LicenseRef-scancode-generic-cla" ]
permissive
fengjixuchui/AndroidJniHelpers
4ef380664a8e3f5ca88e264da38b3295b0b9f3df
97385c90438d57e8b2a094c91c409cec7e33aa43
refs/heads/master
2020-11-24T15:07:51.108055
2018-09-03T11:01:30
2018-09-03T11:01:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,111
h
CryptoHelper.h
// // Created by Christopher Miller on 2/12/17. // #ifndef APPLICATIONRESOURCES_CRYPTOHELPER_H #define APPLICATIONRESOURCES_CRYPTOHELPER_H #include "JniHelpers.h" using spotify::jni::NativeObject; class CryptoHelper : public NativeObject { public: jbyteArray keyBytes; /** * This facsimile of the Java method java.lang.Class.getCanonicalName() is used to maintain * the Jni Helper's relationship to the CryptoHelper class defined in Java. */ const char *getCanonicalName() const { return MAKE_CANONICAL_NAME("us/the/mac/android/jni/helpers", CryptoHelper); } CryptoHelper(); CryptoHelper(JNIEnv *env); void initialize(JNIEnv *env); void mapFields(); void setBytes(jbyteArray jbyteArrayValue); jobject generateKeyNative(JNIEnv *env); static jobject generateKey(JNIEnv *env, jobject java_this); jbyteArray decrypt(JNIEnv *env, jbyteArray jbyteArrayValue1, jbyteArray jbyteArrayValue2); jstring decrypt(JNIEnv *env, jstring jstringValue1); void destroyNative(JNIEnv *env); }; #endif //APPLICATIONRESOURCES_CRYPTOHELPER_H
74c256ee08539292a75de74359529e719e75f3c3
b6607ecc11e389cc56ee4966293de9e2e0aca491
/Petrozavodsk/Winter 2016/Day 6/H/Main.cpp
280d1b8ba416d98ca0b5a8750a9836041060c8ed
[]
no_license
BekzhanKassenov/olymp
ec31cefee36d2afe40eeead5c2c516f9bf92e66d
e3013095a4f88fb614abb8ac9ba532c5e955a32e
refs/heads/master
2022-09-21T10:07:10.232514
2021-11-01T16:40:24
2021-11-01T16:40:24
39,900,971
5
0
null
null
null
null
UTF-8
C++
false
false
3,020
cpp
Main.cpp
/**************************************** ** Solution by NU #2 ** ****************************************/ #include <bits/stdc++.h> using namespace std; #define F first #define S second #define MP make_pair #define all(x) (x).begin(), (x).end() typedef long long ll; typedef unsigned long long ull; typedef long double ld; const double EPS = 1e-9; const double PI = acos(-1.0); const int MOD = 1000 * 1000 * 1000 + 7; const int INF = 2000 * 1000 * 1000; const int MAXN = 100010; template <typename T> inline T sqr(T n) { return n * n; } int n; int color[MAXN]; int size[3 * MAXN]; set <int> g[MAXN]; void dfs(int v, int c, int par = 0) { color[v] = c; size[c]++; for (int to: g[v]) { if (to != par) { dfs(to, c, v); } } } int getSmaller(int a, int b) { struct State { State(int v, set <int>::iterator iter, int par) : v(v), iter(iter), par(par) { } int v; set <int>::iterator iter; int par; }; queue <State> q1, q2; q1.emplace(a, g[a].begin(), 0); q2.emplace(b, g[b].begin(), 0); while (!q1.empty() && !q2.empty()) { State& s1 = q1.front(); if (s1.iter != g[s1.v].end()) { int to = *s1.iter; s1.iter++; if (to != s1.par) { q1.emplace(to, g[to].begin(), s1.v); } } if (s1.iter == g[s1.v].end()) { q1.pop(); } State& s2 = q2.front(); if (s2.iter != g[s2.v].end()) { int to = *s2.iter; s2.iter++; if (to != s2.par) { q2.emplace(to, g[to].begin(), s2.v); } } if (s2.iter == g[s2.v].end()) { q2.pop(); } } if (q1.empty()) { return a; } return b; } int main() { #ifdef Local freopen("in", "r", stdin); #endif scanf("%d", &n); for (int i = 1; i <= n; i++) { color[i] = i; size[i] = 1; } char c; int ncol = n + 1; while (scanf("\n%c", &c) == 1 && c != 'E') { int a, b; scanf("%d%d", &a, &b); if (c == 'T') { if (color[a] == color[b]) { puts("YES"); } else { puts("NO"); } fflush(stdout); } else if (c == 'C') { if (size[color[a]] > size[color[b]]) { swap(a, b); } dfs(a, color[b]); g[a].insert(b); g[b].insert(a); } else { g[a].erase(b); g[b].erase(a); int ocolor = color[a]; int v = getSmaller(a, b); size[ncol] = 0; dfs(v, ncol); size[ocolor] -= size[ncol]; ncol++; } /* cerr << c << ' ' << a << ' ' << b << endl; for (int i = 1; i <= n; i++) { cerr << color[i] << ' '; } cerr << endl; */ } return 0; }
d0acaec77d25923cc0eeda0a4fb60927971a160e
e043b5501df9f8e37d73db7825f6d5db5c31764b
/protocols/MaliciousYao/apps/OnlineP1/AppOnlineP1.cpp
38e5f5b78b28d34f2d9fca1ff11c337d31fd2fab
[ "MIT" ]
permissive
srpgilles/libscapi
5b71d65111c6af1a50d3a87b3862519730358ba8
19bb6c3d7d3f95408fb7bc3ab6f84f8cd28f6fcd
refs/heads/master
2021-09-01T09:47:16.073540
2017-12-18T06:33:09
2017-12-18T06:33:09
115,406,846
0
0
null
2017-12-26T09:19:42
2017-12-26T09:19:41
null
UTF-8
C++
false
false
3,972
cpp
AppOnlineP1.cpp
#include <boost/thread/thread.hpp> #include <lib/include/common/CommonMaliciousYao.hpp> #include <lib/include/primitives/CommunicationConfig.hpp> #include <lib/include/primitives/CryptoPrimitives.hpp> #include <libscapi/include/circuits/GarbledCircuitFactory.hpp> #include <libscapi/include/cryptoInfra/Protocol.hpp> #include <lib/include/primitives/CheatingRecoveryCircuitCreator.hpp> #include <lib/include/primitives/CircuitInput.hpp> #include <lib/include/primitives/ExecutionParameters.hpp> #include <lib/include/OfflineOnline/primitives/BucketBundleList.hpp> #include <lib/include/common/LogTimer.hpp> #include <lib/include/OfflineOnline/specs/OnlineProtocolP1.hpp> using namespace std; //party number const int PARTY = 1; const string HOME_DIR = "../.."; //const string CIRCUIT_FILENAME = HOME_DIR + "/assets/circuits/AES/NigelAes.txt"; //const string CIRCUIT_INPUT_FILENAME = HOME_DIR + "/assets/circuits/AES/AESPartyOneInputs.txt"; const string COMM_CONFIG_FILENAME = HOME_DIR + string("/lib/assets/conf/PartiesConfig.txt"); //const string CIRCUIT_CHEATING_RECOVERY = HOME_DIR + "/assets/circuits/CheatingRecovery/UnlockP1Input.txt"; //const string BUCKETS_PREFIX_MAIN = HOME_DIR + "/data/P1/aes"; //const string BUCKETS_PREFIX_CR = HOME_DIR + "/data/P1/cr"; //file for dlog const string NISTEC_FILE_NAME = "../../../../include/configFiles/NISTEC.txt"; int BUCKET_ID = 0; int main(int argc, char* argv[]) { // boost::thread t(boost::bind(&boost::asio::io_service::run, &io_service)); int counter = 1; CmdParser parser; auto parameters = parser.parseArguments("", argc, argv); auto CIRCUIT_INPUT_FILENAME = HOME_DIR + parameters["inputFileName"]; auto BUCKETS_PREFIX_MAIN = HOME_DIR + parameters["bucketsPrefixMain"]; auto BUCKETS_PREFIX_CR = HOME_DIR + parameters["bucketsPrefixCR"]; //set crypto primitives CryptoPrimitives::setCryptoPrimitives(NISTEC_FILE_NAME); CryptoPrimitives::setNumOfThreads(8); int N1 = stoi(parameters["n1"]); // we load the bundles from file vector<shared_ptr<BucketBundle>> mainBuckets(N1), crBuckets(N1); int size = N1; for (int i = 0; i<N1; i++) { mainBuckets[i] = BucketBundleList::loadBucketFromFile(BUCKETS_PREFIX_MAIN + "." + to_string(BUCKET_ID) + ".cbundle"); crBuckets[i] = BucketBundleList::loadBucketFromFile(BUCKETS_PREFIX_CR + "." + to_string(BUCKET_ID++) + ".cbundle"); } auto input = CircuitInput::fromFile(CIRCUIT_INPUT_FILENAME, mainBuckets[0]->getBundleAt(0)->getNumberOfInputLabelsX()); // only now we start counting the running time string tmp = "reset times"; cout << "tmp size = " << tmp.size() << endl; byte tmpBuf[20]; OnlineProtocolP1* protocol = new OnlineProtocolP1(); vector<long long> times(size); for (int j = 0; j < 10; j+=4) { //cout << "num of threads = " << j << endl; CryptoPrimitives::setNumOfThreads(j); for (int i = 0; i < size; i++) { protocol->getChannel()->write((const byte*)tmp.c_str(), tmp.size()); int readsize = protocol->getChannel()->read(tmpBuf, tmp.size()); auto mainBucket = mainBuckets[i]; auto crBucket = crBuckets[i]; protocol->setBuckets(*mainBucket, *crBucket); protocol->setInput(input); auto start = chrono::high_resolution_clock::now(); protocol->run(); auto end = chrono::high_resolution_clock::now(); auto time = chrono::duration_cast<std::chrono::milliseconds>(end - start).count(); //cout << "exe no. " << i << " took " << time << " millis." << endl; times[i] = time; } int count = 0; for (int i = 0; i < size; i++) { count += times[i]; cout <<times[i] << " "; } auto average = count / size; cout << endl; //System.out.println(); cout << size << " executions took in average" << average << " milis." << endl; } delete protocol; cout << "\nP1 end communication\n"; return 0; }
81420d681389ab9726968819e1cfe451abf5f463
39adfee7b03a59c40f0b2cca7a3b5d2381936207
/codeforces/506/B.cpp
31b44dec98a3e93eb65c43f021fb6e97b44c3206
[]
no_license
ngthanhtrung23/CompetitiveProgramming
c4dee269c320c972482d5f56d3808a43356821ca
642346c18569df76024bfb0678142e513d48d514
refs/heads/master
2023-07-06T05:46:25.038205
2023-06-24T14:18:48
2023-06-24T14:18:48
179,512,787
78
22
null
null
null
null
UTF-8
C++
false
false
2,778
cpp
B.cpp
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++) #define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--) #define REP(i,a) for(int i=0,_a=(a); i<_a; i++) #define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it) #define DEBUG(x) { cout << #x << " = "; cout << (x) << endl; } #define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; } #define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; } #define sqr(x) ((x) * (x)) using namespace std; const int MN = 100111; int V; vector<int> G[MN]; struct DirectedDfs { vector<int> num, low, current, S; int counter; vector< vector<int> > scc; DirectedDfs() : num(V, -1), low(V, 0), current(V, 0), counter(0) { REP(i,V) if (num[i] == -1) dfs(i); } void dfs(int u) { low[u] = num[u] = counter++; S.push_back(u); current[u] = 1; REP(j, G[u].size()) { int v = G[u][j]; if (num[v] == -1) dfs(v); if (current[v]) low[u] = min(low[u], low[v]); } if (low[u] == num[u]) { scc.push_back(vector<int>()); while (1) { int v = S.back(); S.pop_back(); current[v] = 0; scc.back().push_back(v); if (u == v) break; } } } }; int n, m, id[MN], isLoop[MN], lab[MN]; pair<int,int> e[MN]; int getRoot(int u) { if (lab[u] < 0) return u; return lab[u] = getRoot(lab[u]); } void merge(int u, int v) { u = getRoot(u); v = getRoot(v); if (u == v) return ; if (lab[u] > lab[v]) swap(u, v); lab[u] += lab[v]; lab[v] = u; isLoop[u] += isLoop[v]; } int main() { while (scanf("%d%d", &n, &m) == 2) { V = n; FOR(i,0,n) G[i].clear(); FOR(i,1,m) { int u, v; scanf("%d%d", &u, &v); --u; --v; G[u].push_back(v); e[i] = make_pair(u, v); } DirectedDfs tree; int cur = 0; memset(lab, -1, sizeof lab); memset(isLoop, 0, sizeof isLoop); for(auto scc : tree.scc) { ++cur; for(int x : scc) { id[x] = cur; if (scc.size() > 1) isLoop[cur] = 1; } lab[cur] = -scc.size(); } FOR(i,1,m) { int u = id[e[i].first], v = id[e[i].second]; if (u != v) merge(u, v); } int res = 0; FOR(i,1,cur) if (lab[i] < 0) { if (isLoop[i]) res -= lab[i]; else res -= lab[i] + 1; } cout << res << endl; } return 0; }
8b8eac9bc5d4de45de4387d1dbd4d69d0b860b7f
e48032c0f73ee30ea23c042631a38507fdf230c5
/src/Lights/DirectionalLight.cpp
b3ef3813a275bfce1402b998d15aab1ba3e4abd3
[]
no_license
mauro-ferrario/playroom
1d9e09b38d0cc0a065b84bbafa85042771caa2c3
870a1a220faecb331705205989fa4491c449c37b
refs/heads/master
2020-04-03T22:29:55.858999
2019-03-13T10:51:20
2019-03-13T10:51:20
155,604,515
1
0
null
null
null
null
UTF-8
C++
false
false
1,895
cpp
DirectionalLight.cpp
// // DirectionalLight.cpp // playroom // // Created by xxx on 01/11/2018. // #include "DirectionalLight.h" DirectionalLight::DirectionalLight(string name, bool addToGUI, bool castShadow):Light(name, addToGUI, castShadow){ this->setType(LightTypes::DIRECTIONAL); } void DirectionalLight::setupGUI(ofxDatGui& gui){ Light::setupGUI(gui); directionXSlider = lightGUIFolder->addSlider("Direction x", -1, 1, 0); directionYSlider = lightGUIFolder->addSlider("Direction y", -1, 1, 0); directionZSlider = lightGUIFolder->addSlider("Direction z", -1, 1, 0); } void DirectionalLight::draw(){ // No need to draw } void DirectionalLight::addShaderVariableForShadow(ofxAutoReloadedShader& shader, ofxFirstPersonCamera& cam){ Light::addShaderVariableForShadow(shader, cam); glm::mat4 lightView = glm::lookAt(glm::vec3(this->getShadowPosition()), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3( 0.0f, 1.0f, 0.0f)); glm::mat4 lightSpaceMatrix = lightCam.getProjectionMatrix() * lightView; shader.setUniform3f("positionForShadow", getShadowPosition()); shader.setUniformMatrix4f("lightSpaceMatrix", lightSpaceMatrix ); } ofVec3f DirectionalLight::getDirection(){ ofVec3f direction; direction.x = directionXSlider->getValue(); direction.y = directionYSlider->getValue(); direction.z = directionZSlider->getValue(); return direction; } ofVec3f DirectionalLight::getShadowPosition(){ ofVec3f direction = this->getDirection(); ofVec3f position = ofVec3f(300); position.x *= -direction.x; position.y *= -direction.y; position.z *= -direction.z; return position; } void DirectionalLight::passLightToShader(ofxAutoReloadedShader& shader, ofxFirstPersonCamera& cam, string lightName){ Light::passLightToShader(shader, cam, lightName); shader.setUniform3f("dirLight.direction", getDirection()); }
29e7fa54179f3c834f65cd9590e813f42758a7f3
ef8bc39983ae8a1e9a6401709a88102ef125b57d
/CVect2D.h
3e24e9902aa9e4bf185c34bff9965c437d799df4
[]
no_license
AnthonyLamour/BACH_CPP_TP2_SDL_LAMOURAnthony
5bfd642fc951a59d88b4dcbf5d3236929e96f553
dc2f99b899e983c8c77db3e41b37f0bd6f1af310
refs/heads/master
2020-04-05T21:14:02.813982
2018-11-22T09:33:03
2018-11-22T09:33:03
157,212,935
0
0
null
null
null
null
ISO-8859-1
C++
false
false
1,580
h
CVect2D.h
//******************************************************************************************************************************************************************************** // // fichier : CVect2D.h // // description : Gestion de vecteur 2D // // attributs : float fltX, float fltY // // class : CVect2D // //******************************************************************************************************************************************************************************** //08-11-2018 LAMOUR Anthony //08-11-2018 LAMOUR Anthony //******************************************************************************************************************************************************************************** #pragma once #include <math.h> #include "CPoint2D.h" class CVect2D { //donnee membre private: float fltX; float fltY; //focntion membre public: //mutateur et assesseur float getVectX()const; void setVectX(float fltX); float getVectY()const; void setVectY(float fltY); //constructeur sans paramètre CVect2D(); //constructeur avec paramètre par défaut //CVect2D(float fltX, float fltY = 15.0f); //constructeur avec paramètre CVect2D(float fltX,float fltY); //destructeur ~CVect2D(); //addition de vecteur CVect2D additionDeVecteur(CVect2D CVect); //soustraction de vecteur CVect2D soustractionDeVecteur(CVect2D CVect); //porduit scalaire Reel CVect2D scalaireReel(float fltAlpha); //porduit scalaire Vecteur float scalaireVect(CVect2D CVect); //norme float norme(CPoint2D CPtDebut, CPoint2D CPtFin); };
6fdde56d9d4e26aeb468f57d505862458fd307c1
19e5c3407466691aa0b42b2fc9a6790baafc5343
/neighbor.h
c904de5299f231f685744ac39d1bb2f3f8b744a9
[]
no_license
8cH9azbsFifZ/lammps-CSI
168101d48f4ba2af5d1d8235ac7c969a74b283ff
ac4b39f405463aa6329e2bf0f72532248b028562
refs/heads/master
2021-06-02T23:40:27.967156
2019-11-05T00:46:52
2019-11-05T00:46:52
6,374,089
1
0
null
null
null
null
UTF-8
C++
false
false
12,859
h
neighbor.h
/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ #ifndef NEIGHBOR_H #define NEIGHBOR_H #include "pointers.h" namespace LAMMPS_NS { class Neighbor : protected Pointers { public: int style; // 0 = nsq, 1 = binned int every; // build every this many steps int delay; // delay build for this many steps int dist_check; // 0 = always build, 1 = only if 1/2 dist int ago; // how many steps ago neighboring occurred int pgsize; // size of neighbor page int oneatom; // max # of neighbors for one atom double skin; // skin distance double cutghost; // distance for acquiring ghost atoms double *cuttype; // for each type, max neigh cut w/ others int ncalls; // # of times build has been called int ndanger; // # of dangerous builds int nlocal_neighbor; // nlocal at last build int half; // 0/1 if half pair list ever built int full; // 0/1 if full pair list ever built int half_every; // 0/1 if half list built every step int full_every; // 0/1 if full list built every step int half_once; // 0/1 if half pair list built occasionally int full_once; // 0/1 if full pair list built occasionally int half_command; // 0/1 if command requires half list int *numneigh; // # of half neighbors for each atom int **firstneigh; // ptr to 1st half neighbor of each atom int *numneigh_full; // # of full neighbors for each atom int **firstneigh_full; // ptr to 1st full neighbor of each atom int nbondlist; // list of bonds to compute int **bondlist; int nanglelist; // list of angles to compute int **anglelist; int ndihedrallist; // list of dihedrals to compute int **dihedrallist; int nimproperlist; // list of impropers to compute int **improperlist; // granular neighbor list int **firsttouch; // ptr to first touch flag for each atom double **firstshear; // ptr to first shear values for each atom // rRESPA neighbor lists int *numneigh_inner; // # of inner pair neighbors for each atom int **firstneigh_inner; // ptr to inner 1st neigh of each atom int *numneigh_middle; // # of middle pair neighbors for each atom int **firstneigh_middle; // ptr to middle 1st neigh of each atom Neighbor(class LAMMPS *); ~Neighbor(); void init(); int decide(); // decide whether to build or not int check_distance(); // check max distance moved since last build void setup_bins(); // setup bins based on box and cutoff void build(); // create all neighbor lists (half,full,bond) void build_half(); // one-time creation of half neighbor list void build_full(); // one-time creation of full neighbor list void set(int, char **); // set neighbor style and skin distance void modify_params(int, char**); // modify parameters of neighbor build int memory_usage(); // tally memory usage private: int me,nprocs; int maxlocal; // size of numneigh, firstneigh arrays int maxbond,maxangle,maxdihedral,maximproper; // size of bond lists int must_check; // 1 if must check other classes to reneigh int restart_check; // 1 if restart enabled, 0 if no int fix_check; // # of fixes that induce reneigh int *fixchecklist; // which fixes to check double **cutneighsq; // neighbor cutneigh sq for each type pair double cutneighmin; // min neighbor cutoff (for cutforce > 0) double cutneighmax; // max neighbor cutoff for all type pairs double cutneighmaxsq; // cutneighmax squared double *cuttypesq; // cuttype squared double triggersq; // trigger = build when atom moves this dist double **xhold; // atom coords at last neighbor build int maxhold; // size of xhold array int nbinx,nbiny,nbinz; // # of global bins int *bins; // ptr to next atom in each bin int maxbin; // size of bins array int *binhead; // ptr to 1st atom in each bin int maxhead; // size of binhead array int mbins; // # of local bins and offset int mbinx,mbiny,mbinz; int mbinxlo,mbinylo,mbinzlo; double binsizex,binsizey,binsizez; // bin sizes and inverse sizes double bininvx,bininvy,bininvz; int triclinic; // 0 if domain is orthog, 1 if triclinic double *bboxlo,*bboxhi; // copy of full domain bounding box int nstencil; // # of bins in half neighbor stencil int *stencil; // list of bin offsets int maxstencil; // max size of stencil int nstencil_full; // # of bins in full neighbor stencil int *stencil_full; // list of bin offsets int maxstencil_full; // max size of stencil int *nstencil_multi; // # bins in each type-based multi stencil int **stencil_multi; // list of bin offsets in each stencil double **distsq_multi; // sq distances to bins in each stencil int maxstencil_multi; // max sizes of stencils int *nstencil_full_multi; // # bins in full type-based multi stencil int **stencil_full_multi; // list of bin offsets in each stencil double **distsq_full_multi; // sq distances to bins in each stencil int maxstencil_full_multi; // max sizes of stencils int **pages; // half neighbor list pages int maxpage; // # of half pages currently allocated int **pages_full; // full neighbor list pages int maxpage_full; // # of full pages currently allocated // granular neighbor list class FixShearHistory *fix_history; // NULL if history not needed // else is ptr to fix shear history int **pages_touch; // pages of touch flags double **pages_shear; // pages of shear values int maxpage_history; // # of history pages currently allocated // rRESPA neighbor lists int respa; // 0 = single neighbor list // 1 = additional inner list // 2 = additional inner and middle list double inner[2],middle[2]; // rRESPA cutoffs for extra lists double cut_inner_sq; // outer cutoff for inner neighbor list double cut_middle_sq; // outer cutoff for middle neighbor list double cut_middle_inside_sq; // inner cutoff for middle neighbor list int **pages_inner; // inner neighbor list pages int maxpage_inner; // # of inner pages currently allocated int **pages_middle; // middle neighbor list pages int maxpage_middle; // # of middle pages currently allocated int special_flag[4]; // flags for 1-2, 1-3, 1-4 neighbors int exclude; // 0 if no type/group exclusions, 1 if yes int nex_type; // # of entries in type exclusion list int maxex_type; // max # in type list int *ex1_type,*ex2_type; // pairs of types to exclude int **ex_type; // 2d array of excluded type pairs int nex_group; // # of entries in group exclusion list int maxex_group; // max # in group list int *ex1_group,*ex2_group; // pairs of group #'s to exclude int *ex1_bit,*ex2_bit; // pairs of group bits to exclude int nex_mol; // # of entries in molecule exclusion list int maxex_mol; // max # in molecule list int *ex_mol_group; // molecule group #'s to exclude int *ex_mol_bit; // molecule group bits to exclude typedef void (Neighbor::*FnPtr)(); FnPtr half_build; // ptr to half pair list functions FnPtr full_build; // ptr to full pair list functions void half_nsq_no_newton(); // fns for half neighbor lists void half_nsq_newton(); void half_bin_no_newton(); void half_bin_no_newton_multi(); void half_bin_newton(); void half_bin_newton_multi(); void half_bin_newton_tri(); void half_bin_newton_multi_tri(); void half_full_no_newton(); void half_full_newton(); void full_nsq(); // fns for full neighbor lists void full_bin(); void full_bin_multi(); void granular_nsq_no_newton(); // fns for granular neighbor lists void granular_nsq_newton(); void granular_bin_no_newton(); void granular_bin_newton(); void granular_bin_newton_tri(); void respa_nsq_no_newton(); // fns for respa neighbor lists void respa_nsq_newton(); void respa_bin_no_newton(); void respa_bin_newton(); void respa_bin_newton_tri(); FnPtr bond_build; // ptr to bond list functions void bond_all(); // bond list with all bonds void bond_partial(); // exclude certain bonds FnPtr angle_build; // ptr to angle list functions void angle_all(); // angle list with all angles void angle_partial(); // exclude certain angles FnPtr dihedral_build; // ptr to dihedral list functions void dihedral_all(); // dihedral list with all dihedrals void dihedral_partial(); // exclude certain dihedrals FnPtr improper_build; // ptr to improper list functions void improper_all(); // improper list with all impropers void improper_partial(); // exclude certain impropers void add_pages(int); // add neigh list pages void add_pages_full(int); void add_pages_history(int); void add_pages_inner(int); void add_pages_middle(int); void clear_pages(); // clear all neigh list pages void clear_pages_full(); void clear_pages_history(); void clear_pages_inner(); void clear_pages_middle(); void bin_atoms(); // bin all atoms double bin_distance(int, int, int); // distance between binx int coord2bin(double *); // mapping atom coord to a bin int find_special(int, int); // look for special neighbor int exclusion(int, int, int *, int *, int *); // test for pair exclusion typedef void (Neighbor::*SFnPtr)(int, int, int); SFnPtr half_stencil; // ptr to half stencil functions SFnPtr full_stencil; // ptr to full stencil functions void stencil_allocate(int, int, int); void stencil_none(int, int, int); // fns for stencil creation void stencil_half_3d_no_newton(int, int, int); void stencil_half_3d_no_newton_multi(int, int, int); void stencil_half_3d_newton(int, int, int); void stencil_half_3d_newton_multi(int, int, int); void stencil_half_3d_newton_tri(int, int, int); void stencil_half_3d_newton_multi_tri(int, int, int); void stencil_half_2d_no_newton(int, int, int); void stencil_half_2d_no_newton_multi(int, int, int); void stencil_half_2d_newton(int, int, int); void stencil_half_2d_newton_multi(int, int, int); void stencil_half_2d_newton_tri(int, int, int); void stencil_half_2d_newton_multi_tri(int, int, int); void stencil_full_3d(int, int, int); void stencil_full_3d_multi(int, int, int); void stencil_full_2d(int, int, int); void stencil_full_2d_multi(int, int, int); }; } #endif
ae6fdab911abe56c27bb847ccbbbe3744e2d8130
acf30fa254f72c282fce77b22dced66b21f8277d
/src/commands/exportopenpgpcerttoprovidercommand.h
ff43e8a281a433f0571f1bb8ee5f0b8362f95686
[ "CC0-1.0", "BSD-3-Clause" ]
permissive
KDE/kleopatra
fc879c3d1f9fa4e7f54ebcb825eaea8705386d72
3e6db6e439bbb62886dd58cfc4239f256fec5415
refs/heads/master
2023-08-18T04:37:13.963770
2023-08-16T21:17:25
2023-08-16T21:17:34
53,312,712
84
16
null
2020-12-29T18:58:39
2016-03-07T09:27:39
C++
UTF-8
C++
false
false
1,120
h
exportopenpgpcerttoprovidercommand.h
/* -*- mode: c++; c-basic-offset:4 -*- commands/exportopenpgpcerttoprovidercommand.h This file is part of Kleopatra, the KDE keymanager SPDX-FileCopyrightText: 2022 Felix Tiede SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once #include "command.h" #include <QPointer> #include <gpgme++/key.h> namespace QGpgME { class WKSPublishJob; } namespace Kleo { namespace Commands { class ExportOpenPGPCertToProviderCommand : public Command { Q_OBJECT public: explicit ExportOpenPGPCertToProviderCommand(QAbstractItemView *view, KeyListController *parent); explicit ExportOpenPGPCertToProviderCommand(const GpgME::UserID &uid); ~ExportOpenPGPCertToProviderCommand() override; static Restrictions restrictions() { return OnlyOneKey | NeedSecretKey | MustBeOpenPGP; } private Q_SLOTS: void wksJobResult(const GpgME::Error &, const QByteArray &, const QByteArray &); private: void doStart() override; void doCancel() override; QString senderAddress() const; private: GpgME::UserID uid; QPointer<QGpgME::WKSPublishJob> wksJob; }; } }
af7990ca01cb7ad0c710a227d36e543cc264cfb2
cd12f94d64c67c9b8d4412febfe2e456497945de
/cs201/Lecture06_Example3/main.cpp
1a4e725acfcfb703fa9f51c5d1bf54f446bcbd43
[]
no_license
codebiters/cs201
ecce12b908b9546accfd7be787d8b1e97d2d0981
2528e404749763004dc41b4ba74db27ebae39fc1
refs/heads/master
2023-07-19T18:56:09.190145
2021-08-21T04:43:43
2021-08-21T04:43:43
398,132,334
0
0
null
null
null
null
UTF-8
C++
false
false
565
cpp
main.cpp
#include <iostream> /*This program calculates the factorial of a given number*/ using namespace std; int main(int argc, char** argv) { // declaration of variables int factorial, number; factorial = 1; number = 1; // prompt the user to enter upper limit of integers cout << "Please enter the number for factorial: "; cin >> number; // using the while loop to find out the factorial while(number > 1) { factorial = factorial * number; number = number - 1; } cout << "The factorial is: " << factorial; }
af99af0d30f685f65346458c80abd101fdc9f61e
130e9de9fe06fcc720e0aee0961b4f432360e2a9
/variable and basic type/ex2_29.cpp
fee83df99741f12d5dab5ba6ba6cee386c1337bd
[]
no_license
rajivranjanmars/cpp_primer
7dba2c25b193369beaa1886457007eb357f74001
0a56716072f4e1c0582d02796a5573aed76a9b4b
refs/heads/main
2023-05-12T00:54:20.166050
2021-05-26T18:15:05
2021-05-26T18:15:05
339,401,780
9
0
null
null
null
null
UTF-8
C++
false
false
393
cpp
ex2_29.cpp
#include <iostream> #include <cstdio> #include <string> using namespace std; int main(){ int i, *const cp; int *p1, *const p2; const int ic, &r = ic; const int *const p3; const int *p; i = ic; //legal p1 = p3; // illegal p1 = &ic; // illegal p3 = &ic; // illegal p2 = p1; //illegal ic = *p3; // illegal return 0; }
c1f8fc2eb9a1ae14c9c0ee0624f1161102c21b59
d140e74d215ed5de3d571f99edfcfcb68369921f
/src/Revival/PlayerSprite.cpp
cf139a799183613436511d1b75c1cc9601e32652
[]
no_license
dead-pixel-studios/GlobalGameJam-2012-Game
556ae2345e0975655c89a560120d7f239ef3a2aa
3e0e91a5989bef259d05622609d7c4eaa89540cf
refs/heads/master
2016-09-06T19:43:05.465080
2012-01-30T12:05:00
2012-01-30T12:05:00
3,161,819
0
0
null
null
null
null
UTF-8
C++
false
false
3,067
cpp
PlayerSprite.cpp
#include "PlayerSprite.h" #include "Universe.h" #include <sstream> PlayerSprite::PlayerSprite() { this->MaximumVelocityX = 1.0F; this->MaximumVelocityY = 1.0F; this->rotation = 0.0F; texture = gEngine->CreateTexture(CoreFunctions::GetAppPath() + "/data/playerplaceholder.bmp"); texture->Load(); //Player start position (using floats) CurrentPosX = 100.0F; CurrentPosY = 100.0F; _size=CoreSize(64,64); VelocityX = 0.0F; VelocityY = 0.5F; background = gEngine->CreateTexture(CoreFunctions::GetAppPath() + "/data/flat.png"); background->Load(); } bool PlayerSprite::RectangleCollisionDetect(SDL_Rect A, SDL_Rect B) { // http://lazyfoo.net/SDL_tutorials/lesson17/index.php //The sides of the rectangles int leftA, leftB; int rightA, rightB; int topA, topB; int bottomA, bottomB; //Calculate the sides of rect A leftA = A.x; rightA = A.x + A.w; topA = A.y; bottomA = A.y + A.h; //Calculate the sides of rect B leftB = B.x; rightB = B.x + B.w; topB = B.y; bottomB = B.y + B.h; //If any of the sides from A are outside of B if( bottomA <= topB ) { return false; } if( topA >= bottomB ) { return false; } if( rightA <= leftB ) { return false; } if( leftA >= rightB ) { return false; } //If none of the sides from A are outside B return true; } void PlayerSprite::Update(float value) { this->CurrentPosX = this->CurrentPosX + VelocityX; this->CurrentPosY = this->CurrentPosY + VelocityY; CurrentRectangle.x = (int) this->CurrentPosX; CurrentRectangle.y = (int) this->CurrentPosY; CurrentRectangle.h = this->_size.GetHeight(); CurrentRectangle.w = this->_size.GetWidth(); collisionboxrect.x = 200; collisionboxrect.y = 200; collisionboxrect.h = 200; collisionboxrect.w = 200; colliding = RectangleCollisionDetect(CurrentRectangle,collisionboxrect); collisionboxloc.str(""); collisionboxloc << "Collision Box: x:" << collisionboxrect.x; collisionboxloc << "y: " << collisionboxrect.y << " h: " << collisionboxrect.h << " w: " << collisionboxrect.w; currentloc.str(""); currentloc << "Current Box: x:" << (int) this->CurrentPosX; currentloc << "y: " << (int) this->CurrentPosY << " h: " << this->_size.GetHeight() << " w: " << this->_size.GetWidth(); if(colliding == true) { currentloc << " Colliding: true"; } else { currentloc << " Colliding: false"; } this->_pos.SetX((int) this->CurrentPosX); this->_pos.SetY((int) this->CurrentPosY); } void PlayerSprite::Draw() { SDL_Color yellow; yellow.g = 255; yellow.b = 255; yellow.r = 0; this->gEngine->DrawRectangle(new CorePosition(collisionboxrect.x, collisionboxrect.y), new CoreSize(collisionboxrect.w, collisionboxrect.h), 255,0,0,255); this->gEngine->DrawString(collisionboxloc.str(), new CorePosition(10,10), yellow); this->gEngine->DrawString(currentloc.str(), new CorePosition((int) (this->_pos.GetX() + 110), (int) (this->_pos.GetY())), yellow); this->DefaultDraw(); }
e38ae9e61ac24a5d602c600865269f6ca648518c
4bdc29d572fe9aec2d3a3509e78759952835d32d
/blend.cpp
9a064713c93b5350bb6f6086e09d4f2d4344566f
[]
no_license
tailxiuxian/MiniRender
b33fc067bd41a0671563660ce059ac8adc5be895
a1ae3d2c8572f4a5510e9cdd6cb1a54190bffc25
refs/heads/master
2021-06-16T08:51:09.392244
2019-11-04T07:40:55
2019-11-04T07:40:55
149,566,755
4
0
null
null
null
null
UTF-8
C++
false
false
1,916
cpp
blend.cpp
#include "blend.h" #include "comm_func.h" bool is_opaque_pixel_color(IUINT32 color) { #ifdef USE_GDI_VIEW return true; #else return Get_A(color) == 255; #endif } IUINT32 blend_frame_buffer_color(device_t *device, IUINT32 srcColor, IUINT32 dstColor) { float alphaSrc = (float)Get_A(srcColor) / 255.0f; float alphaDst = (float)Get_A(dstColor) / 255.0f; color_t srcFactor, dstFactor; if (device->blend_state.srcState == BLEND_ZERO) { srcFactor = { 0.0f,0.0f,0.0f,0.0f }; } else if (device->blend_state.srcState == BLEND_ONE) { srcFactor = { 1.0f,1.0f,1.0f,1.0f }; } else if (device->blend_state.srcState == BLEND_SRC_ALPHA) { srcFactor = { alphaSrc, alphaSrc, alphaSrc, alphaSrc }; } else if (device->blend_state.srcState == BLEND_ONE_MINUS_SRC_ALPHA) { srcFactor = { 1.0f - alphaSrc, 1.0f - alphaSrc, 1.0f - alphaSrc, 1.0f - alphaSrc }; } if (device->blend_state.srcState == BLEND_ZERO) { dstFactor = { 0.0f,0.0f,0.0f,0.0f }; } else if (device->blend_state.srcState == BLEND_ONE) { dstFactor = { 1.0f,1.0f,1.0f,1.0f }; } else if (device->blend_state.srcState == BLEND_SRC_ALPHA) { dstFactor = { alphaSrc, alphaSrc, alphaSrc, alphaSrc }; } else if (device->blend_state.srcState == BLEND_ONE_MINUS_SRC_ALPHA) { dstFactor = { 1.0f - alphaSrc, 1.0f - alphaSrc, 1.0f - alphaSrc, 1.0f - alphaSrc }; } IUINT32 Rsrc = Get_R(srcColor); IUINT32 Gsrc = Get_G(srcColor); IUINT32 Bsrc = Get_B(srcColor); IUINT32 Asrc = Get_A(srcColor); IUINT32 Rdst = Get_R(dstColor); IUINT32 Gdst = Get_G(dstColor); IUINT32 Bdst = Get_B(dstColor); IUINT32 Adst = Get_A(dstColor); IUINT32 Rframe = Rsrc * srcFactor.r + Rdst * dstFactor.r; IUINT32 Gframe = Gsrc * srcFactor.g + Gdst * dstFactor.g; IUINT32 Bframe = Bsrc * srcFactor.b + Bdst * dstFactor.b; IUINT32 Aframe = Asrc * srcFactor.a + Adst * dstFactor.a; return (Rframe << 24) | (Gframe << 16) | (Bframe << 8) | (Aframe); }
03a1e44854f462e62893efb6e86f9e469dadeaa6
c80f25d24cee6ed8dba1513c227886c07d83cf75
/WeaponGirl_1/Client/trunk/Classes/SceneMain/Poker/WidgetPoker.h
cabaf913a8dd21920c35c2c4c13663365024961d
[ "MIT" ]
permissive
cnsuhao/newProBase
c250e54ead43efb57363347d1700649a35617d15
4fe81d30740a2a0857ca6e09a281fed1146e6202
refs/heads/master
2021-08-23T14:19:24.568828
2015-11-27T13:37:54
2015-11-27T13:37:54
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
899
h
WidgetPoker.h
//////////////////////////////////////////////////////////////////////// // Copyright(c) 2015-9999, WuHan GoodGame, All Rights Reserved // Moudle: WidgetPoker.h // Author: ÅíÎÄÆæ(Peng Wenqi) // Created: 2015/11/24 //////////////////////////////////////////////////////////////////////// #ifndef _JPY_WidgetPoker_H_ #define _JPY_WidgetPoker_H_ #include "Global/Global.h" class Poker; class WidgetPoker : public ui::Widget { protected: WidgetPoker(); virtual ~WidgetPoker(); public: static WidgetPoker* create(Node* pCsbNode, DB_KEY idPoker); bool init(Node* pCsbNode, DB_KEY idPoker); bool isSelected(); void selectPoker(bool bSelect); void setDetail(const std::string& text); void setCount(int nCount); DB_KEY getPokerID() const{ return m_idPoker; } Poker* getPoker() const; protected: DB_KEY m_idPoker; }; #endif // end of _JPY_WidgetPoker_H_
eeac3d9f085ce89a6a406173549e074df5931109
154dfd2a2130a3a7731a9a9b431e8295fbf82cd2
/Codeforces/1033D.cpp
8d8c5dd72a498f00734b44a93697dba671d1a4ea
[]
no_license
ltf0501/Competitive-Programming
1f898318eaecae14b6e040ffc7e36a9497ee288c
9660b28d979721f2befcb590182975f10c9b6ac8
refs/heads/master
2022-11-20T21:08:45.651706
2020-07-23T11:55:05
2020-07-23T11:55:05
245,600,907
0
0
null
null
null
null
UTF-8
C++
false
false
1,398
cpp
1033D.cpp
#include<bits/stdc++.h> using namespace std; #define ll long long const int mod=998244353; int n; ll a[505]; map<ll,int> mp,mp2; vector<ll> v,tmp; ll mysqrt(ll a) { ll k=(ll)sqrt(a+0.5); while(k*k<a)k++; while(k*k>a)k--; return k; } main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%lld",&a[i]); ll k=mysqrt(a[i]+0.5); if(k*k==a[i]) { ll kk=mysqrt(k+0.5); if(kk*kk==k)mp[kk]+=4; else mp[k]+=2; } else { ll kk=(ll)pow(a[i],1.0/3.0); while(kk*kk*kk<a[i])kk++; while(kk*kk*kk>a[i])kk--; if(kk*kk*kk==a[i])mp[kk]+=3; else v.push_back(a[i]); } } int m=v.size(); for(int i=0;i<m;i++) { ll x=-1,y=-1; for(int j=1;j<=n;j++)if(v[i]!=a[j]) { ll g=__gcd(v[i],a[j]); if(g!=1) { if(x==-1)x=g; else if(x!=g)y=g; } } if(x==-1)mp2[v[i]]++; else { if(y==-1)y=v[i]/x; mp[x]++,mp[y]++; } } ll ans=1; for(auto s : mp)ans=ans*(s.second+1)%mod; for(auto s : mp2)ans=ans*(s.second+1)%mod*(s.second+1)%mod; printf("%lld\n",ans);fflush(stdout); return 0; }
d1e11b7af46a723282a3b7aa8e7c87d907efa385
8237ac7bfa1635aa225d6afad017c9bc00b31d65
/synth/synth.ino
0a5c53f90f094bba56bee61fd245b1593166eb7d
[]
no_license
EuCE/synth
f89d0bd2d4d18eeb907c189922d794f9dd9b954c
a39703b2de3249738c7327948f077db5b4e09c32
refs/heads/master
2021-01-10T18:44:18.339229
2014-10-06T02:12:08
2014-10-06T02:12:08
24,801,659
1
0
null
null
null
null
UTF-8
C++
false
false
746
ino
synth.ino
// The maximum PWM output value #define MAX_PWM 0xFF #define OUTPUT_PIN 9 // Fast PWM, 8 bit (datasheet page 136) #define PWM_MODE 0b0101 unsigned int hzToMicros(unsigned int freq) { return 1000000 / freq; } byte sawWave(unsigned int period /* in us */) { unsigned long time = micros() % period; return time * MAX_PWM / period; } void setup() { pinMode(OUTPUT_PIN, OUTPUT); // Apply PWM_MODE TCCR1A = (TCCR1A & 0b11111100) | (PWM_MODE & 0b11); TCCR1B = (TCCR1B & 0b11100111) | (PWM_MODE & 0b1100 << 1); // Turn on PWM output A on pin 9 TCCR1A |= (1 << COM1A1); // No prescaling TCCR1B &= 0b11111001; } unsigned int notes[] = { 262, 328, 392, 523 }; void loop() { OCR1A = sawWave(hzToMicros(notes[(millis() % 3000) / 750])); }
d1f4dfa19575b0c2e054f547d0bf3a6fb212bb9b
f7c94ded48feec20f495f129b34b04d4361e7358
/files/testing.cpp
1df42f7db8f2029c88e336c4fca763ccea5b0c95
[]
no_license
dineshnitt/RayTracer
9194e758c60ab741980824ce7b57629d7e207f33
07b0c5e0f24f3783b354b6eaef2f3272a1a84026
refs/heads/master
2021-01-01T17:28:29.849280
2011-07-06T13:17:12
2011-07-06T13:17:12
1,966,683
0
0
null
null
null
null
UTF-8
C++
false
false
7,734
cpp
testing.cpp
#include "Physics.h" #include "Vector.h" #include "Point.h" #include "Color.h" #include "Line.h" #include "Lineseg.h" #include "Rayseg.h" #include "functions.h" #include <stdlib.h> #include "Ray.h" #include "Sphere.h" #include "Object.h" #include "intersection.h" #include "Point.h" using namespace std; Point zero_p = Point(0.0,0.0,0.0); Color zero_c = Color(0.0,0.0,0.0); Point closest_int(Point p,Vector r_d,Object ob,double &min_in_l,Color &tmp_c,Sphere &tmp_s,Plane &tmp_p){ //closest intersection with object data structure double in_l = 0.0; // temperory intersection length Point in_p,min_in_p; for(int k=0;k<ob.s.size();k++){ // Loop for finding minimum intersection point from all spheres Sphere sp = ob.s[k]; in_p = ray_sphere(p,r_d,sp,in_l); //intersection point if(in_p!=zero_p){//cout<<"1"; if(in_l<min_in_l){cout<<min_in_l<<endl; min_in_l = in_l; min_in_p = in_p; tmp_c = ob.s[k].c; tmp_s = ob.s[k]; } } } for(int k=0;k<ob.p.size();k++){//Loop for finding minimum intersection point from all planes Plane pl = ob.p[k]; in_p = ray_plane(p,r_d,pl,in_l); if(in_p!=zero_p){//cout<<in_p.out()<<min_in_l; if((in_l<min_in_l)&&(in_l>=0.000001)){cout<<endl<<"Length : "<<in_l<<"|"<<min_in_l<<endl; min_in_l = in_l; min_in_p = in_p; tmp_c = ob.p[k].c; // cout<<ob.p[k].out()<<endl; tmp_p = ob.p[k]; } } } return min_in_p; } Point closest_ref(Point p,Vector r_d,Object ob,double &min_in_l,Color &tmp_c,Sphere &tmp_s){ //closest intersection with object data structure double in_l = 0.0; // temperory intersection length Point in_p,min_in_p; //cout<<p.out()<<" : "<<r_d.out()<<endl; for(int k=0;k<ob.s.size();k++){ // Loop for finding minimum intersection point from all spheres Sphere sp = ob.s[k];cout<<endl<<"adsasd"; cout<<sp.out()<<"324"<<endl; if(in_l<min_in_l){ in_p = ray_sphere(p,r_d,sp,in_l); //intersection point cout<<in_l<<in_p.out()<<"<=int_len--"<<endl; if(in_p!=zero_p){ cout<<"\n"<<in_p.out()<<endl; min_in_l = in_l; min_in_p = in_p; tmp_c = ob.s[k].c; tmp_s = ob.s[k]; } } } cout<<endl<<min_in_p.out()<<endl; return min_in_p; } Point closest_int(Point p,Vector r_d,Object ob,double &min_in_l,Color &tmp_c,Sphere &tmp_s){ //closest intersection with object data structure double in_l = 0.0; // temperory intersection length Point in_p,min_in_p; for(int k=0;k<ob.s.size();k++){ // Loop for finding minimum intersection point from all spheres Sphere sp = ob.s[k]; in_p = ray_sphere(p,r_d,sp,in_l); //intersection point if(in_p!=zero_p){ if(in_l<min_in_l){ min_in_l = in_l; min_in_p = in_p; tmp_c = ob.s[k].c; tmp_s = ob.s[k]; } } } return min_in_p; } int main(){ /* Vector v1,v2;Line line; v1 = Vector(1.0,2.0,3.0); v2 = Vector(1.0,2.2,3.0); bool a = (v1==v2); cout<< a<<v1.out()<< " " <<( v1 * 2.0).out(); cout<<endl<<(v1 / 0.0).out(); cout<<endl<<v1.dot(v2)<<endl; cout<<"------------------------------"<<endl; Point p1,p2; p1 = Point(2.0,0.0,1.0); p2 = p1; cout<<p2.out()<<endl; cout<<"---------------------------------"<<endl; cout<<"TESTING FOR COLOR"<<endl; Color c = Color(0.1,0.5,0.3); cout<<c.out()<<endl; cout<<"TESTING FOR LINE SEGMENT\n"; Lineseg l1; Point p4,p5; p4 = Point(12.0,0.0,1.0); p5 = Point(2.0,3.0,0.0); l1 = Lineseg(p4,p5); cout<<l1.out()<<endl; cout<<"TESTING FOR RAY SEGMENT\n"<<endl; Rayseg r; r = Rayseg(l1,c); cout<<r.out()<<endl; cout<<"TESTING FOR A RAY\n"; line = Line(v1,v2); Ray ry = Ray(line,c); cout<<ry.out()<<endl; /*cout<<"TESTING FOR OBJECTS\n"; Sphere s1 = Sphere(p1,2.0,c,1.0); Sphere s2 = Sphere(p4,1.0,c,0.6); Object obj = Object(s1); obj.push(s2); cout<<obj.out()<<endl; cout<<"TESTING FOR INTERSECTION-----------------\n"; Vector v3 = Vector(0.0,0.0,1.0); Point p6 = Point(3.0,5.0,0.0); Point p7 = Point(3.0,5.0,5.0); Sphere s3 = Sphere(p7,2.0,c,0.6); Point x = ray_sphere(p6,v3,s3); cout<<"Intersection Point"<<x.out()<<endl; cout<<"TESTING FOR REFLECTION---------------\n"; //Point p8 = Point(0.0,2.0,1.0); //Point p9 = Point(2.0,2.0,1.0); Point p10 = Point(50.0,50.0,0.0); Object ob1,ob2; Sphere s4 = Sphere(Point(40.0,50.0,30.0),10.0,Color(0.1,1.0,0.0),1.0);Color tmp_c,tmp_c2;double min_in_l=200.00,min_in_l2=200.00; Sphere s5 = Sphere(Point(50.0,50.0,60.0),10.0,Color(0.0,0.1,1.0),1.0); ob1 = Object(s4);ob2 = Object(s5);Vector r_d = Vector(0.0,0.0,1.0); Sphere s_temp,s_temp2; Point clos_p = closest_ref(p10,r_d,ob1,min_in_l,tmp_c,s_temp); Vector refl = Vector(reflect_sphere(p10,clos_p,s4)); Point clos_ref = closest_ref(clos_p,refl,ob2,min_in_l2,tmp_c2,s_temp2); cout<<"Reflected vector : "<<clos_p.out()<<"--"<<refl.out()<<clos_ref.out()<<"--"<<endl; /*cout<<"TESTING FOR SHADOW RAY--------------\n"; Object ob; Point p12 = Point(2.0,2.0,1.0); //centre Sphere s5 = Sphere(p12,1.0,c,1.0); //Point p13 = Point(-0.9,-1.0,1.4); //Sphere s6 = Sphere(p13,1.0,c,1.0); ob = Object(s5); Point p11 = Point(2.0,3.0,1.0); //point Point light = Point(4.0,4.0,1.0); //ob.push(s6); cout<<"Shadow status : "<<shadow_check(p11,light,ob)<<endl; cout<<"TESTING FOR REFRACTION------------\n"; Vector d = Vector(0.0,0.0,1.0); //direction Point p15 = Point(2.7,2.0,0.0); //starting point Point p16 = Point(2.0,2.0,5.0); Sphere s7 = Sphere(p16,1.0,Color(0.3,0.1,0.4),0.3,1.33); Sphere s8 = Sphere(Point(1.2,2.0,9.0),1.0,Color(0.2,0.2,0.2),0.3,1.33); Object ob;ob.push(s7);ob.push(s8); double min_l = 100.0;bool bl; Color temp_c;Sphere temp_s; Point inter = closest_int(p15,d,ob,min_l,temp_c,temp_s); Vector refr = refract_sphere(p15,inter,s7,1.0,1.5,bl); Point inter2 = inside_ray_sphere(inter,refr,s7,min_l); Vector refr2 = refract_sphere(inter,inter2,s7,1.5,1.0,bl); Point inter3 = closest_int(inter2,refr2,ob,min_l,temp_c,temp_s); cout<<"\nRefracted Vector : "<<inter.out()<<inter2.out()<<refr.out()<<refr2.out()<<inter3.out()<<endl; /*cout<<"TESTING FOR BRIGHTNESS------------\n"; Point p17 = Point(-1.0,0.0,0.0); Point p18 = Point(2.0,1.0,0.0); Point p19 = Point(3.0,0.0,0.0); // Sphere s8 = Sphere(p19,1.0,Color(1.0,0.3,0.0),0.3); // Color c1 = shade_sphere(p18,p17,s8); // cout<<"Brightness change : "<<s8.c.out()<<" : "<<c1.out()<<endl; cout<<endl<<"TESTING FOR PLANE INTERSECTION\n"; Vector v = Vector(1.0,1.0,1.0); Point p = Point(0.0,0.0,0.0); Plane P = Plane( Point(0.0,0.0,2.0) , Point(2.0,0.0,2.0) , Point(2.0,2.0,2.0) , Point(0.0,2.0,2.0) ); Point in = ray_plane(p,v,P);cout<<endl<<in.out()<<endl;*/ Object ob; ob.push(Plane(Point(0.0,0.0,0.0),Point(0.0,0.0,120.0),Point(110.0,0.0,120.0),Point(110.0,0.0,0.0),Color(1.0,1.0,1.0),1.5)); ob.push(Cuboid(Point(30.0,0.0,20.0),Point(20.0,0.0,30.0),Point(10.0,0.0,20.0),Point(20.0,0.0,10.0),Point(30.0,50.0,20.0),Point(20.0,50.0,30.0),Point(10.0,50.0,20.0),Point(20.0,50.0,10.0),Color(1.0,0.0,0.0))); ob.push(Sphere(Point(60.0,30.0,50.0),10.0,Color(1.0,1.0,0.0),1.0,1.5)); ob.push(Sphere(Point(60.0,60.0,60.0),10.0,Color(1.0,1.0,0.0),1.0,1.5)); // cuboid near the main cuboid ob.push(Cuboid(Point(10.0,0.0,10.0),Point(10.0,0.0,30.0),Point(30.0,0.0,30.0),Point(30.0,0.0,10.0),Point(15.0,15.0,15.0),Point(15.0,15.0,25.0),Point(25.0,15.0,25.0),Point(25.0,15.0,15.0),Color(0.0,0.0,1.0))); // cuboid near the sphere ob.push(Cuboid(Point(40.0,0.0,40.0),Point(40.0,0.0,60.0),Point(60.0,0.0,60.0),Point(60.0,0.0,40.0),Point(35.0,30.0,35.0),Point(35.0,30.0,65.0),Point(65.0,30.0,65.0),Point(65.0,30.0,35.0),Color(0.0,1.0,1.0))); Point min_in_p = Point( 15.0, 0.0 , 39.2405 ); Vector ref_v = Vector(0.0 , 1.0 , 0.1 ); double min_ref_l=1000.0;Color ref_c;Sphere ref_s;Plane ref_p; Point min_ref_p = closest_int(min_in_p,ref_v,ob,min_ref_l,ref_c,ref_s,ref_p); cout<<min_ref_p.out()<<ref_c.out()<<endl; return 0; }
140d54ff10739bcff6ae1a20676fbd656f033c20
e7e9a50678500116c1fd33c521bc88e027c81588
/src/models/event.cpp
96ef4285ebec88e3450eecd2ec4b384c1e2a0512
[]
no_license
AkharazOmar/TableViewQT
dfdebc1efb6ca716106e3ab3683cd798a99c7adc
66df9d66ab7521574bee4b322da534fda9ee0e79
refs/heads/master
2020-03-21T09:44:46.991964
2018-08-11T21:30:35
2018-08-12T01:15:45
138,415,882
0
0
null
null
null
null
UTF-8
C++
false
false
3,098
cpp
event.cpp
/* * Copyright 2018 <copyright holder> <email> * * 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 "models/event.h" #include <QSharedData> namespace eventManager { namespace model { class EventData : public QSharedData { public: EventData() = default; EventData(const EventData &orig) = default; EventData & operator =(const EventData& cpEventD) { if (this != &cpEventD) { //QSharedData(cpEventD); oidEvent_ = cpEventD.oidEvent_; standardAttributes_ = cpEventD.standardAttributes_; specificAttributes_ = cpEventD.specificAttributes_; } return *this; } EventData(EventData &&orig) noexcept: oidEvent_(std::move(orig.oidEvent_)), standardAttributes_(std::move(orig.standardAttributes_)), specificAttributes_(std::move(orig.specificAttributes_)) { } EventData &operator=(EventData &&orig) noexcept { if (this == &orig) { oidEvent_ = std::move(orig.oidEvent_); standardAttributes_ = std::move(orig.standardAttributes_); specificAttributes_ = std::move(orig.specificAttributes_); } return *this; } ~EventData() = default; QString oidEvent_; QHash<QString, QVariant> standardAttributes_; QHash<QString, QVariant> specificAttributes_; }; const QStringList Event::STANDARD_ATTRIBUTE = { "first", "second", "tree" }; Event::Event() : d ( new EventData() ) { } Event::Event ( const Event& other ) : d ( other.d ) { } Event::~Event() noexcept = default; Event& Event::operator= ( const Event& other ) { if (this != &other) { d = other.d; } return *this; } bool Event::operator== ( const Event& other ) const { return other.d->oidEvent_ == d->oidEvent_; } bool Event::operator!= ( const Event& other ) const { return other.d->oidEvent_ != d->oidEvent_; } const QString &Event::oid() const noexcept { return d->oidEvent_; } void Event::setStandardAttribute ( const QString& name, const QVariant& value ) noexcept { d->standardAttributes_.insert(name, value); } void Event::setSpecificAttribute ( const QString& name, const QVariant& value ) noexcept { d->specificAttributes_.insert(name, value); } const QVariant &Event::standardAttribute(const QString &name) const noexcept { return d->standardAttributes_.find(name).value(); } const QVariant &Event::specificAttribute(const QString &name) const noexcept { return d->specificAttributes_.find(name).value(); } } }
3e09088fa6135d6abe577473bf84bd259f6819e3
6b22688a2eb04a0b63d584fc0817c6d3fe155b40
/listProblem/w1406/main.cpp
e70506da876dc4e4d037300ba8e74c087901d877
[]
no_license
ukiKwon/algorithm-study
615d734576e0ca2377f0b2ef40d2a3b77619ca1b
22581eb26825599f1b56612afb3c4be47938165f
refs/heads/master
2022-10-20T07:37:24.093435
2020-06-09T14:40:20
2020-06-09T14:40:20
115,795,348
0
0
null
null
null
null
UTF-8
C++
false
false
3,639
cpp
main.cpp
#include <iostream> #include <string.h> /* cursor actuall cannot be on first. Therefore, (L + 1) is range of movement of cursor when there is L string. */ #define DEFAULT_WORD ' ' #define LEN_STR 100000 using namespace std; class word { friend class sentence; public: word(char _data = 0, word* _left = 0, word* _right = 0) { data = _data, left = _left, right = _right;} private: char data; word* left, *right; }; class sentence { public: sentence() { first = new word(DEFAULT_WORD, 0, 0); last = new word(DEFAULT_WORD, 0, 0); mcursor = NULL; } void create_base() { //read initial string char input[LEN_STR]; cin >> input; int len = strlen(input); //make string to linked list for (int i = 0; i < len; ++i ) { word* new_word; if (mcursor != NULL) { new_word = new word(input[i], mcursor, 0); mcursor->right = new_word; mcursor = new_word; } else { new_word = new word(input[i], first, 0); first->right = new_word; mcursor = new_word; } } //set 'last' mcursor-> right = last; last->left = mcursor; mcursor = last; }; //insert a word on only left void insert_word(word* _base, char _data) { //| _where->left | - | new word | - | _where | if (_base != first) { word* new_word = new word(_data, _base->left, _base); _base->left->right = new_word; _base->left = new_word; } else { //| _where | - | new_word | - |_where->right | word* new_word = new word(_data, _base, _base->right); _base->right->left = new_word; _base->right = new_word; } }; void delete_word(word* base) { //| target->left | - | target | - | base | if (base != first && base->left != first) { word* target = base->left; target->left->right = base; base->left = target->left;//mcursor = leftTotarget; delete target; } else { /*ignore the command*/} }; void solve_algorithm() { //read command int count = 0; char command[2]; cin >> count; for (int i = 0; i < count; ++i) { cin >> command[0]; if (command[0] == 'L' && mcursor->left != first) { //have mcursor left //cout << ">> move left" << endl; mcursor = mcursor->left; } else if (command[0] == 'D' && mcursor != last) { //have mcursor right //cout << ">> move right" << endl; mcursor = mcursor->right; } else if (command[0] == 'B') { //cout << ">> delete" << endl; delete_word(mcursor); //print_chain();cout<<endl; } else if (command[0] == 'P') { //cout << ">> insert" << endl; cin >> command[1]; insert_word(mcursor, command[1]); //print_chain();cout<<endl; } else { /* no action */ //mcursor is on first or last now } //print_chain();cout<<endl; //cout << "mcursor_data :" << mcursor->data << endl; } }; void print_chain() { word* start = first->right; while (start != last) { cout << start->data; start = start->right; } }; private: word* first, *last, *mcursor; }; int main() { sentence wordchain; //cout << "# create # " << endl; wordchain.create_base(); //cout << "# solve # " << endl; wordchain.solve_algorithm(); //cout << "# print # " << endl; wordchain.print_chain(); }
c799ce2df0220b73cdec13840f9b67a5dfad4179
6cb9f535c40a11a22a4abbfb3c05adb1fd8aec96
/BTOOP_COHANH/set.h
fa0060ac5b6367dc84a38f12e5d00864af0bc71f
[]
no_license
ceontgroup/public-project
f77449a000176dfd4fdceaf65853d44fda217e7e
c311e143cad7d552cfdc47ce70cdbc61ba00e433
refs/heads/master
2016-08-11T18:06:59.377421
2013-06-02T17:46:36
2013-06-02T17:46:36
48,648,449
0
0
null
null
null
null
UTF-8
C++
false
false
236
h
set.h
// Class automatically generated by Dev-C++ New Class wizard #ifndef SET_H #define SET_H /* * Author: Kem */ class set { public: // class constructor set(); // class destructor ~set(); }; #endif // SET_H
c35c73761688c65025152c8436f0d57dee8f9cf3
32cb2f19760079beea29f16bfadaefe675476623
/additional/recursive-algorithms/1517.cpp
b33a713ccccd70f7a1ce1f688ee2bcc9ee048eb1
[]
no_license
junkkerrigan/algorithmics
d00b438ebd9909c0afc73a1a6e0bdd0579b2c240
a7493bcefb2a09987a4891b6de955db57ac9ed8a
refs/heads/master
2021-05-23T14:06:12.730092
2020-06-08T17:59:31
2020-06-08T17:59:31
253,329,013
0
0
null
null
null
null
UTF-8
C++
false
false
314
cpp
1517.cpp
#include <iostream> using namespace std; long p, q; long g(long p) { long t = p % 10; if (!p) return 0; return t * (1 + t) / 2 + p / 10 * 45 + g(p / 10); } long s(long p, long q) { return g(q) - g(p - 1); } int main() { while (scanf("%ld %ld", &p, &q), p + q >= 0) printf("%ld\n", s(p, q)); return 0; }
e2b28d44c2e0a65edd962b13b00426af6473c66e
ae55b48aebec623cf6f6cb47ab4c39b153d7b4d1
/Ugine/include/affector.h
a523ab3ce7399cb4d997cab930f46c567ca4dc60
[]
no_license
AlvaroAbad/Star-Control
fed2d7c935debac4b83cfb7083be948d9e4fb2bf
a693aa4603d0eff65ec56d81eb774ad8e7fd7b21
refs/heads/master
2021-01-12T06:05:07.870793
2016-12-24T18:34:00
2016-12-24T18:34:00
77,295,571
0
0
null
null
null
null
UTF-8
C++
false
false
2,698
h
affector.h
#ifndef UGINE_AFFECTOR_H #define UGINE_AFFECTOR_H #include "types.h" #include "string.h" class Affector { public: Affector() { affectVelocityX = affectVelocityY = affectAngularVelocity = AffectLifeTime = affectedColor=false; minVelocityX= maxVelocityX= minVelocityY= maxVelocityY = minAangularVelocity= maxAngularVelocity = minLifetime= maxLifetime = 0; } Affector(String id,double bound0X, double bound0Y, double bound1X, double bound1Y); virtual ~Affector() {}; virtual String getId(){ return this->id; } virtual double getBound0X() { return this->bound0X; } virtual double getBound0Y() { return this->bound0Y; } virtual double getBound1X() { return this->bound1X; } virtual double getBound1Y() { return this->bound1Y; } virtual bool colorAffected() { return this->affectedColor; } virtual void SetMinColor(uint8 r, uint8 g, uint8 b) { this->affectedColor = true; this->minR = r; this->minG = g; this->minB = b; } virtual void SetMaxColor(uint8 r, uint8 g, uint8 b) { this->affectedColor = true; this->maxR = r; this->maxG = g; this->maxB = b; } virtual uint8 getR(); virtual uint8 getG(); virtual uint8 getB(); virtual bool velocityXAffected() { return this->affectVelocityX; } virtual void setVelocityX(double minVelocityX, double maxVelocityX) { this->affectVelocityX = true; this->minVelocityX = minVelocityX; this->maxVelocityX = maxVelocityX; } virtual double getVelocityX(); virtual bool velocityYAffected() { return this->affectVelocityY; } virtual void setVelocityY(double minVelocityY, double maxVelocityY) { this->affectVelocityY = true; this->minVelocityY = minVelocityY; this->maxVelocityY = maxVelocityY; } virtual double getVelocityY(); virtual bool angularVelocityAffected() { return this->affectAngularVelocity; } virtual void setAngularVelocity(double minAangularVelocity, double maxAngularVelocity) { this->affectAngularVelocity = true; this->minAangularVelocity = minAangularVelocity; this->maxAngularVelocity = maxAngularVelocity; } virtual double getAngularVelocity(); virtual bool lifeTimeAffected() { return this->AffectLifeTime; } virtual void setLifeTime(double minLifetime, double maxLifetime) { this->AffectLifeTime = true; this->minLifetime = minLifetime; this->maxLifetime = maxLifetime; } virtual double getLifeTime(); private: String id; uint8 minR, maxR, minG, maxG, minB, maxB; bool affectVelocityX,affectVelocityY, affectAngularVelocity, AffectLifeTime, affectedColor; double bound0X, bound0Y, bound1X, bound1Y; double minVelocityX, maxVelocityX, minVelocityY, maxVelocityY; double minAangularVelocity, maxAngularVelocity; double minLifetime, maxLifetime; }; #endif
8ac2535b0cb7a40f5a532e659c6b00fa2bed7cb7
7648eecee4a40727b6afbc7fe2ac7ffb5810a8c5
/sessions/main.cpp
cdf79c078db3490e5c508595a2a7051af5476da3
[]
no_license
ronghuazhao/CTP_Practice
782f49a8732a41cd42770cf30f138bee83d1e3f6
592c717630cbc26356aedab18e4abd64702b5504
refs/heads/master
2021-01-17T10:37:26.566908
2016-02-20T01:30:58
2016-02-20T01:30:58
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
1,355
cpp
main.cpp
#include "cfgutil.h" #include "multi_session.h" #include <windows.h> HANDLE g_hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); DWORD WINAPI Login(LPVOID lpParameter) { } int main() { //ÇëÇó±àºÅ int reqId = 0; CThostFtdcReqUserLoginField loginField; //µÇ¼ÇëÇóÊý¾Ý CfgUtil getCfg("./cfg/rsh.cfg"); string mdip = getCfg.getPara("MarketFrontIp"); string tradeip = getCfg.getPara("TradeFrontIp"); string instrument = getCfg.getPara("InstrumentId"); string exchange = getCfg.getPara("ExchangeID"); string brokerid = getCfg.getPara("BrokerId"); string user = getCfg.getPara("BrokerUser"); string passwd = getCfg.getPara("BrokerUserPasswd"); int sessionSize = atoi(getCfg.getPara("SessionSize").c_str()); memset(&loginField,0,sizeof(loginField)); strcpy(loginField.BrokerID, brokerid.c_str()); strcpy(loginField.UserID, user.c_str()); strcpy(loginField.Password, passwd.c_str()); strcpy(loginField.UserProductInfo, "ashu"); for (int i=0; i<sessionSize; i++) { Session *s = new Session; CThostFtdcTraderApi *api = CThostFtdcTraderApi::CreateFtdcTraderApi("./"); api->RegisterFront(const_cast<char*>(tradeip.c_str())); api->RegisterSpi(s); api->Init(); //api->Join(); Sleep(1000); int rtn = api->ReqUserLogin(&loginField, ++reqId); std::cout << rtn << std::endl; } getchar(); return 0; }
01fd3d6aa7687eeef3e6dd6f5e31d5c35e6c4b52
5eba39fa53189f3c334df06cc6487ec01eae679b
/Programas C/Trabalho piteri.cpp
5f8faa1e4ebc98d1631b816189c62fe221dc23b2
[]
no_license
marcosinocencio/C
df938c268b954f6aca58fb64912ca521df3a4701
3d984929fca92e8d1348103fe2cbf7e1b2abde96
refs/heads/main
2023-01-10T01:09:47.486097
2020-11-03T19:02:53
2020-11-03T19:02:53
309,781,568
0
0
null
null
null
null
UTF-8
C++
false
false
6,573
cpp
Trabalho piteri.cpp
#include <stdio.h> #include <stdlib.h> #include <math.h> //////////////////////////////////////////////////////////////// double Equacao_1_grau (double a ,double b) { double x; x=-b/a; return(x); } //////////////////////////////////////////////////////////////// double Delta (double b, double c, double d) { double x; x=c*c-4*b*d; return(x); } //////////////////////////////////////////////////////////////// double r1_2_grau (double b, double c, double d) { double x;double r1; //if ((Delta (b,c,d))>=0) r1 = (-c - sqrt(Delta(b,c,d)))/2.0*b; return(r1); } //////////////////////////////////////////////////////////////// double r2_2_grau (double b, double c, double d) { double x;double r2; //if ((Delta (b,c,d))>=0) r2 = (-c + sqrt(Delta(b,c,d)))/2.0*b; return(r2); } //////////////////////////////////////////////////////////////// double real (double b, double c, double d) { float r; r=-c/(2.0*b); return(r); } //////////////////////////////////////////////////////////////// double im (double b, double c, double d) { double img; img=sqrt(fabs(Delta(b,c,d)))/(2.0*b); return(img); } //////////////////////////////////////////////////////////////// double D_3_grau (double a, double b, double c, double d){ double a1, p, q, D; b=b/a; c=c/a; d=d/a; a1=a/a; p= d-((b*b)/3); q= d+((2*b*b*b)/27)-((b*c)/3); D= (q*q)/4 + (p*p*p)/27; return (D); } //////////////////////////////////////////////////////////////// double Dmenos_r1_3_grau (double a, double b, double c, double d){ double a1, u, v, r1, E, r, t, p, q; b=b/a; c=c/a; d=d/a; a1=a/a; p= d-((b*b)/3); q= d+((2*b*b*b)/27)-((b*c)/3); u= cbrt((-q/2) + sqrt(D_3_grau(a,b,c,d))); v= cbrt((-q/2) - sqrt(D_3_grau(a,b,c,d))); r1 = u + v - (b/3); E=sqrt(fabs(- D_3_grau(a,b,c,d))); r=sqrt(((q*q)/4)+(E*E)); t= acos(-q/(2*r)); r1= 2*(r1/(3*cos((t/3)))) - (b/3); return (r1); } //////////////////////////////////////////////////////////////// double Dmenos_r2_3_grau (double a, double b, double c, double d){ double a1, u, v, r1, r2, E, r, t, p, q; b=b/a; c=c/a; d=d/a; a1=a/a; p= d-((b*b)/3); q= d+((2*b*b*b)/27)-((b*c)/3); u= cbrt((-q/2) + sqrt(D_3_grau(a,b,c,d))); v= cbrt((-q/2) - sqrt(D_3_grau(a,b,c,d))); r1 = u + v - (b/3); E=sqrt(fabs(- D_3_grau(a,b,c,d))); r=sqrt(((q*q)/4)+(E*E)); t= acos(-q/(2*r)); r2= 2*(r1/(3*cos((t+(2*M_PI)/3)))) - (b/3); return (r2); } //////////////////////////////////////////////////////////////// double Dmenos_r3_3_grau (double a, double b, double c, double d){ double a1, u, v, r1, r3, E, r, t, p, q; b=b/a; c=c/a; d=d/a; a1=a/a; p= d-((b*b)/3); q= d+((2*b*b*b)/27)-((b*c)/3); u= cbrt((-q/2) + sqrt(D_3_grau(a,b,c,d))); v= cbrt((-q/2) - sqrt(D_3_grau(a,b,c,d))); r1 = u + v - (b/3); E=sqrt(fabs(- D_3_grau(a,b,c,d))); r=sqrt(((q*q)/4)+(E*E)); t= acos(-q/(2*r)); r3= 2*(r1/(3*cos((t+(4*M_PI)/3)))) - (b/3); return (r3); } //////////////////////////////////////////////////////////////// double Dmais_r1_grau (double a, double b, double c, double d){ double E, u, v, d2, r1, a1, p, q; b=b/a; c=c/a; d=d/a; a1=a/a; p= d-((b*b)/3); q= d+((2*b*b*b)/27)-((b*c)/3); E=sqrt(D_3_grau(a,b,c,d)); u= cbrt((-q/2) + E); v= cbrt((-q/2) - E); r1 = u + v - (b/3); return(r1); } //////////////////////////////////////////////////////////////// double Dmais_r2_grau (double a, double b, double c, double d){ double E, u, v, d2, r1, r2, a1, p, q; b=b/a; c=c/a; d=d/a; a1=a/a; p= d-((b*b)/3); q= d+((2*b*b*b)/27)-((b*c)/3); E=sqrt(D_3_grau(a,b,c,d)); u= cbrt((-q/2) + E); v= cbrt((-q/2) - E); r1 = u + v - (b/3); d2=((b + r1)*(b + r1)) - 4*1*(-d/r1); if (d2<0) r2= (-(b+r1)/2); return (r2); } //////////////////////////////////////////////////////////////// double im_3_grau (double a, double b, double c, double d){ double E, u, v, d2, r1, r2, a1, p, q, im; b=b/a; c=c/a; d=d/a; a1=a/a; p= d-((b*b)/3); q= d+((2*b*b*b)/27)-((b*c)/3); E=sqrt(D_3_grau(a,b,c,d)); u= cbrt((-q/2) + E); v= cbrt((-q/2) - E); r1 = u + v - (b/3); d2=((b + r1)*(b + r1)) - 4*1*(-d/r1); if (d2<0) im = sqrt(fabs(-d2)); else im = sqrt(fabs(d2)); return (im); } //////////////////////////////////////////////////////////////// int main (void){ int z; double a,b,c,d; printf("Entre com o valor de a: \n"); scanf("%lf",&a); printf("Entre com o valor de b: \n"); scanf("%lf",&b); printf("Entre com o valor de c: \n"); scanf("%lf",&c); printf("Entre com o valor de d: \n"); scanf("%lf",&d); system ("cls"); if ((a==0) && (b==0) && (c==0)) printf("Esta e uma equacacao degenerada! \n\n\n\n"); else if ((a==0) && (b==0)) printf("Esta E Uma Equacao do Primeiro Grau e Sua Raiz E : %lf \n\n\n\n",Equacao_1_grau(c,d)); else if ((a==0)) if (Delta(b,c,d)>=0) printf("Esta E Uma Equacao do Segundo Grau e Suas Raizes Sao : %lf,%lf \n\n\n\n", r1_2_grau(b,c,d),r2_2_grau(b,c,d)); else printf("Esta E Uma Equacao do Segundo Grau e Suas Raizes Sao: %lf + %lf*i e %lf - %lf*i \n\n\n\n", real(b,c,d), im(b,c,d), real(b,c,d), im(b,c,d)); else if (D_3_grau (a,b,c,d)>0) printf ("Esta E Uma Equacao do Terceiro Grau e Suas Raizes Sao: %lf, %lf+%lf*i, %lf-%lf*i \n\n\n\n", Dmais_r1_grau(a,b,c,d), Dmais_r2_grau(a,b,c,d), im_3_grau(a,b,c,d), Dmais_r2_grau(a,b,c,d), im_3_grau(a,b,c,d)); else printf ("Esta E Uma Equacao do Terceiro Grau e Suas Raizes Sao: %lf, %lf, %lf \n\n\n\n",Dmenos_r1_3_grau (a,b,c,d), Dmenos_r2_3_grau (a,b,c,d), Dmenos_r3_3_grau(a,b,c,d)); system("pause"); return(0); }
6cadac88483e52b0cfe40f95cc9891eb4c961c05
2a89e46324a6e0dfa5cad89801379d593a12a4c1
/src/ppl/nn/engines/x86/kernels/onnx/fc_kernel.cc
e1d0c207ab339adbf48b2b9959c9c3a4795a694f
[ "Apache-2.0" ]
permissive
fzhsbc/ppl.nn
16ca2a4991316cfee2eb40a48a3003caf5dfac70
370a3ff5296b3c2d8768bb2f5220eaa5e65a94a7
refs/heads/master
2023-09-03T18:40:29.524548
2021-11-09T07:59:04
2021-11-09T08:45:10
426,165,992
0
0
Apache-2.0
2021-11-09T09:26:13
2021-11-09T09:26:13
null
UTF-8
C++
false
false
2,963
cc
fc_kernel.cc
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. #include "ppl/nn/engines/x86/kernels/onnx/fc_kernel.h" namespace ppl { namespace nn { namespace x86 { uint64_t FCKernel::CalcTmpBufferSize(const KernelExecContext& ctx) const { return executor_->cal_temp_buffer_size(); } ppl::common::RetCode FCKernel::DoExecute(KernelExecContext* ctx) { TensorImpl* A = ctx->GetInput<TensorImpl>(0); TensorImpl* Y = ctx->GetOutput<TensorImpl>(0); executor_->set_src_shape(&A->GetShape()); executor_->set_src(A->GetBufferPtr<float>()); executor_->set_dst_shape(&Y->GetShape()); executor_->set_dst(Y->GetBufferPtr<float>()); ppl::common::RetCode rc; rc = executor_->prepare(); if (ppl::common::RC_SUCCESS != rc) { LOG(ERROR) << "Prepare failed: " << ppl::common::GetRetCodeStr(rc); return rc; } BufferDesc tmp_buffer_desc; auto tmp_buffer_size = CalcTmpBufferSize(*ctx); rc = GetX86Device()->AllocTmpBuffer(tmp_buffer_size, &tmp_buffer_desc); if (rc != ppl::common::RC_SUCCESS) { LOG(ERROR) << "alloc tmp buffer size[" << tmp_buffer_size << "] for kernel[" << GetName() << "] failed: " << ppl::common::GetRetCodeStr(rc); return rc; } BufferDescGuard __tmp_buffer_guard(&tmp_buffer_desc, [this](BufferDesc* buffer) -> void { GetX86Device()->FreeTmpBuffer(buffer); }); auto tmp_buffer = tmp_buffer_desc.addr; executor_->set_temp_buffer(tmp_buffer); PPLNN_X86_DEBUG_TRACE("Op: %s\n", GetName().c_str()); PPLNN_X86_DEBUG_TRACE("Input [A]:\n"); PPL_X86_TENSOR_PRINT_DEBUG_MSG(A); PPLNN_X86_DEBUG_TRACE("Output [Y]:\n"); PPL_X86_TENSOR_PRINT_DEBUG_MSG(Y); PPLNN_X86_DEBUG_TRACE("channels: %ld\n", executor_->fc_param()->channels); PPLNN_X86_DEBUG_TRACE("num_output: %ld\n", executor_->fc_param()->num_output); PPLNN_X86_DEBUG_TRACE("buffer: %p\n", tmp_buffer); PPLNN_X86_DEBUG_TRACE("isa: %u\n", GetISA()); rc = executor_->execute(); if (ppl::common::RC_SUCCESS != rc) { LOG(ERROR) << "Execute failed: " << ppl::common::GetRetCodeStr(rc); return rc; } return ppl::common::RC_SUCCESS; } }}} // namespace ppl::nn::x86
387b7b5de9e8c3d7757cdfe87827055565945ed0
79c7c8602c07e99c3827c27092818725639f5a10
/Labyrinth Solver/Labyrinth Solver/Queue.h
8e839dd3b2705c92adb4bcb66caf7f16dd399d12
[]
no_license
LASRIDOR/Labyrinth-Solver-Data-Structure-Course-Project-
7f0c8b1f0af6c3d000e75b7c1c08a2192e19a138
6bc65688bcf557838273dfafb7b4d35b011d85a9
refs/heads/main
2022-12-30T02:49:33.400395
2020-10-17T08:34:42
2020-10-17T08:34:42
303,200,520
0
0
null
null
null
null
UTF-8
C++
false
false
428
h
Queue.h
#ifndef __QUEUE_H #define __QUEUE_H #include <iostream> #include <stdlib.h> using namespace std; #pragma warning (disable: 4996) #include "Square.h" class Queue { private: Square *data; int head, tail; int MAX_SIZE; int AddOne(int x); public: Queue(int size_of_data); ~Queue(); void MakeEmpty(void); int IsEmpty(void); Square Front(void); void EnQueue(Square item); Square DeQueue(void); }; #endif // !__QUEUE_H
02f5e7bf34f54971adf0736865cedb12436bf3f9
a337ce96b4012093ec021ba600bb2dafb56afd38
/gm_module/src/pygm.hxx
fcd80b227a822eb08dd2ed3874098a21b6e9ee1a
[]
no_license
thorbenk/ia13project
f964617a6288eb2dfe51fabf3a85c8e27678d199
568d44bb69633dd0948d1ba598ce70e9250d814b
refs/heads/master
2020-12-24T17:45:24.315844
2013-07-19T11:58:48
2013-07-19T11:58:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
24
hxx
pygm.hxx
void export_adjGraph();
c5587606861947ef76df3d84267a20a31988fb62
c6cfd48aefd600fb15aae50ab8e13992459a69ca
/Pila.cpp
db0d9bbbdb8e8fa9f17cb45c821dc24598d67e07
[ "Apache-2.0" ]
permissive
victorortiz98/Manchester-Triage-Queue-and-Tree-
2fcacb97960a95c7dc0b9de4ba938d0fd1ef0249
d5865433bc623c72464d46c0cd71c772ed08f724
refs/heads/main
2023-06-10T20:06:43.777020
2021-07-03T16:18:03
2021-07-03T16:18:03
382,658,121
0
0
null
null
null
null
UTF-8
C++
false
false
4,395
cpp
Pila.cpp
// // Created by Víctor Ortiz on 16/06/2021. // #include "Pila.h" #include "NodoPila.h" #include "Pacientes.h" #include "Hospital.h" Pila::Pila() { cima = NULL; } Pila::~Pila() { while (cima) pop(); } bool Pila::esVacia() { return cima == NULL; } void Pila::push(Pacientes *v) { pnodo nuevo = new NodoPila(v, cima); //comienzo de la pila nevo nodo cima = nuevo; } void Pila::pop() { pnodo nodo; //Creamos un puntero auxiliar para poder manipular el nodo if (cima) nodo = cima; cima = nodo->siguiente; delete nodo; } int Pila::mostrar(bool escribir) { if (escribir) { cout << "--------------------------------------------" << endl; cout << "Paciente :" << cima->valor->getIdPaciente() << endl; cout << "DNI:" << cima->valor->getDni() << endl; cout << "Nombre:" << cima->valor->getNombre() << endl; cout << "Apellido1:" << cima->valor->getApellido1() << endl; cout << "Apellido2:" << cima->valor->getApellido2() << endl; cout << "Edad:" << cima->valor->getEdad() << endl; cout << "Sexo:" << cima->valor->getSexo() << endl; cout << "--------------------------------------------" << endl; } cima = cima->siguiente; return 0; } void Pila::buscarDni(Pila &pilaPacientes, string dni) { pnodo nodo; while (!esVacia()) { nodo = cima; if (cima->valor->getDni() == dni) { pilaPacientes.mostrar(true); } else { cima = cima->siguiente; } } } int Pila::devolverId() { pnodo nodo; nodo = cima; int devolver = cima->valor->getIdPaciente(); return devolver; } string Pila::devolverDni() { pnodo nodo; nodo = cima; string devolver = cima->valor->getDni(); return devolver; } string Pila::devolverNombre() { pnodo nodo; nodo = cima; string devolver = cima->valor->getNombre(); return devolver; } string Pila::devolverApellido1() { pnodo nodo; nodo = cima; string devolver = cima->valor->getApellido1(); return devolver; } string Pila::devolverApellido2() { pnodo nodo; nodo = cima; string devolver = cima->valor->getApellido2(); return devolver; } int Pila::devolverEdad() { pnodo nodo; nodo = cima; int devolver = cima->valor->getEdad(); return devolver; } char Pila::devolverSexo() { pnodo nodo; nodo = cima; char devolver = cima->valor->getSexo(); return devolver; } void Pila::invertirPila(Pila &pilaPacientesTemp, Pila &pilaPacientes) { int id = cima->valor->getIdPaciente(); std::string DNI = cima->valor->getDni(); std::string nom = cima->valor->getNombre(); std::string ape1 = cima->valor->getApellido1(); std::string ape2 = cima->valor->getApellido2(); int edad = cima->valor->getEdad(); char sexo = cima->valor->getSexo(); Pacientes *pa1 = new Pacientes(id, DNI, nom, ape1, ape2, edad, sexo); pilaPacientesTemp.push(pa1); pilaPacientes.mostrar(true); } //Eliminar nodo de la pila conservando los nodos anteriores // top es el puntero al nodo superior de la pila, top2 es un nodo buffer para almacenar datos de manera temporal void Pila::eliminarElemento(Pila &pilaPacientesTemp, Pila &pilaPacientes, string dni) { pnodo nodo; cout << "Baja paciente :" << endl; bool encontrado = true; cout << "Desapilamos pilaPacientes y lo pasamos a PilaPacientesTemp:" << endl; while (encontrado && !esVacia()) { nodo = cima; bool eli = false; if (cima->valor->getDni() == dni) { cout << "Paciente ELIMINAD0: " << endl; pilaPacientes.mostrar(true); encontrado = false; eli = true; } if (eli == false) { pilaPacientes.invertirPila(pilaPacientesTemp, pilaPacientes); } } while (!esVacia()) { pilaPacientes.invertirPila(pilaPacientesTemp, pilaPacientes); } cout << "Introducimos los valores de pilaPacientesTemp a pilaPacientes y se limpia pilaPacientesTemp:" << endl; while (!pilaPacientesTemp.esVacia()) { pilaPacientesTemp.invertirPila(pilaPacientes, pilaPacientesTemp); } }
a0031c7f2d7ae05b83cef8076f931915f6f0fbd5
ea4f2445a0c97b427e5827138246129f28059a3d
/cpp/ColorMandelbrotSet.cpp
c45d06eb933433582d99fa3412134ee8c1e397a6
[ "MIT" ]
permissive
so61pi/examples
27cfe8a3e7712b25d2f344312f64fd4d4bdeeca3
38e2831cd6517864fc05f499f72fbb4ff6ae27c0
refs/heads/master
2023-01-22T04:13:27.785531
2020-04-30T14:07:36
2020-04-30T14:07:36
116,532,548
5
1
MIT
2023-01-05T00:47:46
2018-01-07T02:56:36
C
UTF-8
C++
false
false
3,641
cpp
ColorMandelbrotSet.cpp
#include <algorithm> #include <cinttypes> #include <cmath> #include <complex> #include <iostream> #include <iterator> #include <vector> #define png_infopp_NULL nullptr #define int_p_NULL nullptr #include <boost/gil/gil_all.hpp> #include <boost/gil/extension/io/png_io.hpp> namespace gil = boost::gil; // map value in range r1 to r2 auto map_value(double val, double r1_from, double r1_to, double r2_from, double r2_to) -> double { return ((val - r1_from) / (r1_to - r1_from)) * (r2_to - r2_from) + r2_from; } class mandelbrot_fn { struct color_line { explicit color_line(int lv) : level{ lv } {} color_line(int lv, gil::bits8 r, gil::bits8 g, gil::bits8 b) : level{ lv }, pixel{ r, g, b } {} int level; gil::rgb8_pixel_t pixel; auto operator<(color_line const& rhs) const noexcept -> bool { return level < rhs.level; } }; public: using const_t = mandelbrot_fn; using value_type = gil::rgb8_pixel_t; using reference = value_type; using const_reference = value_type; using point_t = gil::point2<int>; using result_type = value_type; using argument_type = point_t; static constexpr bool is_mutable = false; explicit mandelbrot_fn(point_t const& size) : m_size{ size } { m_colors.emplace_back( 0, 0, 0, 64); m_colors.emplace_back( 8, 0, 255, 255); m_colors.emplace_back(16, 0, 255, 0); m_colors.emplace_back(24, 255, 128, 0); m_colors.emplace_back(32, 0, 0, 255); m_colors.emplace_back(40, 255, 255, 0); m_colors.emplace_back(48, 255, 255, 255); m_colors.emplace_back(56, 255, 255, 255); m_colors.emplace_back(64, 255, 255, 255); sort(begin(m_colors), end(m_colors)); } auto operator()(point_t const& point) const -> result_type { auto level = get_color_level(point); if (level < 0) { return result_type{ 0, 0, 0 }; } auto uppos = upper_bound(begin(m_colors), end(m_colors), color_line{ level }); if (uppos == end(m_colors)) { --uppos; } auto const& lower = *(uppos - 1); auto const& upper = *uppos; result_type pixel; for (auto i = 0; i < 3; ++i) { pixel[i] = map_value(level, lower.level, upper.level, lower.pixel[i], upper.pixel[i]); } return pixel; } private: // get color level of given point // negative result if the point is in the set auto get_color_level(point_t const& point) const -> int { // map x to [-2, 1] and y to [1.5, -1.5] std::complex<double> c{map_value(point.x, 0, m_size.x, -2, 1), map_value(point.y, 0, m_size.y, 1.5, -1.5)}; int level = 0; for (auto lc = c; level < 64; ++level) { if (std::pow(lc.real(), 2) + std::pow(lc.imag(), 2) > 4) { return level; } lc = std::pow(lc, 2) + c; } return -1; } point_t m_size; std::vector<color_line> m_colors; }; int main() { using point_t = mandelbrot_fn::point_t; using locator_t = gil::virtual_2d_locator<mandelbrot_fn, false>; using image_view_t = gil::image_view<locator_t>; point_t size{ 20'000, 20'000 }; image_view_t view{ size, locator_t{ point_t{ 0, 0 }, point_t{ 1, 1 }, mandelbrot_fn{ size } } }; gil::png_write_view("mandelbrot.png", view); }
3db3edb2c9b37b2cdac8dcede64bbfdf15f10763
200562a6ea2fdcbc71983a5641ef5b4297963c63
/MegamanRunner/Classes/Features/Game/gameScene.h
d666606d28891817e30b63f77569c10959470da2
[]
no_license
mendesbarreto/mega-man-runner
3569827e6394d9fe947f38ac633d86d359274092
851858477abed1af71afeca853644ac09df92be7
refs/heads/develop
2023-01-14T04:20:08.161022
2019-03-27T23:02:34
2019-03-27T23:02:34
177,480,706
2
0
null
2022-12-27T00:30:49
2019-03-24T23:12:53
C++
UTF-8
C++
false
false
335
h
gameScene.h
// // Created by Douglas Mendes on 2019-03-27. // #ifndef MEGAMANRUNNER_GAMESCENE_H #define MEGAMANRUNNER_GAMESCENE_H #include "scene.h" #include "cocos2d.h" class GameScene: core::Scene { public: static cocos2d::Scene* createScene(); virtual bool init(); CREATE_FUNC(GameScene); }; #endif //MEGAMANRUNNER_GAMESCENE_H
680c4ea0dc0b827610aba71ae6a8c6a7ed7ef6ef
036a044d4f1dddb02627340bf38cd9e625ff8587
/src/dropbox/users/UsersSpaceAllocation.h
5e3f1bd3cc32a31a4d41678ae427c0e8318f4810
[ "MIT" ]
permissive
kobolabs/dropboxQt
12737a79cbf4021e950dbcb81fd45f732782af7c
63d43fa882cec8fb980a2aab2464a2d7260b8089
refs/heads/master
2020-08-04T02:49:09.795523
2019-09-25T17:50:21
2019-09-25T17:50:21
211,977,548
0
2
MIT
2019-09-30T23:39:37
2019-09-30T23:39:36
null
UTF-8
C++
false
false
2,373
h
UsersSpaceAllocation.h
/********************************************************** DO NOT EDIT This file was generated from stone specification "users" Part of "Ardi - the organizer" project. osoft4ardi@gmail.com www.prokarpaty.net ***********************************************************/ #pragma once #include "dropbox/endpoint/ApiUtil.h" #include "dropbox/users/UsersIndividualSpaceAllocation.h" #include "dropbox/users/UsersTeamSpaceAllocation.h" namespace dropboxQt{ namespace users{ class SpaceAllocation{ /** Space is allocated differently based on the type of account. field: individual: The user's space allocation applies only to their individual account. field: team: The user shares space with other members of their team. */ public: enum Tag{ /*The user's space allocation applies only to their individual account.*/ SpaceAllocation_INDIVIDUAL, /*The user shares space with other members of their team.*/ SpaceAllocation_TEAM, /*None*/ SpaceAllocation_OTHER }; SpaceAllocation(){} SpaceAllocation(Tag v):m_tag(v){} virtual ~SpaceAllocation(){} Tag tag()const{return m_tag;} ///The user's space allocation applies only to their individual account. const IndividualSpaceAllocation& getIndividual()const{API_CHECK_STATE((SpaceAllocation_INDIVIDUAL == m_tag), "expected tag: SpaceAllocation_INDIVIDUAL", m_tag);return m_individual;}; ///The user shares space with other members of their team. const TeamSpaceAllocation& getTeam()const{API_CHECK_STATE((SpaceAllocation_TEAM == m_tag), "expected tag: SpaceAllocation_TEAM", m_tag);return m_team;}; public: operator QJsonObject ()const; virtual void fromJson(const QJsonObject& js); virtual void toJson(QJsonObject& js, QString name)const; virtual QString toString(bool multiline = true)const; class factory{ public: static std::unique_ptr<SpaceAllocation> create(const QByteArray& data); static std::unique_ptr<SpaceAllocation> create(const QJsonObject& js); }; protected: Tag m_tag; IndividualSpaceAllocation m_individual; TeamSpaceAllocation m_team; };//SpaceAllocation }//users }//dropboxQt
20cda372a15c627d1d93c5bcb78a13a80c3c10d4
33b567f6828bbb06c22a6fdf903448bbe3b78a4f
/opencascade/Interface_ParamList.hxx
ae9e2b35f9da6106d3ef97db01bfe9d8626e89b4
[ "Apache-2.0" ]
permissive
CadQuery/OCP
fbee9663df7ae2c948af66a650808079575112b5
b5cb181491c9900a40de86368006c73f169c0340
refs/heads/master
2023-07-10T18:35:44.225848
2023-06-12T18:09:07
2023-06-12T18:09:07
228,692,262
64
28
Apache-2.0
2023-09-11T12:40:09
2019-12-17T20:02:11
C++
UTF-8
C++
false
false
2,495
hxx
Interface_ParamList.hxx
// Created on: 2008-01-21 // Created by: Galina KULIKOVA // Copyright (c) 2008-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #ifndef _Interface_ParamList_HeaderFile #define _Interface_ParamList_HeaderFile #include <Standard.hxx> #include <Interface_VectorOfFileParameter.hxx> #include <Standard_Transient.hxx> #include <Standard_Integer.hxx> class Interface_FileParameter; class Interface_ParamList; DEFINE_STANDARD_HANDLE(Interface_ParamList, Standard_Transient) class Interface_ParamList : public Standard_Transient { public: //! Creates an vector with size of memory block equal to theIncrement Standard_EXPORT Interface_ParamList(const Standard_Integer theIncrement = 256); //! Returns the number of elements of <me>. Standard_Integer Length() const; //! Returns the lower bound. //! Warning Standard_Integer Lower() const; //! Returns the upper bound. //! Warning Standard_Integer Upper() const; //! Assigns the value <Value> to the <Index>-th item of this array. Standard_EXPORT void SetValue (const Standard_Integer Index, const Interface_FileParameter& Value); //! Return the value of the <Index>th element of the //! array. Standard_EXPORT const Interface_FileParameter& Value (const Standard_Integer Index) const; const Interface_FileParameter& operator () (const Standard_Integer Index) const { return Value(Index); } //! return the value of the <Index>th element of the //! array. Standard_EXPORT Interface_FileParameter& ChangeValue (const Standard_Integer Index); Interface_FileParameter& operator () (const Standard_Integer Index) { return ChangeValue(Index); } Standard_EXPORT void Clear(); DEFINE_STANDARD_RTTIEXT(Interface_ParamList,Standard_Transient) protected: private: Interface_VectorOfFileParameter myVector; }; #include <Interface_ParamList.lxx> #endif // _Interface_ParamList_HeaderFile
b70d9a66c836e080103b28613c82994028b5325c
230cba94d190926083e285e79e8e764c51f6e532
/openMP/task5.cpp
9d4f60eca014b975bbc2cd646bbee8af156bacc2
[]
no_license
vladKrk/High_performance_computing
6e4316ec62fe44bf68c75a5d9daeaa6b51639f79
129e1727fa3bcdafda3b00a30ddb21ce9b8d93f8
refs/heads/main
2023-03-30T15:53:34.819349
2021-04-08T17:54:46
2021-04-08T17:54:46
344,779,176
0
0
null
null
null
null
UTF-8
C++
false
false
2,600
cpp
task5.cpp
#include <omp.h> #include <cstdlib> #include <cstdio> #include <utility> static const int num_threads = 4; double even_odd_sort(int* arr, int n) { bool sorted = false; int init = 0; double t1 = omp_get_wtime(); while (!sorted) { sorted = true; for (int i = init; i < n - 1; i += 2) { if (arr[i] > arr[i + 1]) { std::swap(arr[i], arr[i + 1]); sorted = false; } } init = 1 - init; } double t2 = omp_get_wtime(); return (t2 - t1) * 1000.0;; } double even_odd_sort_omp(int* arr, int n) { bool sorted = false; int init = 0; double t1 = omp_get_wtime(); while (!sorted) { sorted = true; #pragma omp parallel for for (int i = init; i < n - 1; i += 2) { if (arr[i] > arr[i + 1]) { std::swap(arr[i], arr[i + 1]); sorted = false; } } init = 1 - init; } double t2 = omp_get_wtime(); return (t2 - t1) * 1000.0;; } int* generate_array(int n) { static int cnt; cnt++; int* res = new int[n]; srand(cnt); for (int i = 0; i < n; ++i) { res[i] = rand() % 1000; } return res; } // check if array is properly sorted bool check_array(const int* arr, int n) { for (int i = 0; i < n - 1; ++i) { if (arr[i] > arr[i + 1]) return false; } return true; } void test(int n, int cnt) { double t = 0.0; for (int i = 0; i < cnt; ++i) { int* arr = generate_array(n); t += even_odd_sort(arr, n); if (!check_array(arr, n)) { printf("sort failed\n"); delete[] arr; return; } delete[] arr; } printf("array size: %d, average time: %.2lf ms\n", n, t / cnt); } void test_omp(int n, int cnt) { double t = 0.0; for (int i = 0; i < cnt; ++i) { int* arr = generate_array(n); t += even_odd_sort_omp(arr, n); if (!check_array(arr, n)) { printf("omp sort failed\n"); delete[] arr; return; } delete[] arr; } printf("array size: %d, average time using omp: %.2lf ms\n", n, t / cnt); } int main() { omp_set_num_threads(num_threads); test(500, 10); test_omp(500, 10); test(1000, 10); test_omp(1000, 10); test(1500, 10); test_omp(1500, 10); test(2000, 10); test_omp(2000, 10); test(2500, 10); test_omp(2500, 10); return 0; }
70ec21ddb9973fb6bc1433c87387695e540f6fd4
7be8a39598ffcb6684bdfe673cca8f252e579075
/BaseObject.h
6f187e541b7bba692ac387a4d1f613b26e189e22
[]
no_license
bannerholly/raytracing
c0b5be35eb915f080df89951abf9a6a7f563d3d0
f2881aedcc1144ff1d8a01be327764973fbcebfe
refs/heads/master
2023-05-05T17:56:22.265925
2021-05-27T16:30:22
2021-05-27T16:30:22
370,434,597
0
0
null
null
null
null
UTF-8
C++
false
false
3,132
h
BaseObject.h
#pragma once #include "HitRec.h" #include "Vec.h" #include "Ray.h" #include "Material.h" #include <vector> #include <iostream> #include <GL/glut.h> class BaseObject{ public: enum ObjectType { Normal, Emit }; //コンストラクタ BaseObject():o_pos(Vec3{0.0}),material(new Material()){}; BaseObject(const Vec3& v):o_pos(v),material(new Material()){}; BaseObject(const Vec3& v,Material* m):o_pos(v),material(m){ }; //デストラクタ virtual ~BaseObject(){ if(material != nullptr){ // Logger::logClass(this); delete material; } }; //share関連 virtual void shaprePoint(){ ++sharePoint_count; } bool releaseOK(){ --sharePoint_count; if(sharePoint_count <= 0){ return true; } return false; } //レイが物体に当たっているかの判定 virtual bool hit(const Ray& r, float tmin, float tmax, HitRec& record) const = 0; //シャドウレイ(レイの交点から光源にレイを飛ばしたもの)が他の物体に当たるかどうかの判定 virtual bool shadowHit(const Ray& r, float tmin, float tmax) const = 0; //座標からテクスチャ座標を割り出す(基本はUV) virtual Vec3 getTexPos(Vec3& pos) const {}; //セッター inline void setMaterial(Material* m){ material = m; } inline void setPosition(Vec3& v){ o_pos = v; } inline void setMaterialParam(MaterialParam param,Vec3 p){ switch(param){ case MaterialParam::Ambient : material->setAmbientReflect(p); break; case MaterialParam::Diffuse : material->setDiffuseReflect(p); break; case MaterialParam::Specular : material->setSpecularReflect(p); break; }; } inline void setMaterialShiness(int s){ material->setShiness(s); } inline void setMaterialPerfectSpecular(Vec3 p){ material->setPerfectSpecular(p); } inline void setMaterialReflactSpecular(float t,Vec3 v){ material->setEta(t); material->setPerfectSpecular(v); } //ゲッター inline Material* getMaterial(){ return material; } inline Vec3 getPosition(){ return o_pos; } virtual Vec3 getBoundingBoxMin() const { return Vec3(0,0,0); } virtual Vec3 getBoundingBoxMax() const { return Vec3(0,0,0); } //ON,OFF void onPerfectSpecular(){ material->setIsReflect(true); offReflactSpecular(); } void offPerfectSpecular(){ material->setIsReflect(false); } void onReflactSpecular(){ material->setIsReflact(true); offPerfectSpecular(); } void offReflactSpecular(){ material->setIsReflact(false); } protected: Vec3 o_pos; //物体の座標(中心) std::vector<BaseObject*> children; //子のオブジェクト //マテリアル関連 Material* material; int sharePoint_count = 0; };
e19d5cdc11b66b4a298969bf9255c518daa81f4b
0618591a36cfaede8df0da1027381c766d5cbed7
/Interrupts/interrupt.ino
b6d4bc5ce1b1874ac4f7fa2720c707a7b514eac0
[]
no_license
muhammedyozgatli/Arduino_Youtube_Tutorials
6e5aa7273079d8e87786ce12edbf4b39d21006dc
65057fccb90e72adc2abec758bcc3c0478cbfb03
refs/heads/master
2023-04-23T20:54:23.186843
2021-05-17T09:55:39
2021-05-17T09:55:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
771
ino
interrupt.ino
/* Interrupts with Arduino Author: Electrofun For more information visit us: www.electrofun.co.in Prerequisites video: https://www.youtube.com/watch?v=H3l8Y2ra3f8&ab_channel=Electrofun Video explanation at: https://www.youtube.com/watch?v=X-YffrXxM-M&ab_channel=Electrofun */ int pin = 2; //Defining interrupt pin volatile int state = LOW; //Variable shared in ISR void setup() { pinMode(13, OUTPUT); attachInterrupt(digitalPinToInterrupt(pin), funct, RISING); //interrupt on rising pulse on pin no 2 // put your setup code here, to run once: } void loop() { digitalWrite(13, state); //Changing the state when interrupt is generated // put your main code here, to run repeatedly: } void funct() { state = !state; }
798104d2bfe7fa86280a87f41dc7a7d0285f97d3
b00c54389a95d81a22e361fa9f8bdf5a2edc93e3
/external/pdfium/fpdfsdk/include/javascript/color.h
1910e1695525a74952e18e066a18920a3d4e2156
[ "BSD-3-Clause" ]
permissive
mirek190/x86-android-5.0
9d1756fa7ff2f423887aa22694bd737eb634ef23
eb1029956682072bb7404192a80214189f0dc73b
refs/heads/master
2020-05-27T01:09:51.830208
2015-10-07T22:47:36
2015-10-07T22:47:36
41,942,802
15
20
null
2020-03-09T00:21:03
2015-09-05T00:11:19
null
UTF-8
C++
false
false
2,046
h
color.h
// Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #ifndef _COLOR_H_ #define _COLOR_H_ class color : public CJS_EmbedObj { public: color(CJS_Object* pJSObject); virtual ~color(void); FX_BOOL black(OBJ_PROP_PARAMS); FX_BOOL blue(OBJ_PROP_PARAMS); FX_BOOL cyan(OBJ_PROP_PARAMS); FX_BOOL dkGray(OBJ_PROP_PARAMS); FX_BOOL gray(OBJ_PROP_PARAMS); FX_BOOL green(OBJ_PROP_PARAMS); FX_BOOL ltGray(OBJ_PROP_PARAMS); FX_BOOL magenta(OBJ_PROP_PARAMS); FX_BOOL red(OBJ_PROP_PARAMS); FX_BOOL transparent(OBJ_PROP_PARAMS); FX_BOOL white(OBJ_PROP_PARAMS); FX_BOOL yellow(OBJ_PROP_PARAMS); FX_BOOL convert(OBJ_METHOD_PARAMS); FX_BOOL equal(OBJ_METHOD_PARAMS); public: static void ConvertPWLColorToArray(const CPWL_Color& color, CJS_Array& array); static void ConvertArrayToPWLColor(CJS_Array& array, CPWL_Color& color); private: CPWL_Color m_crTransparent; CPWL_Color m_crBlack; CPWL_Color m_crWhite; CPWL_Color m_crRed; CPWL_Color m_crGreen; CPWL_Color m_crBlue; CPWL_Color m_crCyan; CPWL_Color m_crMagenta; CPWL_Color m_crYellow; CPWL_Color m_crDKGray; CPWL_Color m_crGray; CPWL_Color m_crLTGray; }; class CJS_Color : public CJS_Object { public: CJS_Color(JSFXObject pObject) : CJS_Object(pObject) {}; virtual ~CJS_Color(void){}; DECLARE_JS_CLASS(CJS_Color); JS_STATIC_PROP(black, color); JS_STATIC_PROP(blue, color); JS_STATIC_PROP(cyan, color); JS_STATIC_PROP(dkGray, color); JS_STATIC_PROP(gray, color); JS_STATIC_PROP(green, color); JS_STATIC_PROP(ltGray, color); JS_STATIC_PROP(magenta, color); JS_STATIC_PROP(red, color); JS_STATIC_PROP(transparent, color); JS_STATIC_PROP(white, color); JS_STATIC_PROP(yellow, color); JS_STATIC_METHOD(convert,color); JS_STATIC_METHOD(equal,color); }; #endif //_COLOR_H_
35110a2d53d82bb041505eb6aa967d614b8bb1a0
5241a49fc86a3229e1127427146b5537b3dfd48f
/src/Sparrow/Sparrow/Implementations/Nddo/Pm6/Wrapper/PM6MethodWrapper.h
12e19ca9f7188c96d8a763ab7bdecc78b2299c38
[ "BSD-3-Clause" ]
permissive
qcscine/sparrow
05fb1e53ce0addc74e84251ac73d6871f0807337
f1a1b149d7ada9ec9d5037c417fbd10884177cba
refs/heads/master
2023-05-29T21:58:56.712197
2023-05-12T06:56:50
2023-05-12T06:56:50
191,568,488
68
14
BSD-3-Clause
2021-12-15T08:19:47
2019-06-12T12:39:30
C++
UTF-8
C++
false
false
2,446
h
PM6MethodWrapper.h
/** * @file PM6MethodWrapper.h * @copyright This code is licensed under the 3-clause BSD license.\n * Copyright ETH Zurich, Laboratory of Physical Chemistry, Reiher Group.\n * See LICENSE.txt for details. */ #ifndef SPARROW_PM6METHODWRAPPER_H #define SPARROW_PM6METHODWRAPPER_H /* Internal Includes */ #include <Sparrow/Implementations/Nddo/NDDOMethodWrapper.h> #include <Sparrow/Implementations/Nddo/Pm6/PM6Method.h> /* External Includes */ #include <Utils/Technical/CloneInterface.h> #include <string> namespace Scine { namespace Sparrow { /** * @class PM6MethodWrapper PM6MethodWrapper.h * @brief A method wrapper running PM6 calculations. */ class PM6MethodWrapper final : public Utils::CloneInterface<PM6MethodWrapper, NDDOMethodWrapper, Core::Calculator> { public: static constexpr const char* model = "PM6"; /// @brief Default Constructor. PM6MethodWrapper(); // Rule of 5 PM6MethodWrapper(const PM6MethodWrapper& rhs); PM6MethodWrapper& operator=(const PM6MethodWrapper& rhs); PM6MethodWrapper(PM6MethodWrapper&& rhs) = delete; PM6MethodWrapper& operator=(PM6MethodWrapper&& rhs) = delete; /// @brief Default Destructor. ~PM6MethodWrapper() final; /** * @brief Getter for the name of the method. * @returns Returns the name of the method. */ std::string name() const final; /** * @brief Function to apply the settings to the underlying method */ void applySettings() final; /** * @brief Function to add a contribution to the electronic PM6 Hamiltonian. * @param contribution An Utils::AdditiveElectronicContribution polymorphic class. */ void addElectronicContribution(std::shared_ptr<Utils::AdditiveElectronicContribution> contribution) final; private: bool successfulCalculation() const final; Eigen::MatrixXd getOneElectronMatrix() const final; Utils::SpinAdaptedMatrix getTwoElectronMatrix() const final; Utils::DensityMatrix getDensityMatrixGuess() const final; //! Initializes a method with the parameter file present in the settings. void initialize() final; //! Returns the underlying method CISData getCISDataImpl() const final; Utils::LcaoMethod& getLcaoMethod() final; const Utils::LcaoMethod& getLcaoMethod() const final; void calculateImpl(Utils::Derivative requiredDerivative) final; nddo::PM6Method method_; }; } /* namespace Sparrow */ } /* namespace Scine */ #endif /* SPARROW_PM6METHODWRAPPER_H */
54bb69b45bba6b6edfdc835f1ed6c1bb43543717
04bcec54ac17c7254958d2bd35ea45d6402e2f92
/assignment1/qr.cpp
a53a62e3c0ad139f14dc21d29d1dcc6ff263f7b7
[]
no_license
UditSinghParihar/Parallel_Computing_Solutions
408587a2aed6c087edfd46380b0ee46069c1e2f5
1aa2c8883b15e9961008a85b3ca621dca9e2b0eb
refs/heads/master
2020-04-26T14:28:20.368740
2019-05-07T19:12:09
2019-05-07T19:12:09
173,615,286
1
0
null
null
null
null
UTF-8
C++
false
false
1,890
cpp
qr.cpp
#include <iostream> #include <cstdlib> #include <vector> #include <cmath> #include <numeric> using namespace std; void print_matrix(const vector<vector<float>>& mat){ for(auto v : mat){ for(auto element : v){ fprintf(stdout, "%9.3f", element); } cout << endl; } cout << "\n---\n"; } void fill_vector(vector<float>& col, int range){ for(int i=0; i<col.size(); ++i){ col[i] = (rand() % range) + 1; } } void print_vector(const vector<float>& vec){ for(auto element : vec){ cout << element << endl; } cout << "\n---\n"; } void fill_v(const vector<float>& x, vector<float>& v){ const int rows = x.size(); const float x_norm = sqrt(inner_product(x.begin(), x.end(), x.begin(), 0)); v[0] = 1; for(int i=1; i<rows; ++i){ v[i] = x[i]/(x[0]-x_norm); } } void get_householder(vector<vector<float>>& P, const vector<float>& v){ const int rows = P.size(); const float v_norm = sqrt(inner_product(v.begin(), v.end(), v.begin(), 0.0)); const float beta = 2/(v_norm*v_norm); for(int i=0; i<rows; ++i){ for(int j=0; j<rows; ++j){ if(i==j) P[i][j] = 1 - beta*v[i]*v[j]; else P[i][j] = -beta*v[i]*v[j]; } } } void check_householder(const vector<vector<float>>& P, const vector<float>& x){ const int rows = P.size(); vector<float> res(rows); for(int i=0; i<rows; ++i){ for(int j=0; j<rows; ++j){ res[i] += P[i][j]*x[j]; } } cout << "P*x = \n"; print_vector(res); float x_norm = sqrt(inner_product(x.begin(), x.end(), x.begin(), 0)); cout << "x_norm = " << x_norm << endl; } int main(int argc, char const *argv[]){ // 3.a : Householder const int rows=5, range=10; vector<float> x(rows); fill_vector(x, range); print_vector(x); vector<float> v(rows); fill_v(x, v); print_vector(v); vector<vector<float>> P(rows, vector<float>(rows)); get_householder(P, v); print_matrix(P); check_householder(P, x); return 0; }
dd1c60fec523d39ec883d9462cbf2841be58c313
37b5230d6fcd00b432bb9202ee9299977b11b5bf
/lib/interop-1.1.8/include/interop/logic/plot/plot_by_cycle.h
5f2a3edb0f76cbad98f5b3321a985bdbc0ec13d4
[ "MIT" ]
permissive
guillaume-gricourt/HmnIllumina
f1a19880ad969282ce3fe1265f50c0a001287e44
2a925bcb62f0595e668c324906941ab7d3064c11
refs/heads/main
2023-04-28T18:15:56.440126
2023-04-17T17:10:57
2023-04-17T17:10:57
577,830,976
0
0
MIT
2023-09-08T21:56:15
2022-12-13T16:14:48
C++
UTF-8
C++
false
false
3,081
h
plot_by_cycle.h
/** Plot an arbitrary cycle metric by cycle * * @file * @date 4/28/16 * @version 1.0 * @copyright GNU Public License. */ #pragma once #include "interop/model/run_metrics.h" #include "interop/model/plot/filter_options.h" #include "interop/model/plot/plot_data.h" #include "interop/model/plot/candle_stick_point.h" #include "interop/constants/enums.h" #include "interop/logic/utils/metrics_to_load.h" namespace illumina { namespace interop { namespace logic { namespace plot { /** Plot a specified metric value by cycle * * @ingroup plot_logic * @param metrics run metrics * @param type specific metric value to plot by cycle * @param options options to filter the data * @param data output plot data * @param skip_empty set false for testing purposes */ void plot_by_cycle(model::metrics::run_metrics& metrics, const constants::metric_type type, const model::plot::filter_options& options, model::plot::plot_data<model::plot::candle_stick_point>& data, const bool skip_empty=true) INTEROP_THROW_SPEC((model::index_out_of_bounds_exception, model::invalid_metric_type, model::invalid_channel_exception, model::invalid_filter_option, model::invalid_read_exception)); /** Plot a specified metric value by cycle using the candle stick model * * @ingroup plot_logic * @todo Is this temporary? * @param metrics run metrics * @param metric_name name of metric value to plot by cycle * @param options options to filter the data * @param data output plot data * @param skip_empty set false for testing purposes */ void plot_by_cycle(model::metrics::run_metrics& metrics, const std::string& metric_name, const model::plot::filter_options& options, model::plot::plot_data<model::plot::candle_stick_point>& data, const bool skip_empty=true) INTEROP_THROW_SPEC((model::index_out_of_bounds_exception, model::invalid_filter_option, model::invalid_channel_exception, model::invalid_metric_type)); /** List metric types available for by cycle plots * * @param types destination vector to fill with metric types * @param ignore_accumulated if true, ignore accumulated Q20 and Q30 */ void list_by_cycle_metrics(std::vector< logic::utils::metric_type_description_t > &types, const bool ignore_accumulated=false); /** Filter metric types available for by cycle plots * * @param types destination vector to fill with metric types * @param ignore_accumulated if true, ignore accumulated Q20 and Q30 */ void filter_by_cycle_metrics(std::vector< logic::utils::metric_type_description_t > &types, const bool ignore_accumulated=false); }}}}
504040a4febd68e01827df5fe54e825c2cf65db4
abe368495116213ab56e0583e1903564b5857131
/common/Block/DynamicBlockBuffer.cpp
55fc7db19f0a46e1cd192f7b9f721af93b75dc0a
[]
no_license
Jackson1992/CLAIMS
56c630d2a6e74e16e42bb9ee96b1f5257da73371
f9409a99bd75654c78091c25f0d79350693126bb
refs/heads/master
2020-05-25T11:33:16.565631
2015-11-08T13:03:15
2015-11-08T13:03:15
35,158,070
2
0
null
2015-05-06T12:48:48
2015-05-06T12:48:46
null
UTF-8
C++
false
false
2,270
cpp
DynamicBlockBuffer.cpp
/* * DynamicBlockBuffer.cpp * * Created on: Dec 20, 2013 * Author: wangli */ #include "DynamicBlockBuffer.h" //#include <assert.h> #include "BlockStream.h" DynamicBlockBuffer::DynamicBlockBuffer() { // TODO Auto-generated constructor stub } DynamicBlockBuffer::DynamicBlockBuffer(const DynamicBlockBuffer& r){ this->block_list_=r.block_list_; this->lock_=r.lock_; } DynamicBlockBuffer::~DynamicBlockBuffer() { for(unsigned i=0;i<block_list_.size();i++){ delete block_list_[i]; } } bool DynamicBlockBuffer::appendNewBlock(BlockStreamBase* new_block){ block_list_.push_back(new_block); return true; } bool DynamicBlockBuffer::atomicAppendNewBlock(BlockStreamBase* new_block){ lock_.acquire(); const bool ret=appendNewBlock(new_block); lock_.release(); return ret; } BlockStreamBase* DynamicBlockBuffer::getBlock(unsigned index)const{ if(index<block_list_.size()){ return block_list_.at(index); } return 0; } DynamicBlockBuffer::Iterator::Iterator() :cur_(0),dbb_(0){ } DynamicBlockBuffer::Iterator::Iterator(const DynamicBlockBuffer* dbb) :cur_(0),dbb_(dbb){ } DynamicBlockBuffer::Iterator::Iterator(const Iterator & it){ this->cur_=it.cur_; this->dbb_=it.dbb_; this->lock_=it.lock_; } BlockStreamBase* DynamicBlockBuffer::Iterator::nextBlock(){ BlockStreamBase* ret; ret=dbb_->getBlock(cur_); if(ret>0){ cur_++; } return ret; } BlockStreamBase* DynamicBlockBuffer::Iterator::atomicNextBlock(){ lock_.acquire(); BlockStreamBase* ret=nextBlock(); lock_.release(); return ret; } DynamicBlockBuffer::Iterator DynamicBlockBuffer::createIterator()const{ return Iterator(this); } void DynamicBlockBuffer::destory(){ DynamicBlockBuffer::Iterator it=this->createIterator(); BlockStreamBase* block_to_deallocate; while(block_to_deallocate=it.nextBlock()){ delete block_to_deallocate; } this->block_list_.clear(); } unsigned DynamicBlockBuffer::getNumberOfBlocks(){ lock_.acquire(); unsigned ret; ret= block_list_.size(); lock_.release(); return ret; } unsigned long DynamicBlockBuffer::getNumberOftuples()const{ unsigned long ret=0; DynamicBlockBuffer::Iterator it=this->createIterator(); BlockStreamBase* block; while(block=(BlockStreamBase*)it.nextBlock()){ ret+=block->getTuplesInBlock(); } return ret; }
1215c44b7cfdc4e0e5279cdccc42b48d365a8319
011359e589f99ae5fe8271962d447165e9ff7768
/src/burn/misc/pre90s/d_lwings.cpp
907b592d34168743b73779abf628b59ffc6adeec
[]
no_license
PS3emulators/fba-next-slim
4c753375fd68863c53830bb367c61737393f9777
d082dea48c378bddd5e2a686fe8c19beb06db8e1
refs/heads/master
2021-01-17T23:05:29.479865
2011-12-01T18:16:02
2011-12-01T18:16:02
2,899,840
1
0
null
null
null
null
UTF-8
C++
false
false
68,295
cpp
d_lwings.cpp
// FB Alpha "Legendary Wings" driver module // Based on MAME driver by Paul Leaman // To Do: // Missing emulation of CPU 3 && MSM5205 sound #include "tiles_generic.h" #include "burn_ym2203.h" //#define EMULATE_ADPCM static unsigned char *AllMem; static unsigned char *MemEnd; static unsigned char *AllRam; static unsigned char *RamEnd; static unsigned char *DrvZ80ROM0; static unsigned char *DrvZ80ROM1; #ifdef EMULATE_ADPCM static unsigned char *DrvZ80ROM2; #endif static unsigned char *DrvGfxROM0; static unsigned char *DrvGfxROM1; static unsigned char *DrvGfxROM2; static unsigned char *DrvGfxROM3; static unsigned char *DrvTileMap; static unsigned char *DrvGfxMask; static unsigned int *DrvPalette; static unsigned int *Palette; static unsigned char *DrvZ80RAM0; static unsigned char *DrvZ80RAM1; static unsigned char *DrvPalRAM; static unsigned char *DrvFgRAM; static unsigned char *DrvBgRAM; static unsigned char *DrvSprRAM; static unsigned char *DrvSprBuf; static unsigned char *ScrollX; static unsigned char *ScrollY; static unsigned char DrvRecalc; static unsigned char DrvReset; static unsigned char DrvJoy1[8]; static unsigned char DrvJoy2[8]; static unsigned char DrvJoy3[8]; static unsigned char DrvDip[2]; static unsigned char DrvInp[3]; static unsigned char interrupt_enable; static unsigned char soundlatch; static unsigned char flipscreen; static unsigned char DrvZ80Bank; static unsigned char avengers_param[4]; static unsigned int avengers_palette_pen; static unsigned char avengers_soundlatch2; static unsigned char avengers_soundstate; static unsigned char avengers_adpcm; static unsigned char trojan_bg2_scrollx; static unsigned char trojan_bg2_image; static int avengers = 0; static struct BurnInputInfo DrvInputList[] = { {"P1 Coin", BIT_DIGITAL, DrvJoy1 + 6, "p1 coin" }, {"P1 Start", BIT_DIGITAL, DrvJoy1 + 0, "p1 start" }, {"P1 Up", BIT_DIGITAL, DrvJoy2 + 3, "p1 up" }, {"P1 Down", BIT_DIGITAL, DrvJoy2 + 2, "p1 down" }, {"P1 Left", BIT_DIGITAL, DrvJoy2 + 1, "p1 left" }, {"P1 Right", BIT_DIGITAL, DrvJoy2 + 0, "p1 right" }, {"P1 Button 1", BIT_DIGITAL, DrvJoy2 + 4, "p1 fire 1" }, {"P1 Button 2", BIT_DIGITAL, DrvJoy2 + 5, "p1 fire 2" }, {"P2 Coin", BIT_DIGITAL, DrvJoy1 + 7, "p2 coin" }, {"P2 Start", BIT_DIGITAL, DrvJoy1 + 1, "p2 start" }, {"P2 Up", BIT_DIGITAL, DrvJoy3 + 3, "p2 up" }, {"P2 Down", BIT_DIGITAL, DrvJoy3 + 2, "p2 down" }, {"P2 Left", BIT_DIGITAL, DrvJoy3 + 1, "p2 left" }, {"P2 Right", BIT_DIGITAL, DrvJoy3 + 0, "p2 right" }, {"P2 Button 1", BIT_DIGITAL, DrvJoy3 + 4, "p2 fire 1" }, {"P2 Button 2", BIT_DIGITAL, DrvJoy3 + 5, "p2 fire 2" }, {"Reset", BIT_DIGITAL, &DrvReset, "reset" }, {"Dip A", BIT_DIPSWITCH, DrvDip + 0, "dip" }, {"Dip B", BIT_DIPSWITCH, DrvDip + 1, "dip" }, }; STDINPUTINFO(Drv) static struct BurnDIPInfo LwingsDIPList[]= { // Default Values {0x11, 0xff, 0xff, 0xfe, NULL }, {0x12, 0xff, 0xff, 0xfe, NULL }, {0 , 0xfe, 0 , 2, "Flip_Screen" }, {0x11, 0x01, 0x02, 0x02, "Off" }, {0x11, 0x01, 0x02, 0x00, "On" }, {0 , 0xfe, 0 , 4, "Lives" }, {0x11, 0x01, 0x0c, 0x0c, "3" }, {0x11, 0x01, 0x0c, 0x04, "4" }, {0x11, 0x01, 0x0c, 0x08, "5" }, {0x11, 0x01, 0x0c, 0x00, "6" }, {0 , 0xfe, 0 , 4, "Coin_B" }, {0x11, 0x01, 0x30, 0x00, "4C_1C" }, {0x11, 0x01, 0x30, 0x20, "3C_1C" }, {0x11, 0x01, 0x30, 0x10, "2C_1C" }, {0x11, 0x01, 0x30, 0x30, "1C_1C" }, {0 , 0xfe, 0 , 4, "Coin_A" }, {0x11, 0x01, 0xc0, 0xc0, "1C_1C" }, {0x11, 0x01, 0xc0, 0x00, "2C_4C" }, {0x11, 0x01, 0xc0, 0x40, "1C_2C" }, {0x11, 0x01, 0xc0, 0x80, "1C_3C" }, {0 , 0xfe, 0 , 4, "Difficulty" }, {0x12, 0x01, 0x06, 0x02, "Easy" }, {0x12, 0x01, 0x06, 0x06, "Medium" }, {0x12, 0x01, 0x06, 0x04, "Hard" }, {0x12, 0x01, 0x06, 0x00, "Hardest" }, {0 , 0xfe, 0 , 2, "Demo_Sounds" }, {0x12, 0x01, 0x08, 0x00, "Off" }, {0x12, 0x01, 0x08, 0x08, "On" }, {0 , 0xfe, 0 , 2, "Allow_Continue" }, {0x12, 0x01, 0x10, 0x00, "No" }, {0x12, 0x01, 0x10, 0x10, "Yes" }, {0 , 0xfe, 0 , 8, "Bonus_Life" }, {0x12, 0x01, 0xe0, 0xe0, "20000 and every 50000"}, {0x12, 0x01, 0xe0, 0x60, "20000 and every 60000"}, {0x12, 0x01, 0xe0, 0xa0, "20000 and every 70000"}, {0x12, 0x01, 0xe0, 0x20, "30000 and every 60000"}, {0x12, 0x01, 0xe0, 0xc0, "30000 and every 70000"}, {0x12, 0x01, 0xe0, 0x40, "30000 and every 80000"}, {0x12, 0x01, 0xe0, 0x80, "40000 and every 100000"}, {0x12, 0x01, 0xe0, 0x00, "None" }, }; STDDIPINFO(Lwings) static struct BurnDIPInfo LwingsbDIPList[]= { // Default Values {0x11, 0xff, 0xff, 0xfe, NULL }, {0x12, 0xff, 0xff, 0xfe, NULL }, {0 , 0xfe, 0 , 2, "Flip_Screen" }, {0x11, 0x01, 0x02, 0x02, "Off" }, {0x11, 0x01, 0x02, 0x00, "On" }, {0 , 0xfe, 0 , 4, "Lives" }, {0x11, 0x01, 0x0c, 0x0c, "2" }, {0x11, 0x01, 0x0c, 0x04, "3" }, {0x11, 0x01, 0x0c, 0x08, "4" }, {0x11, 0x01, 0x0c, 0x00, "5" }, {0 , 0xfe, 0 , 4, "Coin_B" }, {0x11, 0x01, 0x30, 0x00, "4C_1C" }, {0x11, 0x01, 0x30, 0x20, "3C_1C" }, {0x11, 0x01, 0x30, 0x10, "2C_1C" }, {0x11, 0x01, 0x30, 0x30, "1C_1C" }, {0 , 0xfe, 0 , 4, "Coin_A" }, {0x11, 0x01, 0xc0, 0xc0, "1C_1C" }, {0x11, 0x01, 0xc0, 0x00, "2C_4C" }, {0x11, 0x01, 0xc0, 0x40, "1C_2C" }, {0x11, 0x01, 0xc0, 0x80, "1C_3C" }, {0 , 0xfe, 0 , 4, "Difficulty" }, {0x12, 0x01, 0x06, 0x02, "Easy" }, {0x12, 0x01, 0x06, 0x06, "Medium" }, {0x12, 0x01, 0x06, 0x04, "Hard" }, {0x12, 0x01, 0x06, 0x00, "Hardest" }, {0 , 0xfe, 0 , 2, "Demo_Sounds" }, {0x12, 0x01, 0x08, 0x00, "Off" }, {0x12, 0x01, 0x08, 0x08, "On" }, {0 , 0xfe, 0 , 2, "Allow_Continue" }, {0x12, 0x01, 0x10, 0x00, "No" }, {0x12, 0x01, 0x10, 0x10, "Yes" }, {0 , 0xfe, 0 , 8, "Bonus_Life" }, {0x12, 0x01, 0xe0, 0xe0, "20000 and every 50000" }, {0x12, 0x01, 0xe0, 0x60, "20000 and every 60000" }, {0x12, 0x01, 0xe0, 0xa0, "20000 and every 70000" }, {0x12, 0x01, 0xe0, 0x20, "30000 and every 60000" }, {0x12, 0x01, 0xe0, 0xc0, "30000 and every 70000" }, {0x12, 0x01, 0xe0, 0x40, "30000 and every 80000" }, {0x12, 0x01, 0xe0, 0x80, "40000 and every 100000" }, {0x12, 0x01, 0xe0, 0x00, "None" }, }; STDDIPINFO(Lwingsb) static struct BurnDIPInfo SectionzDIPList[]= { // Default Values {0x11, 0xff, 0xff, 0xff, NULL }, {0x12, 0xff, 0xff, 0x3f, NULL }, {0 , 0xfe, 0 , 2, "Service Mode" }, {0x11, 0x01, 0x01, 0x01, "Off" }, {0x11, 0x01, 0x01, 0x00, "On" }, {0 , 0xfe, 0 , 2, "Flip_Screen" }, {0x11, 0x01, 0x02, 0x02, "Off" }, {0x11, 0x01, 0x02, 0x00, "On" }, {0 , 0xfe, 0 , 4, "Lives" }, {0x11, 0x01, 0x0c, 0x04, "2" }, {0x11, 0x01, 0x0c, 0x0c, "3" }, {0x11, 0x01, 0x0c, 0x08, "4" }, {0x11, 0x01, 0x0c, 0x00, "5" }, {0 , 0xfe, 0 , 4, "Coin_A" }, {0x11, 0x01, 0x30, 0x00, "4C_1C" }, {0x11, 0x01, 0x30, 0x20, "3C_1C" }, {0x11, 0x01, 0x30, 0x10, "2C_1C" }, {0x11, 0x01, 0x30, 0x30, "1C_1C" }, {0 , 0xfe, 0 , 4, "Coin_B" }, {0x11, 0x01, 0xc0, 0x00, "2C_1C" }, {0x11, 0x01, 0xc0, 0xc0, "1C_1C" }, {0x11, 0x01, 0xc0, 0x40, "1C_2C" }, {0x11, 0x01, 0xc0, 0x80, "1C_3C" }, {0 , 0xfe, 0 , 2, "Allow_Continue" }, {0x12, 0x01, 0x01, 0x00, "No" }, {0x12, 0x01, 0x01, 0x01, "Yes" }, {0 , 0xfe, 0 , 4, "Difficulty" }, {0x12, 0x01, 0x06, 0x02, "Easy" }, {0x12, 0x01, 0x06, 0x06, "Normal" }, {0x12, 0x01, 0x06, 0x04, "Hard" }, {0x12, 0x01, 0x06, 0x00, "Very_Hard" }, {0 , 0xfe, 0 , 8, "Bonus_Life" }, {0x12, 0x01, 0x38, 0x38, "20000 50000" }, {0x12, 0x01, 0x38, 0x18, "20000 60000" }, {0x12, 0x01, 0x38, 0x28, "20000 70000" }, {0x12, 0x01, 0x38, 0x08, "30000 60000" }, {0x12, 0x01, 0x38, 0x30, "30000 70000" }, {0x12, 0x01, 0x38, 0x10, "30000 80000" }, {0x12, 0x01, 0x38, 0x20, "40000 100000" }, {0x12, 0x01, 0x38, 0x00, "None" }, {0 , 0xfe, 0 , 3, "Cabinet" }, {0x12, 0x01, 0xc0, 0x00, "Upright One Player" }, {0x12, 0x01, 0xc0, 0x40, "Upright Two Players" }, {0x12, 0x01, 0xc0, 0xc0, "Cocktail" }, }; STDDIPINFO(Sectionz) static struct BurnDIPInfo TrojanlsDIPList[]= { // Default Values {0x11, 0xff, 0xff, 0x1c, NULL }, {0x12, 0xff, 0xff, 0xff, NULL }, {0 , 0xfe, 0 , 3, "Cabinet" }, {0x11, 0x01, 0x03, 0x00, "Upright 1 Player" }, {0x11, 0x01, 0x03, 0x02, "Upright 2 Players" }, {0x11, 0x01, 0x03, 0x03, "Cocktail" }, {0 , 0xfe, 0 , 8, "Bonus_Life" }, {0x11, 0x01, 0x1c, 0x10, "20000 60000" }, {0x11, 0x01, 0x1c, 0x0c, "20000 70000" }, {0x11, 0x01, 0x1c, 0x08, "20000 80000" }, {0x11, 0x01, 0x1c, 0x1c, "30000 60000" }, {0x11, 0x01, 0x1c, 0x18, "30000 70000" }, {0x11, 0x01, 0x1c, 0x14, "30000 80000" }, {0x11, 0x01, 0x1c, 0x04, "40000 80000" }, {0x11, 0x01, 0x1c, 0x00, "None" }, {0 , 0xfe, 0 , 4, "Coin_A" }, {0x12, 0x01, 0x03, 0x00, "2C_1C" }, {0x12, 0x01, 0x03, 0x03, "1C_1C" }, {0x12, 0x01, 0x03, 0x02, "1C_2C" }, {0x12, 0x01, 0x03, 0x01, "1C_3C" }, {0 , 0xfe, 0 , 4, "Coin_B" }, {0x12, 0x01, 0x0c, 0x00, "4C_1C" }, {0x12, 0x01, 0x0c, 0x04, "3C_1C" }, {0x12, 0x01, 0x0c, 0x08, "2C_1C" }, {0x12, 0x01, 0x0c, 0x0c, "1C_1C" }, {0 , 0xfe, 0 , 4, "Lives" }, {0x12, 0x01, 0x30, 0x20, "2" }, {0x12, 0x01, 0x30, 0x30, "3" }, {0x12, 0x01, 0x30, 0x10, "4" }, {0x12, 0x01, 0x30, 0x00, "5" }, {0 , 0xfe, 0 , 2, "Flip_Screen" }, {0x12, 0x01, 0x40, 0x40, "Off" }, {0x12, 0x01, 0x40, 0x00, "On" }, {0 , 0xfe, 0 , 2, "Allow_Continue" }, {0x12, 0x01, 0x80, 0x00, "No" }, {0x12, 0x01, 0x80, 0x80, "Yes" }, }; STDDIPINFO(Trojanls) static struct BurnDIPInfo TrojanDIPList[]= { // Default Values {0x11, 0xff, 0xff, 0xfc, NULL }, {0x12, 0xff, 0xff, 0xff, NULL }, {0 , 0xfe, 0 , 3, "Cabinet" }, {0x11, 0x01, 0x03, 0x00, "Upright 1 Player" }, {0x11, 0x01, 0x03, 0x02, "Upright 2 Players" }, {0x11, 0x01, 0x03, 0x03, "Cocktail" }, {0 , 0xfe, 0 , 8, "Bonus_Life" }, {0x11, 0x01, 0x1c, 0x10, "20000 60000" }, {0x11, 0x01, 0x1c, 0x0c, "20000 70000" }, {0x11, 0x01, 0x1c, 0x08, "20000 80000" }, {0x11, 0x01, 0x1c, 0x1c, "30000 60000" }, {0x11, 0x01, 0x1c, 0x18, "30000 70000" }, {0x11, 0x01, 0x1c, 0x14, "30000 80000" }, {0x11, 0x01, 0x1c, 0x04, "40000 80000" }, {0x11, 0x01, 0x1c, 0x00, "None" }, {0 , 0xfe, 0 , 6, "Starting Level" }, {0x11, 0x01, 0xe0, 0xe0, "1" }, {0x11, 0x01, 0xe0, 0xc0, "2" }, {0x11, 0x01, 0xe0, 0xa0, "3" }, {0x11, 0x01, 0xe0, 0x80, "4" }, {0x11, 0x01, 0xe0, 0x60, "5" }, {0x11, 0x01, 0xe0, 0x40, "6" }, {0 , 0xfe, 0 , 4, "Coin_A" }, {0x12, 0x01, 0x03, 0x00, "2C_1C" }, {0x12, 0x01, 0x03, 0x03, "1C_1C" }, {0x12, 0x01, 0x03, 0x02, "1C_2C" }, {0x12, 0x01, 0x03, 0x01, "1C_3C" }, {0 , 0xfe, 0 , 4, "Coin_B" }, {0x12, 0x01, 0x0c, 0x00, "4C_1C" }, {0x12, 0x01, 0x0c, 0x04, "3C_1C" }, {0x12, 0x01, 0x0c, 0x08, "2C_1C" }, {0x12, 0x01, 0x0c, 0x0c, "1C_1C" }, {0 , 0xfe, 0 , 4, "Lives" }, {0x12, 0x01, 0x30, 0x20, "2" }, {0x12, 0x01, 0x30, 0x30, "3" }, {0x12, 0x01, 0x30, 0x10, "4" }, {0x12, 0x01, 0x30, 0x00, "5" }, {0 , 0xfe, 0 , 2, "Flip_Screen" }, {0x12, 0x01, 0x40, 0x40, "Off" }, {0x12, 0x01, 0x40, 0x00, "On" }, {0 , 0xfe, 0 , 2, "Allow_Continue" }, {0x12, 0x01, 0x80, 0x00, "No" }, {0x12, 0x01, 0x80, 0x80, "Yes" }, }; STDDIPINFO(Trojan) static struct BurnDIPInfo AvengersDIPList[]= { // Default Values {0x11, 0xff, 0xff, 0xff, NULL }, {0x12, 0xff, 0xff, 0xff, NULL }, {0 , 0xfe, 0 , 2, "Service Mode" }, {0x12, 0x01, 0x01, 0x01, "Off" }, {0x12, 0x01, 0x01, 0x00, "On" }, {0 , 0xfe, 0 , 2, "Flip_Screen" }, {0x12, 0x01, 0x02, 0x02, "Off" }, {0x12, 0x01, 0x02, 0x00, "On" }, {0 , 0xfe, 0 , 8, "Coin_B" }, {0x12, 0x01, 0x1c, 0x00, "4C_1C" }, {0x12, 0x01, 0x1c, 0x10, "3C_1C" }, {0x12, 0x01, 0x1c, 0x08, "2C_1C" }, {0x12, 0x01, 0x1c, 0x1c, "1C_1C" }, {0x12, 0x01, 0x1c, 0x0c, "1C_2C" }, {0x12, 0x01, 0x1c, 0x14, "1C_3C" }, {0x12, 0x01, 0x1c, 0x04, "1C_4C" }, {0x12, 0x01, 0x1c, 0x18, "1C_6C" }, {0 , 0xfe, 0 , 8, "Coin_A" }, {0x12, 0x01, 0xe0, 0x00, "4C_1C" }, {0x12, 0x01, 0xe0, 0x80, "3C_1C" }, {0x12, 0x01, 0xe0, 0x40, "2C_1C" }, {0x12, 0x01, 0xe0, 0xe0, "1C_1C" }, {0x12, 0x01, 0xe0, 0x60, "1C_2C" }, {0x12, 0x01, 0xe0, 0xa0, "1C_3C" }, {0x12, 0x01, 0xe0, 0x20, "1C_4C" }, {0x12, 0x01, 0xe0, 0xc0, "1C_6C" }, {0 , 0xfe, 0 , 2, "Allow_Continue" }, {0x11, 0x01, 0x01, 0x00, "No" }, {0x11, 0x01, 0x01, 0x01, "Yes" }, {0 , 0xfe, 0 , 2, "Demo_Sounds" }, {0x11, 0x01, 0x02, 0x00, "Off" }, {0x11, 0x01, 0x02, 0x02, "On" }, {0 , 0xfe, 0 , 4, "Difficulty" }, {0x11, 0x01, 0x0c, 0x04, "Easy" }, {0x11, 0x01, 0x0c, 0x0c, "Normal" }, {0x11, 0x01, 0x0c, 0x08, "Hard" }, {0x11, 0x01, 0x0c, 0x00, "Very_Hard" }, {0 , 0xfe, 0 , 4, "Bonus_Life" }, {0x11, 0x01, 0x30, 0x30, "20k 60k" }, {0x11, 0x01, 0x30, 0x10, "20k 70k" }, {0x11, 0x01, 0x30, 0x20, "20k 80k" }, {0x11, 0x01, 0x30, 0x00, "30k 80k" }, {0 , 0xfe, 0 , 4, "Lives" }, {0x11, 0x01, 0xc0, 0xc0, "3" }, {0x11, 0x01, 0xc0, 0x40, "4" }, {0x11, 0x01, 0xc0, 0x80, "5" }, {0x11, 0x01, 0xc0, 0x00, "6" }, }; STDDIPINFO(Avengers) static int MemIndex() { unsigned char *Next; Next = AllMem; DrvZ80ROM0 = Next; Next += 0x020000; DrvZ80ROM1 = Next; Next += 0x008000; #ifdef EMULATE_ADPCM DrvZ80ROM2 = Next; Next += 0x010000; #endif DrvTileMap = Next; Next += 0x008000; DrvGfxROM0 = Next; Next += 0x020000; DrvGfxROM1 = Next; Next += 0x080000; DrvGfxROM2 = Next; Next += 0x080000; DrvGfxROM3 = Next; Next += 0x020000; DrvGfxMask = Next; Next += 0x000020; DrvPalette = (unsigned int*)Next; Next += 0x0400 * sizeof(int); AllRam = Next; DrvZ80RAM0 = Next; Next += 0x002000; DrvZ80RAM1 = Next; Next += 0x000800; DrvPalRAM = Next; Next += 0x000800; DrvFgRAM = Next; Next += 0x000800; DrvBgRAM = Next; Next += 0x000800; DrvSprRAM = Next; Next += 0x000200; DrvSprBuf = Next; Next += 0x000200; Palette = (unsigned int*)Next; Next += 0x0400 * sizeof(int); ScrollX = Next; Next += 0x000002; ScrollY = Next; Next += 0x000002; RamEnd = Next; MemEnd = Next; return 0; } // Avengers protection code ripped directly from MAME static void avengers_protection_w(unsigned char data) { int pc = ZetPc(-1); if (pc == 0x2eeb) { avengers_param[0] = data; } else if (pc == 0x2f09) { avengers_param[1] = data; } else if (pc == 0x2f26) { avengers_param[2] = data; } else if (pc == 0x2f43) { avengers_param[3] = data; } else if (pc == 0x0445) { avengers_soundstate = 0x80; soundlatch = data; } } static int avengers_fetch_paldata() { static const char pal_data[] = // page 1: 0x03,0x02,0x01,0x00 "0000000000000000" "A65486A6364676D6" "C764C777676778A7" "A574E5E5C5756AE5" "0000000000000000" "F51785D505159405" "A637B6A636269636" "F45744E424348824" "0000000000000000" "A33263B303330203" "4454848454440454" "A27242C232523632" "0000000000000000" "1253327202421102" "3386437373631373" "41A331A161715461" "0000000000000000" "1341715000711203" "4442635191622293" "5143D48383D37186" "0000000000000000" "2432423000412305" "6633343302333305" "7234A565A5A4A2A8" "0000000000000000" "46232422A02234A7" "88241624A21454A7" "A3256747A665D3AA" "0000000000000000" "070406020003050B" "0A05090504050508" "05060A090806040C" // page2: 0x07,0x06,0x05,0x04 "0000000000000000" "2472030503230534" "6392633B23433B53" "0392846454346423" "0000000000000000" "1313052405050423" "3223754805354832" "323346A38686A332" "0000000000000000" "72190723070723D2" "81394776070776D1" "A15929F25959F2F1" "0000000000000000" "650706411A2A1168" "770737C43A3A3466" "87071F013C0C3175" "0000000000000000" "2001402727302020" "4403048F4A484344" "4A050B074E0E4440" "0000000000000000" "3003800C35683130" "5304035C587C5453" "5607080C5B265550" "0000000000000000" "4801D00043854245" "6C020038669A6569" "6604050A69446764" "0000000000000000" "0504000001030504" "0A05090504060307" "04090D0507010403" // page3: 0x0b,0x0a,0x09,0x08 "0000000000000000" "685A586937F777F7" "988A797A67A7A7A7" "B8CA898DC737F787" "0000000000000000" "4738A61705150505" "8797672835250535" "7777072A25350525" "0000000000000000" "3525642404340404" "6554453554440454" "5544053634540434" "0000000000000000" "2301923203430303" "4333834383630373" "3324034473730363" "0000000000000000" "3130304000762005" "5352525291614193" "6463635483D06581" "0000000000000000" "4241415100483107" "6463631302335304" "76757415A5A077A3" "0000000000000000" "53525282A02A43AA" "76747424A31565A5" "88888536A66089A4" "0000000000000000" "05040304000D050C" "0806050604070707" "0A0A060808000C06" // page4: 0x0f,0x0e,0x0d,0x0c "0000000000000000" "3470365956342935" "5590578997554958" "73C078A8C573687A" "0000000000000000" "5355650685030604" "2427362686042607" "010A070584010508" "0000000000000000" "0208432454022403" "737A243455733406" "000D050353000307" "0000000000000000" "000A023233003202" "424C134234424204" "000F241132001105" "0000000000000000" "3031113030300030" "5152215252512051" "7273337374723272" "0000000000000000" "4141214041411041" "6263326363623162" "8385448585834383" "0000000000000000" "5153225152512051" "7375437475734273" "9598559697946495" "0000000000000000" "0205020303020102" "0407040606040304" "060A060809060506" // page5: 0x13,0x12,0x11,0x10 "0000000000000000" "4151D141D3D177F7" "5454C44482C4A7A7" "0404D45491D4F787" "0000000000000000" "0303032374230505" "9696962673560535" "0505054502850525" "0000000000000000" "0303030355030404" "7777770754470454" "0606060603760434" "0000000000000000" "0505053547050303" "4949492945390373" "0808083804580363" "0000000000000000" "0B0C444023442005" "3D3F333433334193" "0000043504046581" "0000000000000000" "0809565085863107" "0B6A352374455304" "00700644050677A3" "0000000000000000" "06073879C8C843AA" "09492739A58765A5" "0050084A060889A4" "0000000000000000" "05060B070B0B050C" "0707090707090707" "00000B08070B0C06" // page6: 0x17,0x16,0x15,0x14 "0000000000000000" "0034308021620053" "0034417042512542" "0034526064502E31" "0000000000000000" "0106412032733060" "11A6522053628350" "22A6632072620D42" "0000000000000000" "1308223052242080" "2478233071235170" "3578243090230960" "0000000000000000" "2111334333331404" "3353324232324807" "45B5314131310837" "0000000000000000" "3232445444445302" "445443534343B725" "567642524242B745" "0000000000000000" "4343556555550201" "5575546454540524" "6787536353537554" "0000000000000000" "6474667676660100" "7696657575650423" "88A8647474645473" "0000000000000000" "0001070701050004" "0003060603040303" "0005050505040302"; int bank = avengers_palette_pen/64; int offs = avengers_palette_pen%64; int page = bank/4; // 0..7 int base = (3-(bank&3)); // 0..3 int row = offs&0xf; // 0..15 int col = offs/16 + base*4; // 0..15 int digit0 = pal_data[page*256*2 + (31-row*2)*16+col]; int digit1 = pal_data[page*256*2 + (30-row*2)*16+col]; int result; if( digit0>='A' ) digit0 += 10 - 'A'; else digit0 -= '0'; if( digit1>='A' ) digit1 += 10 - 'A'; else digit1 -= '0'; result = digit0 * 16 + digit1; if( (avengers_palette_pen&0x3f)!=0x3f ) avengers_palette_pen++; return result; } static unsigned char avengers_protection_r() { static const int xpos[8] = { 10, 7, 0, -7, -10, -7, 0, 7 }; static const int ypos[8] = { 0, 7, 10, 7, 0, -7, -10, -7 }; int best_dist = 0; int best_dir = 0; int x,y; int dx,dy,dist,dir; if(ZetPc(-1) == 0x7c7 ) { // palette data return avengers_fetch_paldata(); } // Point to Angle Function // // Input: two cartesian points // Output: direction code (north,northeast,east,...) // x = avengers_param[0] - avengers_param[2]; y = avengers_param[1] - avengers_param[3]; for( dir=0; dir<8; dir++ ) { dx = xpos[dir]-x; dy = ypos[dir]-y; dist = dx*dx+dy*dy; if( dist < best_dist || dir==0 ) { best_dir = dir; best_dist = dist; } } return best_dir<<5; } unsigned char __fastcall lwings_main_read(unsigned short address) { switch (address) { case 0xf808: case 0xf809: case 0xf80a: return DrvInp[address - 0xf808]; case 0xf80b: case 0xf80c: return DrvDip[address - 0xf80b]; case 0xf80d: return avengers_protection_r(); } return 0; } static void lwings_bankswitch_w(unsigned char data) { DrvZ80Bank = data; int bankaddress = 0x10000 + ((data >> 1) & 3) * 0x4000; ZetMapArea(0x8000, 0xbfff, 0, DrvZ80ROM0 + bankaddress); ZetMapArea(0x8000, 0xbfff, 2, DrvZ80ROM0 + bankaddress); } void __fastcall lwings_main_write(unsigned short address, unsigned char data) { if ((address & 0xf800) == 0xf000) { DrvPalRAM[address & 0x7ff] = data; unsigned char r, g, b; unsigned short coldata = DrvPalRAM[(address & 0x3ff) | 0x400] | (DrvPalRAM[address & 0x3ff] << 8); r = (coldata >> 8) & 0xf0; g = (coldata >> 4) & 0xf0; b = (coldata >> 0) & 0xf0; r |= r >> 4; g |= g >> 4; b |= b >> 4; Palette[address & 0x3ff] = (r << 16) | (g << 8) | b; DrvPalette[address & 0x3ff] = BurnHighCol(r, g, b, 0); return; } // hack if (avengers && (address & 0xfff8) == 0xf808) address += 0x10; switch (address) { case 0xf800: case 0xf801: case 0xf808: case 0xf809: ScrollX[address & 1] = data; return; case 0xf802: case 0xf803: case 0xf80a: case 0xf80b: ScrollY[address & 1] = data; return; case 0xf804: trojan_bg2_scrollx = data; return; case 0xf805: trojan_bg2_image = data; return; case 0xf80c: soundlatch = data; return; case 0xf80d: // watchdog return; case (0xf80e + 0x10): case 0xf80e: lwings_bankswitch_w(data); flipscreen = ~data & 0x01; interrupt_enable = data & 0x08; return; case (0xf809 + 0x10): avengers_protection_w(data); return; case (0xf80c + 0x10): avengers_palette_pen = data << 6; return; case (0xf80d + 0x10): avengers_adpcm = data; return; } } void __fastcall lwings_sound_write(unsigned short address, unsigned char data) { switch (address) { case 0xe000: case 0xe001: case 0xe002: case 0xe003: BurnYM2203Write((address & 2) >> 1, address & 1, data); return; case 0xe006: avengers_soundlatch2 = data; return; } } unsigned char __fastcall lwings_sound_read(unsigned short address) { switch (address) { case 0xc800: return soundlatch; case 0xe006: return avengers_soundlatch2; } return 0; } #ifdef EMULATE_ADPCM void __fastcall trojan_adpcm_out(unsigned short /*port*/, unsigned char /*data*/) { #if 0 if ((port & 0xff) == 0x01) { msm5205_reset_w(offset,(data>>7)&1); msm5205_data_w(offset,data); msm5205_vclk_w(offset,1); msm5205_vclk_w(offset,0); } #endif } unsigned char __fastcall trojan_adpcm_in(unsigned short port) { port &= 0xff; unsigned char ret = 0; if (port == 0x00) { if (avengers) { ret = avengers_soundlatch2 | avengers_soundstate; avengers_soundstate = 0; } else { ret = soundlatch; } } return ret; } #endif static int DrvDoReset() { DrvReset = 0; memset (AllRam, 0, RamEnd - AllRam); for (int i = 0; i < 3; i++) { ZetOpen(i); ZetReset(); if (i == 0) lwings_bankswitch_w(0); ZetClose(); } BurnYM2203Reset(); trojan_bg2_scrollx = 0; trojan_bg2_image = 0; memset(avengers_param, 0, 4); avengers_palette_pen = 0; avengers_soundlatch2 = 0; avengers_soundstate = 0; avengers_adpcm = 0; DrvZ80Bank = 0; flipscreen = 0; interrupt_enable = 0; soundlatch = 0; return 0; } static int DrvGfxDecode() { int Plane0[2] = { 0x000000, 0x000004 }; int Plane1[4] = { 0x080004, 0x080000, 0x000004, 0x000000 }; int Plane1a[4] = { 0x100004, 0x100000, 0x000004, 0x000000 }; int Plane2[4] = { 0x180000, 0x100000, 0x080000, 0x000000 }; int Plane3[4] = { 0x040000, 0x040004, 0x000000, 0x000004 }; // sprite, char int XOffs0[16] = { 0, 1, 2, 3, 8, 9, 10, 11, 256, 257, 258, 259, 264, 265, 266, 267 }; int YOffs0[16] = { 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240 }; // background int XOffs1[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 128, 129, 130, 131, 132, 133, 134, 135 }; int YOffs1[16] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 }; unsigned char *tmp = (unsigned char*)malloc(0x40000); if (tmp == NULL) { return 1; } memcpy (tmp, DrvGfxROM0, 0x08000); GfxDecode(0x0800, 2, 8, 8, Plane0, XOffs0, YOffs0, 0x080, tmp, DrvGfxROM0); memcpy (tmp, DrvGfxROM1, 0x40000); GfxDecode(0x0800, 4, 16, 16, Plane2, XOffs1, YOffs1, 0x100, tmp, DrvGfxROM1); memcpy (tmp, DrvGfxROM2, 0x40000); if (DrvTileMap != NULL) { GfxDecode(0x0800, 4, 16, 16, Plane1a, XOffs0, YOffs0, 0x200, tmp, DrvGfxROM2); memcpy (tmp, DrvGfxROM3, 0x10000); GfxDecode(0x0200, 4, 16, 16, Plane3, XOffs0, YOffs0, 0x200, tmp, DrvGfxROM3); } else { GfxDecode(0x0400, 4, 16, 16, Plane1, XOffs0, YOffs0, 0x200, tmp, DrvGfxROM2); } free (tmp); return 0; } static inline int DrvSynchroniseStream(int nSoundRate) { return (long long)(ZetTotalCycles() * nSoundRate / 4000000); } static inline double DrvGetTime() { return (double)ZetTotalCycles() / 4000000; } static void lwings_main_cpu_init() { ZetOpen(0); ZetMapArea(0x0000, 0x7fff, 0, DrvZ80ROM0); ZetMapArea(0x0000, 0x7fff, 2, DrvZ80ROM0); // 8000 - bfff banked ZetMapArea(0xc000, 0xddff, 0, DrvZ80RAM0); ZetMapArea(0xc000, 0xddff, 1, DrvZ80RAM0); ZetMapArea(0xc000, 0xddff, 2, DrvZ80RAM0); ZetMapArea(0xde00, 0xdfff, 0, DrvSprRAM); ZetMapArea(0xde00, 0xdfff, 1, DrvSprRAM); ZetMapArea(0xde00, 0xdfff, 2, DrvSprRAM); ZetMapArea(0xe000, 0xe7ff, 0, DrvFgRAM); ZetMapArea(0xe000, 0xe7ff, 1, DrvFgRAM); ZetMapArea(0xe000, 0xe7ff, 2, DrvFgRAM); ZetMapArea(0xe800, 0xefff, 0, DrvBgRAM); ZetMapArea(0xe800, 0xefff, 1, DrvBgRAM); ZetMapArea(0xe800, 0xefff, 2, DrvBgRAM); ZetMapArea(0xf000, 0xf7ff, 0, DrvPalRAM); // ZetMapArea(0xf000, 0xf7ff, 1, DrvPalRAM); // write handler ZetMapArea(0xf000, 0xf7ff, 2, DrvPalRAM); ZetSetReadHandler(lwings_main_read); ZetSetWriteHandler(lwings_main_write); ZetMemEnd(); ZetClose(); } static void lwings_sound_init() { ZetOpen(1); ZetMapArea(0x0000, 0x7fff, 0, DrvZ80ROM1); ZetMapArea(0x0000, 0x7fff, 2, DrvZ80ROM1); ZetMapArea(0xc000, 0xc7ff, 0, DrvZ80RAM1); ZetMapArea(0xc000, 0xc7ff, 1, DrvZ80RAM1); ZetMapArea(0xc000, 0xc7ff, 2, DrvZ80RAM1); ZetSetReadHandler(lwings_sound_read); ZetSetWriteHandler(lwings_sound_write); ZetMemEnd(); ZetClose(); BurnYM2203Init(2, 1500000, NULL, DrvSynchroniseStream, DrvGetTime, 0); BurnTimerAttachZet(4000000); } static int DrvInit() { AllMem = NULL; MemIndex(); int nLen = MemEnd - (unsigned char *)0; if ((AllMem = (unsigned char *)malloc(nLen)) == NULL) return 1; memset(AllMem, 0, nLen); MemIndex(); DrvTileMap = NULL; { if (BurnLoadRom(DrvZ80ROM0 + 0x00000, 0, 1)) return 1; if (BurnLoadRom(DrvZ80ROM0 + 0x10000, 1, 1)) return 1; if (BurnLoadRom(DrvZ80ROM0 + 0x18000, 2, 1)) return 1; if (BurnLoadRom(DrvZ80ROM1 + 0x00000, 3, 1)) return 1; if (BurnLoadRom(DrvGfxROM0 + 0x00000, 4, 1)) return 1; for (int i = 0; i < 8; i++) { if (BurnLoadRom(DrvGfxROM1 + i * 0x8000, i + 5, 1)) return 1; } for (int i = 0; i < 4; i++) { if (BurnLoadRom(DrvGfxROM2 + i * 0x8000, i + 13, 1)) return 1; } DrvGfxDecode(); } ZetInit(3); lwings_main_cpu_init(); lwings_sound_init(); GenericTilesInit(); DrvDoReset(); return 0; } static int TrojanInit() { AllMem = NULL; MemIndex(); int nLen = MemEnd - (unsigned char *)0; if ((AllMem = (unsigned char *)malloc(nLen)) == NULL) return 1; memset(AllMem, 0, nLen); MemIndex(); { if (BurnLoadRom(DrvZ80ROM0 + 0x00000, 0, 1)) return 1; if (BurnLoadRom(DrvZ80ROM0 + 0x10000, 1, 1)) return 1; if (BurnLoadRom(DrvZ80ROM0 + 0x18000, 2, 1)) return 1; if (BurnLoadRom(DrvZ80ROM1 + 0x00000, 3, 1)) return 1; #ifdef EMULATE_ADPCM if (BurnLoadRom(DrvZ80ROM2 + 0x00000, 4, 1)) return 1; #endif if (BurnLoadRom(DrvGfxROM0 + 0x00000, 5, 1)) return 1; for (int i = 0; i < 8; i++) { if (BurnLoadRom(DrvGfxROM1 + i * 0x8000, i + 6, 1)) return 1; if (BurnLoadRom(DrvGfxROM2 + i * 0x8000, i + 14, 1)) return 1; } if (BurnLoadRom(DrvGfxROM3 + 0x0000, 22, 1)) return 1; if (BurnLoadRom(DrvGfxROM3 + 0x8000, 23, 1)) return 1; if (BurnLoadRom(DrvTileMap, 24, 1)) return 1; DrvGfxDecode(); { for (int i = 0; i < 32; i++) { DrvGfxMask[i] = (0xf07f0001 & (1 << i)) ? 1 : 0; } } } ZetInit(3); lwings_main_cpu_init(); lwings_sound_init(); #ifdef EMULATE_ADPCM ZetOpen(2); ZetMapArea(0x0000, 0xffff, 0, DrvZ80ROM2); ZetMapArea(0x0000, 0xffff, 2, DrvZ80ROM2); ZetSetInHandler(trojan_adpcm_in); ZetSetOutHandler(trojan_adpcm_out); ZetMemEnd(); ZetClose(); #endif GenericTilesInit(); DrvDoReset(); return 0; } static int DrvExit() { GenericTilesExit(); ZetExit(); free (AllMem); AllMem = NULL; avengers = 0; return 0; } static void draw_foreground(int colbase) { for (int offs = 0x20; offs < 0x3e0; offs++) { int sx = (offs & 0x1f) << 3; int sy = (offs >> 5) << 3; int color = DrvFgRAM[offs | 0x400]; int code = DrvFgRAM[offs] | ((color & 0xc0) << 2); int flipx = color & 0x10; int flipy = color & 0x20; color &= 0x0f; sy -= 8; if (flipy) { if (flipx) { Render8x8Tile_Mask_FlipXY(pTransDraw, code, sx, sy, color, 2, 0x03, colbase, DrvGfxROM0); } else { Render8x8Tile_Mask_FlipY(pTransDraw, code, sx, sy, color, 2, 0x03, colbase, DrvGfxROM0); } } else { if (flipx) { Render8x8Tile_Mask_FlipX(pTransDraw, code, sx, sy, color, 2, 0x03, colbase, DrvGfxROM0); } else { Render8x8Tile_Mask(pTransDraw, code, sx, sy, color, 2, 0x03, colbase, DrvGfxROM0); } } } } static void draw_background() { int scrollx = (ScrollX[0] | (ScrollX[1] << 8)) & 0x1ff; int scrolly = (ScrollY[0] | (ScrollY[1] << 8)) & 0x1ff; for (int offs = 0; offs < 0x400; offs++) { int sy = (offs & 0x1f) << 4; int sx = (offs >> 5) << 4; sy -= 8; sx -= scrollx; sy -= scrolly; if (sx < -15) sx += 512; if (sy < -15) sy += 512; if (sy < -15 || sx < -15 || sy >= nScreenHeight || sx >= nScreenWidth) continue; int color = DrvBgRAM[offs | 0x400]; int code = DrvBgRAM[offs] | (color & 0xe0) << 3;; int flipx = color & 0x08; int flipy = color & 0x10; color &= 0x07; if (flipy) { if (flipx) { Render16x16Tile_FlipXY_Clip(pTransDraw, code, sx, sy, color, 4, 0, DrvGfxROM1); } else { Render16x16Tile_FlipY_Clip(pTransDraw, code, sx, sy, color, 4, 0, DrvGfxROM1); } } else { if (flipx) { Render16x16Tile_FlipX_Clip(pTransDraw, code, sx, sy, color, 4, 0, DrvGfxROM1); } else { Render16x16Tile_Clip(pTransDraw, code, sx, sy, color, 4, 0, DrvGfxROM1); } } } } static void lwings_draw_sprites() { for (int offs = 0x200 - 4; offs >= 0; offs -= 4) { int sx = DrvSprBuf[offs + 3] - 0x100 * (DrvSprBuf[offs + 1] & 0x01); int sy = DrvSprBuf[offs + 2]; if (sy && sx) { int code,color,flipx,flipy; if (sy > 0xf8) sy-=0x100; code = DrvSprBuf[offs] | ((DrvSprBuf[offs + 1] & 0xc0) << 2); color = (DrvSprBuf[offs + 1] & 0x38) >> 3; flipx = DrvSprBuf[offs + 1] & 0x02; flipy = DrvSprBuf[offs + 1] & 0x04; color += 0x18; sy -= 8; if (flipy) { if (flipx) { Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, code, sx, sy, color, 4, 0x0f, 0, DrvGfxROM2); } else { Render16x16Tile_Mask_FlipY_Clip(pTransDraw, code, sx, sy, color, 4, 0x0f, 0, DrvGfxROM2); } } else { if (flipx) { Render16x16Tile_Mask_FlipX_Clip(pTransDraw, code, sx, sy, color, 4, 0x0f, 0, DrvGfxROM2); } else { Render16x16Tile_Mask_Clip(pTransDraw, code, sx, sy, color, 4, 0x0f, 0, DrvGfxROM2); } } } } } static void draw_16x16_with_mask(int sx, int sy, int code, int color, unsigned char *gfxbase, unsigned char *mask, int flipx, int flipy) { unsigned char *src = gfxbase + (code << 8); color = (color << 4) | 0x100; if (flipy) { src += 0xf0; if (flipx) { for (int y = 15; y >= 0; y--, src-=16) { int yy = sy + y; if (yy < 0) break; if (yy >= nScreenHeight) continue; for (int x = 15; x >= 0; x--) { int xx = sx + x; if (xx < 0) break; if (xx >= nScreenWidth) continue; int o = color | src[15-x]; if (mask[src[15-x]]) continue; pTransDraw[(yy * nScreenWidth) + xx] = o; } } } else { for (int y = 15; y >= 0; y--, src-=16) { int yy = sy + y; if (yy < 0) break; if (yy >= nScreenHeight) continue; for (int x = 0; x < 16; x++) { int xx = sx + x; if (xx < 0) continue; if (xx >= nScreenWidth) break; int o = color | src[x]; if (mask[src[x]]) continue; pTransDraw[(yy * nScreenWidth) + xx] = o; } } } } else { if (flipx) { for (int y = 0; y < 16; y++, src+=16) { int yy = sy + y; if (yy < 0) continue; if (yy >= nScreenHeight) break; for (int x = 15; x >= 0; x--) { int xx = sx + x; if (xx < 0) break; if (xx >= nScreenWidth) continue; int o = color | src[15-x]; if (mask[src[15-x]]) continue; pTransDraw[(yy * nScreenWidth) + xx] = o; } } } else { for (int y = 0; y < 16; y++, src+=16) { int yy = sy + y; if (yy < 0) continue; if (yy >= nScreenHeight) break; for (int x = 0; x < 16; x++) { int xx = sx + x; if (xx < 0) continue; if (xx >= nScreenWidth) break; int o = color | src[x]; if (mask[src[x]]) continue; pTransDraw[(yy * nScreenWidth) + xx] = o; } } } } } static void trojan_draw_background(int priority) { int scrollx = (ScrollX[0] | (ScrollX[1] << 8)) & 0x1ff; int scrolly = (ScrollY[0] | (ScrollY[1] << 8)) & 0x1ff; for (int offs = 0; offs < 0x400; offs++) { int color = DrvBgRAM[offs | 0x400]; if (priority && ((~color >> 3) & 1)) continue; int sy = (offs & 0x1f) << 4; int sx = (offs >> 5) << 4; sy -= 8; sx -= scrollx; sy -= scrolly; if (sx < -15) sx += 512; if (sy < -15) sy += 512; if (sy < -15 || sx < -15 || sy >= nScreenHeight || sx >= nScreenWidth) continue; int code = DrvBgRAM[offs] | ((color & 0xe0) << 3); int flipx = color & 0x10; int flipy = 0; color &= 0x07; if (avengers) color ^= 6; draw_16x16_with_mask(sx, sy, code, color, DrvGfxROM1, DrvGfxMask + priority * 16, flipx, flipy); /* if (flipy) { if (flipx) { Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, code, sx, sy, color, 4, 0x00, 0x100, DrvGfxROM1); } else { Render16x16Tile_Mask_FlipY_Clip(pTransDraw, code, sx, sy, color, 4, 0x00, 0x100, DrvGfxROM1); } } else { if (flipx) { Render16x16Tile_Mask_FlipX_Clip(pTransDraw, code, sx, sy, color, 4, 0x00, 0x100, DrvGfxROM1); } else { Render16x16Tile_Mask_Clip(pTransDraw, code, sx, sy, color, 4, 0x00, 0x100, DrvGfxROM1); } } */ } } static void trojan_draw_background2() { for (int offs = 0; offs < 32 * 16; offs++) { int sx = (offs & 0x1f) << 4; int sy = (offs >> 5) << 4; sx -= trojan_bg2_scrollx; if (sx < -15) sx += 512; sy -= 8; if (sy < -15 || sx < -15 || sy >= nScreenHeight || sx >= nScreenWidth) continue; int offset = ((((offs << 6) & 0x7800) | ((offs << 1) & 0x3e)) + (trojan_bg2_image << 5)) & 0x7fff; int color = DrvTileMap[offset + 1]; int code = DrvTileMap[offset + 0] | ((color & 0x80) << 1); int flipx = color & 0x10; int flipy = color & 0x20; color &= 7; if (flipy) { if (flipx) { Render16x16Tile_FlipXY_Clip(pTransDraw, code, sx, sy, color, 4, 0, DrvGfxROM3); } else { Render16x16Tile_FlipY_Clip(pTransDraw, code, sx, sy, color, 4, 0, DrvGfxROM3); } } else { if (flipx) { Render16x16Tile_FlipX_Clip(pTransDraw, code, sx, sy, color, 4, 0, DrvGfxROM3); } else { Render16x16Tile_Clip(pTransDraw, code, sx, sy, color, 4, 0, DrvGfxROM3); } } } } static void trojan_draw_sprites() { for (int offs = 0x180 - 4; offs >= 0; offs -= 4) { int sx = DrvSprBuf[offs + 3] - 0x100 * (DrvSprBuf[offs + 1] & 0x01); int sy = DrvSprBuf[offs + 2]; if (sy && sx) { int flipx, flipy; if (sy > 0xf8) sy-=0x100; int color = DrvSprBuf[offs + 1]; int code = DrvSprBuf[offs] | ((color & 0x20) << 4) | ((color & 0x40) << 2) | ((color & 0x80) << 3); if (avengers) { flipx = 0; flipy = ~color & 0x10; } else { flipx = color & 0x10; flipy = 1; } color = ((color >> 1) & 7) + 0x28; sy -= 8; if (flipy) { if (flipx) { Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, code, sx, sy, color, 4, 0x0f, 0, DrvGfxROM2); } else { Render16x16Tile_Mask_FlipY_Clip(pTransDraw, code, sx, sy, color, 4, 0x0f, 0, DrvGfxROM2); } } else { if (flipx) { Render16x16Tile_Mask_FlipX_Clip(pTransDraw, code, sx, sy, color, 4, 0x0f, 0, DrvGfxROM2); } else { Render16x16Tile_Mask_Clip(pTransDraw, code, sx, sy, color, 4, 0x0f, 0, DrvGfxROM2); } } } } } static int DrvDraw() { if (DrvRecalc) { for (int i = 0; i < 0x400; i++) { int rgb = Palette[i]; DrvPalette[i] = BurnHighCol(rgb >> 16, rgb >> 8, rgb, 0); } } if (DrvTileMap == NULL) { draw_background(); lwings_draw_sprites(); draw_foreground(0x200); } else { trojan_draw_background2(); trojan_draw_background(0); trojan_draw_sprites(); trojan_draw_background(1); draw_foreground(0x300); } if (flipscreen) { unsigned short *ptr = pTransDraw + (nScreenWidth * nScreenHeight) - 1; for (int i = 0; i < nScreenWidth * nScreenHeight / 2; i++, ptr--) { int n = pTransDraw[i]; pTransDraw[i] = *ptr; *ptr = n; } } BurnTransferCopy(DrvPalette); return 0; } static int DrvFrame() { if (DrvReset) { DrvDoReset(); } { memset (DrvInp, 0xff, 3); for (int i = 0; i < 8; i++) { DrvInp[0] ^= (DrvJoy1[i] & 1) << i; DrvInp[1] ^= (DrvJoy2[i] & 1) << i; DrvInp[2] ^= (DrvJoy3[i] & 1) << i; } if ((DrvInp[1] & 0x03) == 0) DrvInp[1] |= 0x03; if ((DrvInp[1] & 0x0c) == 0) DrvInp[1] |= 0x0c; if ((DrvInp[2] & 0x03) == 0) DrvInp[2] |= 0x03; if ((DrvInp[2] & 0x0c) == 0) DrvInp[2] |= 0x0c; } int nInterleave = 16; int nSoundBufferPos = 0; int nCyclesTotal[3] = { 6000000 / 60, 4000000 / 60, 4000000 / 60 }; for (int i = 0; i < nInterleave; i++) { int nSegment; ZetOpen(0); nSegment = nCyclesTotal[0] / (nInterleave - i); nCyclesTotal[0] -= ZetRun(nSegment); if (interrupt_enable && i == (nInterleave - 1)) { if (avengers & 1) { ZetNmi(); } else { // ZetRaiseIrq(0xd7); ZetSetVector(0xd7); ZetRaiseIrq(0); } } ZetClose(); ZetOpen(1); nSegment = nCyclesTotal[1] / (nInterleave - i); nCyclesTotal[1] -= ZetRun(nSegment); if ((i % (nInterleave / 4)) == ((nInterleave / 4)-1)) ZetRaiseIrq(0); ZetClose(); #ifdef EMULATE_ADPCM ZetOpen(2); nSegment = nCyclesTotal[2] / (nInterleave - 1); nCyclesTotal[2] -= ZetRun(nSegment); ZetRaiseIrq(0); // should be every 4000 ZetClose(); #endif if (pBurnSoundOut) { int nSegmentLength = nBurnSoundLen - nSoundBufferPos; short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); ZetOpen(1); BurnYM2203Update(pSoundBuf, nSegmentLength); ZetClose(); nSoundBufferPos += nSegmentLength; } } if (pBurnSoundOut) { int nSegmentLength = nBurnSoundLen - nSoundBufferPos; short* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1); if (nSegmentLength) { ZetOpen(1); BurnYM2203Update(pSoundBuf, nSegmentLength); ZetClose(); } } ZetOpen(1); BurnTimerEndFrame(nCyclesTotal[1]); ZetClose(); if (pBurnDraw) { DrvDraw(); } memcpy (DrvSprBuf, DrvSprRAM, 0x200); return 0; } static int DrvScan(int nAction, int *pnMin) { struct BurnArea ba; if (pnMin != NULL) { *pnMin = 0x029692; } if (nAction & ACB_MEMORY_RAM) { memset(&ba, 0, sizeof(ba)); ba.Data = AllRam; ba.nLen = RamEnd-AllRam; ba.szName = "All Ram"; BurnAcb(&ba); } if (nAction & ACB_DRIVER_DATA) { ZetScan(nAction); BurnYM2203Scan(nAction, pnMin); SCAN_VAR(interrupt_enable); SCAN_VAR(soundlatch); SCAN_VAR(flipscreen); SCAN_VAR(DrvZ80Bank); SCAN_VAR(*((unsigned int*)avengers_param)); SCAN_VAR(avengers_palette_pen); SCAN_VAR(avengers_soundlatch2); SCAN_VAR(avengers_soundstate); SCAN_VAR(avengers_adpcm); SCAN_VAR(trojan_bg2_scrollx); SCAN_VAR(trojan_bg2_image); } ZetOpen(0); lwings_bankswitch_w(DrvZ80Bank); ZetClose(); return 0; } // Section Z (set 1) static struct BurnRomInfo sectionzRomDesc[] = { { "6c_sz01.bin", 0x8000, 0x69585125, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code { "7c_sz02.bin", 0x8000, 0x22f161b8, 1 | BRF_PRG | BRF_ESS }, // 1 { "9c_sz03.bin", 0x8000, 0x4c7111ed, 1 | BRF_PRG | BRF_ESS }, // 2 { "11e_sz04.bin", 0x8000, 0xa6073566, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code { "9h_sz05.bin", 0x4000, 0x3173ba2e, 4 | BRF_GRA }, // 4 Characters { "3e_sz14.bin", 0x8000, 0x63782e30, 5 | BRF_GRA }, // 5 Background Layer 1 Tiles { "1e_sz08.bin", 0x8000, 0xd57d9f13, 5 | BRF_GRA }, // 6 { "3d_sz13.bin", 0x8000, 0x1b3d4d7f, 5 | BRF_GRA }, // 7 { "1d_sz07.bin", 0x8000, 0xf5b3a29f, 5 | BRF_GRA }, // 8 { "3b_sz12.bin", 0x8000, 0x11d47dfd, 5 | BRF_GRA }, // 9 { "1b_sz06.bin", 0x8000, 0xdf703b68, 5 | BRF_GRA }, // 10 { "3f_sz15.bin", 0x8000, 0x36bb9bf7, 5 | BRF_GRA }, // 11 { "1f_sz09.bin", 0x8000, 0xda8f06c9, 5 | BRF_GRA }, // 12 { "3j_sz17.bin", 0x8000, 0x8df7b24a, 6 | BRF_GRA }, // 13 Sprites { "1j_sz11.bin", 0x8000, 0x685d4c54, 6 | BRF_GRA }, // 14 { "3h_sz16.bin", 0x8000, 0x500ff2bb, 6 | BRF_GRA }, // 15 { "1h_sz10.bin", 0x8000, 0x00b3d244, 6 | BRF_GRA }, // 16 { "mb7114e.15g", 0x0100, 0xd96bcc98, 0 | BRF_OPT }, // 17 Proms (not used) }; STD_ROM_PICK(sectionz) STD_ROM_FN(sectionz) struct BurnDriver BurnDrvSectionz = { "sectionz", NULL, NULL, "1985", "Section Z (set 1)\0", NULL, "Capcom", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING, 2, HARDWARE_MISC_MISC, NULL, sectionzRomInfo, sectionzRomName, DrvInputInfo, SectionzDIPInfo, DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 256, 240, 4, 3 }; // Section Z (set 2) static struct BurnRomInfo sectionzaRomDesc[] = { { "sz-01a.bin", 0x8000, 0x98df49fd, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code { "7c_sz02.bin", 0x8000, 0x22f161b8, 1 | BRF_PRG | BRF_ESS }, // 1 { "sz-03j.bin", 0x8000, 0x94547abf, 1 | BRF_PRG | BRF_ESS }, // 2 { "11e_sz04.bin", 0x8000, 0xa6073566, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code { "9h_sz05.bin", 0x4000, 0x3173ba2e, 4 | BRF_GRA }, // 4 Characters { "3e_sz14.bin", 0x8000, 0x63782e30, 5 | BRF_GRA }, // 5 Background Layer 1 Tiles { "1e_sz08.bin", 0x8000, 0xd57d9f13, 5 | BRF_GRA }, // 6 { "3d_sz13.bin", 0x8000, 0x1b3d4d7f, 5 | BRF_GRA }, // 7 { "1d_sz07.bin", 0x8000, 0xf5b3a29f, 5 | BRF_GRA }, // 8 { "3b_sz12.bin", 0x8000, 0x11d47dfd, 5 | BRF_GRA }, // 9 { "1b_sz06.bin", 0x8000, 0xdf703b68, 5 | BRF_GRA }, // 10 { "3f_sz15.bin", 0x8000, 0x36bb9bf7, 5 | BRF_GRA }, // 11 { "1f_sz09.bin", 0x8000, 0xda8f06c9, 5 | BRF_GRA }, // 12 { "3j_sz17.bin", 0x8000, 0x8df7b24a, 6 | BRF_GRA }, // 13 Sprites { "1j_sz11.bin", 0x8000, 0x685d4c54, 6 | BRF_GRA }, // 14 { "3h_sz16.bin", 0x8000, 0x500ff2bb, 6 | BRF_GRA }, // 15 { "1h_sz10.bin", 0x8000, 0x00b3d244, 6 | BRF_GRA }, // 16 { "mb7114e.15g", 0x0100, 0xd96bcc98, 0 | BRF_OPT }, // 17 Proms (not used) }; STD_ROM_PICK(sectionza) STD_ROM_FN(sectionza) struct BurnDriver BurnDrvSectionza = { "sectionza", "sectionz", NULL, "1985", "Section Z (set 2)\0", NULL, "Capcom", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_MISC, NULL, sectionzaRomInfo, sectionzaRomName, DrvInputInfo, SectionzDIPInfo, DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 256, 240, 4, 3 }; // Legendary Wings (US set 1) static struct BurnRomInfo lwingsRomDesc[] = { { "6c_lw01.bin", 0x8000, 0xb55a7f60, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code { "7c_lw02.bin", 0x8000, 0xa5efbb1b, 1 | BRF_PRG | BRF_ESS }, // 1 { "9c_lw03.bin", 0x8000, 0xec5cc201, 1 | BRF_PRG | BRF_ESS }, // 2 { "11e_lw04.bin", 0x8000, 0xa20337a2, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code { "9h_lw05.bin", 0x4000, 0x091d923c, 4 | BRF_GRA }, // 4 Characters { "3e_lw14.bin", 0x8000, 0x5436392c, 5 | BRF_GRA }, // 5 Background Layer 1 Tiles { "1e_lw08.bin", 0x8000, 0xb491bbbb, 5 | BRF_GRA }, // 6 { "3d_lw13.bin", 0x8000, 0xfdd1908a, 5 | BRF_GRA }, // 7 { "1d_lw07.bin", 0x8000, 0x5c73d406, 5 | BRF_GRA }, // 8 { "3b_lw12.bin", 0x8000, 0x32e17b3c, 5 | BRF_GRA }, // 9 { "1b_lw06.bin", 0x8000, 0x52e533c1, 5 | BRF_GRA }, // 10 { "3f_lw15.bin", 0x8000, 0x99e134ba, 5 | BRF_GRA }, // 11 { "1f_lw09.bin", 0x8000, 0xc8f28777, 5 | BRF_GRA }, // 12 { "3j_lw17.bin", 0x8000, 0x5ed1bc9b, 6 | BRF_GRA }, // 13 Sprites { "1j_lw11.bin", 0x8000, 0x2a0790d6, 6 | BRF_GRA }, // 14 { "3h_lw16.bin", 0x8000, 0xe8834006, 6 | BRF_GRA }, // 15 { "1h_lw10.bin", 0x8000, 0xb693f5a5, 6 | BRF_GRA }, // 16 { "63s141.15g", 0x0100, 0xd96bcc98, 0 | BRF_OPT }, // 17 Proms (not used) }; STD_ROM_PICK(lwings) STD_ROM_FN(lwings) struct BurnDriver BurnDrvLwings = { "lwings", NULL, NULL, "1986", "Legendary Wings (US set 1)\0", NULL, "Capcom", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_MISC, NULL, lwingsRomInfo, lwingsRomName, DrvInputInfo, LwingsDIPInfo, DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 240, 256, 3, 4 }; // Legendary Wings (US set 2) static struct BurnRomInfo lwings2RomDesc[] = { { "u13-l", 0x8000, 0x3069c01c, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code { "u14-k", 0x8000, 0x5d91c828, 1 | BRF_PRG | BRF_ESS }, // 1 { "9c_lw03.bin", 0x8000, 0xec5cc201, 1 | BRF_PRG | BRF_ESS }, // 2 { "11e_lw04.bin", 0x8000, 0xa20337a2, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code { "9h_lw05.bin", 0x4000, 0x091d923c, 4 | BRF_GRA }, // 4 Characters { "b_03e.rom", 0x8000, 0x176e3027, 5 | BRF_GRA }, // 5 Background Layer 1 Tiles { "b_01e.rom", 0x8000, 0xf5d25623, 5 | BRF_GRA }, // 6 { "b_03d.rom", 0x8000, 0x001caa35, 5 | BRF_GRA }, // 7 { "b_01d.rom", 0x8000, 0x0ba008c3, 5 | BRF_GRA }, // 8 { "b_03b.rom", 0x8000, 0x4f8182e9, 5 | BRF_GRA }, // 9 { "b_01b.rom", 0x8000, 0xf1617374, 5 | BRF_GRA }, // 10 { "b_03f.rom", 0x8000, 0x9b374dcc, 5 | BRF_GRA }, // 11 { "b_01f.rom", 0x8000, 0x23654e0a, 5 | BRF_GRA }, // 12 { "b_03j.rom", 0x8000, 0x8f3c763a, 6 | BRF_GRA }, // 13 Sprites { "b_01j.rom", 0x8000, 0x7cc90a1d, 6 | BRF_GRA }, // 14 { "b_03h.rom", 0x8000, 0x7d58f532, 6 | BRF_GRA }, // 15 { "b_01h.rom", 0x8000, 0x3e396eda, 6 | BRF_GRA }, // 16 { "63s141.15g", 0x0100, 0xd96bcc98, 0 | BRF_OPT }, // 17 Proms (not used) }; STD_ROM_PICK(lwings2) STD_ROM_FN(lwings2) struct BurnDriver BurnDrvLwings2 = { "lwings2", "lwings", NULL, "1986", "Legendary Wings (US set 2)\0", NULL, "Capcom", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_MISC, NULL, lwings2RomInfo, lwings2RomName, DrvInputInfo, LwingsDIPInfo, DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 240, 256, 3, 4 }; // Ares no Tsubasa (Japan) static struct BurnRomInfo lwingsjRomDesc[] = { { "a_06c.rom", 0x8000, 0x2068a738, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code { "a_07c.rom", 0x8000, 0xd6a2edc4, 1 | BRF_PRG | BRF_ESS }, // 1 { "9c_lw03.bin", 0x8000, 0xec5cc201, 1 | BRF_PRG | BRF_ESS }, // 2 { "11e_lw04.bin", 0x8000, 0xa20337a2, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code { "9h_lw05.bin", 0x4000, 0x091d923c, 4 | BRF_GRA }, // 4 Characters { "b_03e.rom", 0x8000, 0x176e3027, 5 | BRF_GRA }, // 5 Background Layer 1 Tiles { "b_01e.rom", 0x8000, 0xf5d25623, 5 | BRF_GRA }, // 6 { "b_03d.rom", 0x8000, 0x001caa35, 5 | BRF_GRA }, // 7 { "b_01d.rom", 0x8000, 0x0ba008c3, 5 | BRF_GRA }, // 8 { "b_03b.rom", 0x8000, 0x4f8182e9, 5 | BRF_GRA }, // 9 { "b_01b.rom", 0x8000, 0xf1617374, 5 | BRF_GRA }, // 10 { "b_03f.rom", 0x8000, 0x9b374dcc, 5 | BRF_GRA }, // 11 { "b_01f.rom", 0x8000, 0x23654e0a, 5 | BRF_GRA }, // 12 { "b_03j.rom", 0x8000, 0x8f3c763a, 6 | BRF_GRA }, // 13 Sprites { "b_01j.rom", 0x8000, 0x7cc90a1d, 6 | BRF_GRA }, // 14 { "b_03h.rom", 0x8000, 0x7d58f532, 6 | BRF_GRA }, // 15 { "b_01h.rom", 0x8000, 0x3e396eda, 6 | BRF_GRA }, // 16 { "63s141.15g", 0x0100, 0xd96bcc98, 0 | BRF_OPT }, // 17 Proms (not used) }; STD_ROM_PICK(lwingsj) STD_ROM_FN(lwingsj) struct BurnDriver BurnDrvLwingsj = { "lwingsj", "lwings", NULL, "1986", "Ares no Tsubasa (Japan)\0", NULL, "Capcom", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_MISC, NULL, lwingsjRomInfo, lwingsjRomName, DrvInputInfo, LwingsDIPInfo, DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 240, 256, 3, 4 }; // Legendary Wings (bootleg) static struct BurnRomInfo lwingsbRomDesc[] = { { "ic17.bin", 0x8000, 0xfe8a8823, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code { "ic18.bin", 0x8000, 0x2a00cde8, 1 | BRF_PRG | BRF_ESS }, // 1 { "ic19.bin", 0x8000, 0xec5cc201, 1 | BRF_PRG | BRF_ESS }, // 2 { "ic37.bin", 0x8000, 0xa20337a2, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code { "ic60.bin", 0x4000, 0x091d923c, 4 | BRF_GRA }, // 4 Characters { "ic50.bin", 0x8000, 0x5436392c, 5 | BRF_GRA }, // 5 Background Layer 1 Tiles { "ic49.bin", 0x8000, 0xffdbdd69, 5 | BRF_GRA }, // 6 { "ic26.bin", 0x8000, 0xfdd1908a, 5 | BRF_GRA }, // 7 { "ic25.bin", 0x8000, 0x5c73d406, 5 | BRF_GRA }, // 8 { "ic2.bin", 0x8000, 0x32e17b3c, 5 | BRF_GRA }, // 9 { "ic1.bin", 0x8000, 0x52e533c1, 5 | BRF_GRA }, // 10 { "ic63.bin", 0x8000, 0x99e134ba, 5 | BRF_GRA }, // 11 { "ic62.bin", 0x8000, 0xc8f28777, 5 | BRF_GRA }, // 12 { "ic99.bin", 0x8000, 0x163946da, 6 | BRF_GRA }, // 13 Sprites { "ic98.bin", 0x8000, 0x7cc90a1d, 6 | BRF_GRA }, // 14 { "ic87.bin", 0x8000, 0xbca275ac, 6 | BRF_GRA }, // 15 { "ic86.bin", 0x8000, 0x3e396eda, 6 | BRF_GRA }, // 16 { "63s141.15g", 0x0100, 0xd96bcc98, 0 | BRF_OPT }, // 17 Proms (not used) }; STD_ROM_PICK(lwingsb) STD_ROM_FN(lwingsb) struct BurnDriver BurnDrvLwingsb = { "lwingsb", "lwings", NULL, "1986", "Legendary Wings (bootleg)\0", NULL, "bootleg", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_MISC, NULL, lwingsbRomInfo, lwingsbRomName, DrvInputInfo, LwingsbDIPInfo, DrvInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 240, 256, 3, 4 }; // Trojan (US) static struct BurnRomInfo trojanRomDesc[] = { { "t4", 0x8000, 0xc1bbeb4e, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code { "t6", 0x8000, 0xd49592ef, 1 | BRF_PRG | BRF_ESS }, // 1 { "tb05.bin", 0x8000, 0x9273b264, 1 | BRF_PRG | BRF_ESS }, // 2 { "tb02.bin", 0x8000, 0x21154797, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code { "tb01.bin", 0x4000, 0x1c0f91b2, 3 | BRF_PRG | BRF_ESS }, // 4 Z80 #2 Code { "tb03.bin", 0x4000, 0x581a2b4c, 4 | BRF_GRA }, // 5 Characters { "tb13.bin", 0x8000, 0x285a052b, 5 | BRF_GRA }, // 6 Background Layer 1 Tiles { "tb09.bin", 0x8000, 0xaeb693f7, 5 | BRF_GRA }, // 7 { "tb12.bin", 0x8000, 0xdfb0fe5c, 5 | BRF_GRA }, // 8 { "tb08.bin", 0x8000, 0xd3a4c9d1, 5 | BRF_GRA }, // 9 { "tb11.bin", 0x8000, 0x00f0f4fd, 5 | BRF_GRA }, // 10 { "tb07.bin", 0x8000, 0xdff2ee02, 5 | BRF_GRA }, // 11 { "tb14.bin", 0x8000, 0x14bfac18, 5 | BRF_GRA }, // 12 { "tb10.bin", 0x8000, 0x71ba8a6d, 5 | BRF_GRA }, // 13 { "tb18.bin", 0x8000, 0x862c4713, 6 | BRF_GRA }, // 14 Sprites { "tb16.bin", 0x8000, 0xd86f8cbd, 6 | BRF_GRA }, // 15 { "tb17.bin", 0x8000, 0x12a73b3f, 6 | BRF_GRA }, // 16 { "tb15.bin", 0x8000, 0xbb1a2769, 6 | BRF_GRA }, // 17 { "tb22.bin", 0x8000, 0x39daafd4, 6 | BRF_GRA }, // 18 { "tb20.bin", 0x8000, 0x94615d2a, 6 | BRF_GRA }, // 19 { "tb21.bin", 0x8000, 0x66c642bd, 6 | BRF_GRA }, // 20 { "tb19.bin", 0x8000, 0x81d5ab36, 6 | BRF_GRA }, // 21 { "tb25.bin", 0x8000, 0x6e38c6fa, 7 | BRF_GRA }, // 22 Background Layer 2 Tiles { "tb24.bin", 0x8000, 0x14fc6cf2, 7 | BRF_GRA }, // 23 { "tb23.bin", 0x8000, 0xeda13c0e, 8 | BRF_GRA }, // 24 Background Layer 2 Tile Map { "tbp24s10.7j", 0x0100, 0xd96bcc98, 0 | BRF_OPT }, // 25 Proms (not used) { "mb7114e.1e", 0x0100, 0x5052fa9d, 0 | BRF_OPT }, // 26 }; STD_ROM_PICK(trojan) STD_ROM_FN(trojan) struct BurnDriver BurnDrvTrojan = { "trojan", NULL, NULL, "1986", "Trojan (US)\0", NULL, "Capcom", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING, 2, HARDWARE_MISC_MISC, NULL, trojanRomInfo, trojanRomName, DrvInputInfo, TrojanlsDIPInfo, TrojanInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 256, 240, 4, 3 }; // Trojan (Romstar) static struct BurnRomInfo trojanrRomDesc[] = { { "tb04.bin", 0x8000, 0x92670f27, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code { "tb06.bin", 0x8000, 0xa4951173, 1 | BRF_PRG | BRF_ESS }, // 1 { "tb05.bin", 0x8000, 0x9273b264, 1 | BRF_PRG | BRF_ESS }, // 2 { "tb02.bin", 0x8000, 0x21154797, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code { "tb01.bin", 0x4000, 0x1c0f91b2, 3 | BRF_PRG | BRF_ESS }, // 4 Z80 #2 Code { "tb03.bin", 0x4000, 0x581a2b4c, 4 | BRF_GRA }, // 5 Characters { "tb13.bin", 0x8000, 0x285a052b, 5 | BRF_GRA }, // 6 Background Layer 1 Tiles { "tb09.bin", 0x8000, 0xaeb693f7, 5 | BRF_GRA }, // 7 { "tb12.bin", 0x8000, 0xdfb0fe5c, 5 | BRF_GRA }, // 8 { "tb08.bin", 0x8000, 0xd3a4c9d1, 5 | BRF_GRA }, // 9 { "tb11.bin", 0x8000, 0x00f0f4fd, 5 | BRF_GRA }, // 10 { "tb07.bin", 0x8000, 0xdff2ee02, 5 | BRF_GRA }, // 11 { "tb14.bin", 0x8000, 0x14bfac18, 5 | BRF_GRA }, // 12 { "tb10.bin", 0x8000, 0x71ba8a6d, 5 | BRF_GRA }, // 13 { "tb18.bin", 0x8000, 0x862c4713, 6 | BRF_GRA }, // 14 Sprites { "tb16.bin", 0x8000, 0xd86f8cbd, 6 | BRF_GRA }, // 15 { "tb17.bin", 0x8000, 0x12a73b3f, 6 | BRF_GRA }, // 16 { "tb15.bin", 0x8000, 0xbb1a2769, 6 | BRF_GRA }, // 17 { "tb22.bin", 0x8000, 0x39daafd4, 6 | BRF_GRA }, // 18 { "tb20.bin", 0x8000, 0x94615d2a, 6 | BRF_GRA }, // 19 { "tb21.bin", 0x8000, 0x66c642bd, 6 | BRF_GRA }, // 20 { "tb19.bin", 0x8000, 0x81d5ab36, 6 | BRF_GRA }, // 21 { "tb25.bin", 0x8000, 0x6e38c6fa, 7 | BRF_GRA }, // 22 Background Layer 2 Tiles { "tb24.bin", 0x8000, 0x14fc6cf2, 7 | BRF_GRA }, // 23 { "tb23.bin", 0x8000, 0xeda13c0e, 8 | BRF_GRA }, // 24 Background Layer 2 Tile Map { "tbp24s10.7j", 0x0100, 0xd96bcc98, 0 | BRF_OPT }, // 25 Proms (not used) { "mb7114e.1e", 0x0100, 0x5052fa9d, 0 | BRF_OPT }, // 26 }; STD_ROM_PICK(trojanr) STD_ROM_FN(trojanr) struct BurnDriver BurnDrvTrojanr = { "trojanr", "trojan", NULL, "1986", "Trojan (Romstar)\0", NULL, "Capcom (Romstar license)", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_MISC, NULL, trojanrRomInfo, trojanrRomName, DrvInputInfo, TrojanDIPInfo, TrojanInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 256, 240, 4, 3 }; // Tatakai no Banka (Japan) static struct BurnRomInfo trojanjRomDesc[] = { { "troj-04.rom", 0x8000, 0x0b5a7f49, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code { "troj-06.rom", 0x8000, 0xdee6ed92, 1 | BRF_PRG | BRF_ESS }, // 1 { "tb05.bin", 0x8000, 0x9273b264, 1 | BRF_PRG | BRF_ESS }, // 2 { "tb02.bin", 0x8000, 0x21154797, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code { "tb01.bin", 0x4000, 0x1c0f91b2, 3 | BRF_PRG | BRF_ESS }, // 4 Z80 #2 Code { "tb03.bin", 0x4000, 0x581a2b4c, 4 | BRF_GRA }, // 5 Characters { "tb13.bin", 0x8000, 0x285a052b, 5 | BRF_GRA }, // 6 Background Layer 1 Tiles { "tb09.bin", 0x8000, 0xaeb693f7, 5 | BRF_GRA }, // 7 { "tb12.bin", 0x8000, 0xdfb0fe5c, 5 | BRF_GRA }, // 8 { "tb08.bin", 0x8000, 0xd3a4c9d1, 5 | BRF_GRA }, // 9 { "tb11.bin", 0x8000, 0x00f0f4fd, 5 | BRF_GRA }, // 10 { "tb07.bin", 0x8000, 0xdff2ee02, 5 | BRF_GRA }, // 11 { "tb14.bin", 0x8000, 0x14bfac18, 5 | BRF_GRA }, // 12 { "tb10.bin", 0x8000, 0x71ba8a6d, 5 | BRF_GRA }, // 13 { "tb18.bin", 0x8000, 0x862c4713, 6 | BRF_GRA }, // 14 Sprites { "tb16.bin", 0x8000, 0xd86f8cbd, 6 | BRF_GRA }, // 15 { "tb17.bin", 0x8000, 0x12a73b3f, 6 | BRF_GRA }, // 16 { "tb15.bin", 0x8000, 0xbb1a2769, 6 | BRF_GRA }, // 17 { "tb22.bin", 0x8000, 0x39daafd4, 6 | BRF_GRA }, // 18 { "tb20.bin", 0x8000, 0x94615d2a, 6 | BRF_GRA }, // 19 { "tb21.bin", 0x8000, 0x66c642bd, 6 | BRF_GRA }, // 20 { "tb19.bin", 0x8000, 0x81d5ab36, 6 | BRF_GRA }, // 21 { "tb25.bin", 0x8000, 0x6e38c6fa, 7 | BRF_GRA }, // 22 Background Layer 2 Tiles { "tb24.bin", 0x8000, 0x14fc6cf2, 7 | BRF_GRA }, // 23 { "tb23.bin", 0x8000, 0xeda13c0e, 8 | BRF_GRA }, // 24 Background Layer 2 Tile Map { "tbp24s10.7j", 0x0100, 0xd96bcc98, 0 | BRF_OPT }, // 25 Proms (not used) { "mb7114e.1e", 0x0100, 0x5052fa9d, 0 | BRF_OPT }, // 26 }; STD_ROM_PICK(trojanj) STD_ROM_FN(trojanj) struct BurnDriver BurnDrvTrojanj = { "trojanj", "trojan", NULL, "1986", "Tatakai no Banka (Japan)\0", NULL, "Capcom", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_MISC, NULL, trojanjRomInfo, trojanjRomName, DrvInputInfo, TrojanDIPInfo, TrojanInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 256, 240, 4, 3 }; // Avengers (US set 1) static struct BurnRomInfo avengersRomDesc[] = { { "04.10n", 0x8000, 0xa94aadcc, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code { "06.13n", 0x8000, 0x39cd80bd, 1 | BRF_PRG | BRF_ESS }, // 1 { "05.12n", 0x8000, 0x06b1cec9, 1 | BRF_PRG | BRF_ESS }, // 2 { "02.15h", 0x8000, 0x107a2e17, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code { "01.6d", 0x8000, 0xc1e5d258, 3 | BRF_PRG | BRF_ESS }, // 4 Z80 #2 Code { "03.8k", 0x8000, 0xefb5883e, 4 | BRF_GRA }, // 5 Characters { "13.6b", 0x8000, 0x9b5ff305, 5 | BRF_GRA }, // 6 Background Layer 1 Tiles { "09.6a", 0x8000, 0x08323355, 5 | BRF_GRA }, // 7 { "12.4b", 0x8000, 0x6d5261ba, 5 | BRF_GRA }, // 8 { "08.4a", 0x8000, 0xa13d9f54, 5 | BRF_GRA }, // 9 { "11.3b", 0x8000, 0xa2911d8b, 5 | BRF_GRA }, // 10 { "07.3a", 0x8000, 0xcde78d32, 5 | BRF_GRA }, // 11 { "14.8b", 0x8000, 0x44ac2671, 5 | BRF_GRA }, // 12 { "10.8a", 0x8000, 0xb1a717cb, 5 | BRF_GRA }, // 13 { "18.7l", 0x8000, 0x3c876a17, 6 | BRF_GRA }, // 14 Sprites { "16.3l", 0x8000, 0x4b1ff3ac, 6 | BRF_GRA }, // 15 { "17.5l", 0x8000, 0x4eb543ef, 6 | BRF_GRA }, // 16 { "15.2l", 0x8000, 0x8041de7f, 6 | BRF_GRA }, // 17 { "22.7n", 0x8000, 0xbdaa8b22, 6 | BRF_GRA }, // 18 { "20.3n", 0x8000, 0x566e3059, 6 | BRF_GRA }, // 19 { "21.5n", 0x8000, 0x301059aa, 6 | BRF_GRA }, // 20 { "19.2n", 0x8000, 0xa00485ec, 6 | BRF_GRA }, // 21 { "25.15n", 0x8000, 0x230d9e30, 7 | BRF_GRA }, // 22 Background Layer 2 Tiles { "24.13n", 0x8000, 0xa6354024, 7 | BRF_GRA }, // 23 { "23.9n", 0x8000, 0xc0a93ef6, 8 | BRF_GRA }, // 24 Background Layer 2 Tile Map { "tbb_2bpr.7j", 0x0100, 0xd96bcc98, 0 | BRF_OPT }, // 25 Proms (not used) { "tbb_1bpr.1e", 0x0100, 0x5052fa9d, 0 | BRF_OPT }, // 26 }; STD_ROM_PICK(avengers) STD_ROM_FN(avengers) static int AvengersInit() { avengers = 1; return TrojanInit(); } struct BurnDriver BurnDrvAvengers = { "avengers", NULL, NULL, "1987", "Avengers (US set 1)\0", NULL, "Capcom", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_MISC, NULL, avengersRomInfo, avengersRomName, DrvInputInfo, AvengersDIPInfo, AvengersInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 240, 256, 3, 4 }; // Avengers (US set 2) static struct BurnRomInfo avengers2RomDesc[] = { { "avg4.bin", 0x8000, 0x0fea7ac5, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code { "av_06a.13n", 0x8000, 0x491a712c, 1 | BRF_PRG | BRF_ESS }, // 1 { "av_05.12n", 0x8000, 0x9a214b42, 1 | BRF_PRG | BRF_ESS }, // 2 { "02.15h", 0x8000, 0x107a2e17, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code { "01.6d", 0x8000, 0xc1e5d258, 3 | BRF_PRG | BRF_ESS }, // 4 Z80 #2 Code { "03.8k", 0x8000, 0xefb5883e, 4 | BRF_GRA }, // 5 Characters { "13.6b", 0x8000, 0x9b5ff305, 5 | BRF_GRA }, // 6 Background Layer 1 Tiles { "09.6a", 0x8000, 0x08323355, 5 | BRF_GRA }, // 7 { "12.4b", 0x8000, 0x6d5261ba, 5 | BRF_GRA }, // 8 { "08.4a", 0x8000, 0xa13d9f54, 5 | BRF_GRA }, // 9 { "11.3b", 0x8000, 0xa2911d8b, 5 | BRF_GRA }, // 10 { "07.3a", 0x8000, 0xcde78d32, 5 | BRF_GRA }, // 11 { "14.8b", 0x8000, 0x44ac2671, 5 | BRF_GRA }, // 12 { "10.8a", 0x8000, 0xb1a717cb, 5 | BRF_GRA }, // 13 { "18.7l", 0x8000, 0x3c876a17, 6 | BRF_GRA }, // 14 Sprites { "16.3l", 0x8000, 0x4b1ff3ac, 6 | BRF_GRA }, // 15 { "17.5l", 0x8000, 0x4eb543ef, 6 | BRF_GRA }, // 16 { "15.2l", 0x8000, 0x8041de7f, 6 | BRF_GRA }, // 17 { "22.7n", 0x8000, 0xbdaa8b22, 6 | BRF_GRA }, // 18 { "20.3n", 0x8000, 0x566e3059, 6 | BRF_GRA }, // 19 { "21.5n", 0x8000, 0x301059aa, 6 | BRF_GRA }, // 20 { "19.2n", 0x8000, 0xa00485ec, 6 | BRF_GRA }, // 21 { "25.15n", 0x8000, 0x230d9e30, 7 | BRF_GRA }, // 22 Background Layer 2 Tiles { "24.13n", 0x8000, 0xa6354024, 7 | BRF_GRA }, // 23 { "23.9n", 0x8000, 0xc0a93ef6, 8 | BRF_GRA }, // 24 Background Layer 2 Tile Map { "tbb_2bpr.7j", 0x0100, 0xd96bcc98, 0 | BRF_OPT }, // 25 Proms (not used) { "tbb_1bpr.1e", 0x0100, 0x5052fa9d, 0 | BRF_OPT }, // 26 }; STD_ROM_PICK(avengers2) STD_ROM_FN(avengers2) struct BurnDriver BurnDrvAvengers2 = { "avengers2", "avengers", NULL, "1987", "Avengers (US set 2)\0", NULL, "Capcom", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_MISC, NULL, avengers2RomInfo, avengers2RomName, DrvInputInfo, AvengersDIPInfo, AvengersInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 240, 256, 3, 4 }; // Hissatsu Buraiken (Japan) static struct BurnRomInfo buraikenRomDesc[] = { { "av_04a.10n", 0x8000, 0x361fc614, 1 | BRF_PRG | BRF_ESS }, // 0 Z80 #0 Code { "av_06a.13n", 0x8000, 0x491a712c, 1 | BRF_PRG | BRF_ESS }, // 1 { "av_05.12n", 0x8000, 0x9a214b42, 1 | BRF_PRG | BRF_ESS }, // 2 { "02.15h", 0x8000, 0x107a2e17, 2 | BRF_PRG | BRF_ESS }, // 3 Z80 #1 Code { "01.6d", 0x8000, 0xc1e5d258, 3 | BRF_PRG | BRF_ESS }, // 4 Z80 #2 Code { "03.8k", 0x8000, 0xefb5883e, 4 | BRF_GRA }, // 5 Characters { "13.6b", 0x8000, 0x9b5ff305, 5 | BRF_GRA }, // 6 Background Layer 1 Tiles { "09.6a", 0x8000, 0x08323355, 5 | BRF_GRA }, // 7 { "12.4b", 0x8000, 0x6d5261ba, 5 | BRF_GRA }, // 8 { "08.4a", 0x8000, 0xa13d9f54, 5 | BRF_GRA }, // 9 { "11.3b", 0x8000, 0xa2911d8b, 5 | BRF_GRA }, // 10 { "07.3a", 0x8000, 0xcde78d32, 5 | BRF_GRA }, // 11 { "14.8b", 0x8000, 0x44ac2671, 5 | BRF_GRA }, // 12 { "10.8a", 0x8000, 0xb1a717cb, 5 | BRF_GRA }, // 13 { "18.7l", 0x8000, 0x3c876a17, 6 | BRF_GRA }, // 14 Sprites { "16.3l", 0x8000, 0x4b1ff3ac, 6 | BRF_GRA }, // 15 { "17.5l", 0x8000, 0x4eb543ef, 6 | BRF_GRA }, // 16 { "15.2l", 0x8000, 0x8041de7f, 6 | BRF_GRA }, // 17 { "22.7n", 0x8000, 0xbdaa8b22, 6 | BRF_GRA }, // 18 { "20.3n", 0x8000, 0x566e3059, 6 | BRF_GRA }, // 19 { "21.5n", 0x8000, 0x301059aa, 6 | BRF_GRA }, // 20 { "19.2n", 0x8000, 0xa00485ec, 6 | BRF_GRA }, // 21 { "av_25.15n", 0x8000, 0x88a505a7, 7 | BRF_GRA }, // 22 Background Layer 2 Tiles { "av_24.13n", 0x8000, 0x1f4463c8, 7 | BRF_GRA }, // 23 { "23.9n", 0x8000, 0xc0a93ef6, 8 | BRF_GRA }, // 24 Background Layer 2 Tile Map { "tbb_2bpr.7j", 0x0100, 0xd96bcc98, 0 | BRF_OPT }, // 25 Proms (not used) { "tbb_1bpr.1e", 0x0100, 0x5052fa9d, 0 | BRF_OPT }, // 26 }; STD_ROM_PICK(buraiken) STD_ROM_FN(buraiken) struct BurnDriver BurnDrvBuraiken = { "buraiken", "avengers", NULL, "1987", "Hissatsu Buraiken (Japan)\0", NULL, "Capcom", "hardware", NULL, NULL, NULL, NULL, BDF_GAME_WORKING | BDF_CLONE | BDF_ORIENTATION_VERTICAL | BDF_ORIENTATION_FLIPPED, 2, HARDWARE_MISC_MISC, NULL, buraikenRomInfo, buraikenRomName, DrvInputInfo, AvengersDIPInfo, AvengersInit, DrvExit, DrvFrame, DrvDraw, DrvScan, &DrvRecalc, 240, 256, 3, 4 };
c3ec844de4ad8d9adae3b10b279d832ef20544b0
f654ca71af356cc87b5019741029b28dcecf76f1
/dep/include/meowMath/mat4.h
7b8e107347f6e149a9019ddc41b374f48f389d99
[]
no_license
No-Face-the-3rd/Graphics
1205af54bea496815d5152528ca1b4bb6cd039fd
aadbc215c7359cc056a78218f1f226a4fd7a845c
refs/heads/master
2020-04-18T01:15:41.735989
2016-10-20T16:05:00
2016-10-20T16:05:00
66,578,980
0
0
null
null
null
null
UTF-8
C++
false
false
2,678
h
mat4.h
#pragma once #ifndef MAT4_H #define MAT4_H #include "mat3.h" namespace meow { struct mat4 { union { float m[16]; float mm[4][4]; vec4 c[4]; struct { union { vec4 c1; vec3 right; }; union { vec4 c2; vec3 up; }; union { vec4 c3; vec3 forward; }; union { vec4 c4; vec3 position; }; }; }; mat4 &operator=(const mat4 &a); mat4 &operator+=(const float &a); mat4 &operator+=(const mat4 &a); mat4 &operator-=(const float &a); mat4 &operator-=(const mat4 &a); mat4 &operator*=(const float &a); mat4 &operator*=(const mat4 &a); mat4 identity() const; mat4 inverse() const; mat4 transpose() const; //left = a, right = b, bottom = c, top = d, near = e, far = f mat4 orthographicProjection(const float &a, const float &b, const float &c, const float &d, const float &e, const float &f) const; mat4 rotate(const float &a, const int &b); //rotates around an arbitrary axis (true) or around x y z axis (false) mat4 rotate(const vec3 &a, const float &b, bool c = true); mat4 scale(const vec3 &a) const; mat4 translate(const vec3 &a) const; float determinant() const; mat3 minor(const int &a, const int &b) const; }; mat4 operator+(const mat4 &a, const float &b); mat4 operator+(const float &a, const mat4 &b); mat4 operator+(const mat4 &a, const mat4 &b); mat4 operator-(const mat4 &a, const float &b); mat4 operator-(const mat4 &a, const mat4 &b); mat4 operator*(const mat4 &a, const float &b); mat4 operator*(const float &a, const mat4 &b); mat4 operator*(const mat4 &a, const mat4 &b); vec4 operator*(const mat4 &a, const vec4 &b); vec4 operator*(const vec4 &a, const mat4 &b); bool operator==(const mat4 &a, const mat4 &b); bool operator!=(const mat4 &a, const mat4 &b); bool operator<(const mat4 &a, const mat4 &b); bool operator<=(const mat4 &a, const mat4 &b); bool operator>(const mat4 &a, const mat4 &b); bool operator>=(const mat4 &a, const mat4 &b); std::ostream &operator<<(std::ostream &os, const mat4 &a); mat4 mat4Identity(); mat4 inverse(const mat4 &a); mat4 transpose(const mat4 &a); //left = a, right = b, bottom = c, top = d, near = e, far = f mat4 orthographicProjection(const float &a, const float &b, const float &c, const float &d, const float &e, const float &f); mat4 rotate(const float &a, const int &b); //rotates around an arbitrary axis (true) or around x axis y axis z axis (false) mat4 rotate(const vec3 &a, const float &b, bool c = true); mat4 scale(const vec3 &a); mat4 translate(const vec3 &a); float determinant(const mat4 &a); mat4 mat3ToMat4(const mat3 &a); mat3 minor(const mat4 &a, const int &b, const int &c); } #endif
49b6e00381766448c500711812293d223c61f708
aa9cc4b8c7996ede07a26664b0d9214ed8fe3887
/network-protocol-SERVER/network-protocol/source/Collider.cpp
36a1a049917da8f6ee41811de2accbbf23618c27
[]
no_license
orre1996/TankWarsNetworked
5aab1c07e9ed7b4fd7b45bb2348c333733ab335a
dea2c770b7a610cf8122d0e9737af49c6b89ed2b
refs/heads/master
2020-05-02T23:22:32.822806
2019-03-28T20:55:39
2019-03-28T20:55:39
178,278,310
0
0
null
null
null
null
UTF-8
C++
false
false
113
cpp
Collider.cpp
//#include "stdafx.h" #include "Collider.h" Collider::Collider() { } Collider::~Collider() { }
0953611aecb93526bc2849616aef6fa606c2d61b
78ebcd61aa59072d0bdd838187fcf939c69f15de
/src/affine_transformation.cpp
459fd90bd33630561707b70ed2dfdb7419c0d403
[]
no_license
LoicPeter/video-mosaicking
3df300cf0f3493df5fc018d5a734db4cb7fb178c
f47a5558661317a0b6c11918f0fc8ad4881f443e
refs/heads/main
2023-01-20T02:22:59.762665
2020-11-29T16:22:07
2020-11-29T16:22:07
316,986,061
3
0
null
null
null
null
UTF-8
C++
false
false
567
cpp
affine_transformation.cpp
#include "affine_transformation.hpp" void getDisplacedPointsAffine(std::vector<cv::Point2f>& output_points, double *h_ij, const std::vector<cv::Point2f>& input_points) { int nb_input_points = (int)input_points.size(); if (output_points.size()!=nb_input_points) output_points.resize(nb_input_points); for (int p=0; p<nb_input_points; ++p) { output_points[p].x = h_ij[0]*input_points[p].x + h_ij[1]*input_points[p].y + h_ij[2]; output_points[p].y = h_ij[3]*input_points[p].x + h_ij[4]*input_points[p].y + h_ij[5]; } }
4a2f9a38c20322df9870f1b1b4e9bb39bbc16d22
15eb5e21d6abf34f5bfeb94fde78c2e2ffb764b9
/Structures/SegmentTree.h
a0a4ba1f566f61724cf26ea354020ea4ccdd76a5
[]
no_license
buevichd/algo
70e615906fedb3b400ede2f113076c7474d455e5
fb05eb9568b586b471c9b63f2d2b52a820b5086b
refs/heads/master
2022-03-26T18:26:41.414036
2019-12-04T08:20:49
2019-12-04T08:20:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,354
h
SegmentTree.h
template <class T, class V> class IdentityConverter { public: V operator()(const T& obj) { return obj; } }; /** * @tparam ElementType - type of stored elements * @tparam ResultType - type stored in the tree */ template <class ElementType, class ResultType> class SegmentTree { public: using MergeFunctor = std::function<ResultType(ResultType, ResultType)>; using ConvertFunctor = std::function<ResultType(ElementType)>; SegmentTree(std::vector<ElementType> data, MergeFunctor merge_functor, ResultType identity = ResultType(), ConvertFunctor convert_functor = IdentityConverter<ElementType, ResultType>()) : data_(std::move(data)), tree_(4 * data_.size()), addend_(4 * data_.size(), identity), merge_functor_(merge_functor), convert_functor_(convert_functor), identity_(identity) { static_assert(std::is_integral<ElementType>::value); if (!data_.empty()) { Build(0, 0, data_.size()); } } ResultType GetValue(size_t left, size_t right = SIZE_MAX) { if (right == SIZE_MAX) { right = left + 1; } return GetValue(0, 0, data_.size(), left, right); } void SetElement(size_t position, ElementType value) { SetElement(0, 0, data_.size(), position, value); } void SetSegment(size_t left, size_t right, ResultType value) { SetSegment(0, 0, data_.size(), left, right, value); } private: std::vector<ElementType> data_; std::vector<ResultType> tree_; std::vector<ResultType> addend_; MergeFunctor merge_functor_; ConvertFunctor convert_functor_; ResultType identity_; void Build(size_t vertex, size_t left, size_t right) { if (left + 1 == right) { tree_[vertex] = convert_functor_(data_[left]); } else { size_t middle = (right + left) / 2; Build(GetLeftChild(vertex), left, middle); Build(GetRightChild(vertex), middle, right); tree_[vertex] = merge_functor_(tree_[GetLeftChild(vertex)], tree_[GetRightChild(vertex)]); } } ResultType GetValue(size_t vertex, size_t vertex_left, size_t vertex_right, size_t left, size_t right) { if (left >= right) { return identity_; } if (vertex_left == left && vertex_right == right) { return tree_[vertex]; } size_t vertex_middle = (vertex_left + vertex_right) / 2; return merge_functor_( GetValue(GetLeftChild(vertex), vertex_left, vertex_middle, left, std::min(right, vertex_middle)), GetValue(GetRightChild(vertex), vertex_middle, vertex_right, std::max(left, vertex_middle), right)); } void SetElement(size_t vertex, size_t vertex_left, size_t vertex_right, size_t position, ElementType new_value) { if (vertex_left + 1 == vertex_right) { tree_[vertex] = convert_functor_(new_value); } else { size_t vertex_middle = (vertex_left + vertex_right) / 2; if (position < vertex_middle) { SetElement(GetLeftChild(vertex), vertex_left, vertex_middle, position, new_value); } else { SetElement(GetRightChild(vertex), vertex_middle, vertex_right, position, new_value); } tree_[vertex] = merge_functor_(tree_[GetRightChild(vertex)], tree_[GetLeftChild(vertex)]); } } void SetSegment(size_t vertex, size_t vertex_left, size_t vertex_right, size_t left, size_t right, ResultType value) { if (left >= right) { return; } if (vertex_left == left && vertex_right == right) { addend_[vertex] = value; } else { size_t vertex_middle = (vertex_left + vertex_right) / 2; SetSegment(GetLeftChild(vertex), vertex_left, vertex_middle, left, std::min(vertex_middle, right), value); SetSegment(GetRightChild(vertex), vertex_middle, vertex_right, std::max(left, vertex_middle), right, value); } } size_t GetLeftChild(size_t vertex) const { return 2 * vertex + 1; } size_t GetRightChild(size_t vertex) const { return 2 * vertex + 2; } };
b0bfd70105b18fa02b8c53662a856fff095566de
f546ab714e1042b460190845548008d2ad6fcb86
/src/agv_tf/src/tf_listener.cpp
4fbb21112363dabf90d0936442c62b0256c8e399
[]
no_license
jancore/agv_slam_algorithms
ed1318449f3f692a7aa686a17c0243e72ed0f17f
57b0c683d3f36b3775dbc21677278dd79a86052a
refs/heads/master
2020-04-07T08:24:36.442053
2019-02-21T16:28:29
2019-02-21T16:28:29
158,212,489
4
0
null
null
null
null
UTF-8
C++
false
false
2,423
cpp
tf_listener.cpp
#include <ros/ros.h> #include <geometry_msgs/PointStamped.h> #include <sensor_msgs/LaserScan.h> #include "std_msgs/String.h" #include <tf/transform_listener.h> #include "math.h" class Laser_listener { public: Laser_listener(){ ranges = std::vector<double>(); angle_increment = 0.0; } void Callback(const sensor_msgs::LaserScan::ConstPtr& scan){ angle_increment = scan->angle_increment; ranges.resize(scan->ranges.size()); for(unsigned int i = 0; i < scan->ranges.size(); i++){ ranges[i] = scan->ranges[i]; } } std::vector<double> GetRanges(){ return ranges; } double GetAngleIncrement(){ return angle_increment; } private: std::vector<double> ranges; double angle_increment; }; void transformPoint(const tf::TransformListener& listener){ //we'll create a point in the base_laser frame that we'd like to transform to the base_link frame ros::NodeHandle nh; Laser_listener laser_listener; ros::Subscriber sub_laser = nh.subscribe("nav350_scan", 1000, &Laser_listener::Callback, &laser_listener); geometry_msgs::PointStamped laser_point; laser_point.header.frame_id = "base_laser"; //we'll just use the most recent transform available for our simple example laser_point.header.stamp = ros::Time(); //just an arbitrary point in space laser_point.point.x = laser_listener.GetRanges()[0] * cos(-M_PI); laser_point.point.y = laser_listener.GetRanges()[0] * cos(-M_PI); laser_point.point.z = 0.0; try{ geometry_msgs::PointStamped base_point; listener.transformPoint("base_link", laser_point, base_point); ROS_INFO("base_laser: (%.2f, %.2f. %.2f) -----> base_link: (%.2f, %.2f, %.2f) at time %.2f", laser_point.point.x, laser_point.point.y, laser_point.point.z, base_point.point.x, base_point.point.y, base_point.point.z, base_point.header.stamp.toSec()); } catch(tf::TransformException& ex){ ROS_ERROR("Received an exception trying to transform a point from \"base_laser\" to \"base_link\": %s", ex.what()); } } int main(int argc, char** argv){ ros::init(argc, argv, "robot_tf_listener"); ros::NodeHandle n; tf::TransformListener listener(ros::Duration(10)); //we'll transform a point once every second ros::Timer timer = n.createTimer(ros::Duration(1.0), boost::bind(&transformPoint, boost::ref(listener))); ros::spin(); }
b67c6a34eb79273fb8d95160f0d9b3a267fbfd95
3d36b686316c25d96d96f1c42b52947bf6b908fa
/SiSExpressionLib/sisresult/resultexpression.h
617df29188d422a8e28165c30f27450da63e68da
[]
no_license
jason10071/sisConsoletool
be99a40525c2e5e0fa62e147c9fbb579279d5aa4
34ba82bf5707f5e888d55f1e14548b84db31afa3
refs/heads/master
2021-01-10T10:36:52.821405
2020-07-22T07:36:40
2020-07-22T07:36:40
48,153,451
1
3
null
2020-07-03T09:36:30
2015-12-17T05:03:55
C++
UTF-8
C++
false
false
1,372
h
resultexpression.h
#ifndef RESULTEXPRESSION_H #define RESULTEXPRESSION_H #include <iostream> #include <map> #include <list> #include <string> #include <sstream> using namespace std; namespace SE { class ResultExpression { public: enum TreeRole { TREE_ROOT = 0, TREE_NON_LEAF, TREE_LEAF, TREE_UNDEFINED, }; ResultExpression(ResultExpression::TreeRole treeRole); ~ResultExpression(); ResultExpression::TreeRole getTreeRole(); /* sub */ int subSize(); list<string> subs(TreeRole treeRole = ResultExpression::TREE_UNDEFINED); bool subContains(string name); bool subContains(int index); ResultExpression* subFind(string name); ResultExpression* subFind(int index); void subInsert(ResultExpression* resultExpression); /* attribute */ string getName(); void setName(string name); string getValue(); void setValue(string value); int getIndex(); void setIndex(int index); int getLevel(); void setLevel(int level); void clear(); private: void subErase(string name); private: ResultExpression::TreeRole m_treeRole; map<string, ResultExpression*> m_subResults; string m_name; string m_value; int m_index; int m_level; }; } // SE #endif // RESULTEXPRESSION_H
2425daa54e2f973f128678d1c49b1b9dccfa7374
c37613964ab1fb8b5613243323c50f65ca4d14b3
/src/DiceFour.h
879b01f39947b496a918aeaee3a05810e7a78f45
[]
no_license
gillkashdeep/webgamingMidterm
77dd99722242841b8256339d3cbb1faa93505c04
e44cdcf60519689f628ed0b5067a34c167621c0d
refs/heads/master
2021-01-06T23:18:24.487427
2020-03-03T23:50:32
2020-03-03T23:50:32
241,510,592
0
0
null
null
null
null
UTF-8
C++
false
false
278
h
DiceFour.h
#pragma once #ifndef __diceFour__ #define __diceFour__ #include "DisplayObject.h" class DiceFour : public DisplayObject { public: DiceFour(); ~DiceFour(); void draw() override; void update() override; void clean() override; private: double m_currentDirection; }; #endif
0acdb2358df43ae5c20033dbe5c8616930d90996
87d9c581207dee14840e563b6bd6957ce0a9d836
/Boxes through a Tunnel.cpp
961254b2dc61613af8afc29e91b41d7156542bb3
[]
no_license
Somaiyajannat/Competitive-Programming
659643e6612bdf62366ea44bebc1ba090b6c301b
379974e391b7e2e97708a26243783202edf5f43c
refs/heads/master
2022-05-10T22:37:59.939525
2022-05-01T04:29:34
2022-05-01T04:29:34
134,086,660
0
0
null
null
null
null
UTF-8
C++
false
false
489
cpp
Boxes through a Tunnel.cpp
struct box { int length, width, height; /** * Define three fields of type int: length, width and height */ }; typedef struct box box; int get_volume(box b) { int result = b.length * b.width * b.height; return result; /** * Return the volume of the box */ } int is_lower_than_max_height(box b) { if (b.height >= MAX_HEIGHT) { return 0; } return 1; /** * Return 1 if the box's height is lower than MAX_HEIGHT and 0 otherwise */ }
32fea66c30cab53a114269cac19003effa810750
9875d3831c2a7a7ad4ee98bd353586f51bddeb92
/gaudio/gaddress.cpp
2f6f0e51b773ce9df4275a221ceea54811d94038
[]
no_license
bigsealing/gaudio
de65668ad847064deb3b82d4ed8e1b15c6372531
6334409bb4178748d793be34d8e0cad6c2a3d82d
refs/heads/master
2023-06-10T22:23:41.792946
2021-06-26T11:41:31
2021-06-26T11:41:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,328
cpp
gaddress.cpp
#include <string.h> #include "gaudio.h" #include "gcontext.h" #include "streamBuffer.h" #include "gresample.h" #include "gqueue.h" struct gFunctionStruct { const char* name; void* address; }; #define ADDR_WRAPPER(name,ptr) {name,(void*)ptr} static gFunctionStruct gFunctions[] = { ADDR_WRAPPER("stream_tell",stream_tell), ADDR_WRAPPER("stream_seek",stream_seek), ADDR_WRAPPER("stream_read",stream_read), ADDR_WRAPPER("stream_file",stream_file), ADDR_WRAPPER("gresample_create",gresample_create), ADDR_WRAPPER("gresample_process",gresample_process), ADDR_WRAPPER("gresample_close",gresample_close), ADDR_WRAPPER("gqueue_create",gqueue_create), ADDR_WRAPPER("gqueue_destroy",gqueue_destroy), ADDR_WRAPPER("gqueue_resize",gqueue_resize), ADDR_WRAPPER("gqueue_process",gqueue_process), ADDR_WRAPPER("gaudio_init",gaudio_init), ADDR_WRAPPER("gaudio_deinit",gaudio_deinit), ADDR_WRAPPER("gaudio_is_support",gaudio_is_support), ADDR_WRAPPER("gaudio_set_float",gaudio_set_float), ADDR_WRAPPER("gaudio_get_float",gaudio_get_float), ADDR_WRAPPER("gaudio_set_int32",gaudio_set_int32), ADDR_WRAPPER("gaudio_get_int32",gaudio_get_int32), ADDR_WRAPPER("gaudio_set_string",gaudio_set_string), ADDR_WRAPPER("gaudio_get_string",gaudio_get_string), ADDR_WRAPPER("gaudio_error_get",gaudio_error_get), ADDR_WRAPPER("gaudio_listener_set_float3",gaudio_listener_set_float3), ADDR_WRAPPER("gaudio_listener_get_float3",gaudio_listener_get_float3), ADDR_WRAPPER("gaudio_source_create_from_file",gaudio_source_create_from_file), ADDR_WRAPPER("gaudio_source_create_from_buffer",gaudio_source_create_from_buffer), ADDR_WRAPPER("gaudio_source_create_from_virtual_io",gaudio_source_create_from_virtual_io), ADDR_WRAPPER("gaudio_source_create_from_buffer2",gaudio_source_create_from_buffer2), ADDR_WRAPPER("gaudio_source_destroy",gaudio_source_destroy), ADDR_WRAPPER("gaudio_source_set_user",gaudio_source_set_user), ADDR_WRAPPER("gaudio_source_get_user",gaudio_source_get_user), ADDR_WRAPPER("gaudio_source_set_finish_callback",gaudio_source_set_finish_callback), ADDR_WRAPPER("gaudio_source_set_error_callback",gaudio_source_set_error_callback), ADDR_WRAPPER("gaudio_source_set_float3",gaudio_source_set_float3), ADDR_WRAPPER("gaudio_source_get_float3",gaudio_source_get_float3), ADDR_WRAPPER("gaudio_source_play",gaudio_source_play), ADDR_WRAPPER("gaudio_source_play3",gaudio_source_play3), ADDR_WRAPPER("gaudio_source_pause",gaudio_source_pause), ADDR_WRAPPER("gaudio_source_stop",gaudio_source_stop), ADDR_WRAPPER("gaudio_source_seek",gaudio_source_seek), ADDR_WRAPPER("gaudio_source_set_position_callback",gaudio_source_set_position_callback), ADDR_WRAPPER("gaudio_source_set_float",gaudio_source_set_float), ADDR_WRAPPER("gaudio_source_get_float",gaudio_source_get_float), ADDR_WRAPPER("gaudio_source_set_int32",gaudio_source_set_int32), ADDR_WRAPPER("gaudio_source_get_int32",gaudio_source_get_int32), ADDR_WRAPPER("gaudio_source_get_string",gaudio_source_get_string), ADDR_WRAPPER("gaudio_effect_create",gaudio_effect_create), ADDR_WRAPPER("gaudio_effect_destroy",gaudio_effect_destroy), ADDR_WRAPPER("gaudio_effect_set_fft_callback",gaudio_effect_set_fft_callback), ADDR_WRAPPER("gaudio_effect_bind",gaudio_effect_bind), ADDR_WRAPPER("gaudio_effect_bind_to_source",gaudio_effect_bind_to_source), ADDR_WRAPPER("gaudio_effect_unbind",gaudio_effect_unbind), ADDR_WRAPPER("gaudio_effect_unbind_from_source",gaudio_effect_unbind_from_source), ADDR_WRAPPER("gaudio_effect_set_float",gaudio_effect_set_float), ADDR_WRAPPER("gaudio_effect_get_float",gaudio_effect_get_float), ADDR_WRAPPER("gaudio_effect_set_int32",gaudio_effect_set_int32), ADDR_WRAPPER("gaudio_effect_get_int32",gaudio_effect_get_int32), //ADDR_WRAPPER("getCurrentContext",getCurrentContext), {NULL, (void*)NULL} }; void* gaudio_address_get(const char* name) { void* function = NULL; int32_t i = 0; if(name) { while(gFunctions[i].name && strcmp(gFunctions[i].name,name) != 0) i++; function = gFunctions[i].address; } else gerror_set(AUDIO_BAD_VALUE); return function; }
b28f7a32fd6b0d086c4084bd1ee3306884d964a6
7f610e8792081df5955492c9b55755c72c79da17
/LinkedListBasics/main.cpp
dc46633c2a78263fbe426945b2fc089448999378
[]
no_license
Parikshit22/Data-Structures-Algorithms-Cpp
8da910d0c1ba745ccfc016e0d0865f108b30cb04
4515f41c8a41850bc2888d4c83b9ce5dc9b66d68
refs/heads/master
2022-12-09T09:54:42.240609
2020-09-02T03:48:43
2020-09-02T03:48:43
276,821,418
1
0
null
null
null
null
UTF-8
C++
false
false
4,818
cpp
main.cpp
#include <iostream> using namespace std; class node{ public: int data; node* next; node(int n){ data = n; next = NULL; } }; void InsertionAtTail(node *head,int data){ node *q = head; while(q->next!=NULL){ q = q->next; } node*a = new node(data); q->next=a; } void InsertionAtHead(node*&head,int data){ node*a = new node(data); a->next = head; head = a; } int length(node *head){ int len =1; while(head->next!=NULL){ head = head->next; len += 1; } return len; } void InsertionInBetween(node *head, int data, int pos){ node *q = head; if(head == NULL||pos == 0){ InsertionAtHead(q,data); } else if(pos>length(q)){ InsertionAtTail(q,data); } else{ for(int i=0;i<pos-1;i++){ q = q->next; } node*a = new node(data); a->next = q->next; q->next = a; } } void DeletionInHead(node *&head){ node *q = head; head = head->next; delete q; } void DeletionAtTail(node *head){ node *q = head; node *prev = NULL; while(q->next!=NULL){ prev = q; q = q->next; } prev->next = NULL; delete q; } void DeletionInMiddle(node *head, int pos){ node *prev = head; for(int i=1;i<pos;i++){ prev = head; head = head->next; } prev->next = head->next; delete head; } void print(node *head){ node *q = head; for(int i=0;q!=NULL;i++){ cout<<q->data<<endl; q = q->next; } } void IterrativeSearching(node *head, int num){ int i =1; while(head!=NULL){ if(head->data==num){ cout<<"number found at pos "<<i<<endl; return; } head = head->next; i++; } cout<<"Number not found"<<endl; } void RecurrsiveSearching(node *head,int num,int i){ if(head == NULL){ cout<<"Number not found"<<endl; } if(head->data == num){ cout<<"number found at pos "<<i<<endl; return; } RecurrsiveSearching(head->next,num,i+1); } void Reverse(node *&head){ node *q = head; node *prev = NULL; node *fwd; while(q!=NULL){ fwd = q->next; q->next = prev; prev = q; q = fwd; } head = prev; delete prev; delete fwd; delete q; } node* RecurrsiveReverse(node *q,node *prev,node *fwd){ if(q->next==NULL){ q->next = prev; return q; } q->next = prev; RecurrsiveReverse(fwd,q,fwd->next); } void InputFromUser(node *&head){ int data; cin>>data; while(data!=-1){ InsertionAtTail(head,data); cin>>data; } } int MidPoint(node *head){ node *Fast = head->next; node *Slow = head; int i=1; while(Fast->next != NULL && Fast != NULL){ Fast = Fast->next->next; Slow = Slow->next; i++; } return i; } node *ReturnMidPoint(node *head){ int mid = MidPoint(head); for(int i=1;i<mid;i++){ head = head->next; } return head; } istream& operator>>(istream &io,node *head){ int data; cin>>data; InsertionAtTail(head,data); return io; } ostream& operator<<(ostream &io, node *head){ print(head); return io; } node *Merge(node *head,node *midnode){ node *q=NULL; if(head == NULL){ return midnode; } else if(midnode == NULL){ return head; } if(head->data<=midnode->data){ q = head; q->next = Merge(head->next,midnode); } else{ q = midnode; q->next = Merge(head,midnode->next); } return q; } node *MergeSort(node *head){ if(head == NULL || head->next==NULL){ return head; } node *midnode = ReturnMidPoint(head); node *a = head; node *b = midnode->next; midnode->next = NULL; a = MergeSort(a); b = MergeSort(b); node *c = Merge(a,b); return c; } bool DetectCycle(node *head){ node *Fast = head; node *Slow = head; while(Fast!=NULL && Fast->next !=NULL){ Slow = Slow->next; Fast = Fast->next->next; if(Fast == Slow){ return false; } } return true; } int main() { node *head= NULL; InsertionAtHead(head,5); InsertionAtHead(head,7); InsertionAtTail(head,10); InsertionAtHead(head,8); InsertionAtHead(head,2); InsertionAtTail(head,9); InsertionInBetween(head,34,2); DeletionInHead(head); DeletionAtTail(head); DeletionInMiddle(head,2); IterrativeSearching(head,10); RecurrsiveSearching(head,10,1); Reverse(head); head = MergeSort(head); print(head); if(DetectCycle(head)){ cout<<"Cycle is not there"<<endl; } else{ cout<<"cycle is there"<<endl; } return 0; }
aa5ea62819fd45eedf3bd7812abeb20521b9cf84
b7f1b4df5d350e0edf55521172091c81f02f639e
/components/cronet/native/test_util.cc
6e56cd52996359ddadf60d8bff7da4b72ccc83bc
[ "BSD-3-Clause" ]
permissive
blusno1/chromium-1
f13b84547474da4d2702341228167328d8cd3083
9dd22fe142b48f14765a36f69344ed4dbc289eb3
refs/heads/master
2023-05-17T23:50:16.605396
2018-01-12T19:39:49
2018-01-12T19:39:49
117,339,342
4
2
NOASSERTION
2020-07-17T07:35:37
2018-01-13T11:48:57
null
UTF-8
C++
false
false
987
cc
test_util.cc
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/cronet/native/test_util.h" #include "base/bind.h" #include "base/task_scheduler/post_task.h" namespace { // Implementation of PostTaskExecutor methods. void TestExecutor_Execute(Cronet_ExecutorPtr self, Cronet_RunnablePtr command) { CHECK(self); DVLOG(1) << "Post Task"; base::PostTask(FROM_HERE, base::BindOnce( [](Cronet_RunnablePtr command) { Cronet_Runnable_Run(command); Cronet_Runnable_Destroy(command); }, command)); } } // namespace namespace cronet { namespace test { Cronet_ExecutorPtr CreateTestExecutor() { return Cronet_Executor_CreateStub(TestExecutor_Execute); } } // namespace test } // namespace cronet
b6f53862451049a795a23f24a707f9a22bcb4cf7
88c85bfd2e1b889f3fbdefb9073bb988910f0e25
/ApplicationSolarSystem/ApplicationSolarSystem/cgvPoint3D.cpp
932a2b1b49d41345b2769e81d349a110cfa0abe4
[]
no_license
natalijapesic/SolarSystem
ea852bd96c590b57148391f1e38b00d6adff2258
73d363ceebd73bcbf2855ff04e03dbdfd4997e80
refs/heads/master
2020-10-01T21:34:27.010969
2020-03-31T17:25:54
2020-03-31T17:25:54
227,626,973
1
0
null
null
null
null
UTF-8
C++
false
false
1,017
cpp
cgvPoint3D.cpp
#include <stdio.h> #include <math.h> #include "cgvPoint3D.h" // Constructors cgvPoint3D::cgvPoint3D() { c[X] = c[Y] = c[Z] = 0.0; } cgvPoint3D::cgvPoint3D (const double& x, const double& y, const double& z ) { c[X] = x; c[Y] = y; c[Z] = z; } // Copy constructor cgvPoint3D::cgvPoint3D (const cgvPoint3D& p ) { c[X] = p.c[X]; c[Y] = p.c[Y]; c[Z] = p.c[Z]; } // Assignment operator cgvPoint3D& cgvPoint3D::operator = (const cgvPoint3D& p) { c[X] = p.c[X]; c[Y] = p.c[Y]; c[Z] = p.c[Z]; return(*this); } // Destructor cgvPoint3D::~cgvPoint3D() { } // Operators int cgvPoint3D::operator == (const cgvPoint3D& p) { return ((fabs(c[X]-p[X])<IGV_EPSILON) && (fabs(c[Y]-p[Y])<IGV_EPSILON) && (fabs(c[Z]-p[Z])<IGV_EPSILON)); } int cgvPoint3D::operator != (const cgvPoint3D& p) { return ((fabs(c[X]-p[X])>=IGV_EPSILON) || (fabs(c[Y]-p[Y])>=IGV_EPSILON) || (fabs(c[Z]-p[Z])>=IGV_EPSILON)); } void cgvPoint3D::set( const double& x, const double& y, const double& z) { c[X] = x; c[Y] = y; c[Z] = z; }
9a981a2a390b730dd91e3fcabc4723f508377dbb
dd7f9963c0f918372230130662d201ff0b9c23d8
/src/server/baselistener.cpp
56be96db5759d5d29eb5d8ae2cc74ff28dca8c54
[]
no_license
cbueno/batyr
863d0303c71b6f016ede80677e0fd17b19755718
27f8c095ce9d44a11667b40c0d6a853095f93139
refs/heads/master
2020-12-24T19:04:58.639904
2014-04-16T09:38:36
2014-04-16T09:38:36
23,156,810
1
0
null
null
null
null
UTF-8
C++
false
false
373
cpp
baselistener.cpp
#include "server/baselistener.h" using namespace Batyr; BaseListener::BaseListener(Configuration::Ptr _configuration) : logger(Poco::Logger::get("BaseListener")), configuration(_configuration) { //poco_debug(logger, "Setting up listener"); } BaseListener::~BaseListener() { //poco_debug(logger, "Shutting down listener"); //stop(); }
c128b6886ec1a463b0d3cc6aeb9b01da8b77f78e
b6b019e62ddcfe7f4364cd6fa15acad941af220f
/src/test3_chr.hpp
848aa65f4b3eaaf99062c11c5d40fee74e9d27c1
[]
no_license
schaban/crossdata_gfx
999a0e39d111f04a75683d434356b33e64ad0d8b
075b98adca57056ae35bdd360118d6bac583f29c
refs/heads/master
2022-08-31T18:01:36.667398
2022-08-24T11:49:34
2022-08-24T11:49:34
95,958,151
5
4
null
null
null
null
UTF-8
C++
false
false
2,886
hpp
test3_chr.hpp
#define D_KEY_UP 0 #define D_KEY_DOWN 1 #define D_KEY_LEFT 2 #define D_KEY_RIGHT 3 #define D_KEY_L1 4 #define D_KEY_L2 5 #define D_KEY_R1 6 #define D_KEY_R2 7 #define D_KEY_A 8 #define D_KEY_B 9 KEY_CTRL* get_ctrl_keys(); TD_JOYSTICK_CHANNELS* get_td_joy(); float get_anim_speed(); bool stg_hit_ck(const cxVec& pos0, const cxVec& pos1, cxVec* pHitPos, cxVec* pHitNrm); sxGeometryData* get_stg_obst_geo(); struct TSK_QUEUE; struct TSK_JOB; struct TSK_CONTEXT; class cCharacter3 { protected: enum class STATE : uint8_t { DANCE_LOOP = 0, DANCE_ACT, IDLE, TURN, WALK, RUN }; GEX_OBJ* mpObj; GEX_TEX* mpTexB; GEX_TEX* mpTexS; GEX_TEX* mpTexN; sxRigData* mpRig; cxMtx* mpRigMtxL; cxMtx* mpRigMtxW; cxMtx* mpObjMtxW; cxMtx* mpBlendMtxL; int* mpObjToRig; int mRigNodesNum; int mSkinNodesNum; int mRootNodeId; int mMovementNodeId; float mBlendDuration; float mBlendCount; MOTION_LIB mMotLib; float mMotFrame; int mMotIdHandsDefault; int mMotIdDanceLoop; int mMotIdStand; int mMotIdWalk; int mMotIdRun; float mMotVelFrame; cxVec mMotVel; cxVec mPrevWorldPos; cxVec mWorldPos; cxVec mWorldRot; TSK_JOB* mpMotEvalJobs; TSK_QUEUE* mpMotEvalQueue; sxKeyframesData::RigLink* mpMotEvalLink; sxKeyframesData* mpMotEvalKfr; float mMotEvalFrame; bool mInitFlg; STATE mStateMain; uint8_t mStateSub; int mStateParams[4]; float mStateParamsF[4]; typedef void (cCharacter3::*StateFunc)(); void blend_init(int duration); void calc_blend(); float calc_motion(int motId, float frame, float frameStep); void update_coord(); void calc_world(); void dance_loop_ctrl(); void dance_loop_exec(); void dance_act_ctrl(); void dance_act_exec(); void idle_ctrl(); void idle_exec(); void turn_ctrl(); void turn_exec(); void walk_ctrl(); void walk_exec(); void run_ctrl(); void run_exec(); void trans_to_state(STATE st, int subSt = 0, float frame = 0.0f) { mMotFrame = frame; mStateMain = st; mStateSub = subSt; } bool wall_adj_line(); bool wall_adj_ball(); bool wall_adj(); bool prop_adj(); static void mot_node_eval_job(TSK_CONTEXT* pCtx); public: cCharacter3() : mInitFlg(false), mpObj(nullptr), mpTexB(nullptr), mpTexS(nullptr), mpTexN(nullptr), mpRig(nullptr), mpRigMtxL(nullptr), mpRigMtxW(nullptr), mpObjMtxW(nullptr), mpBlendMtxL(nullptr), mpObjToRig(nullptr), mSkinNodesNum(0), mRigNodesNum(0), mRootNodeId(-1), mMovementNodeId(-1), mpMotEvalJobs(nullptr), mpMotEvalQueue(nullptr), mpMotEvalLink(nullptr), mpMotEvalKfr(nullptr), mMotEvalFrame(0.0f), mStateMain(STATE::DANCE_LOOP), mStateSub(0), mMotFrame(0.0f), mBlendDuration(0.0f), mBlendCount(0.0f), mMotVel(0.0f), mPrevWorldPos(0.0f), mWorldPos(0.0f), mWorldRot(0.0f) {} void create(); void destroy(); void update(); void disp(GEX_LIT* pLit = nullptr); cxMtx get_movement_mtx() const; cxVec get_world_pos() const { return mWorldPos; } };
d59018e9f7ae03bdd2a0b765f565139b3c6f1f27
e71b53457bc25af7d92b7a661596b0f31d21853a
/is/storagecreatedialog.h
f2d6467f6a972a462fbeb8081920789236f5d98f
[]
no_license
hackey9/ikit-kp-3sem
868e2f455bf085362a42119f4031e6da947facc3
ad119c7b44bd7133c23bb9fdbb2b1c4a87856cf2
refs/heads/master
2022-08-02T17:48:30.509190
2020-05-21T06:35:30
2020-05-21T06:35:30
264,706,642
0
0
null
null
null
null
UTF-8
C++
false
false
440
h
storagecreatedialog.h
#pragma once #include <QDialog> #include "../database/database.h" namespace Ui { class StorageCreateDialog; } class StorageCreateDialog : public QDialog { Q_OBJECT public: explicit StorageCreateDialog(Database &db, QWidget *parent = nullptr); ~StorageCreateDialog(); signals: void onStoreCreated(); private slots: void on_AddStorageButton_clicked(); private: Ui::StorageCreateDialog *ui; Database &db; };
868ac0c5a922234354cdfc5b49b4487811d469e4
d80556050142e45aa26e353544422f2dfbc0dffb
/leetcode-com/338_Count_Bits.cpp
7d863477402ce97646c32aa279f63ca321b2179e
[]
no_license
Alexzsh/oj
c68822fcb9e70c6a791a87c74f4034bb50148354
48625a3ee463ae9de253b6a19bcc2b1f249c1f2e
refs/heads/master
2021-07-06T06:39:04.956354
2019-04-27T10:51:39
2019-04-27T10:51:39
141,728,785
0
0
null
null
null
null
UTF-8
C++
false
false
520
cpp
338_Count_Bits.cpp
#include<iostream> #include<vector> using namespace std; vector<int> countBits(int num) { vector<int> res={0}; for(int i=1;i<num;++i){ if(!(i&(i-1))) res.push_back(1); else res.push_back(res[i&(i-1)]+1); } return res; } int* countBitss(int num) { int* res = new int[num+1]; for(int i=1;i<=num;++i) { res[i]=res[i>>1]+(i&1); } return res; } int main() { int* r=countBitss(10); for(int i=0;i<=10;++i) cout<<r[i]<<" "; }
e020879edca5d49fa8bc523be7e0726f1b48fe57
d66ea321bd43ff76305d3d33ebab056251b6d413
/libs/erdas/include/NCSEcw/JPC/T1Coder.h
2761ce951bc0b051e591326d60a1cc2bb5a37ba7
[]
no_license
winsento/geoserver-ecw
97d498ab6b8ac0f65569206141dcaad6cc57d623
a41ac9ca2dd8e03cc66a109d393237b3e87ea32c
refs/heads/master
2020-12-30T17:11:02.360195
2017-05-12T09:25:58
2017-05-12T09:25:58
91,062,046
1
1
null
null
null
null
UTF-8
C++
false
false
3,820
h
T1Coder.h
/******************************************************** ** Copyright, 1998 - 2014, Intergraph Corporation. All rights reserved. ** ** FILE: T1Coder.h ** CREATED: 12/02/2003 3:27:34 PM ** AUTHOR: Simon Cope ** PURPOSE: CT1Coder class header ** EDITS: [xx] ddMmmyy NAME COMMENTS *******************************************************/ #ifndef NCSJPCT1CODER_H #define NCSJPCT1CODER_H #include "NCSEcw/JPC/Types/Types.h" #ifndef NCSJPCNode2D_H #include "NCSEcw/SDK/Node2D.h" #endif // NCSJPCNode2D_H #include "NCSEcw/JPC/Markers/QCDMarker.h" #include "NCSMemoryIOStream.h" #ifndef NCSJPCSEGMENT_H #include "NCSEcw/JPC/Types/Segment.h" #endif // NCSJPCSEGMENT_H #include "NCSEcw/JPC/Nodes/SubBand.h" namespace NCS { namespace JPC { template <class T, int T1_SIGN_SHIFT, T T1_SIGN_MASK, T T1_VALUE_MASK> class T_T1Decoder; typedef T_T1Decoder<INT16, 15, INT16_MIN, INT16_MAX> Dec16; typedef T_T1Decoder<INT32, 31, INT32_MIN, INT32_MAX> Dec32; typedef T_T1Decoder<INT64, 63, INT64_MIN, INT64_MAX> Dec64; /** * CT1Coder class - the JPC T1 Coder. * * @author Simon Cope * @version $Revision: #1 $ $Author: ctapley $ $Date: 2014/10/17 $ */ class NCSECW_IMPEX CT1Coder { public: const static int PREDICTABLE_TERMINATION; const static int PASS_RESET_CTX; const static int SEGMENT_SYMBOLS; const static int PASS_TERMINATION; const static int VERTICAL_CAUSAL_CTX; const static int SELECTIVE_CODING_BYPASS; CT1Coder(bool bUseDefinedT_T1Decoder = false); virtual ~CT1Coder(); bool Decode(JPC::CSubBand::Type eSBType, UINT8 roiShift, UINT8 nBits, UINT8 nZeroBits, std::vector<CSegment> &m_Segments, SDK::CBuffer2D *pDecBuf, int Flags, CQCDMarker &Quantization, UINT8 nComponentBits, UINT16 nLevels, UINT8 nResolution, IEEE4 fReconstructionParameter); bool Encode(JPC::CSubBand::Type eSBType, UINT8 nBitsTotal, UINT8 &nZeroBits, std::vector<CSegment> &Segments, SDK::CBuffer2D *pDecBuf, UINT16 nRatio, UINT16 nLayers); static NCSTimeStampUs sm_usTotal; static NCSTimeStampUs sm_usLast; static UINT64 sm_nTotalSamples; static UINT64 sm_nLastSamples; Dec16 *m_Dec16; Dec32 *m_Dec32; Dec64 *m_Dec64; bool m_bUseDefinedT_T1Decoder; static void Init(); // for m_Data32INT16Pool, etc static void Fini(); // for m_Data32INT16Pool, etc class CDataPool { public: SDK::CBuffer2D *m_pData; CDataPool(UINT16 nSize, SDK::CBuffer2D::Type eType) { m_nSize = nSize; m_pData = NULL; if (eType == SDK::CBuffer2D::BT_INT16) m_pData = new SDK::CBuffer2D(0, 0, m_nSize, m_nSize, SDK::CBuffer2D::BT_INT16); // for 8 bit else if (eType == SDK::CBuffer2D::BT_INT32) m_pData = new SDK::CBuffer2D(0, 0, m_nSize, m_nSize, SDK::CBuffer2D::BT_INT32); // for 16 bit // no support for other types m_bInUse = false; }; ~CDataPool() { delete m_pData; m_pData = NULL; }; bool GetInUse(void) { return m_bInUse; }; // through UnRefStream when related to m_Data32INT16Pool, etc void SetInUse(bool bInUse) { m_bInUse = bInUse; }; SDK::CBuffer2D* GetData() { return m_pData; } private: UINT16 m_nSize; bool m_bInUse; }; static CDataPool* GetDataPool(UINT16 nSize, SDK::CBuffer2D::Type eType); static void UnRefData(CDataPool *pDataPool); protected: static std::vector< CDataPool* > m_Data32INT16Pool; static std::vector< CDataPool* > m_Data64INT16Pool; static std::vector< CDataPool* > m_Data128INT16Pool; static std::vector< CDataPool* > m_Data256INT16Pool; static std::vector< CDataPool* > m_Data32INT32Pool; static std::vector< CDataPool* > m_Data64INT32Pool; static std::vector< CDataPool* > m_Data128INT32Pool; static std::vector< CDataPool* > m_Data256INT32Pool; static CMutex m_DataPoolMutex; }; } } #endif // !NCSJPCT1CODER_H
242a501bf53c91226233e9b23b33f228ad0948c8
6d5a257bf72afdd85660ad3e938e2aa3025c680b
/include/Core/QuantumCircuit/OriginClassicalExpression.h
04212dba824b8546b14e3d52541f90a4432ebe18
[ "Apache-2.0" ]
permissive
OriginQ/QPanda-2
682b0e3bcdec7c66a651e8001d639f6146595fdf
a182212503a97981844140b165cb3cee8e293edd
refs/heads/master
2023-08-19T03:01:27.385297
2023-08-04T08:43:03
2023-08-04T08:43:03
136,144,680
1,207
96
Apache-2.0
2023-08-04T08:42:52
2018-06-05T08:23:20
C++
UTF-8
C++
false
false
2,056
h
OriginClassicalExpression.h
/* Copyright (c) 2017-2023 Origin Quantum Computing. All Right 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. */ #ifndef ORIGIN_CLASSICAL_EXPRESSION_H #define ORIGIN_CLASSICAL_EXPRESSION_H #include "Core/QuantumMachine/CBitFactory.h" #include "Core/QuantumCircuit/CExprFactory.h" #include "Core/QuantumCircuit/QNode.h" QPANDA_BEGIN /** * @brief Implementation class of CExpr * @ingroup QuantumCircuit */ class OriginCExpr :public CExpr { public: union content_u { CBit* cbit; int iOperatorSpecifier; cbit_size_t const_value; }; NodeType m_node_type; /**< quantum node type*/ qmap_size_t m_postion; private: CExpr* leftExpr = nullptr; CExpr* rightExpr = nullptr; int contentSpecifier; content_u content; OriginCExpr(); public: OriginCExpr(CBit* cbit); OriginCExpr(CExpr* leftExpr, CExpr* rightExpr, int); OriginCExpr(cbit_size_t); CExpr * getLeftExpr() const; CExpr *getRightExpr() const; std::string getName() const; CBit* getCBit() const; void setLeftExpr(CExpr*); void setRightExpr(CExpr*); cbit_size_t get_val() const; CExpr* deepcopy() const; bool checkValidity() const; void getCBitsName(std::vector<std::string> & names); /** * @brief get quantum node type * @return NodeType */ NodeType getNodeType() const; qmap_size_t getPosition() const; void setPosition(qmap_size_t); /** * @brief get content specifier * @return NodeType */ int getContentSpecifier() const; ~OriginCExpr(); }; QPANDA_END #endif
af4a1731ac24cad6a69ae5e63f57a678b48ff97d
e08dd41b3a1b6af70491ef4177b5ec7f988a24d4
/oopPastexam/oop11machinetest/B.cpp
e3da32b7b66c77408f6bb43a760eadb3d40ed1f1
[]
no_license
xatier/QQP
8b279edc754f1eaf6e8457b86c3889f6915a1072
32db8ed30b117641ed4d4b507cacbd4a7860939e
refs/heads/master
2020-05-26T19:47:09.161818
2015-04-16T17:06:42
2015-04-16T17:06:42
4,889,726
0
0
null
null
null
null
UTF-8
C++
false
false
1,549
cpp
B.cpp
#include <iostream> #include <functional> #include <numeric> #include <vector> using namespace std; //Version A int subset(int* a,int n) { int b=accumulate(a,a+n,0,plus<int>()); if (b%2==1) return 0; vector<vector<int> > t(n,vector<int>(1+b/2)); t[0][0]=t[0][a[0]]=1; for (int i=1;i<n;i++) for (int j=0;j<1+b/2;j++) t[i][j] = j>=a[i]? t[i-1][j]+t[i-1][j-a[i]]: t[i-1][j]; return t[n-1][b/2]; } //Version B (Bonus) //void show(vector<vector<int> >& s,int i,int j) //{ // if (i==0) { // if (s[i][j]>0) cout << j << ' '; // j==a[0] // } else // if (s[i][j]==0) show(s,i-1,j); // else { // show(s,i-1,j-s[i][j]); cout << s[i][j] << ' '; // } //} // //int subset(int* a,int n) //{ // int b=accumulate(a,a+n,0,plus<int>()); // if (b%2==1) return 0; // vector<vector<int> > t(n,vector<int>(1+b/2)),s(n,vector<int>(1+b/2,-1)); // t[0][0]=t[0][a[0]]=1; // s[0][0]=0; s[0][a[0]]=a[0]; // for (int i=1;i<n;i++) // for (int j=0;j<1+b/2;j++) { // if (t[i-1][j]>0) s[i][j]=0; // else if (j>=a[i]&&t[i-1][j-a[i]]>0) s[i][j]=a[i]; // t[i][j] = j>=a[i]? t[i-1][j]+t[i-1][j-a[i]]: t[i-1][j]; // } // if (t[n-1][b/2]>0) { cout << "One subset: "; show(s,n-1,b/2); cout << endl; } // return t[n-1][b/2]; //} int main() { int a[9]={1,2,3,4,5,6,7,8,9}; cout << "Test 1...\n"; cout << subset(a,7) << " subset(s) in total\n\n"; cout << "Test 2...\n"; cout << subset(a,8) << " subset(s) in total\n\n"; cout << "Test 3...\n"; cout << subset(a,9) << " subset(s) in total\n\n"; }
c346124a8ad20002241ddd1eb543f02cac956726
eefb5893de2db35003cbea36c077604f95a023cc
/src/gctools/gc_boot.cc
d7da414527ce2db0757513dd127d43b29fefb5ba
[]
no_license
dota534/clasp
4d20c8f54c33fe5027c6bfe11b9ddaf0e3dd7f27
525ce1cffff39311e3e7df6d0b71fa267779bdf5
refs/heads/master
2021-05-05T03:09:47.626701
2017-07-21T01:31:41
2017-07-21T01:31:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,505
cc
gc_boot.cc
#include <clasp/core/foundation.h> #include <clasp/gctools/gctoolsPackage.fwd.h> #include <clasp/core/array.h> #include <clasp/gctools/gc_boot.h> #include <clasp/core/lisp.h> #include <clasp/core/package.h> #include <clasp/core/numbers.h> namespace gctools { size_t global_kind_max; Kind_info* global_kind_info; Kind_layout* global_kind_layout; Field_info* global_field_info; Field_layout* global_field_layout; Container_layout* global_container_layout; Container_info* global_container_info; /*! This will build the tables that MPS needs to fix pointers in simple classes It uses global_class_layout_codes to malloc space for and build the global_class_info_table and the global_field_layout_table. */ void build_kind_field_layout_tables() { // First pass through the global_kind_layout_codes_table // to count the number of kinds and the number of fields Layout_code* codes = get_kind_layout_codes(); int idx = 0; size_t number_of_fixable_fields = 0; size_t number_of_containers = 0; global_kind_max = 0; size_t num_codes = 0; while (1) { if ( codes[idx].cmd == layout_end ) break; ++num_codes; if ( codes[idx].cmd < 0 || codes[idx].cmd > layout_end ) { printf("%s:%d the layout code table is damaged\n", __FILE__, __LINE__ ); abort(); } if ( codes[idx].cmd == class_kind || codes[idx].cmd == container_kind || codes[idx].cmd == bitunit_container_kind || codes[idx].cmd == templated_kind ) { if ( global_kind_max < codes[idx].data0 ) { global_kind_max = codes[idx].data0; } else { } } else if ( (codes[idx].cmd == fixed_field || codes[idx].cmd == variable_field ) && (codes[idx].data0 == SMART_PTR_OFFSET || codes[idx].data0 == TAGGED_POINTER_OFFSET || codes[idx].data0 == POINTER_OFFSET )) { ++number_of_fixable_fields; } else if ((codes[idx].cmd == fixed_field) && (codes[idx].data0 == CONSTANT_ARRAY_OFFSET)) { // Ignore the Array_O size_t _Length[0] array if (strcmp(codes[idx].description,"_Length")!=0) { // printf("%s:%d There is an unknown CONSTANT_ARRAY named %s that the static analyzer identified - deal with it\n", __FILE__, __LINE__, codes[idx].description ); } } else if ( codes[idx].cmd == variable_array0 ) { ++number_of_containers; } ++idx; } // Now malloc memory for the tables // now that we know the size of everything global_kind_info = (Kind_info*)malloc(sizeof(Kind_info)*(global_kind_max+1)); global_kind_layout = (Kind_layout*)malloc(sizeof(Kind_layout)*(global_kind_max+1)); global_field_layout = (Field_layout*)malloc(sizeof(Field_layout)*number_of_fixable_fields); Field_layout* cur_field_layout= global_field_layout; Field_layout* max_field_layout = (Field_layout*)((char*)global_field_layout + sizeof(Field_layout)*number_of_fixable_fields); global_field_info = (Field_info*)malloc(sizeof(Field_info)*(number_of_fixable_fields)); Field_info* cur_field_info = global_field_info; Field_info* max_field_info = (Field_info*)((char*)global_field_info + sizeof(Field_info)*number_of_fixable_fields); global_container_layout = (Container_layout*)malloc(sizeof(Container_layout)*(number_of_containers+1)); global_container_info = (Container_info*)malloc(sizeof(Container_info)*(number_of_containers+1)); // Fill in the immediate kinds // Traverse the global_kind_layout_codes again and fill the tables codes = get_kind_layout_codes(); size_t cur_container_layout_idx = 0; size_t cur_container_info_idx = 0; int cur_kind=0; idx = 0; for ( idx=0; idx<num_codes; ++idx ) { // printf("%s:%d idx = %d\n", __FILE__, __LINE__, idx); switch (codes[idx].cmd) { case class_kind: cur_kind = codes[idx].data0; // printf("%s:%d cur_kind = %d\n", __FILE__, __LINE__, cur_kind); global_kind_layout[cur_kind].layout_op = class_container_op; global_kind_layout[cur_kind].field_layout_start = NULL; global_kind_layout[cur_kind].container_layout = NULL; global_kind_layout[cur_kind].number_of_fields = 0; global_kind_layout[cur_kind].bits_per_bitunit = 0; global_kind_layout[cur_kind].size = codes[idx].data1; global_kind_info[cur_kind].name = codes[idx].description; global_kind_info[cur_kind].field_info_ptr = NULL; global_kind_info[cur_kind].container_info_ptr = NULL; break; case fixed_field: if ( !(codes[idx].data0 == SMART_PTR_OFFSET || codes[idx].data0 == TAGGED_POINTER_OFFSET || codes[idx].data0 == POINTER_OFFSET )) continue; GCTOOLS_ASSERT(cur_field_layout<max_field_layout); if ( global_kind_layout[cur_kind].field_layout_start == NULL ) global_kind_layout[cur_kind].field_layout_start = cur_field_layout; ++global_kind_layout[cur_kind].number_of_fields; cur_field_layout->field_offset = codes[idx].data2; ++cur_field_layout; GCTOOLS_ASSERT(cur_field_info<max_field_info); if ( global_kind_info[cur_kind].field_info_ptr == NULL ) global_kind_info[cur_kind].field_info_ptr = cur_field_info; cur_field_info->field_name = codes[idx].description; ++cur_field_info; break; case container_kind: cur_kind = codes[idx].data0; global_kind_layout[cur_kind].layout_op = class_container_op; global_kind_layout[cur_kind].number_of_fields = 0; global_kind_layout[cur_kind].size = codes[idx].data1; global_kind_layout[cur_kind].bits_per_bitunit = 0; global_kind_layout[cur_kind].field_layout_start = NULL; global_kind_layout[cur_kind].container_layout = NULL; global_kind_info[cur_kind].name = codes[idx].description; global_kind_info[cur_kind].field_info_ptr = NULL; global_kind_info[cur_kind].container_info_ptr = NULL; break; case bitunit_container_kind: cur_kind = codes[idx].data0; global_kind_layout[cur_kind].layout_op = bitunit_container_op; global_kind_layout[cur_kind].number_of_fields = 0; global_kind_layout[cur_kind].size = codes[idx].data1; global_kind_layout[cur_kind].bits_per_bitunit = codes[idx].data2; global_kind_layout[cur_kind].field_layout_start = NULL; global_kind_layout[cur_kind].container_layout = NULL; global_kind_info[cur_kind].name = codes[idx].description; global_kind_info[cur_kind].field_info_ptr = NULL; global_kind_info[cur_kind].container_info_ptr = NULL; break; case variable_array0: global_kind_layout[cur_kind].container_layout = &global_container_layout[cur_container_layout_idx++]; GCTOOLS_ASSERT(cur_container_layout_idx<=number_of_containers); global_kind_layout[cur_kind].container_layout->data_offset = codes[idx].data2; break; case variable_capacity: global_kind_layout[cur_kind].container_layout->field_layout_start = cur_field_layout; global_kind_layout[cur_kind].container_layout->element_size = codes[idx].data0; global_kind_layout[cur_kind].container_layout->number_of_fields = 0; global_kind_layout[cur_kind].container_layout->end_offset = codes[idx].data1; global_kind_layout[cur_kind].container_layout->capacity_offset = codes[idx].data2; break; case variable_field: if ( !(codes[idx].data0 == SMART_PTR_OFFSET || codes[idx].data0 == TAGGED_POINTER_OFFSET || codes[idx].data0 == POINTER_OFFSET )) continue; GCTOOLS_ASSERT(cur_field_layout<max_field_layout); cur_field_layout->field_offset = codes[idx].data2; ++cur_field_layout; ++global_kind_layout[cur_kind].container_layout->number_of_fields; if ( global_kind_info[cur_kind].container_info_ptr == NULL ) global_kind_info[cur_kind].container_info_ptr = &global_container_info[cur_container_info_idx++]; GCTOOLS_ASSERT(cur_container_info_idx<=number_of_containers); global_kind_info[cur_kind].container_info_ptr->field_name = codes[idx].description; break; case templated_kind: cur_kind = codes[idx].data0; global_kind_layout[cur_kind].layout_op = templated_op; global_kind_layout[cur_kind].field_layout_start = NULL; global_kind_layout[cur_kind].container_layout = NULL; global_kind_layout[cur_kind].number_of_fields = 0; global_kind_layout[cur_kind].size = codes[idx].data1; global_kind_info[cur_kind].name = codes[idx].description; global_kind_info[cur_kind].field_info_ptr = NULL; global_kind_info[cur_kind].container_info_ptr = NULL; break; case templated_class_jump_table_index: break; case container_jump_table_index: break; default: printf("%s:%d Illegal Layout_code table command: %d\n", __FILE__, __LINE__, codes[idx].cmd); THROW_HARD_ERROR(BF("The Layout_code table contained an illegal command: %d\n") % codes[idx].cmd); } } } CL_DEFUN Fixnum gctools__size_of_kind_field_layout_table() { // First pass through the global_kind_layout_codes_table // to count the number of kinds and the number of fields Layout_code* codes = get_kind_layout_codes(); int idx = 0; while (1) { if ( codes[idx].cmd == layout_end ) return idx; ++idx; } } CL_DEFUN core::T_mv gctools__kind_field_layout_entry(size_t idx) { core::SymbolToEnumConverter_sp conv = gctools::As<core::SymbolToEnumConverter_sp>(_sym_STARkind_field_layout_table_cmdsSTAR->symbolValue()); // First pass through the global_kind_layout_codes_table // to count the number of kinds and the number of fields Layout_code* codes = get_kind_layout_codes(); Layout_code& code = codes[idx]; core::Symbol_sp cmd = conv->symbolForEnumIndex(code.cmd); core::Fixnum_sp data0 = core::clasp_make_fixnum(code.data0); core::Fixnum_sp data1 = core::clasp_make_fixnum(code.data1); core::Fixnum_sp data2 = core::clasp_make_fixnum(code.data2); core::Symbol_sp description = _Nil<core::T_O>(); if ( code.description ) { core::SimpleBaseString_sp desc = core::SimpleBaseString_O::make(code.description); core::Package_sp pkg = gctools::As<core::Package_sp>(core::_sym_STARclasp_packageSTAR->symbolValue()); description = pkg->intern(desc); } return Values(cmd,data0,data1,data2,description); } };
97d62ed23c6081109a8774bfd27d2d9ef80eaf8e
2493f74eeab056a62c32b8b3bcb128d581568f17
/include/Code.h
a9b0e1161215896c13ef4da5318b5f442303f28d
[ "MIT" ]
permissive
mfl28/HackAssembler
eb1a7fbf9526c123a2a21c73f5ce8c7e026c4590
0655b29bdd45bc19da223c67dbf9d3b9fe8a64fe
refs/heads/master
2021-07-09T06:30:34.353204
2020-08-29T17:06:22
2020-08-29T17:06:22
184,457,374
1
2
null
null
null
null
UTF-8
C++
false
false
892
h
Code.h
#pragma once #include <bitset> #include <string> namespace HackAssembler::Code { /** * \brief Gets the binary code of the destination-mnemonic. * \param mnemonic One of 8 possible dest-mnemonics defined in the Hack assembly language. * \return The binary code (3 bits) */ std::bitset<3> dest(const std::string& mnemonic); /** * \brief Gets the binary code of the computation-mnemonic. * \param mnemonic One of 28 possible comp-mnemonics defined in the Hack assembly language. * \return The binary code (7 bits) */ std::bitset<7> comp(const std::string& mnemonic); /** * \brief Gets the binary code of the jump-instruction-mnemonic. * \param mnemonic One of 8 possible jump-mnemonics defined in the Hack assembly language. * \return The binary code (3 bits) */ std::bitset<3> jump(const std::string& mnemonic); }
1f52ddf40121fe0680fbfc73834072c923459cbc
134f98b6904f5750d83b10295aa25153205cea19
/sumOfFactTest/unittest1.cpp
d1771bd944c0a7ff16338281c2e176eeea905e13
[]
no_license
luffykid/poj
0d81ef63577bc4d69e41b42c2f585caef5c14d35
d889508fe74bbda3d8b9799cf1639887847e6402
refs/heads/master
2020-03-12T05:17:54.156334
2018-04-21T10:06:11
2018-04-21T10:06:11
130,460,893
0
0
null
null
null
null
UTF-8
C++
false
false
440
cpp
unittest1.cpp
#include "stdafx.h" #include "CppUnitTest.h" #include "../sumoffactorial/stdafx.h" using namespace Microsoft::VisualStudio::CppUnitTestFramework; namespace sumOfFactTest { TEST_CLASS(UnitTest1) { public: TEST_METHOD(TestMethod1) { // TODO: Your test code here int n = 51200; int exceptVal = 9403103; int realVal = sumOfFact(n, [](int n) { return n % 1000000; }); Assert::AreEqual(realVal, exceptVal); } }; }
594b01e2bc361dc2c58810f162a013bb35627322
3960f1c2f53794fdf5e502f2ea3918f769046ffe
/position.cpp
6174d587258e89da346b49536a2594713ce4cd85
[]
no_license
debug18/Iris
20d3753f0bd87488989fb93f83216a7c6c23ca38
9e979f1827b9defd013ee91efff539e8fae630e4
refs/heads/master
2020-01-01T23:51:24.693594
2017-08-10T09:00:36
2017-08-10T09:00:36
92,399,006
8
1
null
null
null
null
UTF-8
C++
false
false
5,243
cpp
position.cpp
#ifndef _BOTZONE_ONLINE #include "position.h" #endif Position::Position() { board[0] = (1ull << toSquare(3, 4)) | (1ull << toSquare(4, 3)); board[1] = (1ull << toSquare(3, 3)) | (1ull << toSquare(4, 4)); player = 0; nullMoveCount = 0; basicEval = 0; hashValue = PIECE_HASH_VALUE[toSquare(3, 3)][1] ^ PIECE_HASH_VALUE[toSquare(3, 4)][0] ^ PIECE_HASH_VALUE[toSquare(4, 3)][0] ^ PIECE_HASH_VALUE[toSquare(4, 4)][1]; } int Position::generateMoves(int moves[]) const { u64 movesBB = getMovesBB(board[player], board[player ^ 1]); int tot = 0; while (movesBB) { moves[tot++] = getlsbid(movesBB); movesBB ^= getlsb(movesBB); } assert(tot <= MAX_MOVES); return tot; } void Position::applyMove(int sq) { place(sq); getFlipped(sq, player, board[player], board[player ^ 1], basicEval, hashValue); nullMoveCount = 0; changePlayer(); } void Position::applyNullMove() { assert(nullMoveCount <= 1); ++nullMoveCount; changePlayer(); } Value Position::getEval() const { int my_tiles = 0, opp_tiles = 0, my_front_tiles = 0, opp_front_tiles = 0; double p = 0, c = 0, l = 0, m = 0, f = 0, d = 0; d = basicEval; // Piece difference, frontier disks and disk squares u64 frontier = getFrontierBB(board[player], board[player ^ 1]); my_tiles = countMyPieces(); opp_tiles = countOppPieces(); my_front_tiles = popcount(frontier & board[player]); opp_front_tiles = popcount(frontier & board[player ^ 1]); if (my_tiles > opp_tiles) p = (100.0 * my_tiles) / (my_tiles + opp_tiles); else if (my_tiles < opp_tiles) p = -(100.0 * opp_tiles) / (my_tiles + opp_tiles); if (my_front_tiles > opp_front_tiles) f = -(100.0 * my_front_tiles) / (my_front_tiles + opp_front_tiles); else if (my_front_tiles < opp_front_tiles) f = (100.0 * opp_front_tiles) / (my_front_tiles + opp_front_tiles); // Corner occupancy my_tiles = opp_tiles = 0; my_tiles += isMyPiece(toSquare(0, 0)); opp_tiles += isOppPiece(toSquare(0, 0)); my_tiles += isMyPiece(toSquare(0, 7)); opp_tiles += isOppPiece(toSquare(0, 7)); my_tiles += isMyPiece(toSquare(7, 0)); opp_tiles += isOppPiece(toSquare(7, 0)); my_tiles += isMyPiece(toSquare(7, 7)); opp_tiles += isOppPiece(toSquare(7, 7)); c = 25 * (my_tiles - opp_tiles); // Corner closeness my_tiles = opp_tiles = 0; if (isEmpty(toSquare(0, 0))) { my_tiles += isMyPiece(toSquare(0, 1)); opp_tiles += isOppPiece(toSquare(0, 1)); my_tiles += isMyPiece(toSquare(1, 0)); opp_tiles += isOppPiece(toSquare(1, 0)); my_tiles += isMyPiece(toSquare(1, 1)); opp_tiles += isOppPiece(toSquare(1, 1)); } if (isEmpty(toSquare(0, 7))) { my_tiles += isMyPiece(toSquare(0, 6)); opp_tiles += isOppPiece(toSquare(0, 6)); my_tiles += isMyPiece(toSquare(1, 6)); opp_tiles += isOppPiece(toSquare(1, 6)); my_tiles += isMyPiece(toSquare(1, 7)); opp_tiles += isOppPiece(toSquare(1, 7)); } if (isEmpty(toSquare(7, 0))) { my_tiles += isMyPiece(toSquare(6, 0)); opp_tiles += isOppPiece(toSquare(6, 0)); my_tiles += isMyPiece(toSquare(6, 1)); opp_tiles += isOppPiece(toSquare(6, 1)); my_tiles += isMyPiece(toSquare(7, 1)); opp_tiles += isOppPiece(toSquare(7, 1)); } if (isEmpty(toSquare(7, 7))) { my_tiles += isMyPiece(toSquare(6, 6)); opp_tiles += isOppPiece(toSquare(6, 6)); my_tiles += isMyPiece(toSquare(6, 7)); opp_tiles += isOppPiece(toSquare(6, 7)); my_tiles += isMyPiece(toSquare(7, 6)); opp_tiles += isOppPiece(toSquare(7, 6)); } l = -12.5 * (my_tiles - opp_tiles); // Mobility my_tiles = popcount(getMovesBB(board[player], board[player ^ 1])); opp_tiles = popcount(getMovesBB(board[player ^ 1], board[player])); if (my_tiles > opp_tiles) m = (100.0 * my_tiles) / (my_tiles + opp_tiles); else if (my_tiles < opp_tiles) m = -(100.0 * opp_tiles) / (my_tiles + opp_tiles); // final weighted score double score = ((10 * p) + (801.724 * c) + (382.026 * l) + (78.922 * m) + (74.396 * f) + (10 * d)) * 100; return (Value)score; } void Position::print() const { printf("Round #%d\n", countAllPieces() - 4 + 1); printf("Black: %d White: %d\n", countBlackPieces(), countWhitePieces()); if (isBlackPlayer()) printf("Now BLACK\n"); else printf("Now WHITE\n"); printf("Hash Value: %lld\n", getHashValue()); printf("Evaluation: %d\n", getEval()); printf(" "); for (int i = 0; i < BOARD_WIDTH; ++i) { printf("%c ", 'a' + i); } printf("\n"); for (int i = 0; i < BOARD_WIDTH; ++i) { printf("%d ", i + 1); for (int j = 0; j < BOARD_WIDTH; ++j) { int sq = toSquare(i, j); if (isEmpty(sq)) printf(". "); else if (isBlackPiece(sq)) printf("b "); else { assert(isWhitePiece(sq)); printf("w "); } } printf("\n"); } }
4c144d3cfc70e17d7fa52627b822e8985a177f46
ee5c245008ee568c055667acc90026a30bb3a8f3
/src/main/process.cpp
1c659323ead94795baa3f7338558b8af866859ae
[]
no_license
MooseOnTheRocks/virtualterminal
7f803425e4c7c976cdbb84272249a5ead486ae9e
4cff574dda2f97f764c176cfa3982c64b474aa17
refs/heads/master
2021-04-16T01:53:06.780268
2020-03-23T21:08:51
2020-03-23T21:08:51
249,317,871
0
0
null
null
null
null
UTF-8
C++
false
false
3,441
cpp
process.cpp
#include "process.h" #include <iostream> #include <windows.h> Process::Process() { mCmd = ""; mIsOpen = false; } Process::~Process() { close(); } void Process::close() { CloseHandle(mProcInfo.hProcess); CloseHandle(mProcInfo.hThread); CloseHandle(mChildOutWr); CloseHandle(mChildInRd); mIsOpen = false; } // TODO: cmd by reference bool Process::start(std::string cmd) { if (cmd.length() == 0) return false; mCmd = cmd; SECURITY_ATTRIBUTES saAttr; saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; if (!CreatePipe(&mChildOutRd, &mChildOutWr, &saAttr, 0)) { std::cout << "CreatePipe for stdout failed" << std::endl; close(); return false; } if (!SetHandleInformation(mChildOutRd, HANDLE_FLAG_INHERIT, 0)) { std::cout << "SetHandleInformation for stdout failed" << std::endl; close(); return false; } if (!CreatePipe(&mChildInRd, &mChildInWr, &saAttr, 0)) { std::cout << "CreatePipe for stdin failed" << std::endl; close(); return false; } if (!SetHandleInformation(mChildInWr, HANDLE_FLAG_INHERIT, 0)) { std::cout << "SetHandleInformation for stdin failed" << std::endl; close(); return false; } ZeroMemory(&mProcInfo, sizeof(PROCESS_INFORMATION)); ZeroMemory(&mStartupInfo, sizeof(STARTUPINFO)); mStartupInfo.cb = sizeof(STARTUPINFO); mStartupInfo.hStdError = mChildOutWr; mStartupInfo.hStdOutput = mChildOutWr; mStartupInfo.hStdInput = mChildInRd; mStartupInfo.dwFlags |= STARTF_USESTDHANDLES; char* cmdline = new char[mCmd.length() + 1]; mCmd.copy(cmdline, mCmd.length()); cmdline[mCmd.length()] = '\0'; std::cout << "cmdline: \"" << cmdline << "\"" << std::endl; BOOL success = CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &mStartupInfo, &mProcInfo ); delete[] cmdline; if (!success) { std::cout << "CreateProcess failed" << std::endl; close(); return false; } mIsOpen = true; return true; } // TODO: Polish bool Process::write(const std::string& s) { DWORD dwWritten = 0; BOOL bSuccess = FALSE; if (!WriteFile(mChildInWr, s.c_str(), s.length(), &dwWritten, NULL)) return false; if (dwWritten == 0) return false; std::cout << "wrote: " << dwWritten << std::endl; return true; } // TODO: Polish bool Process::read(std::string& buf) { DWORD dwRead; CHAR chBuf[4096]; DWORD avail; buf.clear(); while (PeekNamedPipe(mChildOutRd, NULL, 0, NULL, &avail, NULL) && avail > 0) { if (!ReadFile(mChildOutRd, chBuf, 4096, &dwRead, NULL)) { return false; } if (dwRead == 0) { break; } std::string tmp{chBuf, dwRead}; buf += tmp; } return true; } // TODO: GetExitCodeProcess is not sufficient for // determining if the process is actually dead or not. // (Process can return 259 as exit code). bool Process::isAlive() const { if (mCmd.length() == 0) return false; DWORD status; if (!GetExitCodeProcess(mProcInfo.hProcess, &status)) return false; return status == STILL_ACTIVE; } bool Process::isOpen() const { return mIsOpen; }
edf1e94702d5357acc033c9e16542a4296030b3f
b2634b890dc73fcc445d86766a83a24c1dfaa64c
/cpluscplus_pracice/polymorphism.h
3155269f2dd2458101d0e12519eb3ba1fe982e7d
[]
no_license
xiaocong-1024/study
b9793979104e90fe54ef307cd4f3219cc6f74aca
0808254ef75e9a49358b6ab2f1f92d1f7bb17b45
refs/heads/master
2021-06-15T03:44:38.135330
2017-03-22T17:01:31
2017-03-22T17:01:31
null
0
0
null
null
null
null
GB18030
C++
false
false
930
h
polymorphism.h
#pragma once class Point { public: Point(float x = 0, float y = 0);//构造函数 void setPoint(float a, float b);//设置坐标值 float getX()const//获取x坐标 { return _x; } float getY()const//获取y坐标 { return _y; } friend ostream& operator<<(ostream& _cout, const Point& p); protected: float _x; float _y; }; class Circle :public Point { public : Circle(float x = 0, float y = 0, float r = 0);//构造函数 void setRadius(float r);//设置半径值 float getRadius()const;//获取半径值 float area()const; friend ostream& operator<<(ostream& _cout, const Circle& c); protected : float radius; }; class Cylinder :public Circle { public : Cylinder(float x = 0, float y = 0, float r = 0, float h = 0); void setHeight(float h); float getHeight()const; float area()const; float volume()const; friend ostream& operator<<(ostream& _cout, const Cylinder& c); protected : float height; };
1e5cdc8f69f8dbd6543c41b829b23e2d7a140add
71488f1c516dd54decf72b6679598d2f4a40b312
/scrollUp.cc
dd5a6f6612fdb8ce3d47669364b77510091a65b3
[]
no_license
bzheng98/bill-josh-vm
4ba9d1a2c1f9c50218613c97ae7abd51180f7219
a3974f9e1ea548f2a9f6c72d33941a645040fb74
refs/heads/master
2021-05-07T06:52:29.341791
2017-12-05T04:07:32
2017-12-05T04:07:39
111,737,376
0
0
null
null
null
null
UTF-8
C++
false
false
210
cc
scrollUp.cc
#include "scrollUp.h" #include "vm.h" void ScrollUp::update(const CommandInfo &c) { if(c.getCommandType() == SCROLLUP) { vm->scrollViewsUp(); fileManager -> setCursorPosition(vm -> getViewCursor()); } }