blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
7
| license_type
stringclasses 2
values | repo_name
stringlengths 6
79
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 4
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.07k
426M
⌀ | star_events_count
int64 0
27
| fork_events_count
int64 0
12
| gha_license_id
stringclasses 3
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 6
values | src_encoding
stringclasses 26
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 20
6.28M
| extension
stringclasses 20
values | content
stringlengths 20
6.28M
| authors
sequencelengths 1
16
| author_lines
sequencelengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7a6036e96fd845ec37ca25c9aa9f71ddb1a0368c | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/branches/persistence2/engine/core/src/GameAreaListener.cpp | aa1422e2d3feebea40a7ea9300216f714b44cccc | [
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | jacmoe/dsa-hl-svn | 55b05b6f28b0b8b216eac7b0f9eedf650d116f85 | 97798e1f54df9d5785fb206c7165cd011c611560 | refs/heads/master | 2021-04-22T12:07:43.389000 | 2009-11-27T22:01:03 | 2009-11-27T22:01:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,437 | cpp | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2008 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* 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
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#include "stdinc.h" //precompiled header
#include "GameAreaListener.h"
#include "GameEventManager.h"
#include "CoreSubsystem.h"
#include "Exception.h"
namespace rl {
GameAreaListener::~GameAreaListener()
{
GameEventManager::getSingleton().removeAreaListener( this );
}
bool GameAreaListener::eventRaised( GameAreaEvent* anEvent )
{
switch( anEvent->getReason() )
{
case GameAreaEvent::AREA_ENTERED:
this->areaEntered( anEvent );
break;
case GameAreaEvent::AREA_LEFT:
this->areaLeft( anEvent );
break;
}
// consumed or not ;)
return false;
}
}
| [
"timm@4c79e8ff-cfd4-0310-af45-a38c79f83013"
] | [
[
[
1,
50
]
]
] |
7e8ebf50b4cab70e0a58371c84215900f8d81968 | 37c757f24b674f67edd87b75b996d8d5015455cb | /Server/include/dataProcess.h | 1f4dbe31a1e5d83d7d203ca5b3b02f72a0c9bbb1 | [] | no_license | SakuraSinojun/cotalking | 1118602313f85d1c49d73e1603cf6642bc15f36d | 37354d99db6b7033019fd0aaccec84e68aee2adf | refs/heads/master | 2021-01-10T21:20:50.269000 | 2011-04-07T06:15:04 | 2011-04-07T06:15:04 | 32,323,167 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 877 | h | /***************************************************
Project: grouptalk
author: TaXueWuHen
data Process;
***************************************************/
#ifndef __TALK_DATAPROCESS_H__
#define __TALK_DATAPROCESS_H__
#include <stdio.h>
#include <map>
#include "../include/def.h"
#include "../include/defGroupTalk.h"
#include "../include/publicOpt.h"
#include "../include/dataManager.h"
using namespace std;
// data cache
typedef struct st_scDataCache
{
int dataLength;
char data[C_SCDATA_LENGTH * 2];
} scDataCache, *pscDataCache;
class TS_dataProcess
{
private:
int cachePoint;
map<int, pscDataCache> m_dataCache;
TS_dataManager *dataMng;
public:
TS_dataProcess();
~TS_dataProcess();
public:
void* getAddr(int key);
bool dataAnalyse(int key, int size);
void setDataManager(TS_dataManager *pdm);
};
#endif
| [
"SakuraSinojun@02eed91f-dd82-7cf9-bfd0-73567c4360d3"
] | [
[
[
1,
41
]
]
] |
3c497426140ad1e4ebbbb1072d4cf9ba74b7fdc9 | 6188f1aaaf5508e046cde6da16b56feb3d5914bc | /branches/CamFighter 1.0/Source Files/MenuStates/EditModelState.h | 0a5e2dff09eb1fc6b975fb1f5e4d42eb0e4c2539 | [] | no_license | dogtwelve/fighter3d | 7bb099f0dc396e8224c573743ee28c54cdd3d5a2 | c073194989bc1589e4aa665714c5511f001e6400 | refs/heads/master | 2021-04-30T15:58:11.300000 | 2011-06-27T18:51:30 | 2011-06-27T18:51:30 | 33,675,635 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,962 | h | // included in MenuStates.h
#include "../../Graphics/OGL/Button.h"
#include "../SceneSkeleton.h"
namespace Scenes { namespace Menu {
class EditModelState : public BaseState {
std::vector<Graphics::OGL::Button> Buttons;
Filesystem::Vec_string Directories;
Filesystem::Vec_string Files;
std::string CurrentDirectory;
std::string ModelGrFile;
std::string ModelPhFile;
HTexture backGround;
virtual void Init(BaseState *parent)
{
BaseState::Init(parent);
Name = "Model editor";
ModelGrFile.clear();
ModelPhFile.clear();
CurrentDirectory = Filesystem::GetFullPath("Data/models");
Buttons.clear();
GetFiles();
backGround = g_TextureMgr.GetTexture("Data/textures/menu/model_editor.tga");
}
virtual void Clear()
{
BaseState::Clear();
g_TextureMgr.Release(backGround);
backGround = HTexture();
}
virtual void Enter()
{
ModelGrFile.clear();
ModelPhFile.clear();
}
void GetFiles()
{
Directories = Filesystem::GetDirectories(CurrentDirectory);
Files = Filesystem::GetFiles(CurrentDirectory, "*.3dx");
const Filesystem::Vec_string &f3ds = Filesystem::GetFiles(CurrentDirectory, "*.3ds");
Files.insert(Files.end(), f3ds.begin(), f3ds.end());
}
virtual bool Update(xFLOAT T_time)
{
if (!BaseState::Update(T_time))
{
if (g_InputMgr.InputDown_GetAndRaise(IC_LClick))
{
xFLOAT mouseX = (xFLOAT)g_InputMgr.mouseX;
xFLOAT mouseY = (xFLOAT)g_InputMgr.mouseY;
for (size_t i = 0; i < Buttons.size(); ++i)
{
Graphics::OGL::Button &button = Buttons[i];
if (button.HitTest(mouseX, mouseY))
{
if (button.Action == IC_BE_Move)
{
if (!strcmp(button.Text, ".."))
CurrentDirectory = Filesystem::GetParentDir(CurrentDirectory);
else
{
CurrentDirectory += "/";
CurrentDirectory += button.Text;
}
GetFiles();
}
else
if (button.Action == IC_BE_Select)
{
if (ModelGrFile.size())
{
ModelPhFile = CurrentDirectory + "/" + button.Text;
if (ModelPhFile != ModelGrFile)
g_Application.Scene_Set(*
new SceneSkeleton(ModelGrFile.c_str(), ModelPhFile.c_str()), false);
else
g_Application.Scene_Set(*
new SceneSkeleton(ModelGrFile.c_str(), NULL), false);
ModelGrFile.clear();
ModelPhFile.clear();
return true;
}
else
ModelGrFile = CurrentDirectory + "/" + button.Text;
}
return true;
}
}
}
}
return true;
}
virtual void Render(const Graphics::OGL::Font* pFont03, const Graphics::OGL::Font* pFont04,
xDWORD Width, xDWORD Height)
{
if (!backGround.IsNull())
{
glColor4f( 1.0f, 1.0f, 1.0f, 1.f );
glEnable (GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
xFLOAT scale = Height * 0.7f / 1024.f;
xFLOAT iWidth = scale * g_TextureMgr.GetWidth(backGround);
xFLOAT iHeight = scale * g_TextureMgr.GetHeight(backGround);
xFLOAT left = Width - iWidth - 170.f*scale;
xFLOAT top = Height - iHeight - 480.f*scale;
g_TextureMgr.BindTexture(backGround);
glBegin(GL_QUADS);
{
glTexCoord2f(0.01f,0.99f);
glVertex2f(left, top);
glTexCoord2f(0.99f,0.99f);
glVertex2f(left+iWidth, top);
glTexCoord2f(0.99f,0.01f);
glVertex2f(left+iWidth, top+iHeight);
glTexCoord2f(0.01f,0.01f);
glVertex2f(left, top+iHeight);
}
glEnd();
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
}
xFLOAT lineHeight03 = pFont03->LineH();
xFLOAT top = lineHeight03-3, left = 5, width = Width*0.333f-10;
Buttons.clear();
for (size_t i=0; i<Directories.size(); ++i)
{
top += lineHeight03+3;
if (top > Height-lineHeight03) { top = lineHeight03*2.f; left += Width*0.333f; }
Buttons.push_back(Graphics::OGL::Button(Directories[i].c_str(), left, top, width, lineHeight03*1.f, IC_BE_Move));
}
for (size_t i=0; i<Files.size(); ++i)
{
top += lineHeight03+3;
if (top > Height-lineHeight03) { top = lineHeight03*2.f; left += Width*0.333f; }
Buttons.push_back(Graphics::OGL::Button(Files[i].c_str(), left, top, width, lineHeight03*1.f, IC_BE_Select));
Buttons.back().Background.init(0.35f,0.35f,0.35f,1.f);
}
int X = g_InputMgr.mouseX;
int Y = g_InputMgr.mouseY;
std::vector<Graphics::OGL::Button>::iterator begin = Buttons.begin();
std::vector<Graphics::OGL::Button>::iterator end = Buttons.end();
for (; begin != end; ++begin)
{
begin->Hover((xFLOAT)X, (xFLOAT)Y);
begin->Down = ModelGrFile == CurrentDirectory + "/" + begin->Text;
begin->Render(pFont03);
}
}
};
} } // namespace Scenes::Menu
| [
"dmaciej1@f75eed02-8a0f-11dd-b20b-83d96e936561"
] | [
[
[
1,
175
]
]
] |
54d4af5b8e1032bdbfd9308dc662e92e056cc174 | 5e6ff9e6e8427078135a7b4d3b194bcbf631e9cd | /EngineSource/dpslim/dpslim/Database/Headers/MSDatabase.h | abe55790fac1b862a7fd587767617702d20aebf1 | [] | no_license | karakots/dpresurrection | 1a6f3fca00edd24455f1c8ae50764142bb4106e7 | 46725077006571cec1511f31d314ccd7f5a5eeef | refs/heads/master | 2016-09-05T09:26:26.091000 | 2010-02-01T11:24:41 | 2010-02-01T11:24:41 | 32,189,181 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,139 | h | #pragma once
#define _CRT_SECURE_NO_WARNINGS
// Database accessing routines using MFC classes for ODBC
//
// Copyright 2003 by DecisionPower
//
// author: Vicki de Mey
// creation data: 9/18/2003
//
//
#define __MSDATABASE__
#include <afxdb.h> // MFC ODBC database classes
#include <stdafx.h>
#include <string>
#include "DBModel.h"
#include "DBBrand.h"
#include "DBChannel.h"
#include "DBConsumerPrefs.h"
#include "DBDistDisplay.h"
#include "DBInitialConds.h"
#include "DBMassMedia.h"
#include "DBMarketUtility.h"
#include "DBProdAttr.h"
#include "DBProdAttrVal.h"
#include "DBProdChan.h"
#include "DBProduct.h"
#include "DBProductTree.h"
#include "DBSegChan.h"
#include "DBSegment.h"
#include "DBTask.h"
#include "DBTaskProd.h"
#include "DBTaskRates.h"
#include "DBProdMatrix.h"
#include "DBScenarioParams.h"
#include "DBScenarioOutputSummary.h"
#include "DBOptimizationPlan.h"
#include "DBProductEvent.h"
#include "DBTaskEvent.h"
#include "DBSimQueue.h"
#include "DBSimulation.h"
#include "DBSocNetwork.h"
#include "DBNetworkParams.h"
#include "DBSimLog.h"
#include "DBProdSize.h"
// forward declare
class ParameterRecordset;
class ProductTreeRecordset;
//#include "custrecord.h"
//#include "employeerecord.h"
// VdM 12/6/04
// wrapper for out results tables
#ifndef __OUTPUTRESULTS__
#include "OutputResults.h"
#endif
using namespace std;
enum {
kText = 1,
kNumber,
kFloat
};
class MSDatabase
{
public:
// default preferences
CDatabase iTheCurrentDB;
CDatabase writeDataDB;
// read only
ModelRecordset* m_ModelInfo;
ChannelRecordset* m_Channel;
ConsumerPrefsRecordset* m_ConsumerPrefs;
DistDisplayRecordset* m_DistDisplay;
InitialCondsRecordset* m_InitalConds;
MassMediaRecordset* m_MassMedia;
MarketUtilityRecordset* m_MarketUtility;
ProdAttrRecordset* m_ProdAttr;
ProdAttrValRecordset* m_ProdAttrVal;
ProdChanRecordset* m_ProdChan;
ProductRecordset* m_Product;
SegChanRecordset* m_SegChan;
SegmentRecordset* m_Segment;
ProductEventRecordset* m_ProductEvent;
TaskEventRecordset* m_TaskEvent;
TaskRecordset* m_Task;
TaskProdRecordset* m_TaskProd;
TaskRatesRecordset* m_TaskRates;
ProductMatrixRecordset* m_ProdMatrix;
ProductTreeRecordset* m_ProductTree;
ProductSizeRecordset* m_product_size;
// VdM 10/25/04
OptimizationParamsRecordset* m_OptimizationParams;
OptimizationPlanRecordset* m_OptimizationPlan;
// VdM 11/3/04
OptimizationOutSumRecordset* m_OptimizationOutputSummary;
// VdM 12/6/04
OutputResults* theOutputResults;
// SSN 1/11/2005
SimQueueRecordset* m_SimQueue;
// SSN 4/15/2005
SimulationRecordset* m_Simulation;
// SSN 4/26/2005
SocNetworkRecordset* m_SocNetwork;
// SSN 4/26/2005
NetworkParamsRecordset* m_NetworkParams;
SimLogRecordset* m_SimLog;
string comma;
string slash;
string iConnectString;
string iResultsTableName;
string iOptResultsTableName;
long iModelID;
long iRunID;
long iScenarioID;
long iStartTime;
int warningsLogged;
int dayLastWrite;
void ApplyParameters();
void RestoreValues();
void PreloadAllRecordsets(void);
void FreeAllRecordsets(void);
public:
// methods
// create & destroy
MSDatabase(void);
~MSDatabase(void);
int Open(const char* fname, int run_id);
void InitOutput(void);
void GetConnectInfo(string* str) { iConnectString = *str; }
// read
int SelectModel(int run_id);
int Get(int paramID, int inTherecordNum);
void Get(int paramID, int inTheRecordNum, string* outString);
void GetBrandName(int brandID, string* brandName);
void GetProductName(int productID, string* productName);
void GetChannelName(int channelID, string* channelName);
void GetSegmentName(int segmentID, string* segmentName);
void GetTaskName(int taskID, string* taskName);
void GetProdAttrName(int prodAttrID, string* prodAttrName, double& tau);
// write
// void SetResults(string* inString, int optResults, int trialNum, int runNum);
void AddToString(string* outputString, CString str, int doComma);
void AddToString(string* outputString, int val, int doComma);
void AddToString(string* outputString, float val, int doComma);
void AddToString(string* outputString, CTime val, int doComma);
// VdM 10/25/04
// Scenarios
/* void SelectOptimizationParams(int modelID, int scenarioID);
void SelectOptimizationPlan(int modelID);
void SelectOptimizationOutputSummary(int modelID, int scenarioID);
*/ //void SetOptimizationOutputSummary(string* inString);
int GetOptimizationParam(int paramNum);
int SimStart();
int SimDone();
void SimStatus(const string message);
void SimStatus(CTime date, const string message);
SegmentData* NewSegData();
void WriteSegData();
SimLogRecordset* NewLogEntry();
short SimSeed();
};
| [
"Isaac.Noble@fd82578e-0ebe-11df-96d9-85c6b80b8d9c"
] | [
[
[
1,
211
]
]
] |
f4a14f73e014616805ba2c97f5b717de25d44bcc | 037faae47a5b22d3e283555e6b5ac2a0197faf18 | /plugins/gs/zerogs/dx/Regs.cpp | 30928d1fed2ceb67219b5e31b012386bfe9e7720 | [] | no_license | isabella232/pcsx2-sourceforge | 6e5aac8d0b476601bfc8fa83ded66c1564b8c588 | dbb2c3a010081b105a8cba0c588f1e8f4e4505c6 | refs/heads/master | 2023-03-18T22:23:15.102000 | 2008-11-17T20:10:17 | 2008-11-17T20:10:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 29,409 | cpp | /* ZeroGS
* Copyright (C) 2005-2006 [email protected]
*
* 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
*/
#if defined(_WIN32) || defined(__WIN32__)
#include <d3dx9.h>
#include <dxerr9.h>
#endif
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "GS.h"
#include "Mem.h"
#include "Regs.h"
#include "zerogs.h"
#include "targets.h"
#ifdef __MSCW32__
#pragma warning(disable:4244)
#endif
GIFRegHandler g_GIFPackedRegHandlers[16] = {
GIFRegHandlerPRIM, GIFPackedRegHandlerRGBA, GIFPackedRegHandlerSTQ, GIFPackedRegHandlerUV,
GIFPackedRegHandlerXYZF2, GIFPackedRegHandlerXYZ2, GIFRegHandlerTEX0_1, GIFRegHandlerTEX0_2,
GIFRegHandlerCLAMP_1, GIFRegHandlerCLAMP_2, GIFPackedRegHandlerFOG, GIFPackedRegHandlerNull,
GIFRegHandlerXYZF3, GIFRegHandlerXYZ3, GIFPackedRegHandlerA_D, GIFPackedRegHandlerNOP };
GIFRegHandler g_GIFRegHandlers[] = {
GIFRegHandlerPRIM, GIFRegHandlerRGBAQ, GIFRegHandlerST, GIFRegHandlerUV,
GIFRegHandlerXYZF2, GIFRegHandlerXYZ2, GIFRegHandlerTEX0_1, GIFRegHandlerTEX0_2,
GIFRegHandlerCLAMP_1, GIFRegHandlerCLAMP_2, GIFRegHandlerFOG, GIFRegHandlerNull,
GIFRegHandlerXYZF3, GIFRegHandlerXYZ3, GIFRegHandlerNOP, GIFRegHandlerNOP,
GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull,
GIFRegHandlerTEX1_1, GIFRegHandlerTEX1_2, GIFRegHandlerTEX2_1, GIFRegHandlerTEX2_2,
GIFRegHandlerXYOFFSET_1,GIFRegHandlerXYOFFSET_2,GIFRegHandlerPRMODECONT,GIFRegHandlerPRMODE,
GIFRegHandlerTEXCLUT, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull,
GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerSCANMSK, GIFRegHandlerNull,
GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull,
GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull,
GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull,
GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull,
GIFRegHandlerMIPTBP1_1, GIFRegHandlerMIPTBP1_2, GIFRegHandlerMIPTBP2_1, GIFRegHandlerMIPTBP2_2,
GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerTEXA,
GIFRegHandlerNull, GIFRegHandlerFOGCOL, GIFRegHandlerNull, GIFRegHandlerTEXFLUSH,
GIFRegHandlerSCISSOR_1, GIFRegHandlerSCISSOR_2, GIFRegHandlerALPHA_1, GIFRegHandlerALPHA_2,
GIFRegHandlerDIMX, GIFRegHandlerDTHE, GIFRegHandlerCOLCLAMP, GIFRegHandlerTEST_1,
GIFRegHandlerTEST_2, GIFRegHandlerPABE, GIFRegHandlerFBA_1, GIFRegHandlerFBA_2,
GIFRegHandlerFRAME_1, GIFRegHandlerFRAME_2, GIFRegHandlerZBUF_1, GIFRegHandlerZBUF_2,
GIFRegHandlerBITBLTBUF, GIFRegHandlerTRXPOS, GIFRegHandlerTRXREG, GIFRegHandlerTRXDIR,
GIFRegHandlerHWREG, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull,
GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull,
GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull,
GIFRegHandlerSIGNAL, GIFRegHandlerFINISH, GIFRegHandlerLABEL, GIFRegHandlerNull };
C_ASSERT(sizeof(g_GIFRegHandlers)/sizeof(g_GIFRegHandlers[0]) == 100 );
// values for keeping track of changes
u32 s_uTex1Data[2][2] = {0}, s_uClampData[2] = {0};
void __fastcall GIFPackedRegHandlerNull(u32* data)
{
#ifdef _DEBUG
printf("Unexpected packed reg handler %8.8lx_%8.8lx %x\n", data[0], data[1], data[2]);
#endif
}
void __fastcall GIFPackedRegHandlerRGBA(u32* data)
{
gs.rgba = (data[0] & 0xff) |
((data[1] & 0xff) << 8) |
((data[2] & 0xff) << 16) |
((data[3] & 0xff) << 24);
gs.vertexregs.rgba = gs.rgba;
gs.vertexregs.q = gs.q;
}
void __fastcall GIFPackedRegHandlerSTQ(u32* data)
{
*(u32*)&gs.vertexregs.s = data[0]&0xffffff00;
*(u32*)&gs.vertexregs.t = data[1]&0xffffff00;
*(u32*)&gs.q = data[2];
}
void __fastcall GIFPackedRegHandlerUV(u32* data)
{
gs.vertexregs.u = data[0] & 0x3fff;
gs.vertexregs.v = data[1] & 0x3fff;
}
#define KICK_VERTEX2() { \
if( ++gs.primC >= (int)g_primmult[prim->prim]) { \
if( !(g_GameSettings&GAME_XENOSPECHACK) || !ZeroGS::vb[prim->ctxt].zbuf.zmsk ) \
(*ZeroGS::drawfn[prim->prim])(); \
gs.primC -= g_primsub[prim->prim]; \
} \
} \
#define KICK_VERTEX3() { \
if( ++gs.primC >= (int)g_primmult[prim->prim] ) { \
gs.primC -= g_primsub[prim->prim]; \
if( prim->prim == 5 ) { \
/* tri fans need special processing */ \
if( gs.nTriFanVert == gs.primIndex ) \
gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex); \
} \
} \
} \
void __fastcall GIFPackedRegHandlerXYZF2(u32* data)
{
gs.vertexregs.x = (data[0] >> 0) & 0xffff;
gs.vertexregs.y = (data[1] >> 0) & 0xffff;
gs.vertexregs.z = (data[2] >> 4) & 0xffffff;
gs.vertexregs.f = (data[3] >> 4) & 0xff;
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex);
if( data[3] & 0x8000 ) {
KICK_VERTEX3();
}
else {
KICK_VERTEX2();
}
}
void __fastcall GIFPackedRegHandlerXYZ2(u32* data)
{
gs.vertexregs.x = (data[0] >> 0) & 0xffff;
gs.vertexregs.y = (data[1] >> 0) & 0xffff;
gs.vertexregs.z = data[2];
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex);
if( data[3] & 0x8000 ) {
KICK_VERTEX3();
}
else {
KICK_VERTEX2();
}
}
void __fastcall GIFPackedRegHandlerFOG(u32* data)
{
gs.vertexregs.f = (data[3]&0xff0)>>4;
}
void __fastcall GIFPackedRegHandlerA_D(u32* data)
{
if((data[2] & 0xff) < 100)
g_GIFRegHandlers[data[2] & 0xff](data);
else
GIFRegHandlerNull(data);
}
void __fastcall GIFPackedRegHandlerNOP(u32* data)
{
}
extern int g_PrevBitwiseTexX, g_PrevBitwiseTexY;
void tex0Write(int i, u32 *data)
{
u32 psm = (data[0] >> 20) & 0x3f;
if( psm == 9 ) psm = 1; // hmm..., ffx intro menu
if( m_Blocks[psm].bpp == 0 ) {
// kh and others
return;
}
ZeroGS::vb[i].uNextTex0Data[0] = data[0];
ZeroGS::vb[i].uNextTex0Data[1] = data[1];
ZeroGS::vb[i].bNeedTexCheck = 1;
// don't update unless necessary
if( PSMT_ISCLUT(psm) ) {
if( ZeroGS::CheckChangeInClut(data[1], psm) ) {
// loading clut, so flush whole texture
ZeroGS::vb[i].FlushTexData();
}
// check if csa is the same!! (ffx bisaid island, grass)
else if( (data[1]&0x1f780000) != (ZeroGS::vb[i].uCurTex0Data[1]&0x1f780000) ) {
ZeroGS::Flush(i); // flush any previous entries
}
}
}
void tex2Write(int i, u32 *data)
{
tex0Info& tex0 = ZeroGS::vb[i].tex0;
if( ZeroGS::vb[i].bNeedTexCheck )
ZeroGS::vb[i].FlushTexData();
u32 psm = (data[0] >> 20) & 0x3f;
if( psm == 9 ) psm = 1; // hmm..., ffx intro menu
u32* s_uTex0Data = ZeroGS::vb[i].uCurTex0Data;
// don't update unless necessary
if( (s_uTex0Data[0]&0x03f00000) == (data[0]&0x03f00000) ) { // psm is the same
if( PSMT_ISCLUT(psm) ) {
// have to write the CLUT again if changed
if( (s_uTex0Data[1]&0x1fffffe0) == (data[1]&0x1fffffe0) ) {
if( data[1]&0xe0000000 ) {
tex0.cld = (data[1]>>29)&7;
ZeroGS::texClutWrite(i);
// invalidate to make sure target didn't change!
ZeroGS::vb[i].bVarsTexSync = FALSE;
}
return;
}
// CSAs have to be the same!
// if( (data[1]&0xe0000000) == 0 ) {
//
// if( (s_uTex0Data[1]&0x1f100000) != (data[1]&0x1f100000) )
// ZeroGS::Flush(i);
//
// // clut isn't going to be loaded so can ignore, but at least update CSA and CPSM!
// ZeroGS::vb[i].uCurTex0Data[1] = (ZeroGS::vb[i].uCurTex0Data[1]&0xe087ffff)|(data[1]&0x1f780000);
//
// if( ZeroGS::vb[i].tex0.cpsm <= 1 ) ZeroGS::vb[i].tex0.csa = (data[1] >> 24) & 0xf;
// else ZeroGS::vb[i].tex0.csa = (data[1] >> 24) & 0x1f;
//
// ZeroGS::vb[i].tex0.cpsm = (data[1] >> 19) & 0xe;
//
// ZeroGS::vb[i].bVarsTexSync = FALSE;
// return;
// }
// fall through
}
else {
//ZeroGS::vb[i].bVarsTexSync = FALSE;
return;
}
}
ZeroGS::Flush(i);
ZeroGS::vb[i].bVarsTexSync = FALSE;
ZeroGS::vb[i].bTexConstsSync = FALSE;
s_uTex0Data[0] = (s_uTex0Data[0]&~0x03f00000)|(psm<<20);
s_uTex0Data[1] = (s_uTex0Data[1]&0x1f)|(data[1]&~0x1f);
tex0.psm = psm;
if( PSMT_ISCLUT(tex0.psm) ) {
tex0.cbp = (data[1] >> 5) & 0x3fff;
tex0.cpsm = (data[1] >> 19) & 0xe;
tex0.csm = (data[1] >> 23) & 0x1;
if( tex0.cpsm <= 1 ) tex0.csa = (data[1] >> 24) & 0xf;
else tex0.csa = (data[1] >> 24) & 0x1f;
tex0.cld = (data[1] >> 29) & 0x7;
ZeroGS::texClutWrite(i);
}
}
__forceinline void frameWrite(int i, u32 *data)
{
frameInfo& gsfb = ZeroGS::vb[i].gsfb;
if( (gsfb.fbp == ((data[0] ) & 0x1ff) * 32) &&
(gsfb.fbw == ((data[0] >> 16) & 0x3f) * 64) &&
gsfb.psm == ((data[0] >> 24) & 0x3f) &&
(gsfb.fbm == data[1]) ) {
return;
}
ZeroGS::Flush(0);
ZeroGS::Flush(1);
gsfb.fbp = ((data[0] ) & 0x1ff) * 32;
gsfb.fbw = ((data[0] >> 16) & 0x3f) * 64;
gsfb.psm = (data[0] >> 24) & 0x3f;
gsfb.fbm = data[1];
if (gsfb.fbw > 0) {
gsfb.fbh = (1024*1024-64*gsfb.fbp) / gsfb.fbw;
gsfb.fbh &= ~0x1f;
if( gsfb.psm & 2 )
gsfb.fbh *= 2;
if( gsfb.fbh > 1024 ) gsfb.fbh = 1024;
}
else gsfb.fbh = 0;
if( gsfb.psm == 1 ) gsfb.fbm |= 0xff000000;
else if( gsfb.psm & 2 ) {
}
ZeroGS::vb[i].bNeedFrameCheck = 1;
}
__forceinline void testWrite(int i, u32 *data)
{
pixTest* test = &ZeroGS::vb[i].test;
if( (*(u32*)test & 0x0007ffff) == (data[0] & 0x0007ffff) )
return;
ZeroGS::Flush(i);
*(u32*)test = data[0];
// test.ate = (data[0] ) & 0x1;
// test.atst = (data[0] >> 1) & 0x7;
// test.aref = (data[0] >> 4) & 0xff;
// test.afail = (data[0] >> 12) & 0x3;
// test.date = (data[0] >> 14) & 0x1;
// test.datm = (data[0] >> 15) & 0x1;
// test.zte = (data[0] >> 16) & 0x1;
// test.ztst = (data[0] >> 17) & 0x3;
}
__forceinline void clampWrite(int i, u32 *data)
{
clampInfo& clamp = ZeroGS::vb[i].clamp;
if( s_uClampData[i] != data[0] || ((clamp.minv>>8)|(clamp.maxv<<2)) != (data[1]&0x0fff) ) {
// if( ZeroGS::vb[i].bNeedTexCheck )
// ZeroGS::vb[i].FlushTexData();
ZeroGS::Flush(i);
s_uClampData[i] = data[0];
clamp.wms = (data[0] ) & 0x3;
clamp.wmt = (data[0] >> 2) & 0x3;
clamp.minu = (data[0] >> 4) & 0x3ff;
clamp.maxu = (data[0] >> 14) & 0x3ff;
clamp.minv =((data[0] >> 24) & 0xff) | ((data[1] & 0x3) << 8);
clamp.maxv = (data[1] >> 2) & 0x3ff;
ZeroGS::vb[i].bTexConstsSync = FALSE;
}
}
void __fastcall GIFRegHandlerNull(u32* data)
{
#ifdef _DEBUG
if( (((uptr)&data[2])&0xffff) == 0 )
return;
// 0x7f happens on a lot of games
if( data[2] != 0x7f && (data[0] || data[1]) ) {
printf("Unexpected reg handler %x %x %x\n", data[0], data[1], data[2]);
}
#endif
}
void __fastcall GIFRegHandlerPRIM(u32 *data) {
if (data[0] & ~0x3ff) {
#ifdef WARN_LOG
//WARN_LOG("warning: unknown bits in prim %8.8lx_%8.8lx\n", data[1], data[0]);
#endif
}
gs.nTriFanVert = gs.primIndex;
gs.primC = 0;
prim->prim = (data[0]) & 0x7;
gs._prim[0].prim = (data[0]) & 0x7;
gs._prim[1].prim = (data[0]) & 0x7;
gs._prim[1]._val = (data[0]>>3)&0xff;
ZeroGS::Prim();
}
void __fastcall GIFRegHandlerRGBAQ(u32* data)
{
gs.rgba = data[0];
gs.vertexregs.rgba = data[0];
*(u32*)&gs.vertexregs.q = data[1];
}
void __fastcall GIFRegHandlerST(u32* data)
{
*(u32*)&gs.vertexregs.s = data[0]&0xffffff00;
*(u32*)&gs.vertexregs.t = data[1]&0xffffff00;
//*(u32*)&gs.q = data[2];
}
void __fastcall GIFRegHandlerUV(u32* data)
{
gs.vertexregs.u = (data[0]) & 0x3fff;
gs.vertexregs.v = (data[0] >> 16) & 0x3fff;
}
void __fastcall GIFRegHandlerXYZF2(u32* data)
{
gs.vertexregs.x = (data[0]) & 0xffff;
gs.vertexregs.y = (data[0] >> (16)) & 0xffff;
gs.vertexregs.z = data[1] & 0xffffff;
gs.vertexregs.f = data[1] >> 24;
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex);
KICK_VERTEX2();
}
void __fastcall GIFRegHandlerXYZ2(u32* data)
{
gs.vertexregs.x = (data[0]) & 0xffff;
gs.vertexregs.y = (data[0] >> (16)) & 0xffff;
gs.vertexregs.z = data[1];
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex);
KICK_VERTEX2();
}
void __fastcall GIFRegHandlerTEX0_1(u32* data)
{
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[0].zbuf.zmsk ) {
return;
}
tex0Write(0, data);
}
void __fastcall GIFRegHandlerTEX0_2(u32* data)
{
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[1].zbuf.zmsk ) {
return;
}
tex0Write(1, data);
}
void __fastcall GIFRegHandlerCLAMP_1(u32* data)
{
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[0].zbuf.zmsk ) {
return;
}
clampWrite(0, data);
}
void __fastcall GIFRegHandlerCLAMP_2(u32* data)
{
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[1].zbuf.zmsk ) {
return;
}
clampWrite(1, data);
}
void __fastcall GIFRegHandlerFOG(u32* data)
{
//gs.gsvertex[gs.primIndex].f = (data[1] >> 24); // shift to upper bits
gs.vertexregs.f = data[1]>>24;
}
void __fastcall GIFRegHandlerXYZF3(u32* data)
{
gs.vertexregs.x = (data[0]) & 0xffff;
gs.vertexregs.y = (data[0] >> (16)) & 0xffff;
gs.vertexregs.z = data[1] & 0xffffff;
gs.vertexregs.f = data[1] >> 24;
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex);
KICK_VERTEX3();
}
void __fastcall GIFRegHandlerXYZ3(u32* data)
{
gs.vertexregs.x = (data[0]) & 0xffff;
gs.vertexregs.y = (data[0] >> (16)) & 0xffff;
gs.vertexregs.z = data[1];
gs.gsvertex[gs.primIndex] = gs.vertexregs;
gs.primIndex = (gs.primIndex+1)%ARRAYSIZE(gs.gsvertex);
KICK_VERTEX3();
}
void __fastcall GIFRegHandlerNOP(u32* data)
{
}
void tex1Write(int i, u32* data)
{
tex1Info& tex1 = ZeroGS::vb[i].tex1;
if( conf.bilinear == 1 && (tex1.mmag != ((data[0] >> 5) & 0x1) || tex1.mmin != ((data[0] >> 6) & 0x7)) ) {
ZeroGS::Flush(i);
ZeroGS::vb[i].bVarsTexSync = FALSE;
}
tex1.lcm = (data[0] ) & 0x1;
tex1.mxl = (data[0] >> 2) & 0x7;
tex1.mmag = (data[0] >> 5) & 0x1;
tex1.mmin = (data[0] >> 6) & 0x7;
tex1.mtba = (data[0] >> 9) & 0x1;
tex1.l = (data[0] >> 19) & 0x3;
tex1.k = (data[1] >> 4) & 0xff;
}
void __fastcall GIFRegHandlerTEX1_1(u32* data)
{
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[0].zbuf.zmsk ) {
return;
}
tex1Write(0, data);
}
void __fastcall GIFRegHandlerTEX1_2(u32* data)
{
if( (g_GameSettings&GAME_XENOSPECHACK) && ZeroGS::vb[1].zbuf.zmsk )
return;
tex1Write(1, data);
}
void __fastcall GIFRegHandlerTEX2_1(u32* data)
{
tex2Write(0, data);
}
void __fastcall GIFRegHandlerTEX2_2(u32* data)
{
tex2Write(1, data);
}
void __fastcall GIFRegHandlerXYOFFSET_1(u32* data)
{
// eliminator low 4 bits for now
ZeroGS::vb[0].offset.x = (data[0]) & 0xffff;
ZeroGS::vb[0].offset.y = (data[1]) & 0xffff;
// if( !conf.interlace ) {
// ZeroGS::vb[0].offset.x &= ~15;
// ZeroGS::vb[0].offset.y &= ~15;
// }
}
void __fastcall GIFRegHandlerXYOFFSET_2(u32* data)
{
ZeroGS::vb[1].offset.x = (data[0]) & 0xffff;
ZeroGS::vb[1].offset.y = (data[1]) & 0xffff;
// if( !conf.interlace ) {
// ZeroGS::vb[1].offset.x &= ~15;
// ZeroGS::vb[1].offset.y &= ~15;
// }
}
void __fastcall GIFRegHandlerPRMODECONT(u32* data)
{
gs.prac = data[0] & 0x1;
prim = &gs._prim[gs.prac];
ZeroGS::Prim();
}
void __fastcall GIFRegHandlerPRMODE(u32* data)
{
gs._prim[0]._val = (data[0]>>3)&0xff;
if (gs.prac == 0)
ZeroGS::Prim();
}
void __fastcall GIFRegHandlerTEXCLUT(u32* data)
{
if( ZeroGS::vb[0].bNeedTexCheck )
ZeroGS::vb[0].FlushTexData();
if( ZeroGS::vb[1].bNeedTexCheck )
ZeroGS::vb[1].FlushTexData();
gs.clut.cbw = ((data[0] ) & 0x3f) * 64;
gs.clut.cou = ((data[0] >> 6) & 0x3f) * 16;
gs.clut.cov = (data[0] >> 12) & 0x3ff;
}
void __fastcall GIFRegHandlerSCANMSK(u32* data)
{
// ZeroGS::Flush(0);
// ZeroGS::Flush(1);
// ZeroGS::ResolveC(&ZeroGS::vb[0]);
// ZeroGS::ResolveZ(&ZeroGS::vb[0]);
gs.smask = data[0] & 0x3;
}
void __fastcall GIFRegHandlerMIPTBP1_1(u32* data)
{
miptbpInfo& miptbp0 = ZeroGS::vb[0].miptbp0;
miptbp0.tbp[0] = (data[0] ) & 0x3fff;
miptbp0.tbw[0] = (data[0] >> 14) & 0x3f;
miptbp0.tbp[1] = ((data[0] >> 20) & 0xfff) | ((data[1] & 0x3) << 12);
miptbp0.tbw[1] = (data[1] >> 2) & 0x3f;
miptbp0.tbp[2] = (data[1] >> 8) & 0x3fff;
miptbp0.tbw[2] = (data[1] >> 22) & 0x3f;
}
void __fastcall GIFRegHandlerMIPTBP1_2(u32* data)
{
miptbpInfo& miptbp0 = ZeroGS::vb[1].miptbp0;
miptbp0.tbp[0] = (data[0] ) & 0x3fff;
miptbp0.tbw[0] = (data[0] >> 14) & 0x3f;
miptbp0.tbp[1] = ((data[0] >> 20) & 0xfff) | ((data[1] & 0x3) << 12);
miptbp0.tbw[1] = (data[1] >> 2) & 0x3f;
miptbp0.tbp[2] = (data[1] >> 8) & 0x3fff;
miptbp0.tbw[2] = (data[1] >> 22) & 0x3f;
}
void __fastcall GIFRegHandlerMIPTBP2_1(u32* data)
{
miptbpInfo& miptbp1 = ZeroGS::vb[0].miptbp1;
miptbp1.tbp[0] = (data[0] ) & 0x3fff;
miptbp1.tbw[0] = (data[0] >> 14) & 0x3f;
miptbp1.tbp[1] = ((data[0] >> 20) & 0xfff) | ((data[1] & 0x3) << 12);
miptbp1.tbw[1] = (data[1] >> 2) & 0x3f;
miptbp1.tbp[2] = (data[1] >> 8) & 0x3fff;
miptbp1.tbw[2] = (data[1] >> 22) & 0x3f;
}
void __fastcall GIFRegHandlerMIPTBP2_2(u32* data)
{
miptbpInfo& miptbp1 = ZeroGS::vb[1].miptbp1;
miptbp1.tbp[0] = (data[0] ) & 0x3fff;
miptbp1.tbw[0] = (data[0] >> 14) & 0x3f;
miptbp1.tbp[1] = ((data[0] >> 20) & 0xfff) | ((data[1] & 0x3) << 12);
miptbp1.tbw[1] = (data[1] >> 2) & 0x3f;
miptbp1.tbp[2] = (data[1] >> 8) & 0x3fff;
miptbp1.tbw[2] = (data[1] >> 22) & 0x3f;
}
void __fastcall GIFRegHandlerTEXA(u32* data)
{
texaInfo newinfo;
newinfo.aem = (data[0] >> 15) & 0x1;
newinfo.ta[0] = data[0] & 0xff;
newinfo.ta[1] = data[1] & 0xff;
if( *(u32*)&newinfo != *(u32*)&gs.texa ) {
ZeroGS::Flush(0);
ZeroGS::Flush(1);
*(u32*)&gs.texa = *(u32*)&newinfo;
gs.texa.fta[0] = newinfo.ta[0]/255.0f;
gs.texa.fta[1] = newinfo.ta[1]/255.0f;
ZeroGS::vb[0].bTexConstsSync = FALSE;
ZeroGS::vb[1].bTexConstsSync = FALSE;
}
}
void __fastcall GIFRegHandlerFOGCOL(u32* data)
{
ZeroGS::SetFogColor(data[0]&0xffffff);
}
void __fastcall GIFRegHandlerTEXFLUSH(u32* data)
{
ZeroGS::SetTexFlush();
}
void __fastcall GIFRegHandlerSCISSOR_1(u32* data)
{
Rect2& scissor = ZeroGS::vb[0].scissor;
Rect2 newscissor;
newscissor.x0 = ((data[0] ) & 0x7ff) << 3;
newscissor.x1 = ((data[0] >> 16) & 0x7ff) << 3;
newscissor.y0 = ((data[1] ) & 0x7ff) << 3;
newscissor.y1 = ((data[1] >> 16) & 0x7ff) << 3;
if( newscissor.x1 != scissor.x1 || newscissor.y1 != scissor.y1 ||
newscissor.x0 != scissor.x0 || newscissor.y0 != scissor.y0 ) {
ZeroGS::Flush(0);
scissor = newscissor;
ZeroGS::vb[0].bNeedFrameCheck = 1;
}
}
void __fastcall GIFRegHandlerSCISSOR_2(u32* data)
{
Rect2& scissor = ZeroGS::vb[1].scissor;
Rect2 newscissor;
newscissor.x0 = ((data[0] ) & 0x7ff) << 3;
newscissor.x1 = ((data[0] >> 16) & 0x7ff) << 3;
newscissor.y0 = ((data[1] ) & 0x7ff) << 3;
newscissor.y1 = ((data[1] >> 16) & 0x7ff) << 3;
if( newscissor.x1 != scissor.x1 || newscissor.y1 != scissor.y1 ||
newscissor.x0 != scissor.x0 || newscissor.y0 != scissor.y0 ) {
ZeroGS::Flush(1);
scissor = newscissor;
// flush everything
ZeroGS::vb[1].bNeedFrameCheck = 1;
}
}
void __fastcall GIFRegHandlerALPHA_1(u32* data)
{
alphaInfo newalpha;
newalpha.abcd = *(u8*)data;
newalpha.fix = *(u8*)(data+1);
if( *(WORD*)&newalpha != *(WORD*)&ZeroGS::vb[0].alpha ) {
ZeroGS::Flush(0);
if( newalpha.a == 3 ) newalpha.a = 0;
if( newalpha.b == 3 ) newalpha.b = 0;
if( newalpha.c == 3 ) newalpha.c = 0;
if( newalpha.d == 3 ) newalpha.d = 0;
*(WORD*)&ZeroGS::vb[0].alpha = *(WORD*)&newalpha;
}
}
void __fastcall GIFRegHandlerALPHA_2(u32* data)
{
alphaInfo newalpha;
newalpha.abcd = *(u8*)data;
newalpha.fix = *(u8*)(data+1);
if( *(WORD*)&newalpha != *(WORD*)&ZeroGS::vb[1].alpha ) {
ZeroGS::Flush(1);
if( newalpha.a == 3 ) newalpha.a = 0;
if( newalpha.b == 3 ) newalpha.b = 0;
if( newalpha.c == 3 ) newalpha.c = 0;
if( newalpha.d == 3 ) newalpha.d = 0;
*(WORD*)&ZeroGS::vb[1].alpha = *(WORD*)&newalpha;
}
}
void __fastcall GIFRegHandlerDIMX(u32* data)
{
}
void __fastcall GIFRegHandlerDTHE(u32* data)
{
gs.dthe = data[0] & 0x1;
}
void __fastcall GIFRegHandlerCOLCLAMP(u32* data)
{
gs.colclamp = data[0] & 0x1;
}
void __fastcall GIFRegHandlerTEST_1(u32* data)
{
testWrite(0, data);
}
void __fastcall GIFRegHandlerTEST_2(u32* data)
{
testWrite(1, data);
}
void __fastcall GIFRegHandlerPABE(u32* data)
{
//ZeroGS::SetAlphaChanged(0, GPUREG_PABE);
//ZeroGS::SetAlphaChanged(1, GPUREG_PABE);
ZeroGS::Flush(0);
ZeroGS::Flush(1);
gs.pabe = *data & 0x1;
}
void __fastcall GIFRegHandlerFBA_1(u32* data)
{
ZeroGS::Flush(0);
ZeroGS::Flush(1);
ZeroGS::vb[0].fba.fba = *data & 0x1;
}
void __fastcall GIFRegHandlerFBA_2(u32* data)
{
ZeroGS::Flush(0);
ZeroGS::Flush(1);
ZeroGS::vb[1].fba.fba = *data & 0x1;
}
void __fastcall GIFRegHandlerFRAME_1(u32* data)
{
frameWrite(0, data);
}
void __fastcall GIFRegHandlerFRAME_2(u32* data)
{
frameWrite(1, data);
}
void __fastcall GIFRegHandlerZBUF_1(u32* data)
{
zbufInfo& zbuf = ZeroGS::vb[0].zbuf;
int psm = (0x30|((data[0] >> 24) & 0xf));
if( zbuf.zbp == (data[0] & 0x1ff) * 32 &&
zbuf.psm == psm &&
zbuf.zmsk == (data[1] & 0x1) ) {
return;
}
// error detection
if( m_Blocks[psm].bpp == 0 )
return;
ZeroGS::Flush(0);
ZeroGS::Flush(1);
zbuf.zbp = (data[0] & 0x1ff) * 32;
zbuf.psm = 0x30|((data[0] >> 24) & 0xf);
zbuf.zmsk = data[1] & 0x1;
ZeroGS::vb[0].zprimmask = 0xffffffff;
if( zbuf.psm > 0x31 ) ZeroGS::vb[0].zprimmask = 0xffff;
ZeroGS::vb[0].bNeedZCheck = 1;
}
void __fastcall GIFRegHandlerZBUF_2(u32* data)
{
zbufInfo& zbuf = ZeroGS::vb[1].zbuf;
int psm = (0x30|((data[0] >> 24) & 0xf));
if( zbuf.zbp == (data[0] & 0x1ff) * 32 &&
zbuf.psm == psm &&
zbuf.zmsk == (data[1] & 0x1) ) {
return;
}
// error detection
if( m_Blocks[psm].bpp == 0 )
return;
ZeroGS::Flush(0);
ZeroGS::Flush(1);
zbuf.zbp = (data[0] & 0x1ff) * 32;
zbuf.psm = 0x30|((data[0] >> 24) & 0xf);
zbuf.zmsk = data[1] & 0x1;
ZeroGS::vb[1].bNeedZCheck = 1;
ZeroGS::vb[1].zprimmask = 0xffffffff;
if( zbuf.psm > 0x31 ) ZeroGS::vb[1].zprimmask = 0xffff;
}
void __fastcall GIFRegHandlerBITBLTBUF(u32* data)
{
gs.srcbufnew.bp = ((data[0] ) & 0x3fff);// * 64;
gs.srcbufnew.bw = ((data[0] >> 16) & 0x3f) * 64;
gs.srcbufnew.psm = (data[0] >> 24) & 0x3f;
gs.dstbufnew.bp = ((data[1] ) & 0x3fff);// * 64;
gs.dstbufnew.bw = ((data[1] >> 16) & 0x3f) * 64;
gs.dstbufnew.psm = (data[1] >> 24) & 0x3f;
if (gs.dstbufnew.bw == 0) gs.dstbufnew.bw = 64;
}
void __fastcall GIFRegHandlerTRXPOS(u32* data)
{
gs.trxposnew.sx = (data[0] ) & 0x7ff;
gs.trxposnew.sy = (data[0] >> 16) & 0x7ff;
gs.trxposnew.dx = (data[1] ) & 0x7ff;
gs.trxposnew.dy = (data[1] >> 16) & 0x7ff;
gs.trxposnew.dir = (data[1] >> 27) & 0x3;
}
void __fastcall GIFRegHandlerTRXREG(u32* data)
{
gs.imageWtemp = data[0]&0xfff;
gs.imageHtemp = data[1]&0xfff;
}
void __fastcall GIFRegHandlerTRXDIR(u32* data)
{
// terminate any previous transfers
switch( gs.imageTransfer ) {
case 0: // host->loc
gs.imageTransfer = -1;
break;
case 1: // loc->host
ZeroGS::TerminateLocalHost();
break;
}
gs.srcbuf = gs.srcbufnew;
gs.dstbuf = gs.dstbufnew;
gs.trxpos = gs.trxposnew;
gs.imageTransfer = data[0] & 0x3;
gs.imageWnew = gs.imageWtemp;
gs.imageHnew = gs.imageHtemp;
if( gs.imageWnew > 0 && gs.imageHnew > 0 ) {
switch(gs.imageTransfer) {
case 0: // host->loc
ZeroGS::InitTransferHostLocal();
break;
case 1: // loc->host
ZeroGS::InitTransferLocalHost();
break;
case 2:
ZeroGS::TransferLocalLocal();
break;
case 3:
gs.imageTransfer = -1;
break;
default: assert(0);
}
}
else {
#ifndef RELEASE_TO_PUBLIC
//WARN_LOG("ZeroGS: dummy transfer\n");
#endif
gs.imageTransfer = -1;
}
}
static u32 oldhw[4];
void __fastcall GIFRegHandlerHWREG(u32* data)
{
if( gs.imageTransfer == 0 ) {
ZeroGS::TransferHostLocal(data, 2);
}
else {
#ifndef RELEASE_TO_PUBLIC
ERROR_LOG("ZeroGS: HWREG!? %8.8x_%8.8x\n", data[0], data[1]);
//assert(0);
#endif
}
}
extern int g_GSMultiThreaded;
void __fastcall GIFRegHandlerSIGNAL(u32* data)
{
if(!g_GSMultiThreaded) {
SIGLBLID->SIGID = (SIGLBLID->SIGID&~data[1])|(data[0]&data[1]);
// if (gs.CSRw & 0x1) CSR->SIGNAL = 1;
// if (!IMR->SIGMSK && GSirq)
// GSirq();
if (gs.CSRw & 0x1) {
CSR->SIGNAL = 1;
//gs.CSRw &= ~1;
}
if (!IMR->SIGMSK && GSirq)
GSirq();
}
}
void __fastcall GIFRegHandlerFINISH(u32* data)
{
if(!g_GSMultiThreaded) {
if (gs.CSRw & 0x2)
CSR->FINISH = 1;
if (!IMR->FINISHMSK && GSirq)
GSirq();
// if( gs.CSRw & 2 ) {
// //gs.CSRw &= ~2;
// //CSR->FINISH = 0;
//
//
// }
// CSR->FINISH = 1;
//
// if( !IMR->FINISHMSK && GSirq )
// GSirq();
}
}
void __fastcall GIFRegHandlerLABEL(u32* data)
{
if(!g_GSMultiThreaded) {
SIGLBLID->LBLID = (SIGLBLID->LBLID&~data[1])|(data[0]&data[1]);
}
}
// special execute buffers
//ExecuteBufferXeno g_ebXeno;
//
//ExecuteBufferXeno::ExecuteBufferXeno()
//{
// clampdata[0] = clampdata[1] = 0;
// tex0data[0] = tex0data[1] = 0;
// tex1data[0] = tex1data[1] = 0;
// bCanExecute = true;
// curprim._val = 0;
//}
//
//void ExecuteBufferXeno::Execute()
//{
// if( vertices.size() == 0 || !bCanExecute)
// return;
//
// bCanExecute = false;
// ZeroGS::Flush(0);
// ZeroGS::Flush(1);
//
// int oldC = gs.primC;
// int ctx = curprim.ctxt;
//
// Vertex oldverts[3];
// oldverts[0] = gs.gsvertex[0];
// oldverts[1] = gs.gsvertex[1];
// oldverts[2] = gs.gsvertex[2];
//
// u32 oldtex0[2];
// tex1Info oldtex1 = ZeroGS::vb[ctx].tex1;
// clampInfo oldclamp = ZeroGS::vb[ctx].clamp;
// oldtex0[0] = ZeroGS::vb[ctx].uNextTex0Data[0];
// oldtex0[1] = ZeroGS::vb[ctx].uNextTex0Data[1];
//
// int oldmask = ZeroGS::vb[ctx].zbuf.zmsk;
// ZeroGS::vb[ctx].zbuf.zmsk = 1;
// tex0Write(0, tex0data);
// tex1Write(0, tex1data);
// clampWrite(0, clampdata);
// ZeroGS::vb[ctx].bTexConstsSync = FALSE;
// gs.primC = 3;
// u32 oldprim = prim->_val;
// prim->_val = curprim._val;
// for(int i = 0; i < (int)vertices.size(); i += 3) {
// gs.gsvertex[0] = vertices[i];
// gs.gsvertex[1] = vertices[i+1];
// gs.gsvertex[2] = vertices[i+2];
// (*ZeroGS::drawfn[4])(); // draw a triangle
// }
// vertices.resize(0);
//
// ZeroGS::Flush(ctx);
//
// ZeroGS::vb[ctx].zbuf.zmsk = oldmask;
// gs.primC = oldC;
// gs.gsvertex[0] = oldverts[0];
// gs.gsvertex[1] = oldverts[1];
// gs.gsvertex[2] = oldverts[2];
// ZeroGS::vb[ctx].clamp = oldclamp;
// ZeroGS::vb[ctx].tex1 = oldtex1;
// tex0Write(0, oldtex0);
// ZeroGS::vb[ctx].bTexConstsSync = FALSE;
// prim->_val = oldprim;
// bCanExecute = true;
//}
//
//void ExecuteBufferXeno::SetTex0(u32* data)
//{
// if( data[0] != tex0data[0] || (data[1]&0x1fffffff) != (tex0data[1]&0x1fffffff) )
// Execute();
//
// tex0data[0] = data[0];
// tex0data[1] = data[1];
//}
//
//void ExecuteBufferXeno::SetTex1(u32* data)
//{
// if( data[0] != tex1data[0] )
// Execute();
//
// tex1data[0] = data[0];
// tex1data[1] = data[1];
//}
//
//void ExecuteBufferXeno::SetClamp(u32* data)
//{
// if( data[0] != clampdata[0] || (data[1]&0xfff) != clampdata[1] )
// Execute();
//
// clampdata[0] = data[0];
// clampdata[1] = data[1]&0xfff;
//}
//
//void ExecuteBufferXeno::SetTri()
//{
// if( prim->_val != curprim._val )
// Execute();
// curprim._val = prim->_val;
// vertices.push_back(gs.gsvertex[0]);
// vertices.push_back(gs.gsvertex[1]);
// vertices.push_back(gs.gsvertex[2]);
//}
| [
"zerofrog@23c756db-88ba-2448-99d7-e6e4c676ec84"
] | [
[
[
1,
1113
]
]
] |
ecc758e0be2803a8d168107666369f4c6baeb07c | 7e68ef369eff945f581e22595adecb6b3faccd0e | /code/minifw/connector.h | e7edc00fb6aff51225b3b075c658e88219702768 | [] | no_license | kimhmadsen/mini-framework | 700bb1052227ba18eee374504ff90f41e98738d2 | d1983a68c6b1d87e24ef55ca839814ed227b3956 | refs/heads/master | 2021-01-01T05:36:55.074000 | 2008-12-16T00:33:10 | 2008-12-16T00:33:10 | 32,415,758 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 925 | h | /**
@file
*/
#pragma once
#include "eventhandler.h"
#include "reactor.h"
#include "sockconnector.h"
/**
Implements the Connector class from POSA2 page 290
Responsibility:
- Actively connects and initializes an associated Service Handler.
Collaborator:
- ServiceHandler
- Dispatcher
- TransportEndPoint
*/
template <class SERVICE_HANDLER>
// The <SERVICE_HANDLER> is the type of concrete
// service handler activated when a connection.
class Connector : public EventHandler
{
public:
Connector( Reactor* reactor): reactor(reactor){}
~Connector(void);
private:
SOCK_Connector connector;
/// Reactor used for asynchronous connection
/// completion event notifications.
Reactor* reactor;
/// Inherited from EventHandler to allow the
/// Reactor to notify the Connnector when events
/// complete asynchronously
virtual void HandleEvent(HANDLE handle, Event_Type et );
};
| [
"[email protected]@77f6bdef-6155-0410-8b08-fdea0229669f"
] | [
[
[
1,
40
]
]
] |
df43a8a60ecb2183acc565fd03ba37390fdb41d1 | e9944cc3f8c362cd0314a2d7a01291ed21de19ee | / xcommon/自由拼音输入法IME/source/HZmodenormal.cpp | 57185f1d8e30e1e348a33b7bce0d5f3c678d5d58 | [] | no_license | wermanhme1990/xcommon | 49d7185a28316d46992ad9311ae9cdfe220cb586 | c9b1567da1f11e7a606c6ed638a9fde1f6ece577 | refs/heads/master | 2016-09-06T12:43:43.593000 | 2008-12-05T04:24:11 | 2008-12-05T04:24:11 | 39,864,906 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,827 | cpp | /*
* Copyright (C) 1999.4 Li ZhenChun
*
* 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 is 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., 675 Mass Ave, Cambridge, M A 02139, USA.
*
* Author: Li ZhenChun email: [email protected] or [email protected]
*
*/
#include "stdafx.h"
#include "freepy.h"
BOOL CharHandleNormal( HIMC hIMC,WORD wParam,LONG lParam)
{
if( (wParam >= _T('a') && wParam <= _T('z')) || wParam == _T('\'') )
{
return AddChar(hIMC,wParam, EDIT_ADD);
}
else if( wParam == _T('=') || wParam == _T('.') || wParam == _T('>'))
{
return ForwardPage(hIMC);
}
else if( wParam == _T('-') || wParam == _T(',') || wParam == _T('<'))
{
return BackwardPage(hIMC);
}
else if( wParam >= _T('0') && wParam <= _T('9') )
{
return SelectCand(hIMC,wParam);
}
switch ( wParam )
{
case _T('!'):
case _T('@'):
case _T('#'):
case _T('$'):
case _T('%'):
case _T('^'):
case _T('&'):
case _T('*'):
case _T('('):
case _T(')'):
return DeletePhrase(hIMC,wParam);
default:
break;
}
return FALSE;
}
BOOL AddChar( HIMC hIMC, WORD wCode, WORD wEditMode)
{
LPINPUTCONTEXT lpIMC;
LPCOMPOSITIONSTRING lpCompStr;
LPCANDIDATEINFO lpCandInfo;
LPCANDIDATELIST lpCandList;
LPFREEPYCAND lpPYCand;
LPTSTR lpStr;
LPTSTR lpConvStr;
LPTSTR lpPaintStr;
TCHAR szTemp[150];
GENEMSG GnMsg;
LPTSTR lpPYArray;
WORD *lpwPYArrayLen;
WORD *lpwPYArrayCurPos;
SHORT *lpwUnConvPos;
SHORT *lpwEditCaret;
TCHAR cTempChar;
WORD wPYCount;
int i;
BOOL fRet = FALSE;
TCHAR szPreStr[150];
WORD wPreUnConvPos;
WORD wPreEditCaret;
lpIMC = ImmLockIMC(hIMC);
lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
lpStr = GETLPCOMPSTR(lpCompStr);
lpConvStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szConvCompStr;
lpPaintStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPaintCompStr;
lpPYArray = (LPTSTR)(((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPYArray);
lpwPYArrayLen = &(((LPMYCOMPSTR)lpCompStr)->FreePYComp.wPYArrayLen);
lpwPYArrayCurPos = &(((LPMYCOMPSTR)lpCompStr)->FreePYComp.wPYArrayCurPos);
lpwUnConvPos = &(((LPMYCOMPSTR)lpCompStr)->FreePYComp.wUnConvPos);
lpwEditCaret = &(((LPMYCOMPSTR)lpCompStr)->FreePYComp.wEditCaret);
_tcscpy(szPreStr,lpStr);
wPreUnConvPos = *lpwUnConvPos;
wPreEditCaret = *lpwEditCaret;
if( wEditMode == EDIT_BACK )
{
if(!_tcslen(lpStr) || (*lpwEditCaret) < 1 )
{
MessageBeep(0xFFFFFFFF );
fRet = TRUE;
goto my_exit;
}
else if(*lpwEditCaret <= *lpwUnConvPos)
{
*lpConvStr = _T('\0');
*lpwUnConvPos = 0;
}
else
{
_tcscpy(szTemp, lpStr + *lpwEditCaret);
_tcscpy(lpStr + *lpwEditCaret -1,szTemp);
*lpwEditCaret -= 1;
if( !_tcslen(lpStr))
{
MakeResultString(hIMC, FALSE);
fRet = TRUE;
goto my_exit;
}
}
}
else if( wEditMode == EDIT_DELETE )
{
if(!_tcslen(lpStr) || (*lpwEditCaret) == (SHORT)_tcslen(lpStr) )
{
MessageBeep(0xFFFFFFFF );
fRet = TRUE;
goto my_exit;
}
else
{
_tcscpy(szTemp,lpStr + *lpwEditCaret + 1);
_tcscpy(lpStr + *lpwEditCaret,szTemp);
if( !_tcslen(lpStr))
{
MakeResultString(hIMC, FALSE);
fRet = TRUE;
goto my_exit;
}
}
}
else if( wEditMode == EDIT_ADD )
{
_tcscpy(szTemp,lpStr + *lpwEditCaret);
*(lpStr + *lpwEditCaret) = (TCHAR)wCode;
_tcscpy(lpStr + *lpwEditCaret +1,szTemp);
*lpwEditCaret += 1;
}
else
{
MessageBeep(0xFFFFFFFF );
fRet = TRUE;
goto my_exit;
}
lpCompStr->dwCompStrLen = _tcslen(lpStr);
if(!_tcslen(lpConvStr))
{
*lpwPYArrayCurPos = 0;
}
wPYCount=ParsePY(lpStr + *lpwUnConvPos,lpPYArray + (*lpwPYArrayCurPos)*MAX_PY_LEN,MAX_PY_LEN);
*lpwPYArrayLen = *lpwPYArrayCurPos + wPYCount;
i = *lpwPYArrayLen;
while(i--)
{
if((cTempChar = *(lpPYArray + i*MAX_PY_LEN)) == _T('i') || cTempChar == _T('u') || cTempChar == _T('v') )
{
_tcscpy(lpStr,szPreStr);
*lpwEditCaret = wPreEditCaret;
*lpwUnConvPos = wPreUnConvPos;
*lpwPYArrayLen = *lpwPYArrayLen - 1;
MessageBeep(0xFFFFFFFF );
fRet = TRUE;
goto my_exit;
}
}
if(EffectPYArrayLen(lpPYArray,MAX_PY_LEN,*lpwPYArrayLen) > MAX_PHRASE_LEN)
{
_tcscpy(lpStr,szPreStr);
*lpwEditCaret = wPreEditCaret;
*lpwUnConvPos = wPreUnConvPos;
*lpwPYArrayLen = *lpwPYArrayLen - 1;
MessageBeep(0xFFFFFFFF );
fRet = TRUE;
goto my_exit;
}
lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
lpCandList = (LPCANDIDATELIST)((LPBYTE)lpCandInfo + lpCandInfo->dwOffset[0]);
lpPYCand = (LPFREEPYCAND)(&((LPMYCAND)lpCandInfo)->FreePYCand);
ConvertPY( lpPYArray + (*lpwPYArrayCurPos)*MAX_PY_LEN, MAX_PY_LEN, wPYCount, lpPYCand);
lpPYCand->awBeforePos[1] = 0;
lpPYCand->awBeforePos[0] = 0;
lpPYCand->awCurrentPos[1] = 0;
lpPYCand->awCurrentPos[0] = 0;
lpPYCand->wSelectDirect = SELECT_FORWARD;
lpPYCand->wSelectStatus = 1;
lpCandList->dwCount = CreateCandStr(lpPYCand, SELECT_FORWARD, (LPTSTR)(((LPMYCAND)lpCandInfo)->szCandStr),MAXCANDSTRSIZE);
lpCandList->dwPageStart = 2;
lpCandList->dwPageSize = 10;
CreatePaintStr( lpPYArray + (*lpwPYArrayCurPos) * MAX_PY_LEN,
MAX_PY_LEN,(WORD)((*lpwPYArrayLen)-(*lpwPYArrayCurPos)),lpConvStr,lpPaintStr);
GnMsg.msg = WM_IME_COMPOSITION;
GnMsg.wParam = 0;
GnMsg.lParam = GCS_COMPSTR;
TRACE(TEXT("AddChar GenerateMessage"));
GenerateMessage(hIMC, (LPGENEMSG)&GnMsg);
ImmUnlockIMCC(lpIMC->hCandInfo);
fRet = TRUE;
my_exit:
ImmUnlockIMCC(lpIMC->hCompStr);
ImmUnlockIMC(hIMC);
return fRet;
}
BOOL ForwardPage(HIMC hIMC)
{
LPINPUTCONTEXT lpIMC;
LPCANDIDATEINFO lpCandInfo;
LPCANDIDATELIST lpCandList;
LPFREEPYCAND lpPYCand;
GENEMSG GnMsg;
DWORD dwCount;
if( !IsCompStr(hIMC) ) return FALSE;
lpIMC = ImmLockIMC(hIMC);
lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
lpCandList = (LPCANDIDATELIST)((LPBYTE)lpCandInfo + lpCandInfo->dwOffset[0]);
lpPYCand = (LPFREEPYCAND)(&((LPMYCAND)lpCandInfo)->FreePYCand);
dwCount = CreateCandStr(lpPYCand, SELECT_FORWARD, (LPTSTR)(((LPMYCAND)lpCandInfo)->szCandStr), MAXCANDSTRSIZE);
if (dwCount > 0)
{
lpCandList->dwCount = dwCount;
}
lpCandList->dwPageStart = 2;
lpCandList->dwPageSize = 10;
if(lpCandList->dwCount)
{
GnMsg.msg = WM_IME_COMPOSITION;
GnMsg.wParam = 0;
GnMsg.lParam = GCS_COMPSTR;
GenerateMessage(hIMC, (LPGENEMSG)&GnMsg);
}
ImmUnlockIMCC(lpIMC->hCandInfo);
ImmUnlockIMC(hIMC);
return TRUE;
}
BOOL BackwardPage(HIMC hIMC)
{
LPINPUTCONTEXT lpIMC;
LPCANDIDATEINFO lpCandInfo;
LPCANDIDATELIST lpCandList;
LPFREEPYCAND lpPYCand;
GENEMSG GnMsg;
DWORD dwCount;
if( !IsCompStr(hIMC) )
{
return FALSE;
}
lpIMC = ImmLockIMC(hIMC);
lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
lpCandList = (LPCANDIDATELIST)((LPBYTE)lpCandInfo + lpCandInfo->dwOffset[0]);
lpPYCand = (LPFREEPYCAND)(&((LPMYCAND)lpCandInfo)->FreePYCand);
dwCount = CreateCandStr(lpPYCand, SELECT_BACKWARD, (LPTSTR)(((LPMYCAND)lpCandInfo)->szCandStr),MAXCANDSTRSIZE);
if (dwCount > 0)
{
lpCandList->dwCount = dwCount;
}
lpCandList->dwPageStart = 2;
lpCandList->dwPageSize = 10;
if(lpCandList->dwCount)
{
GnMsg.msg = WM_IME_COMPOSITION;
GnMsg.wParam = 0;
GnMsg.lParam = GCS_COMPSTR;
GenerateMessage(hIMC, (LPGENEMSG)&GnMsg);
}
ImmUnlockIMCC(lpIMC->hCandInfo);
ImmUnlockIMC(hIMC);
return TRUE;
}
BOOL SelectCand(HIMC hIMC,WORD wParam)
{
LPINPUTCONTEXT lpIMC;
LPCOMPOSITIONSTRING lpCompStr;
LPCANDIDATEINFO lpCandInfo;
LPCANDIDATELIST lpCandList;
LPFREEPYCAND lpPYCand;
LPTSTR lpStr;
LPTSTR lpConvStr;
LPTSTR lpPaintStr;
LPTSTR lpPYArray;
SHORT *lpwUnConvPos;
SHORT *lpwEditCaret;
WORD *lpwPYArrayLen;
WORD *lpwPYArrayCurPos;
GENEMSG GnMsg;
WORD wIdx,awLen[2],wPosSpan,wTotal,wCount;
TCHAR szTempStr[(MAX_PHRASE_LEN + 1)*2];
int i;
DWORD dwAttrib;
if( !IsCompStr(hIMC) )
return FALSE;
lpIMC = ImmLockIMC(hIMC);
lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
lpCandList = (LPCANDIDATELIST)((LPBYTE)lpCandInfo + lpCandInfo->dwOffset[0]);
lpPYCand = (LPFREEPYCAND)(&((LPMYCAND)lpCandInfo)->FreePYCand);
lpCompStr = (LPCOMPOSITIONSTRING)ImmLockIMCC(lpIMC->hCompStr);
lpStr = GETLPCOMPSTR(lpCompStr);
lpConvStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szConvCompStr;
lpPaintStr = ((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPaintCompStr;
lpPYArray = (LPTSTR)(((LPMYCOMPSTR)lpCompStr)->FreePYComp.szPYArray);
lpwPYArrayLen = &(((LPMYCOMPSTR)lpCompStr)->FreePYComp.wPYArrayLen);
lpwPYArrayCurPos = &(((LPMYCOMPSTR)lpCompStr)->FreePYComp.wPYArrayCurPos);
lpwUnConvPos = &(((LPMYCOMPSTR)lpCompStr)->FreePYComp.wUnConvPos);
lpwEditCaret = &(((LPMYCOMPSTR)lpCompStr)->FreePYComp.wEditCaret);
TRACE(TEXT("lpStr : %s"), lpStr);
TRACE(TEXT("lpConvStr : %s"), lpConvStr);
TRACE(TEXT("lpPaintStr : %s"), lpPaintStr);
if( wParam == (WORD)_T('0') )
wIdx = 9;
else
wIdx = wParam - (WORD)_T('1');
if(wIdx >= lpCandList->dwCount)
return FALSE;
wTotal = wIdx + 1;
switch(lpPYCand->wSelectDirect)
{
case SELECT_FORWARD:
if(wConversionSet & CONVERSION_SET_GBK)
{
wIdx += lpPYCand->awBeforePos[lpPYCand->wSelectStatus];
}
else
{
if(lpPYCand->wSelectStatus)
{
wIdx += lpPYCand->awBeforePos[lpPYCand->wSelectStatus];
}
else
{
wIdx = lpPYCand->awBeforePos[lpPYCand->wSelectStatus];
wCount = 0;
while( wCount != wTotal)
{
for(i=0;i < lpPYCand->wHZNum;i++)
{
if((lpPYCand->aHanZi + i)->wLen > wIdx)
break;
}
#ifdef _UNICODE
if(i)
_tcsncpy(szTempStr,(lpPYCand->aHanZi+i)->lpHZ + (wIdx - (lpPYCand->aHanZi+i-1)->wLen),1);
else
_tcsncpy(szTempStr,(lpPYCand->aHanZi+i)->lpHZ + wIdx,1);
szTempStr[1] = _T('\0');
#else
if(i)
_tcsncpy(szTempStr,(lpPYCand->aHanZi+i)->lpHZ + 2*(wIdx - (lpPYCand->aHanZi+i-1)->wLen),2);
else
_tcsncpy(szTempStr,(lpPYCand->aHanZi+i)->lpHZ+2*wIdx,2);
szTempStr[2] = _T('\0');
#endif
if( (*((LPBYTE)szTempStr) >= GB_QUFIRST && *((LPBYTE)szTempStr) <= GB_QULAST) &&
(*((LPBYTE)szTempStr+1) >= GB_WEIFIRST && *((LPBYTE)szTempStr+1) <= GB_WEILAST) )
{
wCount++;
}
wIdx++;
}
wIdx--;
}
}
break;
case SELECT_BACKWARD:
if(wConversionSet & CONVERSION_SET_GBK)
{
wIdx += lpPYCand->awCurrentPos[lpPYCand->wSelectStatus]+1;
}
else
{
if(lpPYCand->wSelectStatus)
{
wIdx += lpPYCand->awCurrentPos[lpPYCand->wSelectStatus]+1;
}
else
{
wIdx = lpPYCand->awBeforePos[lpPYCand->wSelectStatus];
wTotal--;
wCount = 10;
while( wCount != wTotal)
{
for(i=0;i < lpPYCand->wHZNum;i++)
{
if((lpPYCand->aHanZi+i)->wLen > wIdx) break;
}
#ifdef _UNICODE
if(i)
_tcsncpy(szTempStr,(lpPYCand->aHanZi+i)->lpHZ + (wIdx - (lpPYCand->aHanZi+i-1)->wLen),1);
else
_tcsncpy(szTempStr,(lpPYCand->aHanZi+i)->lpHZ + wIdx,1);
szTempStr[1] = _T('\0');
#else
if(i)
_tcsncpy(szTempStr,(lpPYCand->aHanZi+i)->lpHZ + 2*(wIdx - (lpPYCand->aHanZi+i-1)->wLen),2);
else
_tcsncpy(szTempStr,(lpPYCand->aHanZi+i)->lpHZ+2*wIdx,2);
szTempStr[2] = _T('\0');
#endif
if( (*((LPBYTE)szTempStr) >= GB_QUFIRST && *((LPBYTE)szTempStr) <= GB_QULAST) &&
(*((LPBYTE)szTempStr+1) >= GB_WEIFIRST && *((LPBYTE)szTempStr+1) <= GB_WEILAST) ) {
wCount--;
}
wIdx--;
}
wIdx++;
}
}
break;
default:
break;
}
awLen[1] = lpPYCand->wPhraseNum;
awLen[0] = (lpPYCand->aHanZi + lpPYCand->wHZNum - 1)->wLen;
if(0 < wIdx < awLen[lpPYCand->wSelectStatus])
{
if(lpPYCand->wSelectStatus)
{
_tcscpy(szTempStr,(lpPYCand->aPhrase+wIdx)->lpHZPH->szHZ);
_tcscat(lpConvStr,szTempStr);
lpPYCand ->abKey[0] |= (lpPYCand->aPhrase+wIdx)->lpKeyPH->abKey[0] << lpPYCand->wKeyLen;
for(i=1;i<=(lpPYCand->aPhrase+wIdx)->lpKeyPH->wLen;i++)
{
lpPYCand ->abKey[(lpPYCand->wKeyLen++) + 1] =
(lpPYCand->aPhrase+wIdx)->lpKeyPH->abKey[i];
}
}
else
{
for(i=0;i < lpPYCand->wHZNum;i++)
{
if((lpPYCand->aHanZi+i)->wLen > wIdx )
{
break;
}
}
#ifdef _UNICODE
if(i)
{
_tcsncpy(szTempStr,(lpPYCand->aHanZi+i)->lpHZ + (wIdx - (lpPYCand->aHanZi+i-1)->wLen), 1);
}
else
{
_tcsncpy(szTempStr,(lpPYCand->aHanZi+i)->lpHZ + wIdx,1);
}
szTempStr[1] = _T('\0');
#else
if(i)
{
_tcsncpy(szTempStr,(lpPYCand->aHanZi+i)->lpHZ + 2*(wIdx - (lpPYCand->aHanZi+i-1)->wLen),2);
}
else
{
_tcsncpy(szTempStr,(lpPYCand->aHanZi+i)->lpHZ + 2 * wIdx,2);
}
szTempStr[2] = _T('\0');
#endif
_tcscat(lpConvStr,szTempStr);
lpPYCand ->abKey[0] |= ((lpPYCand->aHanZi+i)->wKey & 0x0100) >>(8 - lpPYCand->wKeyLen);
lpPYCand ->abKey[(lpPYCand->wKeyLen++) + 1] = (BYTE)(lpPYCand->aHanZi+i)->wKey & 0xff;
}
#ifdef _UNICODE
if( EffectPYArrayLen(lpPYArray,MAX_PY_LEN,*lpwPYArrayLen) == _tcslen(lpConvStr) )
{
if(_tcslen(szTempStr) == _tcslen(lpConvStr) && lpPYCand->wSelectStatus)
{
(lpPYCand->aPhrase + wIdx)->lpHZPH->dwAttrib++;
}
else if(_tcslen(lpConvStr) > 1)
{
dwAttrib=dwCurPhraseAttrib;
if(dwAttrib <= 1)
{
dwAttrib = 1;
}
else
{
dwAttrib --;
}
SavePhToMapFile(lpConvStr,lpPYCand->abKey,(WORD)(_tcslen(lpConvStr)),dwAttrib,1);
}
#else
if( EffectPYArrayLen(lpPYArray,MAX_PY_LEN,*lpwPYArrayLen) == _tcslen(lpConvStr)/2 )
{
if(_tcslen(szTempStr) == _tcslen(lpConvStr) && lpPYCand->wSelectStatus)
{
((lpPYCand->aPhrase + wIdx)->lpHZPH->dwAttrib)++;
}
else if(_tcslen(lpConvStr) > 2)
{
dwAttrib=dwCurPhraseAttrib;
if(dwAttrib <= 1)
{
dwAttrib=1;
}
else
{
dwAttrib--;
}
SavePhToMapFile(lpConvStr,lpPYCand->abKey,(WORD)(_tcslen(lpConvStr)/2),dwAttrib,1);
}
#endif
MakeResultString(hIMC,TRUE);
goto my_exit;
}
else
{
#ifdef _UNICODE
wPosSpan = CalculatePosSpan(lpPYArray+(*lpwPYArrayCurPos)*MAX_PY_LEN,
MAX_PY_LEN,(WORD)((*lpwPYArrayLen)-(*lpwPYArrayCurPos)),(WORD)_tcslen(szTempStr));
#else
wPosSpan = CalculatePosSpan(lpPYArray+(*lpwPYArrayCurPos)*MAX_PY_LEN,
MAX_PY_LEN,(WORD)((*lpwPYArrayLen)-(*lpwPYArrayCurPos)),(WORD)(_tcslen(szTempStr)/2));
#endif
*lpwPYArrayCurPos += wPosSpan;
*lpwUnConvPos = CalculateUnConvPos(lpPYArray + (*lpwPYArrayCurPos)*MAX_PY_LEN,
MAX_PY_LEN,(WORD)((*lpwPYArrayLen)-(*lpwPYArrayCurPos)),lpStr);
*lpwEditCaret = (SHORT)_tcslen(lpStr);
ConvertPY( lpPYArray + (*lpwPYArrayCurPos)*MAX_PY_LEN,
MAX_PY_LEN,(WORD)((*lpwPYArrayLen)-(*lpwPYArrayCurPos)),lpPYCand);
lpPYCand->awBeforePos[1] = 0;
lpPYCand->awBeforePos[0] = 0;
lpPYCand->awCurrentPos[1] = 0;
lpPYCand->awCurrentPos[0] = 0;
lpPYCand->wSelectDirect = SELECT_FORWARD;
lpPYCand->wSelectStatus = 1;
lpCandList->dwCount = CreateCandStr(lpPYCand, SELECT_FORWARD, (LPTSTR)(((LPMYCAND)lpCandInfo)->szCandStr),MAXCANDSTRSIZE);
lpCandList->dwPageStart = 2;
lpCandList->dwPageSize = 10;
CreatePaintStr( lpPYArray + (*lpwPYArrayCurPos)*MAX_PY_LEN,
MAX_PY_LEN,(WORD)((*lpwPYArrayLen)-(*lpwPYArrayCurPos)),lpConvStr,lpPaintStr);
}
}
GnMsg.msg = WM_IME_COMPOSITION;
GnMsg.wParam = 0;
GnMsg.lParam = GCS_COMPSTR;
GenerateMessage(hIMC, (LPGENEMSG)&GnMsg);
my_exit:
ImmUnlockIMCC(lpIMC->hCandInfo);
ImmUnlockIMCC(lpIMC->hCompStr);
ImmUnlockIMC(hIMC);
return TRUE;
}
BOOL DeletePhrase(HIMC hIMC,WORD wParam)
{
LPINPUTCONTEXT lpIMC;
LPCANDIDATEINFO lpCandInfo;
LPCANDIDATELIST lpCandList;
LPFREEPYCAND lpPYCand;
LPKEYPH lpKPh;
LPHZPH lpHZPh,lpCurHZPh,lpPreHZPh;
WORD wLen,wIdx;
WORD wRet = 0;
if( !IsCompStr(hIMC) )
{
return FALSE;
}
lpIMC = ImmLockIMC(hIMC);
lpCandInfo = (LPCANDIDATEINFO)ImmLockIMCC(lpIMC->hCandInfo);
lpCandList = (LPCANDIDATELIST)((LPBYTE)lpCandInfo + lpCandInfo->dwOffset[0]);
lpPYCand = (LPFREEPYCAND)(&((LPMYCAND)lpCandInfo)->FreePYCand);
if( ! lpPYCand->wSelectStatus )
{
ImmUnlockIMCC(lpIMC->hCandInfo);
ImmUnlockIMC(hIMC);
return FALSE;
}
switch( wParam )
{
case _T('!'):
wIdx = 0;
break;
case _T('@'):
wIdx = 1;
break;
case _T('#'):
wIdx = 2;
break;
case _T('$'):
wIdx = 3;
break;
case _T('%'):
wIdx = 4;
break;
case _T('^'):
wIdx = 5;
break;
case _T('&'):
wIdx = 6;
break;
case _T('*'):
wIdx = 7;
break;
case _T('('):
wIdx = 8;
break;
case _T(')'):
wIdx = 9;
break;
default:
wIdx = 0;
break;
}
switch(lpPYCand->wSelectDirect)
{
case SELECT_FORWARD:
wIdx += lpPYCand->awBeforePos[lpPYCand->wSelectStatus];
break;
case SELECT_BACKWARD:
wIdx += lpPYCand->awCurrentPos[lpPYCand->wSelectStatus]+1;
break;
default:
break;
}
wLen = lpPYCand->wPhraseNum;
if(0 < wIdx < wLen )
{
lpKPh = (lpPYCand->aPhrase+wIdx)->lpKeyPH;
lpHZPh = (lpPYCand->aPhrase+wIdx)->lpHZPH;
if( ((LPBYTE)lpKPh >= (LPBYTE)lpMapFileBase
&& (LPBYTE)lpKPh < (LPBYTE)lpMapFileBase + MAX_PY_NUM*sizeof(KEYPH) ) ||
((LPBYTE)lpKPh >= (LPBYTE)lpMapFileBase + 2*MAX_PY_NUM*sizeof(KEYPH)
&&(LPBYTE)lpKPh < (LPBYTE)lpMapFileBase + dwMapFileUsrOffset ) )
{
lpHZPh->dwAttrib = 0;
wRet = 1;
}
else
{
lpCurHZPh = lpKPh->lpHZPH;
if( lpCurHZPh == lpHZPh)
{
if(lpHZPh->lpNext == NULL)
{
lpKPh->wLen = -1;
}
lpKPh->lpHZPH = lpHZPh->lpNext;
wRet = 1;
}
else
{
lpPreHZPh = lpCurHZPh;
do
{
lpCurHZPh = lpCurHZPh->lpNext;
if(lpCurHZPh == lpHZPh)
{
lpPreHZPh->lpNext = lpCurHZPh->lpNext;
wRet = 1;
break;
}
lpPreHZPh = lpCurHZPh;
}
while(lpCurHZPh->lpNext != NULL);
}
}
}
if( wRet )
{
MakeResultString(hIMC,FALSE);
}
ImmUnlockIMCC(lpIMC->hCandInfo);
ImmUnlockIMC(hIMC);
return TRUE;
} | [
"[email protected]"
] | [
[
[
1,
733
]
]
] |
4af9b1a09b66c8270a7d1b53bccf07e2cb963141 | 3856c39683bdecc34190b30c6ad7d93f50dce728 | /LastProject/Source/Cube.cpp | 1e618efa92ba7957ce0b746f967e2592fc0b9241 | [] | no_license | yoonhada/nlinelast | 7ddcc28f0b60897271e4d869f92368b22a80dd48 | 5df3b6cec296ce09e35ff0ccd166a6937ddb2157 | refs/heads/master | 2021-01-20T09:07:11.577000 | 2011-12-21T22:12:36 | 2011-12-21T22:12:36 | 34,231,967 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 4,015 | cpp | /**
@file Cube.cpp
@date 2011/09/17
@author 백경훈
@brief 큐브 클래스
*/
#include "stdafx.h"
#include "Cube.h"
#ifdef _CELLCUBE
CCube::CCube()
{
Clear();
}
CCube::~CCube()
{
Release();
}
VOID CCube::Clear()
{
m_pD3dDevice = NULL ;
m_pTexture = NULL;
m_iStartVB = 0;
m_iStartIB = 0;
m_fCubeSize = 0.0f;
m_pCell = NULL;
}
HRESULT CCube::Create( LPDIRECT3DDEVICE9 a_pD3dDevice,
LPDIRECT3DVERTEXBUFFER9 &a_pVB, LPDIRECT3DINDEXBUFFER9 &a_pIB,
INT a_iStartVB, INT a_iStartIB, FLOAT a_fCubeSize )
{
m_pD3dDevice = a_pD3dDevice;
m_iStartVB = a_iStartVB;
m_iStartIB = a_iStartIB;
m_fCubeSize = a_fCubeSize;
//_InitVB( a_pVB );
//_InitIB( a_pIB );
m_pCell = new CCell[6];
for(INT Loop=0; Loop<6; ++Loop)
{
m_pCell[Loop].Create( m_pD3dDevice, a_pVB, a_pIB,
m_iStartVB + ( Loop * 4 ), 0, m_fCubeSize, Loop );
}
return S_OK;
}
HRESULT CCube::Release()
{
/*if(m_pVB != NULL)
{
m_pVB->Release();
m_pVB=NULL;
}
if(m_pIB != NULL)
{
m_pIB->Release();
m_pIB=NULL;
}*/
if(m_pTexture != NULL)
{
m_pTexture->Release();
m_pTexture=NULL;
}
SAFE_DELETE_ARRAY( m_pCell );
return S_OK;
}
HRESULT CCube::InitTexture( DWORD a_Color, DWORD a_OutLineColor )
{
/*if( FAILED( D3DXCreateTextureFromFile( GD3D9DEVICE, L"Media/TerrainTexture/test.bmp", &m_pTexture ) ) )
{
return E_FAIL;
}*/
LPBYTE pData;
LPDWORD pDWord;
D3DLOCKED_RECT Texture_Locked;
INT TextureSize = 8;
if( m_pTexture != NULL )
{
m_pTexture->Release();
m_pTexture=NULL;
}
if( FAILED( m_pD3dDevice->CreateTexture( TextureSize, TextureSize, 1, 0, D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED, &m_pTexture, NULL ) ) )
{
return E_FAIL;
}
memset( &Texture_Locked, 0, sizeof(D3DLOCKED_RECT) );
if( FAILED(m_pTexture->LockRect(0, &Texture_Locked, NULL, 0)) )
{
return E_FAIL;
}
pData = (LPBYTE)Texture_Locked.pBits;
for(INT iLoopY=0; iLoopY<TextureSize; ++iLoopY)
{
pDWord = LPDWORD(pData + iLoopY * Texture_Locked.Pitch);
for(INT iLoopX=0; iLoopX<TextureSize; ++iLoopX)
{
//외곽선 처리
if( iLoopX == 0 || iLoopX == TextureSize-1 || iLoopY == 0 || iLoopY == TextureSize-1 )
{
*(pDWord + iLoopX) = a_OutLineColor;
}
else
{
*(pDWord + iLoopX) = a_Color;
}
}
}
if( FAILED(m_pTexture->UnlockRect(0)) )
{
return E_FAIL;
}
return S_OK;
}
VOID CCube::Update()
{
}
VOID CCube::Render()
{
//m_pD3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE);
//m_pD3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
//m_pD3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
//m_pD3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW);
//m_pD3dDevice->SetTexture( 0, m_pTexture );
//m_pD3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
//m_pD3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
//m_pD3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
//m_pD3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
//m_pD3dDevice->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
//m_pD3dDevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
//m_pD3dDevice->SetRenderState(D3DRS_COLORVERTEX, TRUE);
//m_pD3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof( CUBEVERTEX ) );
//m_pD3dDevice->SetFVF( CUBEVERTEX::FVF );
//m_pD3dDevice->SetIndices( m_pIB );
//m_pD3dDevice->SetTexture( 0, m_pTexture );
for(INT Loop=0; Loop<6; ++Loop)
{
//CMatrices::GetInstance()->SetupModeltoWorld( m_pCell[Loop].Get_MatWorld() );
if( m_pCell[Loop].Get_FaceVisble() == TRUE )
{
m_pCell[Loop].Render();
}
}
//m_pD3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, m_iStartVB, 0, CUBEVERTEX::VertexNum, 0, 12 );
//m_pD3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE);
//m_pD3dDevice->SetTexture( 0, NULL );
}
#endif | [
"[email protected]@d02aaf57-2019-c8cd-d06c-d029ef2af4e0"
] | [
[
[
1,
181
]
]
] |
23c0012024f3d3d38284a5a78b279dec8c35dc8b | 65a392af0450708ed4fa26f66393e12bdf387634 | /Kernel/initialize.cpp | 7c550993bab0ca7772116e9244fc7fbd95458d83 | [] | no_license | zhouxs1023/mU | d5abea6e883cb746aa28ff6ee2b3902babb053d8 | c9ecc5f0a4fd13567b3c9ca24ff05ba149af743e | refs/heads/master | 2021-05-27T11:37:59.464000 | 2011-06-17T22:39:25 | 2011-06-17T22:39:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 26,566 | cpp | #include <mU/Number.h>
#include <mU/String.h>
#include <mU/Pattern.h>
#include <mU/Kernel.h>
#include <mU/Interface.h>
namespace mU {
namespace {
Wrap(CompoundExpression)
{
var r;
size_t n = Size(x);
for(size_t i = 0; i < n; ++i)
{
r = Eval(At(x,i));
if(ExQ(r))
{
var h = Head(r);
if(h == TAG(Return))
{
var b = Body(r);
return Size(b) == 0 ? r : Eval(At(b,0));
}
else if(h == TAG(Break) || h == TAG(Continue))
break;
}
}
return r;
}
Wrap(Flatten)
{
var c = At(x,0);
if(VecQ(c))
{
var r = Vec();
Flatten(r,c);
return r;
}
else if(ExQ(c))
{
var r = Vec();
var h = Head(c);
var b = Body(c);
Flatten(r,h,b);
return Ex(h,r);
}
return 0;
}
Wrap(FlattenAll)
{
var c = At(x,0);
if(VecQ(c))
{
var r = Vec();
FlattenAll(r,c);
return r;
}
else if(ExQ(c))
{
var r = Vec();
var h = Head(c);
var b = Body(c);
FlattenAll(r,h,b);
return Ex(h,r);
}
return 0;
}
Wrap(And)
{
var r = Vec();
size_t n = Size(x);
for(size_t i = 0; i < n; ++i)
{
var c = Eval(At(x,i));
if(c == False) return False;
if(c == True) continue;
Push(r,c);
}
if(Size(r) == 0) return True;
return 0;
}
Wrap(Or)
{
var r = Vec();
size_t n = Size(x);
for(size_t i = 0; i < n; ++i)
{
var c = Eval(At(x,i));
if(c == True) return True;
if(c == False) continue;
Push(r,c);
}
if(Size(r) == 0) return False;
return 0;
}
Wrap(Not)
{
return At(x,0) == True
? False
: At(x,0) == False
? True
: 0;
}
Wrap(If)
{
return At(x,0) == True
? Eval(At(x,1))
: At(x,0) == False && Size(x) == 3
? Eval(At(x,2))
: Null;
}
Wrap(For)
{
var r;
for(Eval(At(x,0));
Eval(At(x,1)) == True;
Eval(At(x,2)))
{
r = Eval(At(x,3));
if(ExQ(r))
{
var h = Head(r);
if(h == TAG(Return)) return r;
if(h == TAG(Break)) break;
if(h == TAG(Continue)) continue;
}
}
return Null;
}
Wrap(While)
{
var r;
while(Eval(At(x,0)) == True)
{
r = Eval(At(x,1));
if(ExQ(r))
{
var h = Head(r);
if(h == TAG(Return)) return r;
if(h == TAG(Break)) break;
if(h == TAG(Continue)) continue;
}
}
return Null;
}
Wrap(SameQ)
{
return Same(At(x,0),At(x,1)) ? True : False;
}
Wrap(Less)
{
return Less(At(x,0),At(x,1)) ? True : False;
}
Wrap(Equal)
{
return Equal(At(x,0),At(x,1)) ? True : False;
}
Wrap(Greater)
{
return Greater(At(x,0),At(x,1)) ? True : False;
}
Wrap(UnsameQ)
{
return !Same(At(x,0),At(x,1)) ? True : False;
}
Wrap(GreaterEqual)
{
return !Less(At(x,0),At(x,1)) ? True : False;
}
Wrap(Unequal)
{
return !Equal(At(x,0),At(x,1)) ? True : False;
}
Wrap(LessEqual)
{
return !Greater(At(x,0),At(x,1)) ? True : False;
}
Wrap(FreeQ)
{
return FreeQ(At(x,0),At(x,1)) ? True : False;
}
Wrap(With)
{
var a = At(x,0);
size_t n = Size(a);
map_t m;
for(size_t i = 0; i < n; ++i)
if(ExQ(At(a,i),TAG(Set)))
m[Left(At(a,i))] = Eval(Right(At(a,i)));
return Eval(Subs(m,At(x,1)));
}
Wrap(Block)
{
var a = At(x,0);
size_t n = Size(a);
std::vector<Var> locals(n);
std::vector<var> local_values(n);
for(size_t i = 0; i < n; ++i)
{
var c = At(a,i);
if(ExQ(c,TAG(Set)))
{
locals[i] = Left(c);
local_values[i] = Eval(Left(c));
Set(Left(c),Eval(Right(c)));
}
else if(SymQ(At(a,i)))
{
locals[i] = c;
local_values[i] = Eval(c);
}
}
var r = Eval(At(x,1));
for(size_t i = 0; i < n; ++i)
Set(locals[i],local_values[i]);
return r;
}
Wrap(Module)
{
wstring s = Unique();
var a = At(x,0);
size_t n = Size(a);
map_t m;
for(size_t i = 0; i < n; ++i)
{
var c = At(a,i);
if(ExQ(c,TAG(Set)))
{
var t = Sym(Name(Left(c)) + s);
m[Left(c)] = t;
Set(t,Eval(Right(c)));
}
else if(SymQ(At(a,i)))
{
var t = Sym(Name(c) + s);
m[c] = t;
}
}
var r = Eval(Subs(m,At(x,1)));
map_t::const_iterator
iter = m.begin();
while(iter != m.end())
{
Unset(iter->second);
++iter;
}
return r;
}
Wrap(MatchQ)
{
map_t m;
return MatchQ(m,Pat(At(x,1)),At(x,0)) ? True : False;
}
Wrap(MemberQ)
{
return MemberQ(At(x,0),At(x,1)) ? True : False;
}
Wrap(Dispatch)
{
if(VecQ(At(x,0)))
return Dispatch(At(x,0));
return Dispatch(x);
}
Wrap(Replace)
{
var a = At(x,0);
var b = At(x,1);
if(VecQ(b))
{
size_t n = Size(b);
for(size_t i = 0; i < n; ++i)
a = Replace(a,At(b,i));
return a;
}
return Replace(a,b);
}
Wrap(ReplaceAll)
{
var a = At(x,0);
var b = At(x,1);
if(VecQ(b))
{
size_t n = Size(b);
for(size_t i = 0; i < n; ++i)
a = ReplaceAll(a,At(b,i));
return a;
}
return ReplaceAll(a,b);
}
Wrap(ReplaceRepeated)
{
var r = WRAP(ReplaceAll)(x);
while(!Same(r,At(x,0)))
{
At(x,0) = r;
r = WRAP(ReplaceAll)(x);
}
return r;
}
Wrap(OddQ)
{
return OddQ(At(x,0)) ? True : False;
}
Wrap(EvenQ)
{
return EvenQ(At(x,0)) ? True : False;
}
Wrap(SetAttributes)
{
var a = At(x,0);
var b = At(x,1);
if(VecQ(b))
{
size_t n = Size(b);
for(size_t i = 0; i < n; ++i)
Attributes[a].insert(At(b,i));
}
else
Attributes[a].insert(b);
return Null;
}
Wrap(StringJoin)
{
size_t n = Size(x);
var c = At(x,0);
if(StrQ(c))
{
var r = Str();
CStr(r) = CStr(c);
for(size_t i = 1; i < n; ++i)
S::AddTo(r,At(x,i));
return r;
}
return 0;
}
Wrap(Join)
{
size_t n = Size(x);
var c = At(x,0);
if(VecQ(c))
{
size_t m = Size(c);
for(size_t i = 1; i < n; ++i)
m += Size(At(x,i));
var r = Vec(m);
vec_t::rep_t::iterator iter = CVec(r).begin();
std::copy(CVec(c).begin(),CVec(c).end(),iter);
for(size_t i = 1; i < n; ++i)
std::copy(CVec(At(x,i)).begin(),CVec(At(x,i)).end(),iter += Size(At(x,i - 1)));
return r;
}
return 0;
}
Wrap(Get)
{
if(StrQ(At(x,0)))
{
var r = ParseFile(CStr(At(x,0)));
return r ? r : Nil;
}
return 0;
}
Wrap(Put)
{
var a = At(x,0);
var b = At(x,1);
if(StrQ(b))
{
wofstream f(string(CStr(b).begin(),CStr(b).end()).c_str());
if(f)
{
Println(a,f);
f.close();
return True;
}
}
return False;
}
Wrap(PutAppend)
{
var a = At(x,0);
var b = At(x,1);
if(StrQ(b))
{
wofstream f(string(CStr(b).begin(),CStr(b).end()).c_str(),wios::app);
if(f)
{
Println(a,f);
f.close();
return True;
}
}
return False;
}
Wrap(Attributes)
{
var r = Vec();
std::map<Var,attr_t>::const_iterator
iter = Attributes.find(At(x,0));
if(iter != Attributes.end())
CVec(r).assign(iter->second.begin(),iter->second.end());
return r;
}
Wrap(Timing)
{
return Timing(At(x,0));
}
Wrap(Path)
{
return Size(x) ? Str(Path() + CStr(At(x,0))) : Str(Path());
}
Wrap(Install)
{
return Install(CStr(At(x,0)).c_str());
}
Wrap(Uninstall)
{
return Uninstall(At(x,0)) ? True : False;
}
Wrap(Run)
{
return Run(CStr(At(x,0))) ? True : False;
}
//Wrap(Task)
//{
// return Task(At(x,0));
//}
//Wrap(Kill)
//{
// return Kill(At(x,0)) ? True : False;
//}
Wrap(NumberQ)
{
return NumQ(At(x,0)) ? True : False;
}
Wrap(AtomQ)
{
return AtomQ(At(x,0)) ? True : False;
}
Wrap(IntegerQ)
{
return IntQ(At(x,0)) ? True : False;
}
Wrap(SymbolQ)
{
return SymQ(At(x,0)) ? True : False;
}
Wrap(StringQ)
{
return StrQ(At(x,0)) ? True : False;
}
Wrap(Input)
{
var r = Size(x) > 0
? Read(wcin,At(x,0))
: Read(wcin);
return r ? r : Nil;
}
Wrap(Print)
{
Write(wcout,Size(x) == 1 ? static_cast<Var>(At(x,0)) : x);
return Null;
}
Wrap(Pretty)
{
return Pretty(At(x,0));
}
Wrap(Unset)
{
Unset(At(x,0));
return Null;
}
Wrap(Clear)
{
size_t n = Size(x);
for(size_t i = 0; i < n; ++i)
Clear(At(x,i));
return Null;
}
Wrap(Evaluate)
{
return Eval(At(x,0));
}
Wrap(Part)
{
var c = At(x,0);
size_t n = Size(x);
for(size_t i = 1; i < n; ++i)
{
int j = Z::SI(At(x,i));
if(j == 0) return Tag(c);
if(ExQ(c)) c = Body(c);
if(VecQ(c))
{
j < 0 ? j += Size(c) : --j;
if(j < 0 || j >= Size(c))
return c;
c = At(c,j);
}
}
return c;
}
Wrap(Length)
{
var c = At(x,0);
size_t n = 0;
if(VecQ(c))
n = Size(c);
else if(ExQ(c))
n = Size(Body(c));
return Int((uint)n);
}
Wrap(Head)
{
return Tag(At(x,0));
}
Wrap(Context)
{
var r;
if(Size(x))
r = Context(At(x,0));
else
r = Context();
return Str(ContextName[r]);
}
Wrap(Contexts)
{
size_t n = CTab(Contexts).size();
var r = Vec(n);
tab_t::rep_t::const_iterator
iter = CTab(Contexts).begin();
for(size_t i = 0; i < n; ++i)
{
At(r,i) = Str(iter->first);
++iter;
}
return r;
}
Wrap(ContextPath)
{
size_t n = ContextPath.top().size();
var r = Vec(n);
std::list<Var>::const_iterator
iter = ContextPath.top().begin();
for(size_t i = 0; i < n; ++i)
{
At(r,i) = Str(ContextName[*iter]);
++iter;
}
return r;
}
Wrap(Begin)
{
var r = Ctx2(CStr(At(x,0)).c_str());
Begin(r);
return Str(ContextName[r]);
}
Wrap(End)
{
var r = Context();
End();
return Str(ContextName[r]);
}
Wrap(BeginPackage)
{
var r = Ctx2(CStr(At(x,0)).c_str());
BeginPackage(r);
return Null;
}
Wrap(EndPackage)
{
EndPackage();
return Null;
}
Wrap(Unevaluated)
{
return At(x,0);
}
Wrap(Apply)
{
if(VecQ(At(x,1)))
return Eval(Ex(At(x,0),At(x,1)));
return 0;
}
Wrap(Map)
{
if(VecQ(At(x,1)))
{
var a = At(x,0);
var b = At(x,1);
size_t n = Size(b);
var r = Vec(n);
for(size_t i = 0; i < n; ++i)
At(r,i) = Eval(Ex(a,Vec(At(b,i))));
return r;
}
return 0;
}
Wrap(Property)
{
std::map<Var,map_t>::const_iterator
iter = Properties.find(At(x,0));
if(iter != Properties.end())
{
map_t::const_iterator
iter2 = iter->second.find(At(x,1));
if(iter2 != iter->second.end())
return iter2->second;
}
return 0;
}
Wrap(Full)
{
wostringstream t;
FullPrint(At(x,0),t);
return Str(t.str());
}
Wrap(ToString)
{
wostringstream t;
Print(Pretty(At(x,0)),t);
return Str(t.str());
}
Wrap(ToExpression)
{
if(StrQ(At(x,0)))
{
var r = ParseString(CStr(At(x,0)));
return r ? r : Nil;
}
return 0;
}
Wrap(Exit)
{
if(Size(x) && IntQ(At(x,0)))
exit(Z::SI(At(x,0)));
exit(-1);
return Null;
}
Wrap(Quit)
{
exit(-1);
return Null;
}
Wrap(Set)
{
Set(At(x,0),At(x,1));
return At(x,1);
}
Wrap(SetDelayed)
{
Set(At(x,0),At(x,1));
return Null;
}
Wrap(Hold)
{
return 0;
}
Wrap(Array)
{
size_t n = Size(x);
var h = At(x,0);
var b = Vec();
size_t m = Size(At(x,1));
if(n == 2) return Array(h,b,m,&At(At(x,1),0));
if(n == 3) return Array(h,b,m,&At(At(x,1),0),&At(At(x,2),0));
return 0;
}
Wrap(Table)
{
return Table(At(x,0),Size(x) - 1,&At(x,1));
}
Wrap(Do)
{
Do(At(x,0),Size(x) - 1,&At(x,1));
return Null;
}
Wrap(N)
{
size_t n = Size(x);
if(n == 1) return Evalf(At(x,0));
if(n == 2 && IntQ(At(x,1)))
return Evalf(At(x,0),Z::UI(At(x,1)));
return 0;
}
Wrap(IntegerPart)
{
return IntegerPart(At(x,0));
}
Wrap(Floor)
{
return Floor(At(x,0));
}
Wrap(Ceiling)
{
return Ceiling(At(x,0));
}
Wrap(Round)
{
return Round(At(x,0));
}
Wrap(Expand)
{
return Expand(At(x,0));
}
Wrap(Variables)
{
return Variables(At(x,0));
}
Wrap(Coefficient)
{
return Coefficient(At(x,0),At(x,1));
}
Wrap(Exponent)
{
return Exponent(At(x,0),At(x,1));
}
Wrap(Deg)
{
return Deg(At(x,0),At(x,1));
}
Wrap(CoefficientList)
{
var c = At(x,1);
if(VecQ(c))
return CoefficientList(At(x,0),c);
return Coefficients(At(x,0),c);
}
Wrap(FromCoefficientList)
{
var c = At(x,1);
if(VecQ(c))
return FromCoefficientList(At(x,0),c);
return FromCoefficients(At(x,0),c);
}
Wrap(Power)
{
return Power(At(x,0),At(x,1));
}
Wrap(Mod)
{
return Mod(At(x,0),At(x,1));
}
Wrap(StringLength)
{
if(StrQ(At(x,0))) return Int(S::Length(At(x,0)));
return 0;
}
Wrap(StringInsert)
{
var c = At(x,0);
if(StrQ(c))
{
uint n = S::Length(c);
var r = Str();
CStr(r) = CStr(c);
if(Size(x) > 2 && StrQ(At(x,1)) && IntQ(At(x,2)))
{
int a = Z::SI(At(x,2));
a < 0 ? a += n : --a;
if(a < 0 || a >= n)
return r;
S::Insert(r,At(x,1),a);
return r;
}
}
return 0;
}
Wrap(StringTake)
{
var c = At(x,0);
if(StrQ(c))
{
uint n = S::Length(c);
var d = At(x,1);
if(VecQ(d))
{
int a = Z::SI(At(d,0));
a < 0 ? a += n : --a;
if(a < 0 || a >= n)
return c;
if(Size(d) > 1)
{
int b = Z::SI(At(d,1));
b < 0 ? b += n : --b;
if(b < 0 || b >= n)
return c;
return S::Substr(c,a,b < a ? 0 : b - a + 1);
}
else
return S::Substr(c,a,1);
}
else if(IntQ(d))
{
int a = Z::SI(d);
return a < 0 ? S::Substr(c,a + n,-a) : S::Substr(c,0,a);
}
}
return 0;
}
Wrap(StringDrop)
{
var c = At(x,0);
if(StrQ(c))
{
uint n = S::Length(c);
var r = Str();
CStr(r) = CStr(c);
var d = At(x,1);
if(VecQ(d))
{
int a = Z::SI(At(d,0));
a < 0 ? a += n : --a;
if(a < 0 || a >= n)
return r;
if(Size(d) > 1)
{
int b = Z::SI(At(d,1));
b < 0 ? b += n : --b;
if(b < 0 || b >= n)
return r;
S::Erase(r,a,b < a ? 0 : b - a + 1);
}
else
S::Erase(r,a,1);
}
else if(IntQ(d))
{
int a = Z::SI(d);
a < 0 ? S::Erase(r,a + n,-a) : S::Erase(r,0,a);
}
return r;
}
return 0;
}
Wrap2(Function)
{
var c = At(x,0);
if(Size(x) == 1)
return Eval(Supply(Ex(TAG(Function),c),c,y));
map_t m;
if(VecQ(c))
{
size_t n = Size(c);
for(size_t i = 0; i < n; ++i)
m[At(c,i)] = At(y,i);
}
else
m[c] = At(y,0);
return Eval(Subs(m,At(x,1)));
}
}
//void(*Types[TYPE_SIZE])(Var);
var Contexts;
stdext::hash_map<Var,const wchar*> ContextName;
std::stack<Var> ContextStack;
std::stack<std::list<Var> > ContextPath;
map_t OwnValues;
std::map<Var,dict_t> FactValues;
std::map<Var,def_t> DownValues;
std::map<Var,def_t> SubValues;
std::map<Var,map_t> Properties;
std::map<Var,attr_t> Attributes;
stdext::hash_map<Var,CProc> CProcs;
stdext::hash_map<Var,COper> COpers;
var
Global, System, Null, True, False, Nil,
Constant, Flat, HoldAll, HoldAllComplete, HoldFirst,
HoldRest, Listable, Locked, NHoldAll, NHoldFirst,
NHoldRest, NumericFunction, OneIdentity, Orderless, Protected,
ReadProtected, SequenceHold, Stub, Temporary,
TAG(Symbol), TAG(List), TAG(String), TAG(Integer), TAG(Rational), TAG(Real),
TAG(Postfix), TAG(Prefix), TAG(Differential),
TAG(Minus), TAG(Divide), TAG(Plus), TAG(Times), TAG(Power),
TAG(Return), TAG(Continue), TAG(Break),
TAG(Set), TAG(Rule), TAG(Pattern), TAG(Blank), TAG(Optional), TAG(Condition),
TAG(PatternTest), TAG(Unevaluated), TAG(Derivative), TAG(Function), TAG(Slot),
TAG(BlankSequence), TAG(SlotSequence), TAG(Part), TAG(Property), TAG(Sequence),
TAG(Sqrt), TAG(Radical), TAG(RuleDelayed), TAG(SetDelayed),
TAG(CompoundExpression), TAG(Integrate), TAG(D), TAG(Sum), TAG(Limit),
TAG(Infinity), TAG(Pi), TAG(E), TAG(I), TAG(Mod), TAG(Dot), TAG(Pow),
TAG(Timing),
TAG(And), TAG(Or), TAG(Not), TAG(If), TAG(For), TAG(While),
TAG(Flatten), TAG(FlattenAll), TAG(SameQ), TAG(Less), TAG(Equal), TAG(Greater),
TAG(UnsameQ), TAG(GreaterEqual), TAG(Unequal), TAG(LessEqual), TAG(FreeQ),
TAG(MatchQ), TAG(MemberQ), TAG(With), TAG(Block), TAG(Module),
TAG(ReplaceRepeated), TAG(Replace), TAG(ReplaceAll), TAG(OddQ), TAG(EvenQ),
TAG(SetAttributes), TAG(StringJoin), TAG(Join), TAG(Attributes),
TAG(Get), TAG(Put), TAG(PutAppend),
TAG(Install), TAG(Uninstall),
TAG(NumberQ), TAG(AtomQ), TAG(IntegerQ), TAG(SymbolQ), TAG(StringQ),
TAG(Pretty), TAG(Input), TAG(Print), TAG(Clear),
TAG(BeginPackage), TAG(EndPackage), TAG(Begin), TAG(End),
TAG(Evaluate), TAG(Dispatch), TAG(Length), TAG(Path), TAG(Head), TAG(Context),
TAG(Contexts), TAG(ContextPath), TAG(Apply), TAG(Map), TAG(Unset), TAG(Full),
TAG(ToString), TAG(ToExpression),
TAG(Exit), TAG(Quit), TAG(Hold), TAG(Run), /*TAG(Task), TAG(Kill),*/ TAG(Array),
TAG(Table), TAG(Do), TAG(Box), TAG(N), TAG(IntegerPart),
TAG(Floor), TAG(Ceiling), TAG(Round),
TAG(Expand), TAG(Variables), TAG(Coefficient),
TAG(Exponent), TAG(Deg), TAG(CoefficientList), TAG(FromCoefficientList),
TAG(Graphics2D), TAG(Graphics3D),
TAG(Options), TAG(StringLength), TAG(StringInsert), TAG(StringTake),
TAG(StringDrop);
void Initialize()
{
static bool Initialized = false;
if (Initialized) return;
Contexts = Tab();
Global = Ctx(L"Global`");
System = Ctx(L"System`");
DEF_SYSTEM_SYM(Null)
DEF_SYSTEM_SYM(True)
DEF_SYSTEM_SYM(False)
DEF_SYSTEM_SYM(Nil)
DEF_SYSTEM_SYM(Constant)
DEF_SYSTEM_SYM(Flat)
DEF_SYSTEM_SYM(HoldAll)
DEF_SYSTEM_SYM(HoldAllComplete)
DEF_SYSTEM_SYM(HoldFirst)
DEF_SYSTEM_SYM(HoldRest)
DEF_SYSTEM_SYM(Listable)
DEF_SYSTEM_SYM(Locked)
DEF_SYSTEM_SYM(NHoldAll)
DEF_SYSTEM_SYM(NHoldFirst)
DEF_SYSTEM_SYM(NHoldRest)
DEF_SYSTEM_SYM(NumericFunction)
DEF_SYSTEM_SYM(OneIdentity)
DEF_SYSTEM_SYM(Orderless)
DEF_SYSTEM_SYM(Protected)
DEF_SYSTEM_SYM(ReadProtected)
DEF_SYSTEM_SYM(SequenceHold)
DEF_SYSTEM_SYM(Stub)
DEF_SYSTEM_SYM(Temporary)
DEF_SYSTEM_TAG_SYM(Symbol)
DEF_SYSTEM_TAG_SYM(List)
DEF_SYSTEM_TAG_SYM(String)
DEF_SYSTEM_TAG_SYM(Integer)
DEF_SYSTEM_TAG_SYM(Rational)
DEF_SYSTEM_TAG_SYM(Real)
DEF_SYSTEM_TAG_SYM(Return)
DEF_SYSTEM_TAG_SYM(Continue)
DEF_SYSTEM_TAG_SYM(Break)
DEF_SYSTEM_TAG_SYM(Set)
DEF_SYSTEM_TAG_SYM(Rule)
DEF_SYSTEM_TAG_SYM(Minus)
DEF_SYSTEM_TAG_SYM(Divide)
DEF_SYSTEM_TAG_SYM(Plus)
DEF_SYSTEM_TAG_SYM(Times)
DEF_SYSTEM_TAG_SYM(Power)
DEF_SYSTEM_TAG_SYM(Integrate)
DEF_SYSTEM_TAG_SYM(D)
DEF_SYSTEM_TAG_SYM(Postfix)
DEF_SYSTEM_TAG_SYM(Prefix)
DEF_SYSTEM_TAG_SYM(Differential)
DEF_SYSTEM_TAG_SYM(Pattern)
DEF_SYSTEM_TAG_SYM(Blank)
DEF_SYSTEM_TAG_SYM(Optional)
DEF_SYSTEM_TAG_SYM(Condition)
DEF_SYSTEM_TAG_SYM(PatternTest)
DEF_SYSTEM_TAG_SYM(Unevaluated)
DEF_SYSTEM_TAG_SYM(Derivative)
DEF_SYSTEM_TAG_SYM(Function)
DEF_SYSTEM_TAG_SYM(Slot)
DEF_SYSTEM_TAG_SYM(BlankSequence)
DEF_SYSTEM_TAG_SYM(SlotSequence)
DEF_SYSTEM_TAG_SYM(Part)
DEF_SYSTEM_TAG_SYM(Property)
DEF_SYSTEM_TAG_SYM(Sequence)
DEF_SYSTEM_TAG_SYM(RuleDelayed)
DEF_SYSTEM_TAG_SYM(SetDelayed)
DEF_SYSTEM_TAG_SYM(CompoundExpression)
DEF_SYSTEM_TAG_SYM(Sum)
DEF_SYSTEM_TAG_SYM(Limit)
DEF_SYSTEM_TAG_SYM(Infinity)
DEF_SYSTEM_TAG_SYM(Pi)
DEF_SYSTEM_TAG_SYM(E)
DEF_SYSTEM_TAG_SYM(I)
DEF_SYSTEM_TAG_SYM(Sqrt)
DEF_SYSTEM_TAG_SYM(Radical)
DEF_SYSTEM_TAG_SYM(Mod)
DEF_SYSTEM_TAG_SYM(Dot)
DEF_SYSTEM_TAG_SYM(Pow)
DEF_SYSTEM_TAG_SYM(Timing)
DEF_SYSTEM_TAG_SYM(And)
DEF_SYSTEM_TAG_SYM(Or)
DEF_SYSTEM_TAG_SYM(Not)
DEF_SYSTEM_TAG_SYM(If)
DEF_SYSTEM_TAG_SYM(For)
DEF_SYSTEM_TAG_SYM(While)
DEF_SYSTEM_TAG_SYM(Flatten)
DEF_SYSTEM_TAG_SYM(FlattenAll)
DEF_SYSTEM_TAG_SYM(SameQ)
DEF_SYSTEM_TAG_SYM(Less)
DEF_SYSTEM_TAG_SYM(Equal)
DEF_SYSTEM_TAG_SYM(Greater)
DEF_SYSTEM_TAG_SYM(UnsameQ)
DEF_SYSTEM_TAG_SYM(GreaterEqual)
DEF_SYSTEM_TAG_SYM(Unequal)
DEF_SYSTEM_TAG_SYM(LessEqual)
DEF_SYSTEM_TAG_SYM(FreeQ)
DEF_SYSTEM_TAG_SYM(MatchQ)
DEF_SYSTEM_TAG_SYM(MemberQ)
DEF_SYSTEM_TAG_SYM(With)
DEF_SYSTEM_TAG_SYM(Block)
DEF_SYSTEM_TAG_SYM(Module)
DEF_SYSTEM_TAG_SYM(ReplaceRepeated)
DEF_SYSTEM_TAG_SYM(Replace)
DEF_SYSTEM_TAG_SYM(ReplaceAll)
DEF_SYSTEM_TAG_SYM(OddQ)
DEF_SYSTEM_TAG_SYM(EvenQ)
DEF_SYSTEM_TAG_SYM(SetAttributes)
DEF_SYSTEM_TAG_SYM(StringJoin)
DEF_SYSTEM_TAG_SYM(Join)
DEF_SYSTEM_TAG_SYM(Attributes)
DEF_SYSTEM_TAG_SYM(Get)
DEF_SYSTEM_TAG_SYM(Put)
DEF_SYSTEM_TAG_SYM(PutAppend)
DEF_SYSTEM_TAG_SYM(Install)
DEF_SYSTEM_TAG_SYM(Uninstall)
DEF_SYSTEM_TAG_SYM(NumberQ)
DEF_SYSTEM_TAG_SYM(AtomQ)
DEF_SYSTEM_TAG_SYM(IntegerQ)
DEF_SYSTEM_TAG_SYM(SymbolQ)
DEF_SYSTEM_TAG_SYM(StringQ)
DEF_SYSTEM_TAG_SYM(Pretty)
DEF_SYSTEM_TAG_SYM(Input)
DEF_SYSTEM_TAG_SYM(Print)
DEF_SYSTEM_TAG_SYM(Clear)
DEF_SYSTEM_TAG_SYM(BeginPackage)
DEF_SYSTEM_TAG_SYM(EndPackage)
DEF_SYSTEM_TAG_SYM(Begin)
DEF_SYSTEM_TAG_SYM(End)
DEF_SYSTEM_TAG_SYM(Evaluate)
DEF_SYSTEM_TAG_SYM(Dispatch)
DEF_SYSTEM_TAG_SYM(Length)
DEF_SYSTEM_TAG_SYM(Path)
DEF_SYSTEM_TAG_SYM(Head)
DEF_SYSTEM_TAG_SYM(Context)
DEF_SYSTEM_TAG_SYM(Contexts)
DEF_SYSTEM_TAG_SYM(ContextPath)
DEF_SYSTEM_TAG_SYM(Apply)
DEF_SYSTEM_TAG_SYM(Map)
DEF_SYSTEM_TAG_SYM(Unset)
DEF_SYSTEM_TAG_SYM(Full)
DEF_SYSTEM_TAG_SYM(ToString)
DEF_SYSTEM_TAG_SYM(ToExpression)
DEF_SYSTEM_TAG_SYM(Exit)
DEF_SYSTEM_TAG_SYM(Quit)
DEF_SYSTEM_TAG_SYM(Hold)
DEF_SYSTEM_TAG_SYM(Run)
//DEF_SYSTEM_TAG_SYM(Task)
//DEF_SYSTEM_TAG_SYM(Kill)
DEF_SYSTEM_TAG_SYM(Array)
DEF_SYSTEM_TAG_SYM(Table)
DEF_SYSTEM_TAG_SYM(Do)
DEF_SYSTEM_TAG_SYM(Box)
DEF_SYSTEM_TAG_SYM(N)
DEF_SYSTEM_TAG_SYM(IntegerPart)
DEF_SYSTEM_TAG_SYM(Floor)
DEF_SYSTEM_TAG_SYM(Ceiling)
DEF_SYSTEM_TAG_SYM(Round)
DEF_SYSTEM_TAG_SYM(Expand)
DEF_SYSTEM_TAG_SYM(Variables)
DEF_SYSTEM_TAG_SYM(Coefficient)
DEF_SYSTEM_TAG_SYM(Exponent)
DEF_SYSTEM_TAG_SYM(Deg)
DEF_SYSTEM_TAG_SYM(CoefficientList)
DEF_SYSTEM_TAG_SYM(FromCoefficientList)
DEF_SYSTEM_TAG_SYM(Graphics2D)
DEF_SYSTEM_TAG_SYM(Graphics3D)
DEF_SYSTEM_TAG_SYM(Options)
DEF_SYSTEM_TAG_SYM(StringLength)
DEF_SYSTEM_TAG_SYM(StringInsert)
DEF_SYSTEM_TAG_SYM(StringTake)
DEF_SYSTEM_TAG_SYM(StringDrop)
DEF_CPROC(Plus)
DEF_CPROC(Times)
DEF_CPROC(Dot)
DEF_WRAPPED_CPROC(Timing)
DEF_WRAPPED_CPROC(And)
DEF_WRAPPED_CPROC(Or)
DEF_WRAPPED_CPROC(Not)
DEF_WRAPPED_CPROC(If)
DEF_WRAPPED_CPROC(For)
DEF_WRAPPED_CPROC(While)
DEF_WRAPPED_CPROC(Flatten)
DEF_WRAPPED_CPROC(FlattenAll)
DEF_WRAPPED_CPROC(SameQ)
DEF_WRAPPED_CPROC(Less)
DEF_WRAPPED_CPROC(Equal)
DEF_WRAPPED_CPROC(Greater)
DEF_WRAPPED_CPROC(UnsameQ)
DEF_WRAPPED_CPROC(GreaterEqual)
DEF_WRAPPED_CPROC(Unequal)
DEF_WRAPPED_CPROC(LessEqual)
DEF_WRAPPED_CPROC(FreeQ)
DEF_WRAPPED_CPROC(MatchQ)
DEF_WRAPPED_CPROC(MemberQ)
DEF_WRAPPED_CPROC(With)
DEF_WRAPPED_CPROC(Block)
DEF_WRAPPED_CPROC(Module)
DEF_WRAPPED_CPROC(ReplaceRepeated)
DEF_WRAPPED_CPROC(Replace)
DEF_WRAPPED_CPROC(ReplaceAll)
DEF_WRAPPED_CPROC(OddQ)
DEF_WRAPPED_CPROC(EvenQ)
DEF_WRAPPED_CPROC(SetAttributes)
DEF_WRAPPED_CPROC(StringJoin)
DEF_WRAPPED_CPROC(Join)
DEF_WRAPPED_CPROC(Attributes)
DEF_WRAPPED_CPROC(Get)
DEF_WRAPPED_CPROC(Put)
DEF_WRAPPED_CPROC(PutAppend)
DEF_WRAPPED_CPROC(Install)
DEF_WRAPPED_CPROC(Uninstall)
DEF_WRAPPED_CPROC(NumberQ)
DEF_WRAPPED_CPROC(AtomQ)
DEF_WRAPPED_CPROC(IntegerQ)
DEF_WRAPPED_CPROC(SymbolQ)
DEF_WRAPPED_CPROC(StringQ)
DEF_WRAPPED_CPROC(Pretty)
DEF_WRAPPED_CPROC(Input)
DEF_WRAPPED_CPROC(Print)
DEF_WRAPPED_CPROC(Clear)
DEF_WRAPPED_CPROC(BeginPackage)
DEF_WRAPPED_CPROC(EndPackage)
DEF_WRAPPED_CPROC(Begin)
DEF_WRAPPED_CPROC(End)
DEF_WRAPPED_CPROC(Evaluate)
DEF_WRAPPED_CPROC(Unevaluated)
DEF_WRAPPED_CPROC(Dispatch)
DEF_WRAPPED_CPROC(Length)
DEF_WRAPPED_CPROC(Path)
DEF_WRAPPED_CPROC(Head)
DEF_WRAPPED_CPROC(Context)
DEF_WRAPPED_CPROC(Contexts)
DEF_WRAPPED_CPROC(ContextPath)
DEF_WRAPPED_CPROC(Apply)
DEF_WRAPPED_CPROC(Map)
DEF_WRAPPED_CPROC(Unset)
DEF_WRAPPED_CPROC(Full)
DEF_WRAPPED_CPROC(ToString)
DEF_WRAPPED_CPROC(ToExpression)
DEF_WRAPPED_CPROC(Exit)
DEF_WRAPPED_CPROC(Quit)
DEF_WRAPPED_CPROC(Set)
DEF_WRAPPED_CPROC(SetDelayed)
DEF_WRAPPED_CPROC(Hold)
DEF_WRAPPED_CPROC(Run)
//DEF_WRAPPED_CPROC(Task)
//DEF_WRAPPED_CPROC(Kill)
DEF_WRAPPED_CPROC(Array)
DEF_WRAPPED_CPROC(Table)
DEF_WRAPPED_CPROC(Do)
DEF_WRAPPED_CPROC(N)
DEF_WRAPPED_CPROC(IntegerPart)
DEF_WRAPPED_CPROC(Floor)
DEF_WRAPPED_CPROC(Ceiling)
DEF_WRAPPED_CPROC(Round)
DEF_WRAPPED_CPROC(Expand)
DEF_WRAPPED_CPROC(Variables)
DEF_WRAPPED_CPROC(Coefficient)
DEF_WRAPPED_CPROC(Exponent)
DEF_WRAPPED_CPROC(Deg)
DEF_WRAPPED_CPROC(CoefficientList)
DEF_WRAPPED_CPROC(FromCoefficientList)
DEF_WRAPPED_CPROC(StringLength)
DEF_WRAPPED_CPROC(Set)
DEF_WRAPPED_CPROC(Part)
DEF_WRAPPED_CPROC(Property)
DEF_WRAPPED_CPROC(SetDelayed)
DEF_WRAPPED_CPROC(CompoundExpression)
DEF_WRAPPED_CPROC(Power)
DEF_WRAPPED_CPROC(Mod)
DEF_WRAPPED_COPER(Function)
SET_ATTR(CompoundExpression,HoldAll)
SET_ATTR(Timing,HoldAll)
SET_ATTR(For,HoldAll)
SET_ATTR(While,HoldAll)
SET_ATTR(Plus,OneIdentity)
SET_ATTR(Plus,Flat)
SET_ATTR(Plus,Orderless)
SET_ATTR(Plus,Listable)
SET_ATTR(Times,OneIdentity)
SET_ATTR(Times,Flat)
SET_ATTR(Times,Orderless)
SET_ATTR(Times,Listable)
SET_ATTR(Power,OneIdentity)
SET_ATTR(Power,Listable)
SET_ATTR(Pi,Constant)
SET_ATTR(E,Constant)
SET_ATTR(Set,HoldFirst)
SET_ATTR(SetDelayed,HoldAll)
SET_ATTR(Hold,HoldAll)
SET_ATTR(And,OneIdentity)
SET_ATTR(And,Flat)
SET_ATTR(And,HoldAll)
SET_ATTR(Or,OneIdentity)
SET_ATTR(Or,Flat)
SET_ATTR(Or,HoldAll)
SET_ATTR(If,HoldRest)
SET_ATTR(Pattern,HoldFirst)
SET_ATTR(Condition,HoldAll)
SET_ATTR(PatternTest,HoldRest)
SET_ATTR(With,HoldAll)
SET_ATTR(Block,HoldAll)
SET_ATTR(Module,HoldAll)
SET_ATTR(SetAttributes,HoldFirst)
SET_ATTR(StringJoin,Flat)
SET_ATTR(StringJoin,OneIdentity)
SET_ATTR(Join,Flat)
SET_ATTR(Join,OneIdentity)
SET_ATTR(Attributes,HoldAll)
SET_ATTR(Clear,HoldAll)
SET_ATTR(Unevaluated,HoldAll)
SET_ATTR(Function,HoldAll)
SET_ATTR(Context,HoldFirst)
SET_ATTR(Property,HoldAll)
SET_ATTR(RuleDelayed,HoldRest)
SET_ATTR(Unset,HoldFirst)
//SET_ATTR(Task,HoldAll)
SET_ATTR(Table,HoldAll)
SET_ATTR(Do,HoldAll)
ContextPath.push(std::list<Var>());
ContextPath.top().push_back(System);
ContextPath.top().push_back(Global);
ContextStack.push(Global);
Initialized = true;
}
}
DLLMAIN(mU::Initialize)
using namespace mU;
#define SYS(x) Sym(_W(#x),System)
CAPI void Install() {
CProcs[SYS(CProc)] = (CProc)cfunc(cnoload("kernel"), SYS(CProc));
Begin(System);
ParseFile(Path() + _W("Kernel/Kernel.u"));
End();
}
CAPI void Uninstall() {
wcout << "#Kernel# Uninstall Successfully!" << std::endl;
}
| [
"[email protected]",
"[email protected]"
] | [
[
[
1,
423
],
[
432,
852
],
[
854,
872
],
[
881,
881
],
[
906,
908
],
[
910,
913
],
[
1234,
1252
]
],
[
[
424,
431
],
[
853,
853
],
[
873,
880
],
[
882,
905
],
[
909,
909
],
[
914,
1233
],
[
1253,
1253
]
]
] |
67042873d6f1b0eadc8badd38240aab8bf5c2c37 | 15730792376cc6ffa986d6bcb88ba9fd7acf9369 | /raytracer3.0.06.no_rec.samp/surface.cpp | 7362e28ce76a3feec514e4a6e0f7d61e8f333486 | [] | no_license | markrosoft/se-195-project-ray-tracer | 0b8c14422e52aa5ede17a158c6ef7521934ce029 | 0712d443be8c0da986ab1315a257740fbb3a653d | refs/heads/master | 2021-01-10T07:14:00.513000 | 2011-11-18T06:42:15 | 2011-11-18T06:42:15 | 43,331,160 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,375 | cpp | #define _CRT_SECURE_NO_WARNINGS 1
#include "common.h"
#include "surface.h"
#include "stdio.h"
#include "string.h"
// -----------------------------------------------------------
// Hicolor surface class implementation
// -----------------------------------------------------------
Surface * Surface_Create( int a_Width, int a_Height ) {
Surface *s = (Surface *)malloc(sizeof(Surface));
s->m_Width = a_Width;
s->m_Height = a_Height;
s->m_Buffer = (Pixel *)malloc(a_Width*a_Height*sizeof(Pixel));
return s;
}
void Surface_Clear( Surface * s, Pixel a_Color )
{
int z = s->m_Width * s->m_Height;
for ( int i = 0; i < z; i++ ) s->m_Buffer[i] = a_Color;
}
void Surface_Print( Surface * s, char* a_String, int x1, int y1, Pixel color )
{
Pixel* t = s->m_Buffer + x1 + y1 * s->m_Width;
int i;
for ( i = 0; i < (int)(strlen( a_String )); i++ )
{
long pos = 0;
if ((a_String[i] >= 'A') && (a_String[i] <= 'Z')) pos = s->s_Transl[a_String[i] - ('A' - 'a')];
else pos = s->s_Transl[a_String[i]];
Pixel* a = t;
char* c = (char*)s->s_Font[pos];
int h, v;
for ( v = 0; v < 5; v++ )
{
for ( h = 0; h < 5; h++ ) if (*c++ == 'o') *(a + h) = color;
a += s->m_Width;
}
t += 6;
}
}
void Surface_SetChar( Surface * s, int c, char* c1, char* c2, char* c3, char* c4, char* c5 )
{
strcpy( s->s_Font[c][0], c1 );
strcpy( s->s_Font[c][1], c2 );
strcpy( s->s_Font[c][2], c3 );
strcpy( s->s_Font[c][3], c4 );
strcpy( s->s_Font[c][4], c5 );
}
void Surface_InitCharset(Surface * s)
{
Surface_SetChar(s, 0, ":ooo:", "o:::o", "ooooo", "o:::o", "o:::o" );
Surface_SetChar(s, 1, "oooo:", "o:::o", "oooo:", "o:::o", "oooo:" );
Surface_SetChar(s, 2, ":oooo", "o::::", "o::::", "o::::", ":oooo" );
Surface_SetChar(s, 3, "oooo:", "o:::o", "o:::o", "o:::o", "oooo:" );
Surface_SetChar(s, 4, "ooooo", "o::::", "oooo:", "o::::", "ooooo" );
Surface_SetChar(s, 5, "ooooo", "o::::", "ooo::", "o::::", "o::::" );
Surface_SetChar(s, 6, ":oooo", "o::::", "o:ooo", "o:::o", ":ooo:" );
Surface_SetChar(s, 7, "o:::o", "o:::o", "ooooo", "o:::o", "o:::o" );
Surface_SetChar(s, 8, "::o::", "::o::", "::o::", "::o::", "::o::" );
Surface_SetChar(s, 9, ":::o:", ":::o:", ":::o:", ":::o:", "ooo::" );
Surface_SetChar(s, 10, "o::o:", "o:o::", "oo:::", "o:o::", "o::o:" );
Surface_SetChar(s, 11, "o::::", "o::::", "o::::", "o::::", "ooooo" );
Surface_SetChar(s, 12, "oo:o:", "o:o:o", "o:o:o", "o:::o", "o:::o" );
Surface_SetChar(s, 13, "o:::o", "oo::o", "o:o:o", "o::oo", "o:::o" );
Surface_SetChar(s, 14, ":ooo:", "o:::o", "o:::o", "o:::o", ":ooo:" );
Surface_SetChar(s, 15, "oooo:", "o:::o", "oooo:", "o::::", "o::::" );
Surface_SetChar(s, 16, ":ooo:", "o:::o", "o:::o", "o::oo", ":oooo" );
Surface_SetChar(s, 17, "oooo:", "o:::o", "oooo:", "o:o::", "o::o:" );
Surface_SetChar(s, 18, ":oooo", "o::::", ":ooo:", "::::o", "oooo:" );
Surface_SetChar(s, 19, "ooooo", "::o::", "::o::", "::o::", "::o::" );
Surface_SetChar(s, 20, "o:::o", "o:::o", "o:::o", "o:::o", ":oooo" );
Surface_SetChar(s, 21, "o:::o", "o:::o", ":o:o:", ":o:o:", "::o::" );
Surface_SetChar(s, 22, "o:::o", "o:::o", "o:o:o", "o:o:o", ":o:o:" );
Surface_SetChar(s, 23, "o:::o", ":o:o:", "::o::", ":o:o:", "o:::o" );
Surface_SetChar(s, 24, "o:::o", "o:::o", ":oooo", "::::o", ":ooo:" );
Surface_SetChar(s, 25, "ooooo", ":::o:", "::o::", ":o:::", "ooooo" );
Surface_SetChar(s, 26, ":ooo:", "o::oo", "o:o:o", "oo::o", ":ooo:" );
Surface_SetChar(s, 27, "::o::", ":oo::", "::o::", "::o::", ":ooo:" );
Surface_SetChar(s, 28, ":ooo:", "o:::o", "::oo:", ":o:::", "ooooo" );
Surface_SetChar(s, 29, "oooo:", "::::o", "::oo:", "::::o", "oooo:" );
Surface_SetChar(s, 30, "o::::", "o::o:", "ooooo", ":::o:", ":::o:" );
Surface_SetChar(s, 31, "ooooo", "o::::", "oooo:", "::::o", "oooo:" );
Surface_SetChar(s, 32, ":oooo", "o::::", "oooo:", "o:::o", ":ooo:" );
Surface_SetChar(s, 33, "ooooo", "::::o", ":::o:", "::o::", "::o::" );
Surface_SetChar(s, 34, ":ooo:", "o:::o", ":ooo:", "o:::o", ":ooo:" );
Surface_SetChar(s, 35, ":ooo:", "o:::o", ":oooo", "::::o", ":ooo:" );
Surface_SetChar(s, 36, "::o::", "::o::", "::o::", ":::::", "::o::" );
Surface_SetChar(s, 37, ":ooo:", "::::o", ":::o:", ":::::", "::o::" );
Surface_SetChar(s, 38, ":::::", ":::::", "::o::", ":::::", "::o::" );
Surface_SetChar(s, 39, ":::::", ":::::", ":ooo:", ":::::", ":ooo:" );
Surface_SetChar(s, 40, ":::::", ":::::", ":::::", ":::o:", "::o::" );
Surface_SetChar(s, 41, ":::::", ":::::", ":::::", ":::::", "::o::" );
Surface_SetChar(s, 42, ":::::", ":::::", ":ooo:", ":::::", ":::::" );
Surface_SetChar(s, 43, ":::o:", "::o::", "::o::", "::o::", ":::o:" );
Surface_SetChar(s, 44, "::o::", ":::o:", ":::o:", ":::o:", "::o::" );
Surface_SetChar(s, 45, ":::::", ":::::", ":::::", ":::::", ":::::" );
Surface_SetChar(s, 46, "ooooo", "ooooo", "ooooo", "ooooo", "ooooo" );
Surface_SetChar(s, 47, "::o::", "::o::", ":::::", ":::::", ":::::" ); // Tnx Ferry
Surface_SetChar(s, 48, "o:o:o", ":ooo:", "ooooo", ":ooo:", "o:o:o" );
Surface_SetChar(s, 49, "::::o", ":::o:", "::o::", ":o:::", "o::::" );
char c[] = "abcdefghijklmnopqrstuvwxyz0123456789!?:=,.-() #'*/";
int i;
for ( i = 0; i < 256; i++ ) s->s_Transl[i] = 45;
for ( i = 0; i < 50; i++ ) s->s_Transl[(unsigned char)c[i]] = i;
}
| [
"[email protected]"
] | [
[
[
1,
114
]
]
] |
7dfc4fc2fb7135fc29ba0a38497fc82a49f33dfc | 61bcb936a14064e2a819269d25b5c09b92dad45f | /Winter2011/Final Project/Final Project.cpp | 7e339f27144ee977d238016556811b1872891b51 | [] | no_license | lanxinwoaini/robotic-vision-631 | 47fe73588a5b51296b9ac7fbacd4a553e4fd8e34 | fdb160a8498ec668a32116c655368d068110aba7 | refs/heads/master | 2021-01-10T08:06:58.829000 | 2011-04-20T15:19:06 | 2011-04-20T15:19:06 | 47,861,917 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,190 | cpp | // Final Project.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "Final Project.h"
#include "Final ProjectDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CFinalProjectApp
BEGIN_MESSAGE_MAP(CFinalProjectApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// CFinalProjectApp construction
CFinalProjectApp::CFinalProjectApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CFinalProjectApp object
CFinalProjectApp theApp;
// CFinalProjectApp initialization
BOOL CFinalProjectApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
CFinalProjectDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
cvDestroyAllWindows();
return FALSE;
}
| [
"[email protected]"
] | [
[
[
1,
79
]
]
] |
9256a879e20b030093ba858690888f71d52c0ace | 3e69b159d352a57a48bc483cb8ca802b49679d65 | /tags/release-2005-10-27/eeschema/libfield.cpp | 629a6deda044d22e5a9b8d1d035b9f820fba6f59 | [] | no_license | BackupTheBerlios/kicad-svn | 4b79bc0af39d6e5cb0f07556eb781a83e8a464b9 | 4c97bbde4b1b12ec5616a57c17298c77a9790398 | refs/heads/master | 2021-01-01T19:38:40 | 2006-06-19T20:01:24 | 2006-06-19T20:01:24 | 40,799,911 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,674 | cpp | /*********************************************************************/
/* EESchema - edition des librairies: Edition des champs ( Fields ) */
/*********************************************************************/
/* Fichier libfield.cpp */
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "wx/spinctrl.h"
/* Routines locales */
static void ShowMoveField(WinEDA_DrawPanel * panel, wxDC *DC, bool erase);
/* Variables locales */
extern int CurrentUnit;
static wxPoint StartCursor, LastTextPosition;
/***********************************************************/
static void ExitMoveField(WinEDA_DrawFrame * frame, wxDC * DC)
/***********************************************************/
{
frame->m_CurrentScreen->ManageCurseur = NULL;
frame->m_CurrentScreen->ForceCloseManageCurseur = NULL;
if(CurrentDrawItem == NULL) return;
wxPoint curpos;
curpos = frame->m_CurrentScreen->m_Curseur;
frame->m_CurrentScreen->m_Curseur = StartCursor;
ShowMoveField(frame->DrawPanel, DC, TRUE);
frame->m_CurrentScreen->m_Curseur = curpos;
CurrentDrawItem->m_Flags = 0;
CurrentDrawItem = NULL;
}
/****************************************************************************/
void WinEDA_LibeditFrame::StartMoveField(wxDC * DC, LibDrawField *field)
/****************************************************************************/
/* Initialise le deplacement d'un champ ( ref ou Name) */
{
if( (CurrentLibEntry == NULL) || ( field == NULL ) ) return;
CurrentDrawItem = field;
LastTextPosition = field->m_Pos;
CurrentDrawItem->m_Flags |= IS_MOVED;
m_CurrentScreen->ManageCurseur = ShowMoveField;
m_CurrentScreen->ForceCloseManageCurseur = ExitMoveField;
m_CurrentScreen->ManageCurseur(DrawPanel, DC, TRUE);
StartCursor = m_CurrentScreen->m_Curseur;
}
/*****************************************************************/
/* Routine d'affichage du texte 'Field' en cours de deplacement. */
/* Routine normalement attachee au curseur */
/*****************************************************************/
static void ShowMoveField(WinEDA_DrawPanel * panel, wxDC *DC, bool erase)
{
int color;
LibDrawField *Field = (LibDrawField *)CurrentDrawItem;
if( (CurrentLibEntry == NULL) || (Field == NULL) ) return;
GRSetDrawMode(DC, XOR_MODE);
switch (Field->m_FieldId)
{
case VALUE:
color = ReturnLayerColor(LAYER_VALUEPART);
break;
case REFERENCE:
color = ReturnLayerColor(LAYER_REFERENCEPART);
break;
default:
color = ReturnLayerColor(LAYER_FIELDS);
break;
}
if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY;
if( erase )
DrawGraphicText(panel, DC,
wxPoint(LastTextPosition.x, - LastTextPosition.y),
color, Field->m_Text,
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify);
LastTextPosition.x = panel->GetScreen()->m_Curseur.x;
LastTextPosition.y = - panel->GetScreen()->m_Curseur.y;
if ( (Field->m_Flags & IS_NEW) )
Field->m_Pos = LastTextPosition;
DrawGraphicText(panel, DC,
wxPoint(LastTextPosition.x, - LastTextPosition.y),
color, Field->m_Text,
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify);
}
/*******************************************************************/
void WinEDA_LibeditFrame::PlaceField(wxDC * DC, LibDrawField *Field)
/*******************************************************************/
{
int color;
if(Field == NULL ) return;
GRSetDrawMode(DC, GR_DEFAULT_DRAWMODE);
switch (Field->m_FieldId)
{
case REFERENCE:
color = ReturnLayerColor(LAYER_REFERENCEPART);
break;
case VALUE:
color = ReturnLayerColor(LAYER_VALUEPART);
break;
default:
color = ReturnLayerColor(LAYER_FIELDS);
break;
}
if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY;
Field->m_Pos.x = GetScreen()->m_Curseur.x;
Field->m_Pos.y = - GetScreen()->m_Curseur.y;
DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y),
color, Field->m_Text,
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify);
Field->m_Flags = 0;
m_CurrentScreen->SetModify();
m_CurrentScreen->ManageCurseur = NULL;
m_CurrentScreen->ForceCloseManageCurseur = NULL;
CurrentDrawItem = NULL;
}
/******************************************************************/
void WinEDA_LibeditFrame::EditField(wxDC * DC, LibDrawField *Field)
/******************************************************************/
{
wxString Text;
int color;
char * title = "Text:";
if( Field == NULL) return;
switch (Field->m_FieldId)
{
case REFERENCE:
title ="Reference:";
color = ReturnLayerColor(LAYER_REFERENCEPART);
break;
case VALUE:
title ="Value:";
color = ReturnLayerColor(LAYER_VALUEPART);
break;
default:
color = ReturnLayerColor(LAYER_FIELDS);
break;
}
if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY;
Text = Field->m_Text;
Get_Message(title,Text, this);
Text.Replace(" ", "_");
GRSetDrawMode(DC, XOR_MODE);
DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y),
color, Field->m_Text,
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify);
if( ! Text .IsEmpty() )
{
SaveCopyInUndoList();
Field->m_Text = Text;
}
else DisplayError(this, _("No new text: no change") );
if( Field->m_Flags == 0 ) GRSetDrawMode(DC, GR_DEFAULT_DRAWMODE);
DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y),
color, Field->m_Text,
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify);
m_CurrentScreen->SetModify();
if ( Field->m_FieldId == VALUE ) ReCreateHToolbar();
}
/********************************************************************/
void WinEDA_LibeditFrame::RotateField(wxDC * DC, LibDrawField *Field)
/********************************************************************/
/* Routine de modification de l'orientation ( Horiz ou Vert. ) du champ.
si un champ est en cours d'edition, modif de celui ci.
sinon Modif du champ pointe par la souris
*/
{
int color;
if( Field == NULL) return;
m_CurrentScreen->SetModify();
switch (Field->m_FieldId)
{
case REFERENCE:
color = ReturnLayerColor(LAYER_REFERENCEPART);
break;
case VALUE:
color = ReturnLayerColor(LAYER_VALUEPART);
break;
default:
color = ReturnLayerColor(LAYER_FIELDS);
break;
}
if( Field->m_Attributs & TEXT_NO_VISIBLE ) color = DARKGRAY;
GRSetDrawMode(DC, XOR_MODE);
DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y),
color, Field->m_Text,
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify);
if( Field->m_Orient) Field->m_Orient = 0;
else Field->m_Orient = 1;
if( Field->m_Flags == 0 ) GRSetDrawMode(DC, GR_DEFAULT_DRAWMODE);
DrawGraphicText(DrawPanel, DC, wxPoint(Field->m_Pos.x, - Field->m_Pos.y),
color, Field->m_Text,
Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ,
Field->m_Size,
Field->m_HJustify, Field->m_VJustify);
}
/****************************************************************************/
LibDrawField * WinEDA_LibeditFrame::LocateField(EDA_LibComponentStruct *LibEntry)
/****************************************************************************/
/* Localise le champ (ref ou name) pointe par la souris
retourne:
pointeur sur le champ (NULL= Pas de champ)
*/
{
int x0, y0, x1, y1; /* Rectangle d'encadrement des textes a localiser */
int dx, dy; /* Dimensions du texte */
LibDrawField *Field;
int hjustify, vjustify;
/* Localisation du Nom */
x0 = LibEntry->m_Name.m_Pos.x;
y0 = - LibEntry->m_Name.m_Pos.y;
dx = LibEntry->m_Name.m_Size.x * strlen(LibEntry->m_Name.m_Text),
dy = LibEntry->m_Name.m_Size.y;
hjustify = LibEntry->m_Name.m_HJustify; vjustify = LibEntry->m_Name.m_VJustify;
if (LibEntry->m_Name.m_Orient) EXCHG(dx, dy);
if ( hjustify == GR_TEXT_HJUSTIFY_CENTER ) x0 -= dx/2;
else if ( hjustify == GR_TEXT_HJUSTIFY_RIGHT ) x0 -= dx;
if ( vjustify == GR_TEXT_VJUSTIFY_CENTER ) y0 -= dy/2;
else if ( vjustify == GR_TEXT_VJUSTIFY_BOTTOM ) y0 += dy;
x1 = x0 + dx; y1 = y0 + dy;
if( (m_CurrentScreen->m_Curseur.x >= x0) && ( m_CurrentScreen->m_Curseur.x <= x1) &&
(m_CurrentScreen->m_Curseur.y >= y0) && ( m_CurrentScreen->m_Curseur.y <= y1) )
return &LibEntry->m_Name;
/* Localisation du Prefix */
x0 = LibEntry->m_Prefix.m_Pos.x;
y0 = - LibEntry->m_Prefix.m_Pos.y;
dx = LibEntry->m_Prefix.m_Size.x * strlen(LibEntry->m_Prefix.m_Text),
dy = LibEntry->m_Prefix.m_Size.y;
hjustify = LibEntry->m_Prefix.m_HJustify; vjustify = LibEntry->m_Prefix.m_VJustify;
if (LibEntry->m_Prefix.m_Orient) EXCHG(dx, dy);
if ( hjustify == GR_TEXT_HJUSTIFY_CENTER ) x0 -= dx/2;
else if ( hjustify == GR_TEXT_HJUSTIFY_RIGHT ) x0 -= dx;
if ( vjustify == GR_TEXT_VJUSTIFY_CENTER ) y0 -= dy/2;
else if ( vjustify == GR_TEXT_VJUSTIFY_BOTTOM ) y0 -= dy;
x1 = x0 + dx; y1 = y0 + dy;
if( (m_CurrentScreen->m_Curseur.x >= x0) && ( m_CurrentScreen->m_Curseur.x <= x1) &&
(m_CurrentScreen->m_Curseur.y >= y0) && ( m_CurrentScreen->m_Curseur.y <= y1) )
return &LibEntry->m_Prefix;
/* Localisation des autres fields */
for (Field = LibEntry->Fields; Field != NULL;
Field = (LibDrawField*)Field->Pnext)
{
if ( Field->m_Text == "") continue;
x0 = Field->m_Pos.x; y0 = - Field->m_Pos.y;
dx = Field->m_Size.x * strlen(Field->m_Text),
dy = Field->m_Size.y;
hjustify = Field->m_HJustify; vjustify = Field->m_VJustify;
if (Field->m_Orient) EXCHG(dx, dy);
if (LibEntry->m_Prefix.m_Orient) EXCHG(dx, dy);
if ( hjustify == GR_TEXT_HJUSTIFY_CENTER ) x0 -= dx/2;
else if ( hjustify == GR_TEXT_HJUSTIFY_RIGHT ) x0 -= dx;
if ( vjustify == GR_TEXT_VJUSTIFY_CENTER ) y0 -= dy/2;
else if ( vjustify == GR_TEXT_VJUSTIFY_BOTTOM ) y0 -= dy;
x1 = x0 + dx; y1 = y0 + dy;
if( (m_CurrentScreen->m_Curseur.x >= x0) && ( m_CurrentScreen->m_Curseur.x <= x1) &&
(m_CurrentScreen->m_Curseur.y >= y0) && ( m_CurrentScreen->m_Curseur.y <= y1) )
return(Field);
}
return NULL;
}
| [
"bokeoa@244deca0-f506-0410-ab94-f4f3571dea26"
] | [
[
[
1,
339
]
]
] |
44ab621450525a72ef6562ed96b69e60917a4940 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/wave/samples/list_includes/list_includes_version.hpp | 303bc911f440795459e2386c12b66eb0a5eb511a | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200000 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 965 | hpp | /*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: List include dependencies of a given source file version number
http://www.boost.org/
Copyright (c) 2001-2007 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(LIST_INCLUDES_VERSION_HPP_FF662D6C_C3E6_4BEC_A062_5D9BD7415EBF_INCLUDED)
#define LIST_INCLUDES_VERSION_HPP_FF662D6C_C3E6_4BEC_A062_5D9BD7415EBF_INCLUDED
#define LIST_INCLUDES_VERSION_MAJOR 0
#define LIST_INCLUDES_VERSION_MINOR 3
#define LIST_INCLUDES_VERSION_SUBMINOR 0
#endif // !defined(LIST_INCLUDES_VERSION_HPP_FF662D6C_C3E6_4BEC_A062_5D9BD7415EBF_INCLUDED)
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
] | [
[
[
1,
20
]
]
] |
4ab64db77dda1872d9816b72d9061c4f4a5db666 | 406b4b18f5c58c689d2324f49db972377fe8feb6 | /ANE/Include/StlCustomize/ane_string.h | 6ef03e1eac041755ce72cf67cf5d82fcf0ebea34 | [] | no_license | Mobiwoom/ane | e17167de36699c451ed92eab7bf733e7d41fe847 | ec20667c556a99351024f3ae9c8880e944c5bfbd | refs/heads/master | 2021-01-17T13:09:57.966000 | 2010-03-23T16:30:17 | 2010-03-23T16:30:17 | 33,132,357 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 354 | h | #pragma once
#include <xstring>
namespace Ane
{
typedef std::basic_string<char, std::char_traits<char>, std::allocator<char>> string;
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>> wstring;
#ifdef _DEBUG
typedef Ane::string _tstring;
#else
typedef Ane::wstring _tstring;
#endif
}//namespace Ane | [
"inthejm@5abed23c-1faa-11df-9e62-c93c6248c2ac"
] | [
[
[
1,
16
]
]
] |
435bdba381c163c105b91a2675cb5a6141c3200e | 4b0f51aeecddecf3f57a29ffa7a184ae48f1dc61 | /CleanProject/ParticleUniverse/include/ParticleRenderers/ParticleUniverseBillboardRenderer.h | 0df7e028c57f9a7fb0e87620e14a42ac55b81df2 | [] | no_license | bahao247/apeengine2 | 56560dbf6d262364fbc0f9f96ba4231e5e4ed301 | f2617b2a42bdf2907c6d56e334c0d027fb62062d | refs/heads/master | 2021-01-10T14:04:02.319000 | 2009-08-26T08:23:33 | 2009-08-26T08:23:33 | 45,979,392 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,087 | h | /*
-----------------------------------------------------------------------------
This source file is part of the Particle Universe product.
Copyright (c) 2006-2008 Henry van Merode
Usage of this program is free for non-commercial use and licensed under the
the terms of the GNU Lesser General Public License.
You should have received a copy of the GNU Lesser 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, or go to
http://www.gnu.org/copyleft/lesser.txt.
-----------------------------------------------------------------------------
*/
#ifndef __PU_BILLBOARD_RENDERER_H__
#define __PU_BILLBOARD_RENDERER_H__
#include "ParticleUniversePrerequisites.h"
#include "ParticleUniverseRenderer.h"
#include "ParticleUniverseTechnique.h"
namespace ParticleUniverse
{
/** The BillboardRenderer class is responsible to render particles as a billboard.
*/
class _ParticleUniverseExport BillboardRenderer : public ParticleRenderer
{
public:
/** Alternative billboard type.
@remarks
This is an extended version of Ogre's billboard type. It has BBT_ORIENTED_SHAPE added
which basicly means that the billboard orientation is derived from the particle
orientation.
*/
enum BillboardType
{
BBT_POINT,
BBT_ORIENTED_COMMON,
BBT_ORIENTED_SELF,
BBT_ORIENTED_SHAPE,
BBT_PERPENDICULAR_COMMON,
BBT_PERPENDICULAR_SELF
};
BillboardRenderer(void);
virtual ~BillboardRenderer(void);
/** @copydoc ParticleRenderer::_prepare */
virtual void _prepare(ParticleTechnique* technique);
/**
*/
void setBillboardType(BillboardType bbt);
/**
*/
BillboardType getBillboardType(void) const;
/**
*/
void setUseAccurateFacing(bool acc);
/**
*/
bool isUseAccurateFacing(void) const;
/**
*/
void setBillboardOrigin(Ogre::BillboardOrigin origin) { mBillboardSet->setBillboardOrigin(origin); }
/**
*/
Ogre::BillboardOrigin getBillboardOrigin(void) const { return mBillboardSet->getBillboardOrigin(); }
/**
*/
void setBillboardRotationType(Ogre::BillboardRotationType rotationType);
/**
*/
Ogre::BillboardRotationType getBillboardRotationType(void) const;
/**
*/
void setCommonDirection(const Ogre::Vector3& vec);
/**
*/
const Ogre::Vector3& getCommonDirection(void) const;
/**
*/
void setCommonUpVector(const Ogre::Vector3& vec);
/**
*/
const Ogre::Vector3& getCommonUpVector(void) const;
/**
*/
void setPointRenderingEnabled(bool enabled);
/**
*/
bool isPointRenderingEnabled(void) const;
/**
*/
virtual void _updateRenderQueue(Ogre::RenderQueue* queue, ParticlePool* pool);
/**
*/
virtual void _notifyAttached(Ogre::Node* parent, bool isTagPoint = false);
/** @copydoc ParticleRenderer::_setMaterialName */
virtual void _setMaterialName(const Ogre::String& materialName);
/**
*/
virtual void _notifyCurrentCamera(Ogre::Camera* cam);
/**
*/
virtual void _notifyParticleQuota(size_t quota);
/**
*/
virtual void _notifyDefaultDimensions(Ogre::Real width, Ogre::Real height, Ogre::Real depth);
/**
*/
virtual void _notifyParticleResized(void);
/**
*/
virtual void _notifyParticleZRotated(void);
/**
*/
virtual void setRenderQueueGroup(Ogre::uint8 queueId);
/**
*/
virtual Ogre::SortMode _getSortMode(void) const;
/**
*/
virtual void copyAttributesTo (ParticleRenderer* renderer);
/**
*/
Ogre::BillboardSet* getBillboardSet(void) const { return mBillboardSet; }
/** @copydoc ParticleRenderer::setVisible */
virtual void setVisible(bool visible);
protected:
/**
*/
Ogre::BillboardSet* mBillboardSet;
/**
*/
BillboardType mBillboardType;
};
}
#endif
| [
"pablosn@06488772-1f9a-11de-8b5c-13accb87f508"
] | [
[
[
1,
171
]
]
] |
843fcdc530734c9683720431a75f920eed35feed | 15732b8e4190ae526dcf99e9ffcee5171ed9bd7e | /INC/AppModel.h | 2155cdbfc75282b04debfa4cfd624f4e8b58e3b3 | [] | no_license | clovermwliu/whutnetsim | d95c07f77330af8cefe50a04b19a2d5cca23e0ae | 924f2625898c4f00147e473a05704f7b91dac0c4 | refs/heads/master | 2021-01-10T13:10:00.678000 | 2010-04-14T08:38:01 | 2010-04-14T08:38:01 | 48,568,805 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 5,276 | h | //Copyright (c) 2010, Information Security Institute of Wuhan Universtiy(ISIWhu)
//All rights reserved.
//
//PLEASE READ THIS DOCUMENT CAREFULLY BEFORE UTILIZING THE PROGRAM
//BY UTILIZING THIS PROGRAM, YOU AGREE TO BECOME BOUND BY THE TERMS OF
//THIS LICENSE. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENSE, DO
//NOT USE THIS PROGRAM OR ANY PORTION THEREOF IN ANY FORM OR MANNER.
//
//This License allows you to:
//1. Make copies and distribute copies of the Program's source code provide that any such copy
// clearly displays any and all appropriate copyright notices and disclaimer of warranty as set
// forth in this License.
//2. Modify the original copy or copies of the Program or any portion thereof ("Modification(s)").
// Modifications may be copied and distributed under the terms and conditions as set forth above.
// Any and all modified files must be affixed with prominent notices that you have changed the
// files and the date that the changes occurred.
//Termination:
// If at anytime you are unable to comply with any portion of this License you must immediately
// cease use of the Program and all distribution activities involving the Program or any portion
// thereof.
//Statement:
// In this program, part of the code is from the GTNetS project, The Georgia Tech Network
// Simulator (GTNetS) is a full-featured network simulation environment that allows researchers in
// computer networks to study the behavior of moderate to large scale networks, under a variety of
// conditions. Our work have great advance due to this project, Thanks to Dr. George F. Riley from
// Georgia Tech Research Corporation. Anyone who wants to study the GTNetS can come to its homepage:
// http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/
//
//File Information:
//
//
//File Name:
//File Purpose:
//Original Author:
//Author Organization:
//Construct Data:
//Modify Author:
//Author Organization:
//Modify Data:
#ifndef __appmodel_h__
#define __appmodel_h__
#include "node.h"
#include "ElementCustom.h"
#include "FileScript.h"
#include "ErrorHandler.h"
#include <map>
#define ERROR_MODEL_SUCCESS ERROR_NO_ERROR
#define ERROR_MODEL_INSERT_EXIST 0x00050201
#define ERROR_MODEL_DELETE_NOT_EXIST 0x00050202
#define ERROR_MODEL_GET_NOT_EXIST 0x00050203
#define ERROR_MODEL_WHEN_INIT_CUSTOMELEMENT 0x00050204
class AppModel:public CErrorHandler{
//////////////////////////////////////////////////////////////////////////
//基础方法
//////////////////////////////////////////////////////////////////////////
public:
//构造函数及析构函数
AppModel(void);
~AppModel(void);
AppModel(CFileScript &f):pScriptCache(&f){ SetLastError(ERROR_MODEL_SUCCESS); }//直接指定配置缓存对象
AppModel(string StrScriptCache); //根据ConfigCachePath路径构造配置缓存,指针赋给pConfigCache
virtual AppModel* Copy() const = 0;//描述:返回当前对象的拷贝,纯虚函数,所有派生类需给出实现
virtual bool GetModelValue(void **p) = 0;//描述:计算模型的值,纯虚函数,所有派生类需给出实现
virtual void Initialize(void *p) = 0;//描述:初始化模型相关参数,纯虚函数,所有派生类需给出实现
private:
CFileScript *pScriptCache; //模型存取配置文件用的配置缓存对象,经构造函数传入赋值
bool bprivateCache; //如果是Model类自己构造的配置缓存,则为true;否则为false
//////////////////////////////////////////////////////////////////////////
//和结点绑定
//////////////////////////////////////////////////////////////////////////
protected:
Node *node;//绑定的结点指针,有的子类不需要
public:
virtual void AttachNode(Node *n);//所有继承该方法的子类应先实现这个方法
//////////////////////////////////////////////////////////////////////////
//自定义部件相关
//////////////////////////////////////////////////////////////////////////
private:
struct ElementStruct
{
int ID;//子类指定的该自定义部件的id
bool RevelantToNode;//该自定义部件是否和结点相关
CElementCustom thisElement;//自定义部件对象
};//一个自定义部件
map<int, ElementStruct> ElementIndex;//存储自定义部件及相关信息
protected:
//Size_t GetElementSize() { return ElementIndex.size(); }
//描述:增加一个自定义部件到ElementIndex,返回当前ElementIndex中的Element个数
Size_t AddElement(int id, bool revelantToNode, string strSectionName);
//描述:删除ID为id的自定义部件,返回当前ElementIndex中剩余的Element个数
Size_t DeleteElement(int id);
//描述:调用自定义部件类的相关方法,获得ID为id的自定义部件的值,并返回
double GetElementValueById(int id);
//////////////////////////////////////////////////////////////////////////
///错误处理相关
//////////////////////////////////////////////////////////////////////////
virtual Error_str GetLastErrorEx();
};
#endif | [
"pengelmer@f37e807c-cba8-11de-937e-2741d7931076"
] | [
[
[
1,
147
]
]
] |
e016e631f675b172a6a61670d41095e35f4e8137 | a699a508742a0fd3c07901ab690cdeba2544a5d1 | /RailwayDetection/KellService/KellService/IOCP/MemoryPool.cpp | a25c2cc109ea75273fdfd9624e76a795bb9d1b42 | [] | no_license | xiaomailong/railway-detection | 2bf92126bceaa9aebd193b570ca6cd5556faef5b | 62e998f5de86ee2b6282ea71b592bc55ee25fe14 | refs/heads/master | 2021-01-17T06:04:48.782000 | 2011-09-27T15:13:55 | 2011-09-27T15:13:55 | 42,157,845 | 0 | 1 | null | 2015-09-09T05:24:10 | 2015-09-09T05:24:09 | null | UTF-8 | C++ | false | false | 4,427 | cpp | #include "StdAfx.h"
#include "MemoryPool.h"
#include "GobalConfig.h"
CMemoryPool::CMemoryPool()
{
m_pGobalConfig = NULL;
m_hEvent = NULL;
m_vecPrepOverKeyPire.clear();
m_vecUsedOverKeyPire.clear();
}
CMemoryPool::~CMemoryPool()
{
ClearMemoryPool();
}
LPOverKeyPire CMemoryPool::GetNewOverKeyPire()
{
LPOverKeyPire pOverKeyPire = NULL;
CListOverKeyPire::iterator iterBack;
m_scMemoryCriticalSection.Lock();
if(MemoryPoolAutoManage())
{
iterBack = m_vecPrepOverKeyPire.begin();
pOverKeyPire = (LPOverKeyPire)(*iterBack);
m_vecPrepOverKeyPire.erase(iterBack);
m_vecUsedOverKeyPire.push_back(pOverKeyPire);
}
m_scMemoryCriticalSection.Unlock();
return pOverKeyPire;
}
void CMemoryPool::ReleaseOverKeyPire(LPOverKeyPire pPire)
{
if(pPire)
{
CListOverKeyPire::iterator iterTemp;
m_scMemoryCriticalSection.Lock();
for (iterTemp = m_vecUsedOverKeyPire.begin(); iterTemp != m_vecUsedOverKeyPire.end(); ++iterTemp)
{
if(pPire == (LPOverKeyPire)(*iterTemp))
{
m_vecUsedOverKeyPire.erase(iterTemp);
m_vecPrepOverKeyPire.push_back(pPire);
break;
}
}
m_scMemoryCriticalSection.Unlock();
}
}
bool CMemoryPool::InitMemoryPool(CGobalConfig * pGobalConfig)
{
ASSERT(pGobalConfig);
if(!pGobalConfig)
return false;
m_pGobalConfig = pGobalConfig;
unsigned int nMemoryPoolSize = pGobalConfig->GetMemoryPoolSize();;
unsigned int nPrepMemoryPoolSize = m_vecPrepOverKeyPire.size();
if(nPrepMemoryPoolSize < nMemoryPoolSize)
{
LPOverKeyPire pPire;
for(unsigned int nIndex = nPrepMemoryPoolSize; nIndex < nMemoryPoolSize; ++nIndex)
{
pPire = (LPOverKeyPire)::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OverKeyPire));
if(pPire)
{
m_vecPrepOverKeyPire.push_back(pPire);
continue;
}
return false;
}
}
return true;
}
void CMemoryPool::ClearMemoryPool()
{
CListOverKeyPire::iterator iterTemp;
m_scMemoryCriticalSection.Lock();
if(!m_vecUsedOverKeyPire.empty())
{
for (iterTemp = m_vecUsedOverKeyPire.begin(); iterTemp != m_vecUsedOverKeyPire.end(); ++iterTemp)
{
::HeapFree(::GetProcessHeap(), 0, (LPVOID)(*iterTemp));
}
m_vecUsedOverKeyPire.clear();
}
if(!m_vecPrepOverKeyPire.empty())
{
for (iterTemp = m_vecPrepOverKeyPire.begin(); iterTemp != m_vecPrepOverKeyPire.end(); ++iterTemp)
{
::HeapFree(::GetProcessHeap(), 0, (LPVOID)(*iterTemp));
}
m_vecPrepOverKeyPire.clear();
}
m_scMemoryCriticalSection.Unlock();
}
void CMemoryPool::RecycleMemory()
{
unsigned int nMemoryPoolSize = 0;
m_scMemoryCriticalSection.Lock();
nMemoryPoolSize = m_vecPrepOverKeyPire.size();
if(nMemoryPoolSize > m_pGobalConfig->GetMemoryRecycleSize())
{
DecrescenceMemoryPoolSize(nMemoryPoolSize);
}
m_scMemoryCriticalSection.Unlock();
}
bool CMemoryPool::MemoryPoolAutoManage()
{
ASSERT(m_pGobalConfig);
if(!m_pGobalConfig)
return false;
unsigned int nPrepOverKeyPireSize = m_vecPrepOverKeyPire.size();
if(nPrepOverKeyPireSize < m_pGobalConfig->GetMemoryDownLine())
{
return IncrementMemoryPoolSize(nPrepOverKeyPireSize);
}
else if(nPrepOverKeyPireSize > m_pGobalConfig->GetMemoryRecycleSize())
{
return DecrescenceMemoryPoolSize(nPrepOverKeyPireSize);
}
return true;
}
bool CMemoryPool::IncrementMemoryPoolSize(unsigned int nCurrentSize)
{
ASSERT(m_pGobalConfig);
if(!m_pGobalConfig)
return false;
if(nCurrentSize >= m_pGobalConfig->GetMemoryPoolSize())
return true;
LPOverKeyPire pPire;
for( ; nCurrentSize < m_pGobalConfig->GetMemoryPoolSize(); ++nCurrentSize)
{
pPire = (LPOverKeyPire)::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OverKeyPire));
if(pPire)
{
m_vecPrepOverKeyPire.push_back(pPire);
continue;
}
return false;
}
return true;
}
bool CMemoryPool::DecrescenceMemoryPoolSize(unsigned int nCurrentSize)
{
ASSERT(m_pGobalConfig);
if(!m_pGobalConfig)
return false;
unsigned int nMemorySize = m_pGobalConfig->GetMemoryPoolSize();
if(nCurrentSize > nMemorySize)
{
CListOverKeyPire::iterator iterPire;
for (; nCurrentSize > nMemorySize; --nCurrentSize)
{
iterPire = m_vecPrepOverKeyPire.end();
--iterPire;
::HeapFree(::GetProcessHeap(), 0, (LPVOID)(*iterPire));
m_vecPrepOverKeyPire.erase(iterPire);
}
}
return true;
}
| [
"[email protected]@4d6b9eea-9d24-033f-dd66-d003eccfd9d3"
] | [
[
[
1,
191
]
]
] |
9c451e762cf55849de081d6b63075715b50470f2 | 6f2d9e6d1f0dcb3a00f2885e99a0f566571034c8 | /server/src/frmServer.h | 79c97afebb37013e06b3d11e223feccc0a9f4795 | [] | no_license | crawford/HoIP | bfd7547bd64fe0739e706fcdce4e5b1d6a5ce796 | 3c14f29375431aad7688444fa1f88201093b398b | refs/heads/master | 2021-01-21T22:29:37.296000 | 2010-09-04T21:27:59 | 2010-09-04T21:27:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 484 | h | #ifndef FRMSERVER_H
#define FRMSERVER_H
#include "ui_server.h"
#include "serialPort.h"
#include <QDialog>
#include <QTcpServer>
#include <QTcpSocket>
class FrmServer : public QDialog, Ui::Server {
Q_OBJECT
public:
FrmServer(QWidget *parent = 0, Qt::WindowFlags f = 0);
~FrmServer();
private:
QTcpServer *server;
QTcpSocket *socket;
SerialPort *port;
private slots:
void handleNewConnection();
void lostClient();
void handleCommand();
};
#endif
| [
"[email protected]"
] | [
[
[
1,
27
]
]
] |
ac64156b1b3090ddac5305d2fc2c9ce6e08fc5cb | 66581a883c3eab4c6c7b7c1d5850892485a5cab8 | /Action Bros Now/EntityManager.h | 06bbf032703975ccece50ca70f5909d8325e01c2 | [] | no_license | nrolando/d-m-seniorprojectgsp | 9457841f43697a73d956b202541064022dd4a189 | 503f311142bf4995f3e5c6fc6110317babde08f9 | refs/heads/master | 2021-01-10T05:49:14.926000 | 2010-02-17T03:29:10 | 2010-02-17T03:29:10 | 49,738,324 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,436 | h | //a singleton class that will contain all the entities in the game
//accesses a txt file to load all the enemies for a given lvl
//uses the entity's char id to search spriteContainer and set entity's
//imgptr to proper sprite sheet
#ifndef ENTITYMANAGER_H
#define ENTITYMANAGER_H
#include "Boss.h"
#include "Enemy.h"
#include "Player.h"
#include "spriteContainer.h"
#include <fstream>
#include <vector>
#include <string>
class EntityManager
{
private:
std::vector<BaseGameEntity*> entityVector;
public:
EntityManager();
~EntityManager();
BaseGameEntity* getEntVec(int i) { return entityVector[i];}
std::vector<BaseGameEntity*> getEntVec() { return entityVector; }
bool update(clock_t);
void moveEnemies(clock_t);
void UpdateEnemyState(Player*);
//creates the entity vector for the enemies for this level
bool loadFromFile(int); //progress
void loadFromFile(char* fileName);
void setImgPtrs();
bool isVectorEmpty() { return entityVector.empty();}
bool isEnemiesDead();
int getVecSize() { return entityVector.size(); }
int getStateByKey(char);
int getHealthByKey(char);
int getMaxHealthByKey(char);
int getSpecialByKey(char);
int getMaxSpecialByKey(char);
void stunEnt(int i, int a) { entityVector[i]->stun(a); }
int getHealth(int i) { return entityVector[i]->getHealth(); }
//update the entities
//void entiyUpdate(Player* player);
};
#endif | [
"nicklamort@2c89e556-c775-11de-bfbd-4d0f0f27293a",
"dheardjr@2c89e556-c775-11de-bfbd-4d0f0f27293a",
"DHeardjr@2c89e556-c775-11de-bfbd-4d0f0f27293a"
] | [
[
[
1,
23
],
[
25,
26
],
[
28,
31
],
[
33,
37
],
[
39,
54
]
],
[
[
24,
24
],
[
38,
38
]
],
[
[
27,
27
],
[
32,
32
]
]
] |
f2f3492b73aa82f7cc46567655b61364bcbc143d | d2996420f8c3a6bbeef63a311dd6adc4acc40436 | /src/net/UdpSocket.cpp | 38b7c492c8279c82134bc7feb0d2804eb5a3a4cf | [] | no_license | aruwen/graviator | 4d2e06e475492102fbf5d65754be33af641c0d6c | 9a881db9bb0f0de2e38591478429626ab8030e1d | refs/heads/master | 2021-01-19T00:13:10.843000 | 2011-03-13T13:15:25 | 2011-03-13T13:15:25 | 32,136,578 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,353 | cpp | #include "UdpSocket.h"
using namespace net;
UdpSocket::UdpSocket()
{
mSocket = 0;
mPort = 0;
}
UdpSocket::~UdpSocket()
{
close();
}
bool UdpSocket::open( unsigned short port )
{
assert( !isOpen() );
// create socket
mSocket = ::socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
if ( mSocket <= 0 )
{
printf( "failed to create socket\n" );
mSocket = 0;
return false;
}
// bind to port
sockaddr_in address;
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons( (unsigned short) port );
if ( bind( mSocket, (const sockaddr*) &address, sizeof(sockaddr_in) ) < 0 )
{
close();
return false;
}
// set non-blocking io
DWORD nonBlocking = 1;
if ( ioctlsocket( mSocket, FIONBIO, &nonBlocking ) != 0 )
{
close();
return false;
}
mPort = port;
return true;
}
void UdpSocket::close()
{
if ( mSocket != 0 )
{
closesocket( mSocket );
mSocket = 0;
}
}
bool UdpSocket::isOpen() const
{
return mSocket != 0;
}
unsigned short UdpSocket::getPort()
{
return mPort;
}
bool UdpSocket::send( const Address & destination, const void * data, int size)
{
assert( data );
assert( size > 0 );
if ( mSocket == 0 )
return false;
sockaddr_in address;
address.sin_family = AF_INET;
address.sin_addr.s_addr = htonl( destination.getAddress() );
address.sin_port = htons( (unsigned short) destination.getPort() );
int sent_bytes = sendto( mSocket,
(const char*)data,
size,
0,
(sockaddr*)&address,
sizeof(sockaddr_in) );
return sent_bytes == size;
}
int UdpSocket::receive( Address & sender, void * data, int size )
{
assert( data );
assert( size > 0 );
if ( mSocket == 0 )
return false;
typedef int socklen_t;
sockaddr_in from;
socklen_t fromLength = sizeof( from );
int received_bytes = recvfrom( mSocket, (char*)data, size, 0, (sockaddr*)&from, &fromLength );
if ( received_bytes <= 0 )
return 0;
unsigned int address = ntohl( from.sin_addr.s_addr );
unsigned int port = ntohs( from.sin_port );
sender = Address( address, port );
return received_bytes;
}
| [
"[email protected]@c8d5bfcc-1391-a108-90e5-e810ef6ef867"
] | [
[
[
1,
122
]
]
] |
8238df9a046b234589c029765cf68773ad3ecfa6 | 2acd91cf2dfe87f4c78fba230de2c2ffc90350ea | / salad-bar-in-space-game/edge/bouncibility/third_party/irrklang/include/ik_ISoundStopEventReceiver.h | e0723e14fbbdaf2706eaaae2012f5e45296d40f6 | [] | no_license | Joshvanburen/salad-bar-in-space-game | 5f410a06be475edee1ab85950c667e6a6f970763 | b23a35c832258f4fc1a921a45ab4238c734ef1f0 | refs/heads/master | 2016-09-01T18:46:29.672000 | 2008-05-07T18:40:30 | 2008-05-07T18:40:30 | 32,195,299 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,017 | h | // Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_IRRKLANG_SOUND_STOP_EVENT_RECEIVER_H_INCLUDED__
#define __I_IRRKLANG_SOUND_STOP_EVENT_RECEIVER_H_INCLUDED__
#include "ik_IRefCounted.h"
#include "ik_SAudioStreamFormat.h"
namespace irrklang
{
//! An enumeration listing all reasons for a fired sound stop event
enum E_STOP_EVENT_CAUSE
{
//! The sound stop event was fired because the sound finished playing
ESEC_SOUND_FINISHED_PLAYING = 0,
//! The sound stop event was fired because the sound was stopped by the user, calling ISound::stop().
ESEC_SOUND_STOPPED_BY_USER,
//! The sound stop event was fired because the source of the sound was removed, for example
//! because irrKlang was shut down or the user called ISoundEngine::removeSoundSource().
ESEC_SOUND_STOPPED_BY_SOURCE_REMOVAL,
//! This enumeration literal is never used, it only forces the compiler to
//! compile these enumeration values to 32 bit.
ESEC_FORCE_32_BIT = 0x7fffffff
};
//! Interface to be implemented by the user, which recieves sound stop events.
/** The interface has only one method to be implemented by the user: OnSoundStopped().
Implement this interface and set it via ISound::setSoundStopEventReceiver().
The sound stop event is guaranteed to be called when a sound or sound stream is finished,
either because the sound reached its playback end, its sound source was removed,
ISoundEngine::stopAllSounds() has been called or the whole engine was deleted. */
class ISoundStopEventReceiver
{
public:
//! destructor
virtual ~ISoundStopEventReceiver() {};
//! Called when a sound has stopped playing.
/** This is the only method to be implemented by the user.
The sound stop event is guaranteed to be called when a sound or sound stream is finished,
either because the sound reached its playback end, its sound source was removed,
ISoundEngine::stopAllSounds() has been called or the whole engine was deleted.
Please note: Sound events will occur in a different thread when the engine runs in
multi threaded mode (default). In single threaded mode, the event will happen while
the user thread is calling ISoundEngine::update().
\param sound: Sound which has been stopped.
\param reason: The reason why the sound stop event was fired. Usually, this will be ESEC_SOUND_FINISHED_PLAYING.
When the sound was aborded by calling ISound::stop() or ISoundEngine::stopAllSounds();, this would be
ESEC_SOUND_STOPPED_BY_USER. If irrKlang was deleted or the sound source was removed, the value is
ESEC_SOUND_STOPPED_BY_SOURCE_REMOVAL.
\param userData: userData pointer set by the user when registering the interface
via ISound::setSoundStopEventReceiver(). */
virtual void OnSoundStopped(ISound* sound, E_STOP_EVENT_CAUSE reason, void* userData) = 0;
};
} // end namespace irrklang
#endif
| [
"[email protected]@1a2710a4-8244-0410-8b66-391840787a9e"
] | [
[
[
1,
72
]
]
] |
8250f1f30a688c7395e9142b099dcc818b81a439 | ac559231a41a5833220a1319456073365f13d484 | /src/old/server-jaus/jaus/mobility/drivers/globalwaypointdriver.h | f7c3b1c2559ae08dd980862e8275475ddf1eb9ba | [] | no_license | mtboswell/mtboswell-auvc2 | 6521002ca12f9f7e1ec5df781ed03419129b8f56 | 02bb0dd47936967a7b9fa7d091398812f441c1dc | refs/heads/master | 2020-04-01T23:02:15.282000 | 2011-07-17T16:48:34 | 2011-07-17T16:48:34 | 32,832,956 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,193 | h | ////////////////////////////////////////////////////////////////////////////////////
///
/// \file globalwaypointdriver.h
/// \brief This file contains the definition of the GlobalWaypointDriver class,
/// used as an interface for the driving of platform to a target waypoint.
///
/// <br>Author(s): Bo Sun
/// <br>Created: 10 February 2010
/// <br>Copyright (c) 2010
/// <br>Applied Cognition and Training in Immersive Virtual Environments
/// <br>(ACTIVE) Laboratory
/// <br>Institute for Simulation and Training (IST)
/// <br>University of Central Florida (UCF)
/// <br>All rights reserved.
/// <br>Email: [email protected]
/// <br>Web: http://active.ist.ucf.edu
///
/// Redistribution and use in source and binary forms, with or without
/// modification, are permitted provided that the following conditions are met:
/// * Redistributions of source code must retain the above copyright
/// notice, this list of conditions and the following disclaimer.
/// * Redistributions in binary form must reproduce the above copyright
/// notice, this list of conditions and the following disclaimer in the
/// documentation and/or other materials provided with the distribution.
/// * Neither the name of the ACTIVE LAB, IST, UCF, nor the
/// names of its contributors may be used to endorse or promote products
/// derived from this software without specific prior written permission.
///
/// THIS SOFTWARE IS PROVIDED BY THE ACTIVE LAB''AS IS'' AND ANY
/// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
/// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
/// DISCLAIMED. IN NO EVENT SHALL UCF BE LIABLE FOR ANY
/// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
/// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
/// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
/// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
/// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
/// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
///
////////////////////////////////////////////////////////////////////////////////////
#ifndef __JAUS_MOBILITY_GLOBAL_WAYPOINT_DRIVER__H
#define __JAUS_MOBILITY_GLOBAL_WAYPOINT_DRIVER__H
#include "jaus/core/management/management.h"
#include "jaus/mobility/drivers/settravelspeed.h"
#include "jaus/mobility/drivers/setglobalwaypoint.h"
#include "jaus/mobility/drivers/querytravelspeed.h"
#include "jaus/mobility/drivers/queryglobalwaypoint.h"
#include "jaus/mobility/drivers/reporttravelspeed.h"
#include "jaus/mobility/drivers/reportglobalwaypoint.h"
#include "jaus/mobility/sensors/globalposesensor.h"
#include "jaus/mobility/sensors/velocitystatesensor.h"
namespace JAUS
{
typedef JAUS::ReportGlobalWaypoint GlobalWaypoint;
typedef JAUS::ReportTravelSpeed TravelSpeed;
////////////////////////////////////////////////////////////////////////////////////
///
/// \class GlobalWaypointDriver
/// \brief The Global Waypoint Driver allows for the driving of platform to a
/// target waypoint.
///
// The function of the Global Waypoint Driver is to move the platform given a
/// single target waypoint, desired travel speed, current platform pose and
/// current velocity state. A single waypoint is provided via the Set Global
/// Waypoint message. The waypoint remains unchanged until a new Set Global
/// Waypoint message is received. A waypoint consists of the desired position
/// and orientation of the platform. The second input consists of the desired
/// travel speed. The travel speed remains unchanged unless a new Set Travel
/// Speed Message is received. The travel speed may then be changed at any time
/// during waypoint navigation. The travel speed is reset to zero for all
/// transitions from the Ready State.
///
/// <b>This implmentation of this service requires at a minimum a Global Pose
/// and Velocity State sensor service on the same component that this
/// service belongs to. The sensor services can be synchronizing versions
/// of the services also (see example_synchronize.cpp for how to do this).</b>
///
////////////////////////////////////////////////////////////////////////////////////
class JAUS_MOBILITY_DLL GlobalWaypointDriver : public Management::Child
{
public:
const static std::string Name; ///< String name of the Service.
GlobalWaypointDriver();
virtual ~GlobalWaypointDriver();
// Overloaded by the inheriting class to generate commands for the controlled driver.
virtual Message* GenerateDriveCommand(const Byte status) = 0;
// Overloaded by the inheriting class to generate default commands for the controlled driver.
virtual Message* GenerateIdleDriveCommand(const Byte status) const = 0;
// Returns true if target waypoint is achieved.
virtual bool IsWaypointAchieved(const GlobalPose& currentPose,
const JAUS::SetGlobalWaypoint& desiredWaypoint) const = 0;
// Virtual method called whenever waypoint driver updates, overload to add additional behaviors/checks needed.
virtual void WaypointDriverUpdateEvent(const unsigned int timeSinceLastUpdateMs) {}
// Method is called when desired waypoint is achieved.
virtual void WaypointAchieved(const JAUS::SetGlobalWaypoint& waypoint) = 0;
// Method called whenever a Set Global Waypoint command is received by service.
virtual bool SetGlobalWaypoint(const JAUS::SetGlobalWaypoint* command);
// Method called whenever a Set Travel Speed command is received by service, overload for extra functionality.
virtual bool SetDesiredTravelSpeed(const JAUS::SetTravelSpeed* command) {return true;}
// Change the Desired Travel Speed without sending a SetTravelSpeed command
virtual bool SetDesiredTravelSpeed(const double speed);
// Try to take control of lower-level (e.g. primitive) driver, in order to move to waypoint.
virtual bool SetDriverToControl(const Address& driver);
// Gets the current GlobalWaypoint command.
virtual JAUS::SetGlobalWaypoint GetGlobalWaypoint() const;
// Gets the current GlobalPoseSensor report.
virtual GlobalPose GetGlobalPose() const;
// Gets the current velocity state report.
virtual VelocityState GetVelocityState() const;
// Gets the current travel speed command.
virtual JAUS::SetTravelSpeed GetDesiredTravelSpeed() const;
// Gets the time when the last wrench effort command was received.
virtual Time GetGlobalWaypointTime() const;
// Gets the time when the last travel speed command was received.
virtual Time GetTravelSpeedTime() const;
// Gets the address of the lower-level (e.g. primitive) driver being controlled.
virtual Address GetControlledDriverID() const;
// Generates Global Waypoint Driver related events.
virtual bool GenerateEvent(const Events::Subscription& info) const;
// Adds support for Report Global Waypoint events.
virtual bool IsEventSupported(const Events::Type type,
const double requestedPeriodicRate,
const Message* queryMessage,
double& confirmedPeriodicRate,
std::string& errorMessage) const;
// By default, the Global Waypoint Driver is discoverable to other components (overload to hide).
virtual bool IsDiscoverable() const { return true; }
// Method called whenever a message is received.
virtual void Receive(const Message* message);
// Creates messages associated with this service.
virtual Message* CreateMessage(const UShort messageCode) const;
// Prints information about the service.
virtual void PrintStatus() const;
// Method called when transitioning to a ready state.
virtual bool Resume();
// Method called to transition due to reset.
virtual bool Reset();
// Method called when transitioning to a standby state.
virtual bool Standby();
// Method called when transitioning to an emergency state.
virtual bool SetEmergency();
// Method called when leaving the emergency state.
virtual bool ClearEmergency();
// Method called when control is released.
virtual bool ReleaseControl();
private:
// In this method, drive commands are generated.
virtual void CheckServiceStatus(const unsigned int timeSinceLastCheckMs);
// Creates a ReportGlobalWaypoint from QueryGlobalWaypoint.
void CreateReportFromQuery(const QueryGlobalWaypoint* query,
GlobalWaypoint& report) const;
// Creates a ReportTravelSpeed from QueryTravelSpeed.
void CreateReportFromQuery(const QueryTravelSpeed* query,
TravelSpeed& report) const;
// Checks if Driver is controlled, acquire control if necessary.
bool CheckDriver();
// Checks if Sensor data is availabe, acquire subscriptions if necessary.
bool CheckSensors();
// Removes Control of driver and stops subscriptions.
bool ReleaseResources();
bool mWaypointAchievedFlag; ///< Flag indicating whether a Waypoint is achieved after being set.
Mutex mGlobalWaypointDriverMutex; ///< Mutex for thread protection of data.
Address mControlledDriverID; ///< Address of the controlled driver used for waypoint driving.
GlobalPoseSensor* mpGlobalPoseSensor; ///< Pointer to the Velocity State Sensor if service is directly accessible.
VelocityStateSensor* mpVelocityStateSensor; ///< Pointer to the Velocity State Sensor if service is directly accessible.
Time mGlobalWaypointTime; ///< Time when the last target waypoint was received.
Time mTravelSpeedTime; ///< Time when the last travel speed was received.
JAUS::SetGlobalWaypoint mGlobalWaypoint; ///< The last target waypoint received.
JAUS::SetTravelSpeed mDesiredTravelSpeed; ///< The last travel speed received.
GlobalPose mGlobalPose; ///< The last global pose reported by the Global Pose Sensor.
VelocityState mVelocityState; ///< The last Velocity State reported by the Velocity State Sensor.
};
}
#endif
/* End of File */
| [
"[email protected]"
] | [
[
[
1,
179
]
]
] |
a82e25a6ea893c5b21b2d17ee818a9ce05366de6 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/os/ossrv/stdlibs/apps/libc/testwideapis/src/twideapisserver.cpp | 8fde57ac6c25e69e5af6def398b405b03acf871c | [] | no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646000 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,318 | cpp | /*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#include <c32comm.h>
#if defined (__WINS__)
#define PDD_NAME _L("ECDRV")
#else
#define PDD_NAME _L("EUART1")
#define PDD2_NAME _L("EUART2")
#define PDD3_NAME _L("EUART3")
#define PDD4_NAME _L("EUART4")
#endif
#define LDD_NAME _L("ECOMM")
/**
* @file
*
* Pipe test server implementation
*/
#include "twideapisserver.h"
#include "twideapis.h"
_LIT(KServerName, "twideapis");
CWideApiTestServer* CWideApiTestServer::NewL()
{
CWideApiTestServer *server = new(ELeave) CWideApiTestServer();
CleanupStack::PushL(server);
server->ConstructL(KServerName);
CleanupStack::Pop(server);
return server;
}
static void InitCommsL()
{
TInt ret = User::LoadPhysicalDevice(PDD_NAME);
User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
#ifndef __WINS__
ret = User::LoadPhysicalDevice(PDD2_NAME);
ret = User::LoadPhysicalDevice(PDD3_NAME);
ret = User::LoadPhysicalDevice(PDD4_NAME);
#endif
ret = User::LoadLogicalDevice(LDD_NAME);
User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
ret = StartC32();
User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
}
LOCAL_C void MainL()
{
// Leave the hooks in for platform security
#if (defined __DATA_CAGING__)
RProcess().DataCaging(RProcess::EDataCagingOn);
RProcess().SecureApi(RProcess::ESecureApiOn);
#endif
//InitCommsL();
CActiveScheduler* sched=NULL;
sched=new(ELeave) CActiveScheduler;
CActiveScheduler::Install(sched);
CWideApiTestServer* server = NULL;
// Create the CTestServer derived server
TRAPD(err, server = CWideApiTestServer::NewL());
if(!err)
{
// Sync with the client and enter the active scheduler
RProcess::Rendezvous(KErrNone);
sched->Start();
}
delete server;
delete sched;
}
/**
* Server entry point
* @return Standard Epoc error code on exit
*/
TInt main()
{
__UHEAP_MARK;
CTrapCleanup* cleanup = CTrapCleanup::New();
if(cleanup == NULL)
{
return KErrNoMemory;
}
TRAP_IGNORE(MainL());
delete cleanup;
__UHEAP_MARKEND;
return KErrNone;
}
CTestStep* CWideApiTestServer::CreateTestStep(const TDesC& aStepName)
{
CTestStep* testStep = NULL;
// This server creates just one step but create as many as you want
// They are created "just in time" when the worker thread is created
// install steps
if(aStepName == Kwfreopen_val)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kwfreopen_valm)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kwfreopen_valinv)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kwfdopen_val)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kwfdopen_ivalm)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kgetws_null)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kgetws_val)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kputws_null)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kputws_val1)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kputws_val2)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kwremove_val1)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kwremove_val2)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kwremove_val3)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kwremove_null)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kwfdopen_ivalm1)
{
testStep = new CTestWideApi(aStepName);
}
else if(aStepName == Kwpopen_1)
{
testStep = new CTestWideApi(aStepName);
}
return testStep;
}
| [
"none@none"
] | [
[
[
1,
188
]
]
] |
938e680e6446e224916086e3210e192989d99706 | 06ff805f168597297a87642c951867b453e401f7 | /Algorithm/boost/boost/mpl/aux_/config/eti.hpp | 10917b2a5165e6ef68d5d25119329bdff67cd33d | [] | no_license | fredska/algorithms | 58459720295f8cf36edc88f68e4b37962235e533 | 10538d9677894b450f359db9301108b459b604ca | refs/heads/master | 2021-01-02T09:38:34.466000 | 2011-11-09T17:32:57 | 2011-11-09T17:32:57 | 2,652,603 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,356 | hpp |
#ifndef BOOST_MPL_AUX_CONFIG_ETI_HPP_INCLUDED
#define BOOST_MPL_AUX_CONFIG_ETI_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2001-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id: eti.hpp,v 1.1 2010-07-13 06:44:24 egraf Exp $
// $Date: 2010-07-13 06:44:24 $
// $Revision: 1.1 $
#include <boost/mpl/aux_/config/msvc.hpp>
#include <boost/mpl/aux_/config/workaround.hpp>
// flags for MSVC 6.5's so-called "early template instantiation bug"
#if !defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG) \
&& !defined(BOOST_MPL_PREPROCESSING_MODE) \
&& BOOST_WORKAROUND(BOOST_MSVC, < 1300)
# define BOOST_MPL_CFG_MSVC_60_ETI_BUG
#endif
#if !defined(BOOST_MPL_CFG_MSVC_70_ETI_BUG) \
&& !defined(BOOST_MPL_PREPROCESSING_MODE) \
&& BOOST_WORKAROUND(BOOST_MSVC, == 1300)
# define BOOST_MPL_CFG_MSVC_70_ETI_BUG
#endif
#if !defined(BOOST_MPL_CFG_MSVC_ETI_BUG) \
&& !defined(BOOST_MPL_PREPROCESSING_MODE) \
&& ( defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG) \
|| defined(BOOST_MPL_CFG_MSVC_70_ETI_BUG) \
)
# define BOOST_MPL_CFG_MSVC_ETI_BUG
#endif
#endif // BOOST_MPL_AUX_CONFIG_ETI_HPP_INCLUDED
| [
"[email protected]"
] | [
[
[
1,
47
]
]
] |
b01fa5ec11d0bb72d450e9806b47eb0d2f9d3218 | 540b8836343eb1d7343f86847f57a1033b9158d5 | /Problem_011.cpp | 2169bd10c58046622cb6373a46b177c142f32edb | [] | no_license | Haynesy/Euler | 2503160385f45e17e422a6176806b25264aafcb2 | 1525c8a334e3b1029e6afe5ed3b6e013a77e9c29 | refs/heads/master | 2020-12-30T10:23:41.879000 | 2009-10-05T06:21:04 | 2009-10-05T06:21:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,645 | cpp | /**
Problem 11
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72
21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95
78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57
86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58
19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40
04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66
88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69
04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36
20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54
01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48
The product of these numbers is 26 63 78 14 = 1788696.
What is the greatest product of four adjacent numbers in any
direction (up, down, left, right, or diagonally) in the 2020
grid?
**/
#include <iostream>
#include "Level.h"
using namespace std;
int prob_011(void)
{
// Arrays via Variables
int myArray[20][20] = {};
system("pause");
return 0;
} | [
"[email protected]"
] | [
[
[
1,
43
]
]
] |
End of preview. Expand
in Dataset Viewer.
README.md exists but content is empty.
Use the Edit dataset card button to edit it.
- Downloads last month
- 37