blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
5
146
content_id
stringlengths
40
40
detected_licenses
listlengths
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
listlengths
1
16
author_lines
listlengths
1
16
fdd3eadcf49bc32c0de8516190c573edc066e62d
e83babea370f43f4bad3294c9832318cfb657578
/src/tp2/tp2_application.cpp
528977f658f0fbf3ba6ecae5aa78472f632bc695
[]
no_license
maoueh/inf8702
6f5b233a3818422eca308d53804916184691d1a9
34931a16049cf7fed3835658c5bc9aedd5b1b540
refs/heads/master
2021-01-10T19:47:25.485668
2009-09-16T23:12:18
2009-09-16T23:12:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,650
cpp
#include "tp2_application.h" #include "tp2_shader_program.h" #include "color.h" #include "logger.h" #include "texture_unit.h" #include "window.h" #define FOG_DELTA 10.0f Tp2Application::Tp2Application(CommandLine* commandLine) : OpenGlApplication(commandLine), mName("Tp2 - INF8702"), mRotationAngleX(0.0f), mRotationAngleY(0.0f), mRotationAngleZ(0.0f), mRotationFreqX(0.15f), mRotationFreqY(0.1f), mRotationFreqZ(0.2f), mIsSpotLightOn(TRUE), mIsDirectionalLightOn(TRUE), mIsPointLightOn(TRUE), m3dLabsTextureUnit(NULL), mRustTextureUnit(NULL), mStonewallTextureUnit(NULL), mPointLightAmbient(0.0f, 0.0f, 0.0f), mPointLightDiffuse(1.0f, 0.5f, 1.0f), mPointLightSpecular(1.0f, 0.5f, 1.0f), mPointLightEmission(1.0f, 1.0f, 1.0f), mSpotLightAmbient(0.0f, 0.0f, 0.0f), mSpotLightDiffuse(1.0f, 1.0f, 1.0f), mSpotLightSpecular(1.0f, 1.0f, 1.0f), mSpotLightEmission(1.0f, 1.0f, 1.0f), mDirectionalLightAmbient(0.0f, 0.0f, 0.0f), mDirectionalLightDiffuse(0.86f, 0.69f, 0.04f), mDirectionalLightSpecular(0.91f, 0.93f, 0.0f), mDirectionalLightEmission(1.0f, 1.0f, 1.0f), mMaterialAmbient(0.0f, 0.0f, 0.0f), mMaterialDiffuse(1.0f, 1.0f, 1.0f), mMaterialSpecular(1.0f, 1.0f, 1.0f), mMaterialEmission(0.0f, 0.0f, 0.0f), mActiveColorComponent(RED_COMPONENT), mIsShaderOn(FALSE), mFogColor(Color::BLACK), mCubeColor(Color::RED), mLastMouseX(0), mLastMouseY(0), mAxisScaleFactor(15.0f), mAutomaticRotation(FALSE) { mPointLightPosition[0] = 20.0f; mPointLightPosition[1] = 10.0f; mPointLightPosition[2] = 3.0f; mPointLightPosition[3] = 1.0f; mDirectionalLightPosition[0] = -60.0f; mDirectionalLightPosition[1] = 0.0f; mDirectionalLightPosition[2] = 3.0f; mDirectionalLightPosition[3] = 0.0f; mMaterialShininess[0] = 100.0f; } Tp2Application::~Tp2Application() { } void Tp2Application::initialize() { OpenGlApplication::initialize(); // Separate calculation of the specular contribution after texturing is done glLightModeli( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR ); glLightModeli( GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE ); glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE ); // Two-side mode in OpenGL glEnable( GL_VERTEX_PROGRAM_TWO_SIDE ); // Two-side mode in GLSL initializeTextures(); // Compile Display List compileQuadGridList(20.0f, 30, 30, TRUE); // The Vertex and Fragment Shaders are initialized in the constructor mShaderProgram = new Tp2ShaderProgram(&mIsPointLightOn, &mIsSpotLightOn, &mIsDirectionalLightOn); mShaderProgram->link(); } void Tp2Application::compileQuadGridList(FLOAT size, INT rowCount, INT columnCount, BOOL isOutsideNormal) { mQuadGridListId = glGenLists(1); glNewList(mQuadGridListId, GL_COMPILE); { applyTextures(); drawQuadGrid(size, rowCount, columnCount, isOutsideNormal); } glEndList(); } void Tp2Application::drawQuadGrid(FLOAT size, INT rowCount, INT columnCount, BOOL isOutsideNormal) { INT normFact = isOutsideNormal ? 1 : -1; FLOAT startX = -size / 2.0f; FLOAT startY = 0.0f; FLOAT startZ = size / 2.0f; FLOAT s1, t1, s2, t2; FLOAT incrementX = size / (FLOAT) columnCount; FLOAT incrementZ = size / (FLOAT) rowCount; glBegin(GL_QUADS); glNormal3f(0.0f, (FLOAT) normFact, 0.0f); for ( INT i = 0; i < columnCount; ++i ) { for ( INT k = 0; k < rowCount; ++k ) { s1 = (i * incrementX) / size; s2 = ((i + 1) * incrementX) / size; t1 = (k * incrementZ) / size; t2 = ((k + 1) * incrementZ) / size; glMultiTexCoord2f(GL_TEXTURE0, s1, t1); glMultiTexCoord2f(GL_TEXTURE1, s1, t1); glMultiTexCoord2f(GL_TEXTURE2, s1, t1); glVertex3f(startX + i * incrementX, 0.0f, startZ - k * incrementZ); glMultiTexCoord2f(GL_TEXTURE0, s2, t1); glMultiTexCoord2f(GL_TEXTURE1, s2, t1); glMultiTexCoord2f(GL_TEXTURE2, s2, t1); glVertex3f((startX + i * incrementX) + incrementX, 0.0f, startZ - k * incrementZ); glMultiTexCoord2f(GL_TEXTURE0, s2, t2); glMultiTexCoord2f(GL_TEXTURE1, s2, t2); glMultiTexCoord2f(GL_TEXTURE2, s2, t2); glVertex3f((startX + i * incrementX) + incrementX, 0.0f, (startZ - k * incrementZ) - incrementZ); glMultiTexCoord2f(GL_TEXTURE0, s1, t2); glMultiTexCoord2f(GL_TEXTURE1, s1, t2); glMultiTexCoord2f(GL_TEXTURE2, s1, t2); glVertex3f(startX + i * incrementX, 0.0f, (startZ - k * incrementZ) - incrementZ); } } glEnd(); } void Tp2Application::keyPressed(Window* window, INT keyCode, INT repeat) { FLOAT* component = NULL; switch(keyCode) { case VK_X : mIsShaderOn = !mIsShaderOn; break; case VK_F1 : mActiveColorComponent = RED_COMPONENT; break; case VK_F2 : mActiveColorComponent = GREEN_COMPONENT; break; case VK_F3 : mActiveColorComponent = BLUE_COMPONENT; break; case VK_PRIOR : // Page Up component = &mCubeColor.components[mActiveColorComponent]; *component = CLIP(*component + 0.05f, 0.0f, 1.0f); break; case VK_NEXT : // Page Down component = &mCubeColor.components[mActiveColorComponent]; *component = CLIP(*component - 0.05f, 0.0f, 1.0f); break; case VK_S : mIsSpotLightOn = !mIsSpotLightOn; // Toggle Spot Light break; case VK_D : mIsDirectionalLightOn = !mIsDirectionalLightOn; // Toggle Directional Light break; case VK_A : mIsPointLightOn = !mIsPointLightOn; // Toggle Point Light break; case VK_SPACE : mAutomaticRotation = !mAutomaticRotation; // Toggle Automatic Rotation break; } OpenGlApplication::keyPressed(window, keyCode, repeat); } void Tp2Application::mousePressed(MouseEvent& event) { if ( event.button == MOUSE_BUTTON_LEFT ) { mLastMouseX = event.x; mLastMouseY = event.y; } } void Tp2Application::mouseDragged(MouseEvent& event) { mRotationAngleX += event.y - mLastMouseY; mRotationAngleZ -= event.x - mLastMouseX; mLastMouseX = event.x; mLastMouseY = event.y; } void Tp2Application::draw() { glFogi (GL_FOG_MODE, GL_LINEAR); glFogf (GL_FOG_START, mCameraRho); glFogf (GL_FOG_END, mCameraRho + FOG_DELTA); glFogfv(GL_FOG_COLOR, mFogColor.components); glFogf (GL_FOG_DENSITY, 1.0); if ( mIsShaderOn ) mShaderProgram->use(); else glUseProgram(EMPTY_SHADER_PROGRAM); // Draw Cube glPushMatrix(); { // Apply Material // TODO Define Material + Properties glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mMaterialAmbient.components); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mMaterialDiffuse.components); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mMaterialSpecular.components); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mMaterialEmission.components); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mMaterialShininess); if (mAutomaticRotation) { mRotationAngleX += 360.0f * (mRotationFreqX / mFramerate); mRotationAngleY += 360.0f * (mRotationFreqY / mFramerate); mRotationAngleZ += 360.0f * (mRotationFreqZ / mFramerate); if (mRotationAngleX >= 360.0f) mRotationAngleX -= 360.0f; if (mRotationAngleY >= 360.0f) mRotationAngleY -= 360.0f; if (mRotationAngleZ >= 360.0f) mRotationAngleZ -= 360.0f; } glRotatef(180.0, 1.0, 0.0, 0.0); glRotatef(mRotationAngleX, 1.0, 0.0, 0.0); glRotatef(mRotationAngleY, 0.0, 1.0, 0.0); glRotatef(mRotationAngleZ, 0.0, 0.0, 1.0); glColor4f(0.0, 0.0, 1.0, 1.0); glCallList(mQuadGridListId); deactivateTextures(); } glPopMatrix(); glUseProgram(EMPTY_SHADER_PROGRAM); // Draw Axis without shaders glPushMatrix(); { glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glDisable(GL_FOG); glLineWidth(3.0); glBegin(GL_LINES); { // X axis in red glColor4f(1.0, 0.0, 0.0, 1.0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(1.0f * mAxisScaleFactor, 0.0, 0.0); // Y axis in green glColor4f(0.0, 1.0, 0.0, 1.0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 1.0f * mAxisScaleFactor, 0.0); // Z axis in blue glColor4f(0.0, 0.0, 1.0, 1.0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 0.0, 1.0f * mAxisScaleFactor); } glEnd(); glEnable(GL_FOG); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); } glPopMatrix(); if ( mIsShaderOn ) mShaderProgram->use(); else glUseProgram(EMPTY_SHADER_PROGRAM); glFlush(); } void Tp2Application::updateWorld() { updateLights(); } void Tp2Application::updateLights() { if (mIsPointLightOn) { glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_AMBIENT, mPointLightAmbient.components); glLightfv(GL_LIGHT0, GL_DIFFUSE, mPointLightDiffuse.components); glLightfv(GL_LIGHT0, GL_SPECULAR, mPointLightSpecular.components); glLightfv(GL_LIGHT0, GL_EMISSION, mPointLightEmission.components); glLightfv(GL_LIGHT0, GL_POSITION, mPointLightPosition); } else glDisable(GL_LIGHT0); if (mIsSpotLightOn) { FLOAT spotPosition[4] = { mCameraX, mCameraY, mCameraZ, 1.0 }; FLOAT spotDirection[3] = { -mCameraX, -mCameraY, -mCameraZ }; glEnable(GL_LIGHT1); glLightfv(GL_LIGHT1, GL_AMBIENT, mSpotLightAmbient.components); glLightfv(GL_LIGHT1, GL_DIFFUSE, mSpotLightDiffuse.components); glLightfv(GL_LIGHT1, GL_SPECULAR, mSpotLightSpecular.components); glLightfv(GL_LIGHT1, GL_EMISSION, mSpotLightEmission.components); glLightfv(GL_LIGHT1, GL_POSITION, spotPosition); glLightf (GL_LIGHT1, GL_SPOT_EXPONENT, 1.0); glLightf (GL_LIGHT1, GL_SPOT_CUTOFF, 30.0); glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, spotDirection); } else glDisable(GL_LIGHT1); if (mIsDirectionalLightOn) { glEnable(GL_LIGHT2); glLightfv(GL_LIGHT2, GL_AMBIENT, mDirectionalLightAmbient.components); glLightfv(GL_LIGHT2, GL_DIFFUSE, mDirectionalLightDiffuse.components); glLightfv(GL_LIGHT2, GL_SPECULAR, mDirectionalLightSpecular.components); glLightfv(GL_LIGHT2, GL_EMISSION, mDirectionalLightEmission.components); glLightfv(GL_LIGHT2, GL_POSITION, mDirectionalLightPosition); } else glDisable(GL_LIGHT2); } void Tp2Application::applyTextures() { mStonewallTextureUnit->activate(); mRustTextureUnit->activate(); m3dLabsTextureUnit->activate(); } void Tp2Application::initializeTextures() { mStonewallTextureUnit = new TextureUnit(GL_TEXTURE0, "stonewall_diffuse.bmp"); mStonewallTextureUnit->initialize(); mStonewallTextureUnit->addCombiner(GL_TEXTURE_ENV_MODE, GL_MODULATE); mRustTextureUnit = new TextureUnit(GL_TEXTURE1, "rust.bmp"); mRustTextureUnit->initialize(); mRustTextureUnit->addCombiner(GL_TEXTURE_ENV_MODE, GL_COMBINE). addCombiner(GL_COMBINE_RGB, GL_MODULATE). addCombiner(GL_SOURCE0_RGB, GL_TEXTURE). addCombiner(GL_SOURCE1_RGB, GL_PREVIOUS); m3dLabsTextureUnit = new TextureUnit(GL_TEXTURE2, "3d_labs.bmp"); m3dLabsTextureUnit->initialize(); m3dLabsTextureUnit->addCombiner(GL_TEXTURE_ENV_MODE, GL_MODULATE); } void Tp2Application::deactivateTextures() { glActiveTexture(GL_TEXTURE1); glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE2); glDisable(GL_TEXTURE_2D); glActiveTexture(GL_TEXTURE0); glDisable(GL_TEXTURE_2D); }
[ "Matt@Extra-PC.(none)" ]
[ [ [ 1, 362 ] ] ]
b7851eca62f3a01337cf9964619ed3c2a9f2d5c2
00c36cc82b03bbf1af30606706891373d01b8dca
/OpenGUI/OpenGUI_TimerManager.cpp
80e858bd5f764f37ff93bdc68164f06f1317927e
[ "BSD-3-Clause" ]
permissive
VB6Hobbyst7/opengui
8fb84206b419399153e03223e59625757180702f
640be732a25129a1709873bd528866787476fa1a
refs/heads/master
2021-12-24T01:29:10.296596
2007-01-22T08:00:22
2007-01-22T08:00:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,060
cpp
// OpenGUI (http://opengui.sourceforge.net) // This source code is released under the BSD License // See LICENSE.TXT for details #include "OpenGUI_TimerManager.h" #include "OpenGUI_System.h" namespace OpenGUI { template<> TimerManager* Singleton<TimerManager>::mptr_Singleton = 0; TimerManager& TimerManager::getSingleton( void ) { assert( mptr_Singleton ); return ( *mptr_Singleton ); } //############################################################################ TimerManager* TimerManager::getSingletonPtr( void ) { return mptr_Singleton; } //############################################################################ //############################################################################ //############################################################################ TimerManager::TimerManager() { #if OPENGUI_PLATFORM == OPENGUI_PLATFORM_WIN32 timeBeginPeriod( 1 ); #endif m_timeSinceStart = 0; TimerManager::_init_timePassedSinceLastCall(); } //############################################################################ TimerManager::~TimerManager() { #if OPENGUI_PLATFORM == OPENGUI_PLATFORM_WIN32 timeEndPeriod( 1 ); #endif } //############################################################################ TimerPtr TimerManager::getTimer() { Timer* timer = new Timer; timer->reset(); return TimerPtr( timer ); } //############################################################################ unsigned long TimerManager::getMillisecondsSinceStart() { return m_timeSinceStart; } //############################################################################ /*!\note This should not be called unless you are not allowing System to perform its own time advancement. */ void TimerManager::addTime( unsigned int amount_milliseconds ) { m_timeSinceStart += amount_milliseconds; } //############################################################################ /*! Time can only be advanced, you cannot go backwards. Attempts to do so will result in undefined behavior, but the most likely result will be a huge jump forward in time passed. \note This should not be called unless you are not allowing System to perform its own time advancement. */ void TimerManager::setTime( unsigned long timefromstart_milliseconds ) { m_timeSinceStart = timefromstart_milliseconds; } //############################################################################ void TimerManager::_AutoAdvance() { addTime( _timePassedSinceLastCall() ); } //############################################################################ //############################################################################ void TimerManager::_init_timePassedSinceLastCall() { m_last_timePassedSinceLastCall = _timeCurrent(); } //############################################################################ unsigned long TimerManager::_timePassedSinceLastCall() { unsigned long cur = _timeCurrent(); unsigned long delta = cur - m_last_timePassedSinceLastCall; m_last_timePassedSinceLastCall = cur; return delta; } //############################################################################ unsigned long TimerManager::_timeCurrent() { #if OPENGUI_PLATFORM == OPENGUI_PLATFORM_WIN32 /* We do this because clock() is not affected by timeBeginPeriod on Win32. QueryPerformanceCounter is a little overkill for the amount of precision that I consider acceptable. If someone submits a patch that replaces this code with QueryPerformanceCounter, I wouldn't complain. Until then, timeGetTime gets the results I'm after. -EMS See: http://www.geisswerks.com/ryan/FAQS/timing.html And: http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q274323& */ return timeGetTime(); #else return ( unsigned long )(( float )( clock() ) / (( float )CLOCKS_PER_SEC / 1000.0 ) ); #endif } //############################################################################ } ;//namespace OpenGUI{
[ "zeroskill@2828181b-9a0d-0410-a8fe-e25cbdd05f59" ]
[ [ [ 1, 100 ] ] ]
8e6cf7e353d269b1897944b2b0418c0cab1686d7
2fe1bab56e0e08499b167f2b4a293e2f16c951a0
/Sim65Main.cpp
98844e166634fe566f605017d59ee09ce5fc0afa
[]
no_license
g6ujj/sim6502
24096d523634d8be8717f5e32c56568c04bd33df
9d036bb27815c73c6a52d0577e83422ea43b4b8d
refs/heads/master
2021-01-01T17:28:38.007286
2011-11-26T22:51:07
2011-11-26T22:51:07
2,858,152
0
1
null
null
null
null
UTF-8
C++
false
false
2,451
cpp
/*************************************************************** * Name: Sim65Main.cpp * Purpose: Code for Application Frame * Author: Neil Stoker ([email protected]) * Created: 2011-11-26 * Copyright: Neil Stoker (https://sites.google.com/site/g6ujjcode/) * License: **************************************************************/ #ifdef WX_PRECOMP #include "wx_pch.h" #endif #ifdef __BORLANDC__ #pragma hdrstop #endif //__BORLANDC__ #include "Sim65Main.h" //helper functions enum wxbuildinfoformat { short_f, long_f }; wxString wxbuildinfo(wxbuildinfoformat format) { wxString wxbuild(wxVERSION_STRING); if (format == long_f ) { #if defined(__WXMSW__) wxbuild << _T("-Windows"); #elif defined(__WXMAC__) wxbuild << _T("-Mac"); #elif defined(__UNIX__) wxbuild << _T("-Linux"); #endif #if wxUSE_UNICODE wxbuild << _T("-Unicode build"); #else wxbuild << _T("-ANSI build"); #endif // wxUSE_UNICODE } return wxbuild; } BEGIN_EVENT_TABLE(Sim65Frame, wxFrame) EVT_CLOSE(Sim65Frame::OnClose) EVT_MENU(idMenuQuit, Sim65Frame::OnQuit) EVT_MENU(idMenuAbout, Sim65Frame::OnAbout) END_EVENT_TABLE() Sim65Frame::Sim65Frame(wxFrame *frame, const wxString& title) : wxFrame(frame, -1, title) { #if wxUSE_MENUS // create a menu bar wxMenuBar* mbar = new wxMenuBar(); wxMenu* fileMenu = new wxMenu(_T("")); fileMenu->Append(idMenuQuit, _("&Quit\tAlt-F4"), _("Quit the application")); mbar->Append(fileMenu, _("&File")); wxMenu* helpMenu = new wxMenu(_T("")); helpMenu->Append(idMenuAbout, _("&About\tF1"), _("Show info about this application")); mbar->Append(helpMenu, _("&Help")); SetMenuBar(mbar); #endif // wxUSE_MENUS wxFlexGridSizer *fgs=new wxFlexGridSizer(); #if wxUSE_STATUSBAR // create a status bar with some information about the used wxWidgets version CreateStatusBar(2); SetStatusText(_("Hello Code::Blocks user!"),0); SetStatusText(wxbuildinfo(short_f), 1); #endif // wxUSE_STATUSBAR } Sim65Frame::~Sim65Frame() { } void Sim65Frame::OnClose(wxCloseEvent &event) { Destroy(); } void Sim65Frame::OnQuit(wxCommandEvent &event) { Destroy(); } void Sim65Frame::OnAbout(wxCommandEvent &event) { wxString msg = wxbuildinfo(long_f); wxMessageBox(msg, _("Welcome to...")); }
[ [ [ 1, 100 ] ] ]
2ecb2017c10b1247e5ac9b24421e9a3f758f70b2
6630a81baef8700f48314901e2d39141334a10b7
/1.4/Testing/Cxx/swFrameworkDependent/Config/swConfigInterface.h
8b973e2e00f9949ee4d401ec6bce43965ee967f4
[]
no_license
jralls/wxGuiTesting
a1c0bed0b0f5f541cc600a3821def561386e461e
6b6e59e42cfe5b1ac9bca02fbc996148053c5699
refs/heads/master
2021-01-10T19:50:36.388929
2009-03-24T20:22:11
2009-03-26T18:51:24
623,722
1
0
null
null
null
null
ISO-8859-1
C++
false
false
1,891
h
/////////////////////////////////////////////////////////////////////////////// // Name: swFrameworkDependent/Config/swConfigInterface.h // Author: Reinhold Füreder // Created: 2004 // Copyright: (c) 2005 Reinhold Füreder // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// #ifndef SWCONFIGINTERFACE_H #define SWCONFIGINTERFACE_H #ifdef __GNUG__ #pragma interface "swConfigInterface.h" #endif #include "Common.h" namespace sw { /*! \class ConfigInterface \brief Config interface definition. Only resource directory config property is globally required. Other config properties are case dependent. */ class ConfigInterface { public: /*! \fn ConfigInterface () \brief Constructor */ ConfigInterface (); /*! \fn virtual ~ConfigInterface () \brief Destructor */ virtual ~ConfigInterface (); /*! \fn virtual bool GetResourceDir (wxString &resDir) = 0 \brief Get resource directory from config. \param resDir resource directory \return true, if found */ virtual bool GetResourceDir (wxString &resDir) = 0; /*! \fn virtual bool GetStrConfigProperty (const wxString &key, wxString &value) = 0 \brief Get string typed property from config. \param key key identifying config property \param value string typed config property value for given key \return true, if found */ virtual bool GetStrConfigProperty (const wxString &key, wxString &value) = 0; protected: private: private: // No copy and assignment constructor: ConfigInterface (const ConfigInterface &rhs); ConfigInterface & operator= (const ConfigInterface &rhs); }; } // End namespace sw #endif // SWCONFIGINTERFACE_H
[ "john@64288482-8357-404e-ad65-de92a562ee98" ]
[ [ [ 1, 73 ] ] ]
f6228f0912c124f7a5e53689f4a1eb862b5c40f1
b816fdbc7bb0da01eb39346b9b787c028791afec
/Project Panda/src/mechanics/aging/Age.h
95d9304cba6920b2c074513b2c20d33b6f338942
[]
no_license
martinpinto/Project-Panda
0537feac43574ae3453d0228638fed7015a44116
f1db30b885a7557e59974323035e3a411072f060
refs/heads/master
2021-01-25T12:19:27.325670
2011-11-19T17:54:12
2011-11-19T17:54:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
757
h
/* * Age.h * * Created on: 04.09.2011 * Author: Martin Pinto-Bazurco, Martin Prodanov * */ #include <iostream> #include <vector> #include <ctime> #ifndef _AGE_H_ #define _AGE_H_ #define MAX_AGE 1000000; enum AgePhase { Baby, Child, Teenager, Adult, Grandpa }; class Age { public: Age(); Age(bool canDie); Age(int agingFactor); Age(int agingFactor, bool canDie, int maxAge); virtual ~Age(); int getCurrentAge(); long getBirthday(); AgePhase getAgePhase(); bool canDie(); int getMaxAge(); void setMaxAge(int maxAge); private: int age; int agingFactor; // causes the gotshi to age a factor faster long birthday; bool dies; int maxAge; int computeCurrentAge(); }; #endif
[ [ [ 1, 10 ], [ 12, 17 ], [ 26, 26 ], [ 30, 30 ], [ 32, 34 ], [ 38, 40 ], [ 46, 47 ], [ 49, 50 ], [ 52, 52 ] ], [ [ 11, 11 ], [ 18, 25 ], [ 27, 29 ], [ 31, 31 ], [ 35, 37 ], [ 41, 45 ], [ 48, 48 ], [ 51, 51 ] ] ]
276dd55de19799f12ed23c0edba71edfba697d69
1d693dd1b12b23c72dd0bb12a3fc29ed88a7e2d5
/src/nbnetvm/jit/bytecode_analyse.cpp
46728fb2ed206c36f7dd4b47cdd0e697e59f3690
[]
no_license
rrdenicol/Netbee
8765ebc2db4ba9bd27c2263483741b409da8300a
38edb4ffa78b8fb7a4167a5d04f40f8f4466be3e
refs/heads/master
2021-01-16T18:42:17.961177
2011-12-26T20:27:03
2011-12-26T20:27:03
3,053,086
0
0
null
null
null
null
UTF-8
C++
false
false
45,205
cpp
/*****************************************************************************/ /* */ /* Copyright notice: please read file license.txt in the NetBee root folder. */ /* */ /*****************************************************************************/ /** @file bytecode_analyse.c * \brief This file contains the functions that perform bytecode analysis and verification of a NetVM segment * */ #include <stdlib.h> #include <stdio.h> #ifndef WIN32 #include <string.h> #endif #include "bytecode_analyse.h" #include "netvmjitglobals.h" #include "../opcodes.h" // NetVM opcodes definitions #include "codetable.h" #include "bytecode_segments.h" #include "comperror.h" #include "../../nbee/globals/debug.h" #include <iostream> //!Macro that set the stack pointer to its initial value (different between .init and .push or .pull segments) #define SET_INITIAL_STACK(SP, N) (SP = N) //set stack pointer to N //!Number of elements that an instruction pushes to or pops from the stack enum{ NO_STACK_ELEMENTS = 0, ONE_STACK_ELEMENT = 1, TWO_STACK_ELEMENTS = 2, THREE_STACK_ELEMENTS = 3 }; //!Macro that updtates PC to point to the next instruction in the bytecode: #define NEXT_INSTR(PC) (pc + GetInstructionLen(bytecode[PC])) #define MAX(A,B) ( ( (A) > (B) ) ? (A) : (B) ) /*! \brief Instruction Indexes */ typedef struct InstrIndexes { uint32_t *InstrIndexesArray; //!< Array of the instruction indexes uint32_t NumInstructions; //!< Number of NetIL instructions in the segment uint32_t SegmentLength; //!< Bytecode Segment Length } InstrIndexes; InstrIndexes * New_Instr_Indexes(nvmByteCodeSegment * segment, ErrorList * errList); void Free_Instr_Indexes(InstrIndexes * InsIndexes); /*! \brief adds to the current stack depth numOfElements stack elements as a PUSH-like operation would do. Returns the eventual stack overflow tested on StackLimit \param sp: pointer to the current stack depth \param StackLimit: maximum stack length \param numElements: number of elements to be PUSHed onto the stack \return local/stack access flags */ uint32_t Stack_PUSH(int32_t *sp, int32_t StackLimit, uint32_t numElements) { (*sp) += numElements; if ((*sp) >= StackLimit) return FLAG_LST_STACK_OVFLOW; return FLAG_NO_ERROR; } /*! \brief subtract to the current stack depth numOfElements stack elements as a POP-like operation would do. Returns the eventual stack underflow or pop from empty stack errors \param sp: pointer to the current stack depth \param consumedElements: number of elements to be POPed from the stack \return local/stack access flags */ uint32_t Stack_POP(int32_t *sp, uint32_t consumedElements) { if ((*sp) == 0) return FLAG_LST_STACK_EMPTY; if ((*sp) < (int32_t)consumedElements){ return FLAG_LST_STACK_UNDERFLOW; } (*sp) -= consumedElements; return FLAG_NO_ERROR; // OK } /*! \brief increment the current stack depth as a DUP-like operation would do. Returns the eventual dup from empty stack or stack overflow errors \param sp: pointer to the current stack depth \param StackLimit: maximum stack length \return local/stack access flags */ uint32_t Stack_DUP(int32_t *sp, int32_t StackLimit) { if ((*sp) == 0) return FLAG_LST_STACK_EMPTY; (*sp) += ONE_STACK_ELEMENT; if ((*sp) >= StackLimit) return FLAG_LST_STACK_OVFLOW; return FLAG_NO_ERROR; // OK } /*! \brief Simulates a stack POP and a locals definition reference. Returns the result of the POP and the eventual local's index out of boundaries error \param LocalsRefs: The locals references array \param locIndex: Accessed local's index \param localsSize: Size of the Locals Area \param sp: pointer to the current stack depth \return local/stack access flags */ uint32_t Local_ST(uint32_t *LocalsRefs, uint32_t locIndex, uint16_t localsSize, int32_t *sp) { uint32_t result = 0; result = Stack_POP(sp, ONE_STACK_ELEMENT); if (locIndex >= localsSize) { result |= FLAG_LST_LOCAL_OUTOB; return result; } if (result == 0) LocalsRefs[locIndex] = TRUE; return result; } /*! \brief Simulates a stack PUSH and a locals use reference. Returns the result of the PUSH, the eventual local's index out of boundaries, or the Unreferenced Local error \param LocalsRefs: The locals references array \param locIndex: Accessed local's index \param localsSize: Size of the Locals Area \param sp: Pointer to the current stack depth \param stackLimit: The maximum stack length \return local/stack access flags */ uint32_t Local_LD(uint32_t *LocalsRefs, uint32_t locIndex, uint16_t localsSize, int32_t *sp, int32_t stackLimit) { uint32_t result = 0; result = Stack_PUSH(sp, stackLimit, ONE_STACK_ELEMENT); if (locIndex >= localsSize){ result |= FLAG_LST_LOCAL_OUTOB; return result; } return result; } /*! \brief Verifies the effective locals area utilization scanning the Locals References array \param LocalsRefs: The locals references array \param localsSize: Size of the Locals Area \return the number of locals effectively used in the bytecode */ uint16_t Get_Locals_Use(uint32_t *LocalsRefs, uint16_t localsSize) { uint16_t result = 0, i; if (LocalsRefs == NULL) return nvmJitSUCCESS; for (i = 0; i < localsSize; i++){ if (LocalsRefs[i]) result++; } return result; } /*! \brief update the current InstructionInfo stack depth to currStackDepth \param BCInfoArray: pointer to the InstructionInfo array \param pc: current instruction index \param currStackDepth: the current stack depth \return NOTHING */ void Update_Instr_Stack_Depth(InstructionInfo * BCInfoArray, uint32_t pc, int32_t currStackDepth) { VERB0(JIT_BUILD_BLOCK_LVL2, "Update_Instr_Stack_Depth"); BCInfoArray[pc].StackDepth = MAX(BCInfoArray[pc].StackDepth,currStackDepth); } /*! \brief Initialize the Instruction Indexes struct \param segment: pointer to the NetVM bytecode segment descriptor \param errList: pointer to the compilation errors list \return a pointer to the newly allocated InstrIndexes struct */ InstrIndexes * New_Instr_Indexes(nvmByteCodeSegment * segment, ErrorList * errList) { uint8_t *bytecode; uint8_t opcode; uint32_t pc, insnNum, segmentLen; InstrIndexes * InstrIndexesStruct; uint32_t *InstrIndexesArray; //uint32_t ncases = 0; bytecode = segment->ByteCode; segmentLen = segment->SegmentSize; if (segmentLen == 0){ return NULL; } InstrIndexesArray = (uint32_t *) CALLOC(segment->SegmentSize, sizeof(uint32_t)); if (InstrIndexesArray == NULL){ return NULL; } InstrIndexesStruct = (InstrIndexes *) CALLOC(1, sizeof(InstrIndexes)); if (InstrIndexesStruct == NULL){ free(InstrIndexesArray); free(InstrIndexesStruct); return NULL; } //Instruction Indexes array initialization: pc = 0; insnNum = 0; while(pc < segmentLen){ opcode = bytecode[pc]; if (strcmp(nvmOpCodeTable[opcode].CodeName, OPCODE_NAME_INVALID) == 0){ Analysis_Error(errList, FLAG_OP_NOT_DEF, NULL, pc, 0, 0); free(InstrIndexesArray); free(InstrIndexesStruct); return NULL; } InstrIndexesArray[pc] = insnNum; // Instruction Start index pc += GetInstructionLen(&bytecode[pc]); insnNum++; } // BYTECODE_FALLOUT_TEST: if (pc != segmentLen){ Analysis_Error(errList, FLAG_BC_FALLOUT, NULL, pc, 0, 0); free(InstrIndexesArray); free(InstrIndexesStruct); return NULL; } if (insnNum == 0){ free(InstrIndexesArray); free(InstrIndexesStruct); return NULL; } InstrIndexesStruct->InstrIndexesArray = InstrIndexesArray; InstrIndexesStruct->NumInstructions = insnNum; InstrIndexesStruct->SegmentLength = segmentLen; return InstrIndexesStruct; } uint32_t Translate_BC_Index(InstrIndexes * InstrIndexesStruct, uint32_t BCPC, uint32_t *isValid, ErrorList * errList) { if (BCPC > InstrIndexesStruct->SegmentLength){ (*isValid) = FALSE; Analysis_Error(errList, FLAG_INVALID_BR_TARGET, NULL, BCPC, 0, 0); return nvmJitSUCCESS; } if ((InstrIndexesStruct->InstrIndexesArray[BCPC] == 0) && (BCPC != 0)){ (*isValid) = FALSE; Analysis_Error(errList, FLAG_INVALID_BR_TARGET, NULL, BCPC, 0, 0); return nvmJitSUCCESS; } *isValid = TRUE; return InstrIndexesStruct->InstrIndexesArray[BCPC]; } int32_t Create_ByteCode_Info_Array(nvmJitByteCodeInfo * BCInfo, InstrIndexes * InstrIndexesStruct, ErrorList * errList) { uint32_t BCPC, BCInfoPC; // Bytecode program counter, BCInfo program counter uint8_t opcode; //current instruction opcode uint8_t *bytecode; //bytecode array uint32_t segmentLen; //code length InstructionInfo * BCInfoArray; //Array of InstructionInfo uint32_t numInstructions, btarget; uint32_t isValid = FALSE; SwInsnInfo *swInfo = NULL; uint32_t i = 0; uint32_t insnLen = 0; //std::cout << "Create Bytecode Array" << std::endl; if (InstrIndexesStruct == NULL || BCInfo == NULL){ return nvmJitFAILURE; } if (BCInfo->Segment->SegmentSize == 0 || InstrIndexesStruct->NumInstructions == 0){ return nvmJitFAILURE; } BCInfoArray = BCInfo->BCInfoArray; bytecode = BCInfo->Segment->ByteCode; numInstructions = InstrIndexesStruct->NumInstructions; segmentLen = InstrIndexesStruct->SegmentLength; BCPC = 0; BCInfoPC = 0; while ((BCPC < segmentLen) && (BCInfoPC < numInstructions)){ opcode = bytecode[BCPC]; BCInfoArray[BCInfoPC].Opcode = opcode; BCInfoArray[BCInfoPC].SwInfo = NULL; switch(opcode){ case JUMP: case CALL: nvmFLAG_SET(BCInfoArray[BCInfoPC].Flags, FLAG_BR_INSN); //SET_BR_INSN(BCInfoArray[BCInfoPC].Flags); btarget = Translate_BC_Index(InstrIndexesStruct, SHORT_JMP_TARGET(BCPC), &isValid, errList); if (!isValid) return nvmJitFAILURE; BCInfoArray[BCInfoPC].Arguments[0] = btarget; BCInfoArray[BCInfoPC].NumArgs = 1; break; case JUMPW: case CALLW: nvmFLAG_SET(BCInfoArray[BCInfoPC].Flags, FLAG_BR_INSN); //SET_BR_INSN(BCInfoArray[BCInfoPC].Flags); btarget = Translate_BC_Index(InstrIndexesStruct, LONG_JMP_TARGET(BCPC), &isValid, errList); if (!isValid) return nvmJitFAILURE; BCInfoArray[BCInfoPC].Arguments[0] = btarget; BCInfoArray[BCInfoPC].NumArgs = 1; break; case JEQ: case JNE: /* case BJFLDEQ: case BJFLDNEQ: case BJFLDLT: case BJFLDLE: case BJFLDGT: case BJFLDGE: case SJFLDEQ: case SJFLDNEQ: case SJFLDLT: case SJFLDLE: case SJFLDGT: case SJFLDGE: case IJFLDEQ: case IJFLDNEQ: case IJFLDLT: case IJFLDLE: case IJFLDGT: case IJFLDGE: case BMJFLDEQ: case SMJFLDEQ: case IMJFLDEQ: */ case JCMPEQ: case JCMPNEQ: case JCMPG: case JCMPGE: case JCMPL: case JCMPLE: case JCMPG_S: case JCMPGE_S: case JCMPL_S: case JCMPLE_S: case JFLDEQ: case JFLDNEQ: case JFLDLT: case JFLDGT: nvmFLAG_SET(BCInfoArray[BCInfoPC].Flags, FLAG_BR_INSN); //SET_BR_INSN(BCInfoArray[BCInfoPC].Flags); BCInfoArray[BCInfoPC].Arguments[0] = Translate_BC_Index(InstrIndexesStruct, LONG_JMP_TARGET(BCPC), &isValid, errList); if (!isValid) return nvmJitFAILURE; BCInfoArray[BCInfoPC].Arguments[1] = Translate_BC_Index(InstrIndexesStruct, BCPC + GetInstructionLen(&bytecode[BCPC]), &isValid, errList); if (!isValid) return nvmJitFAILURE; BCInfoArray[BCInfoPC].NumArgs = 2; break; case SWITCH: nvmFLAG_SET(BCInfoArray[BCInfoPC].Flags, FLAG_SW_INSN); swInfo = (SwInsnInfo*)malloc(sizeof(SwInsnInfo)); if (swInfo == NULL) return nvmJitFAILURE; swInfo->NumCases = LONG_ARG(BCPC + 4); swInfo->CaseTargets = (uint32_t*)calloc(swInfo->NumCases, 4); swInfo->Values = (uint32_t*)calloc(swInfo->NumCases, sizeof(uint32_t)); if (swInfo->CaseTargets == NULL) return nvmJitFAILURE; insnLen = GetInstructionLen(&bytecode[BCPC]); swInfo->DefTarget = Translate_BC_Index(InstrIndexesStruct, (*(int32_t*)&bytecode[BCPC + 1]) + insnLen + BCPC, &isValid, errList); for (i = 0; i < swInfo->NumCases; i++) { //swInfo->Values[i] = (uint32_t)bytecode[BCPC + 4 + 1 + 8*i]; // ??? swInfo->Values[i] = *(uint32_t*)&bytecode[BCPC + 1 + 8 + 8*i]; swInfo->CaseTargets[i] = Translate_BC_Index(InstrIndexesStruct, *(int32_t*)&bytecode[BCPC + 1 + 12 + 8*i] + insnLen + BCPC, &isValid, errList); } BCInfoArray[BCInfoPC].NumArgs = 0; BCInfoArray[BCInfoPC].SwInfo = swInfo; break; default: switch (nvmOpCodeTable[opcode].ArgLen){ case T_NO_ARG_INST: BCInfoArray[BCInfoPC].NumArgs = 0; break; case T_1BYTE_ARG_INST: BCInfoArray[BCInfoPC].NumArgs = 1; BCInfoArray[BCInfoPC].Arguments[0] = BYTE_ARG(BCPC); break; case T_1INT_ARG_INST: BCInfoArray[BCInfoPC].NumArgs = 1; BCInfoArray[BCInfoPC].Arguments[0] = LONG_ARG(BCPC); break; case T_2INT_ARG_INST: BCInfoArray[BCInfoPC].NumArgs = 2; BCInfoArray[BCInfoPC].Arguments[0] = LONG_ARG(BCPC); BCInfoArray[BCInfoPC].Arguments[1] = LONG_ARG(BCPC + 4); break; default: //NOTHING Analysis_Error(errList, FLAG_INVALID_ARGS_SZ, NULL, BCPC, 0, 0); return nvmJitFAILURE; break; } break; } BCInfoArray[BCInfoPC].BCpc = BCPC; std::map<uint32_t, uint32_t>::iterator k = BCInfo->Segment->Insn2LineMap.find(BCPC); if (k != BCInfo->Segment->Insn2LineMap.end()) { BCInfoArray[BCInfoPC].SrcLine = k->second; //std::cout << "Map: " << BCPC << " --> " << k->second << std::endl; } else { BCInfoArray[BCInfoPC].SrcLine = 0; } BCInfoPC ++; BCPC += GetInstructionLen(&bytecode[BCPC]); } if (BCInfoArray[BCInfoPC-1].Opcode != EXIT && \ BCInfoArray[BCInfoPC-1].Opcode != RET && \ BCInfoArray[BCInfoPC-1].Opcode != SNDPKT && \ (!nvmFLAG_ISSET(BCInfoArray[BCInfoPC - 1].Flags, FLAG_BR_INSN)) && \ (!nvmFLAG_ISSET(BCInfoArray[BCInfoPC - 1].Flags, FLAG_SW_INSN)) ){ Analysis_Error(errList, FLAG_END_OF_SEG_WO_RET, NULL, BCPC, 0, 0); return nvmJitFAILURE; } if (BCPC != segmentLen){ Analysis_Error(errList, FLAG_WRONG_NUM_INSTR, NULL, BCPC, 0, 0); return nvmJitFAILURE; } return nvmJitSUCCESS; } /*! \brief creates and initializes a nvmJitByteCodeInfo structure given its corresponding NetVM bytecode segment descriptor \param segment: pointer to the NetVM bytecode segment descriptor \param errList: pointer to the compilation errors list \return pointer to the new allocated nvmJitByteCodeInfo structure */ nvmJitByteCodeInfo * New_ByteCode_Info(nvmByteCodeSegment * segment, ErrorList * errList) { InstructionInfo * BCInfoArray; nvmJitByteCodeInfo * BCInfo; InstrIndexes * InstrIndexesStruct; uint32_t numInstructions; if (segment == NULL){ return NULL; } if (segment->SegmentSize == 0){ return NULL; } if (strcmp(segment->Name,".ports") == 0){ return NULL; } InstrIndexesStruct = New_Instr_Indexes(segment, errList); if (InstrIndexesStruct == NULL){ return NULL; } numInstructions = InstrIndexesStruct->NumInstructions; BCInfoArray = (InstructionInfo *) CALLOC(numInstructions, sizeof(InstructionInfo)); if (BCInfoArray == NULL){ Free_Instr_Indexes(InstrIndexesStruct); return NULL; } BCInfo = (nvmJitByteCodeInfo *) CALLOC(1, sizeof(nvmJitByteCodeInfo)); if (BCInfo == NULL){ Free_Instr_Indexes(InstrIndexesStruct); free(BCInfoArray); return NULL; } // BCInfo->StackSize = segment->MaxStackSize; // BCInfo->LocalsSize = segment->LocalsSize; BCInfo->BCInfoArray = BCInfoArray; BCInfo->MaxStackDepth = 0; BCInfo->LocalsUse = 0; BCInfo->NumBasicBlocks = 0; BCInfo->Segment = segment; BCInfo->NumInstructions = numInstructions; BCInfo->LocalsReferences = NULL; BCInfo->AnalysisFlags = 0; if (Create_ByteCode_Info_Array(BCInfo, InstrIndexesStruct, errList) < 0){ BCInfo->AnalysisFlags = errList->Tail->ErrFlags; Free_Instr_Indexes(InstrIndexesStruct); //nvmJitFree_ByteCode_Info(BCInfo); return BCInfo; } VERB0(JIT_BUILD_BLOCK_LVL2, "BCInfo Created"); Free_Instr_Indexes(InstrIndexesStruct); return BCInfo; } /*! \brief Frees memory allocated for the nvmJitByteCodeInfo Structure \param BCInfo: pointer to the nvmJitByteCodeInfo struct \return Nothing */ void nvmJitFree_ByteCode_Info(nvmJitByteCodeInfo * BCInfo) { if (BCInfo != NULL){ if (BCInfo->LocalsReferences != NULL) free(BCInfo->LocalsReferences); if (BCInfo->BCInfoArray != NULL) free(BCInfo->BCInfoArray); free(BCInfo); } } void Free_Instr_Indexes(InstrIndexes * InsIndexes) { if (InsIndexes != NULL){ if (InsIndexes->InstrIndexesArray != NULL) free(InsIndexes->InstrIndexesArray); free(InsIndexes); } } /*! \brief sets a new Basic Block leader. Used to create a new basic block following a RET or a branch/jump Instruction \param BCInfoArray: pointer to the InstructionInfo array \param pc: current instruction index \param currStackDepth: the current stack depth \param BBCount: pointer to the Basic Block counter \return NOTHING */ void Set_Basic_Block_Leader(InstructionInfo * BCInfoArray, uint32_t pc, int32_t currStackDepth, uint16_t *BBCount) { if (!nvmFLAG_ISSET(BCInfoArray[pc].Flags, FLAG_BB_LEADER)){ (*BBCount)++; BCInfoArray[pc].BasicBlockId = (*BBCount); } nvmFLAG_SET(BCInfoArray[pc].Flags, FLAG_BB_LEADER); if (!nvmFLAG_ISSET(BCInfoArray[pc].Flags, FLAG_VISITED)){ } BCInfoArray[pc].StackDepth = MAX(BCInfoArray[pc].StackDepth,currStackDepth); } /*! \brief sets the end of a Basic Block updating the InstructionInfo element's numSuccessors. Used when we encounter a branch/jump instruction or a RET \param BCInfoArray: pointer to the InstructionInfo array \param pc: current instruction index \param currStackDepth: the current stack depth \param consumedElements: number of stack elements elements consumed by the instruction \param numSuccessors: the numer of edges coming out from the basic block: (0 if RET, 1 if JUMP, 2 if BRANCH) \return NOTHING */ void Set_End_Of_Basic_Block(InstructionInfo * BCInfoArray, uint32_t pc, int32_t currStackDepth, uint16_t consumedElements, uint16_t numSuccessors) { nvmFLAG_SET(BCInfoArray[pc].Flags, FLAG_BB_END); BCInfoArray[pc].NumSuccessors = numSuccessors; BCInfoArray[pc].StackDepth = currStackDepth; BCInfoArray[pc].StackAfter =(uint32_t) (currStackDepth - consumedElements); } /*! \brief split an existing Basic Block in 2 \param BCInfoArray: pointer to the InstructionInfo array \param pc: current instruction index \return NOTHING */ void Split_Basic_Block(InstructionInfo * BCInfoArray, uint32_t pc) { if (pc > 0){ BCInfoArray[pc - 1].NumSuccessors++; nvmFLAG_SET(BCInfoArray[pc - 1].Flags, FLAG_BB_END); } BCInfoArray[pc].NumPredecessors++; } /*! \brief updates the first InstructionInfo element adding the first Basic Block information \param BCInfoArray: pointer to the InstructionInfo array \param pc: current instruction index \param initStackDepth: the initial stack depth \param BBCount: pointer to the Basic Block counter \return NOTHING */ void Add_First_Basic_Block(InstructionInfo * BCInfoArray, uint32_t pc, int32_t initStackDepth, uint16_t *BBCount) { BCInfoArray[pc].NumPredecessors=0; BCInfoArray[pc].NumSuccessors=0; Set_Basic_Block_Leader(BCInfoArray, pc, initStackDepth, BBCount); } /*! \brief adds a Basic Block information backward in the code \param BCInfoArray: pointer to the InstructionInfo array \param pc: current instruction index \param currStackDepth: the current stack depth \param BBCount: pointer to the Basic Block counter \return TRUE if there are incoming edges with different stack depths FALSE otherwise */ uint32_t Add_BW_Basic_Block(InstructionInfo * BCInfoArray, uint32_t pc, int32_t currStackDepth, uint16_t *BBCount) { uint32_t diffInStackDepth=FALSE; if (!nvmFLAG_ISSET(BCInfoArray[pc].Flags, FLAG_BB_LEADER)){ // Split the basic block Split_Basic_Block(BCInfoArray, pc); } if ((currStackDepth != BCInfoArray[pc].StackDepth) && nvmFLAG_ISSET(BCInfoArray[pc].Flags, FLAG_VISITED)){ nvmFLAG_SET(BCInfoArray[pc].Flags, FLAG_STACK_MERGE_ERR); diffInStackDepth=TRUE; } Set_Basic_Block_Leader(BCInfoArray, pc, currStackDepth, BBCount); BCInfoArray[pc].NumPredecessors++; return diffInStackDepth; } /*! \brief adds a Basic Block information forward in the code \param BCInfoArray: pointer to the InstructionInfo array \param pc: current instruction index \param currStackDepth: the current stack depth \param BBCount: pointer to the Basic Block counter \return TRUE if there are incoming edges with different stack depths FALSE otherwise */ uint32_t Add_FW_Basic_Block(InstructionInfo * BCInfoArray, uint32_t pc, int32_t currStackDepth, uint16_t *BBCount) { uint32_t diffInStackDepth=FALSE; if (!nvmFLAG_ISSET(BCInfoArray[pc].Flags, FLAG_BB_LEADER)){ // Split the basic block Split_Basic_Block(BCInfoArray, pc); } if ((currStackDepth != BCInfoArray[pc].StackDepth) && nvmFLAG_ISSET(BCInfoArray[pc].Flags, FLAG_VISITED)){ nvmFLAG_SET(BCInfoArray[pc].Flags, FLAG_STACK_MERGE_ERR); diffInStackDepth = TRUE; } Set_Basic_Block_Leader(BCInfoArray, pc, currStackDepth, BBCount); BCInfoArray[pc].NumPredecessors++; return diffInStackDepth; } /*! \brief creates Basic Blocks because of a JUMP-like instruction. If the branch points to the next instruction marks the current instr for successive deletion \param BCInfo: pointer to a nvmJitByteCodeInfo structure \param pc: current instruction index \param branchTarget: index target of the branch \param currStackDepth: the current stack depth \param BBCount: pointer to the Basic Block counter \return TRUE if creates Basic Blocks with different stack depth from incoming edges FALSE otherwise */ uint32_t Manage_JUMP(nvmJitByteCodeInfo * BCInfo, uint32_t pc, uint32_t branchTarget, int32_t currStackDepth, uint16_t *BBCount) { InstructionInfo * BCInfoArray; uint32_t diffInStackDepth=FALSE; BCInfoArray = BCInfo->BCInfoArray ; nvmFLAG_SET(BCInfoArray[pc].Flags, FLAG_BR_INSN);// current is a branch/jmp instruction if (branchTarget == pc + 1){// JMP to next instruction diffInStackDepth = Add_FW_Basic_Block(BCInfoArray, branchTarget, currStackDepth, BBCount); } else{ if (branchTarget <= pc) // JMP Backward in the code diffInStackDepth = Add_BW_Basic_Block(BCInfoArray, branchTarget, currStackDepth, BBCount); else // JMP Forward in the code diffInStackDepth = Add_FW_Basic_Block(BCInfoArray, branchTarget, currStackDepth, BBCount); // Next Instruction is BB Leader if ((pc + 1) < BCInfo->NumInstructions) Set_Basic_Block_Leader(BCInfoArray, pc + 1, 0, BBCount); } Set_End_Of_Basic_Block(BCInfoArray,pc,currStackDepth, NO_STACK_ELEMENTS, JMP_OUT_EDGES); return diffInStackDepth; } /*! \brief creates Basic Blocks because of a Branch-like instruction. If the branch points to the next instruction marks the current instr for successive deletion \param BCInfo: pointer to a nvmJitByteCodeInfo structure \param pc: current instruction index \param branchTarget: index target of the branch \param currStackDepth: the current stack depth \param consumedElements: the number of stack elements consumed by the branch instr \param BBCount: pointer to the Basic Block counter \return TRUE if creates Basic Blocks with different stack depth from incoming edges FALSE otherwise */ uint32_t Manage_BRANCH(nvmJitByteCodeInfo * BCInfo, uint32_t pc, uint32_t branchTarget, int32_t currStackDepth, uint16_t consumedElements, uint16_t *BBCount) { InstructionInfo * BCInfoArray; uint32_t numInsns = BCInfo->NumInstructions; uint32_t diffInStackDepth=FALSE; BCInfoArray = BCInfo->BCInfoArray ; nvmFLAG_SET(BCInfoArray[pc].Flags, FLAG_BR_INSN); // current is a branch/jmp instruction if (branchTarget == pc + 1){// BRANCH to next instruction = 2 * JUMP next diffInStackDepth = Add_FW_Basic_Block(BCInfoArray, branchTarget,(uint16_t) (currStackDepth - consumedElements), BBCount); diffInStackDepth |= Add_FW_Basic_Block(BCInfoArray, branchTarget,(uint16_t) (currStackDepth - consumedElements), BBCount); } else{ if (branchTarget <= pc) // BRANCH Backward in the code diffInStackDepth = Add_BW_Basic_Block(BCInfoArray, branchTarget, (uint32_t) (currStackDepth - consumedElements), BBCount); else // BRANCH Forward in the code diffInStackDepth = Add_FW_Basic_Block(BCInfoArray, branchTarget, (uint32_t) (currStackDepth - consumedElements), BBCount); if ((pc+1) < numInsns) { //Next statement is Basic Block Leader with 1 more incoming edge: diffInStackDepth |= Add_FW_Basic_Block(BCInfoArray, pc + 1,(uint16_t) (currStackDepth - consumedElements), BBCount); } } Set_End_Of_Basic_Block(BCInfoArray,pc,currStackDepth, consumedElements, BRANCH_OUT_EDGES); return diffInStackDepth; } nvmJitByteCodeInfo * nvmJitAnalyse_ByteCode_Segment_Ex(nvmByteCodeSegment * segment, ErrorList * errList, uint16_t *BBCount) { uint32_t pc; //Instr index int32_t sp; //current stack depth tracking // uint16_t BBCount; //Basic Block Counter int32_t maxStackDepth; //Maximum Reached Stack Depth nvmJitByteCodeInfo * BCInfo; //nvmJitByteCodeInfo structure that //will retain the results of the bytecode //analysis InstructionInfo * BCInfoArray; //Array of InstructionInfo uint32_t numInstructions; //Number of Instructions uint32_t *LocalsReferences = NULL; //Locals Refs Array int32_t StackLimit = 0; //Operands Stack Size uint16_t LocalsSize = 0; //Locals Region Size uint32_t i; uint32_t xchBufUse = FALSE, datMemUse = FALSE, shdMemUse = FALSE; uint32_t diffStackDepth = FALSE; uint32_t result = 0; if (segment == NULL){ return NULL; } if (segment->SegmentSize == 0){ return NULL; } if (segment->SegmentType == PORT_SEGMENT){ return NULL; } BCInfo = New_ByteCode_Info(segment, errList); if (BCInfo == NULL){ return NULL; } if (segment->SegmentType == INIT_SEGMENT){ SET_INITIAL_STACK(sp, 0); // .init segment } else { SET_INITIAL_STACK(sp, 1); // the calling port is on the stack } StackLimit = segment->MaxStackSize; LocalsSize = segment->LocalsSize; if (LocalsSize != 0){ //Allocate the Locals References Array LocalsReferences = (uint32_t *) CALLOC(LocalsSize, sizeof(uint32_t)); if (LocalsReferences == NULL){ return NULL; } } else{ LocalsReferences = NULL; } VERB0(JIT_BUILD_BLOCK_LVL2, "\n___________________ ByteCode Analysis Step: ____________________\n\n"); VERB1(JIT_BUILD_BLOCK_LVL2, "\t>Segment Name: %s\n", segment->Name); VERB1(JIT_BUILD_BLOCK_LVL2, "\t>Locals Size: %d\n", LocalsSize); VERB1(JIT_BUILD_BLOCK_LVL2, "\t>Max Stack Size: %d\n\n", StackLimit); BCInfoArray = BCInfo->BCInfoArray; numInstructions = BCInfo->NumInstructions; pc = 0; // BBCount = 0; maxStackDepth = sp; //first instruction is BB leader: // Add_First_Basic_Block(BCInfoArray, pc, sp, &BBCount); Add_First_Basic_Block(BCInfoArray, pc, sp, BBCount); while (pc < numInstructions){ switch(BCInfoArray[pc].Opcode){ case RET: case SNDPKT: nvmFLAG_SET(BCInfoArray[pc].Flags, FLAG_RET_INSN); // only END OF BB Set_End_Of_Basic_Block(BCInfoArray,pc,sp, NO_STACK_ELEMENTS, RET_OUT_EDGES); //Next statement is Basic Block Leader (if in the segment) if ((pc + 1) < numInstructions){ // Set_Basic_Block_Leader(BCInfoArray, pc + 1, 0, &BBCount); Set_Basic_Block_Leader(BCInfoArray, pc + 1, 0, BBCount); sp = BCInfoArray[pc + 1].StackDepth; } break; // JUMPS NO STACK OPERATIONS case JUMP: case JUMPW: // diffStackDepth = Manage_JUMP(BCInfo, pc, BCInfoArray[pc].Arguments[0],sp, &BBCount); diffStackDepth = Manage_JUMP(BCInfo, pc, BCInfoArray[pc].Arguments[0],sp, BBCount); if (diffStackDepth){ nvmFLAG_SET(BCInfo->AnalysisFlags, FLAG_STACK_MERGE); // Analysis_Error(errList, FLAG_STACK_MERGE, BCInfoArray[pc].Arguments[0], sp, BBCount); Analysis_Error(errList, FLAG_STACK_MERGE, &BCInfoArray[BCInfoArray[pc].Arguments[0]], 0, sp, *BBCount); } if ((pc + 1) < numInstructions){ sp = BCInfoArray[pc + 1].StackDepth; } break; //BRANCHES STACK TRANSITION: value ==> ... case JEQ: case JNE: /* case BJFLDEQ: case BJFLDNEQ: case BJFLDLT: case BJFLDLE: case BJFLDGT: case BJFLDGE: case SJFLDEQ: case SJFLDNEQ: case SJFLDLT: case SJFLDLE: case SJFLDGT: case SJFLDGE: case IJFLDEQ: case IJFLDNEQ: case IJFLDLT: case IJFLDLE: case IJFLDGT: case IJFLDGE: */ // diffStackDepth = Manage_BRANCH(BCInfo, pc, BCInfoArray[pc].Arguments[0], sp, ONE_STACK_ELEMENT, &BBCount); diffStackDepth = Manage_BRANCH(BCInfo, pc, BCInfoArray[pc].Arguments[0], sp, ONE_STACK_ELEMENT, BBCount); if (diffStackDepth){ nvmFLAG_SET(BCInfo->AnalysisFlags, FLAG_STACK_MERGE); // Analysis_Error(errList, FLAG_STACK_MERGE, BCInfoArray[pc].Arguments[0], sp, BBCount); Analysis_Error(errList, FLAG_STACK_MERGE, &BCInfoArray[BCInfoArray[pc].Arguments[0]], 0, sp, *BBCount); } result |= Stack_POP(&sp, ONE_STACK_ELEMENT); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; case SWITCH: // diffStackDepth = Manage_BRANCH(BCInfo, pc, BCInfoArray[pc].SwInfo->DefTarget, sp, ONE_STACK_ELEMENT, &BBCount); diffStackDepth = Manage_BRANCH(BCInfo, pc, BCInfoArray[pc].SwInfo->DefTarget, sp, ONE_STACK_ELEMENT, BBCount); if (diffStackDepth){ nvmFLAG_SET(BCInfo->AnalysisFlags, FLAG_STACK_MERGE); // Analysis_Error(errList, FLAG_STACK_MERGE, BCInfoArray[pc].Arguments[0], sp, BBCount); Analysis_Error(errList, FLAG_STACK_MERGE, &BCInfoArray[BCInfoArray[pc].Arguments[0]], 0, sp, *BBCount); } for ( i = 0; i < BCInfoArray[pc].SwInfo->NumCases; i++ ) { // diffStackDepth = Manage_BRANCH(BCInfo, pc, BCInfoArray[pc].SwInfo->CaseTargets[i], sp, ONE_STACK_ELEMENT, &BBCount); diffStackDepth = Manage_BRANCH(BCInfo, pc, BCInfoArray[pc].SwInfo->CaseTargets[i], sp, ONE_STACK_ELEMENT, BBCount); //diffStackDepth = Manage_BRANCH(BCInfo, pc, BCInfoArray[pc].SwInfo->CaseTargets[i], sp, NO_STACK_ELEMENTS, &BBCount); if (diffStackDepth){ nvmFLAG_SET(BCInfo->AnalysisFlags, FLAG_STACK_MERGE); // Analysis_Error(errList, FLAG_STACK_MERGE, BCInfoArray[pc].Arguments[0], sp, BBCount); Analysis_Error(errList, FLAG_STACK_MERGE, &BCInfoArray[BCInfoArray[pc].Arguments[0]], 0, sp, *BBCount); } } result |= Stack_POP(&sp, ONE_STACK_ELEMENT); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; //BRANCHES STACK TRANSITION: value, value ==> ... case JCMPEQ: case JCMPNEQ: case JCMPG: case JCMPGE: case JCMPL: case JCMPLE: case JCMPG_S: case JCMPGE_S: case JCMPL_S: case JCMPLE_S: /* case BMJFLDEQ: case SMJFLDEQ: case IMJFLDEQ: */ // diffStackDepth = Manage_BRANCH(BCInfo, pc, BCInfoArray[pc].Arguments[0], sp, TWO_STACK_ELEMENTS, &BBCount); diffStackDepth = Manage_BRANCH(BCInfo, pc, BCInfoArray[pc].Arguments[0], sp, TWO_STACK_ELEMENTS, BBCount); if (diffStackDepth){ nvmFLAG_SET(BCInfo->AnalysisFlags, FLAG_STACK_MERGE); // Analysis_Error(errList, FLAG_STACK_MERGE, BCInfoArray[pc].Arguments[0], sp, BBCount); Analysis_Error(errList, FLAG_STACK_MERGE, &BCInfoArray[BCInfoArray[pc].Arguments[0]], 0, sp, *BBCount); } result |= Stack_POP(&sp, TWO_STACK_ELEMENTS); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; //field comparisons STACK TRANSITION: value, value, value ==> ... case JFLDEQ: case JFLDNEQ: case JFLDLT: case JFLDGT: // diffStackDepth = Manage_BRANCH(BCInfo, pc, BCInfoArray[pc].Arguments[0], sp, THREE_STACK_ELEMENTS, &BBCount); diffStackDepth = Manage_BRANCH(BCInfo, pc, BCInfoArray[pc].Arguments[0], sp, THREE_STACK_ELEMENTS, BBCount); if (diffStackDepth){ nvmFLAG_SET(BCInfo->AnalysisFlags, FLAG_STACK_MERGE); // Analysis_Error(errList, FLAG_STACK_MERGE, BCInfoArray[pc].Arguments[0], sp, BBCount); Analysis_Error(errList, FLAG_STACK_MERGE, &BCInfoArray[BCInfoArray[pc].Arguments[0]], 0, sp, *BBCount); } result |= Stack_POP(&sp, THREE_STACK_ELEMENTS); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; // PUSHes STACK TRANSITION: ... ==> value case PUSH: case CONST_1: case CONST_2: case CONST_0: case CONST__1: // case TSTAMP: case IRND: case TSTAMP_S: case TSTAMP_US: case IRND: case PBL: case COPIN: case COPINIT: Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_PUSH(&sp, StackLimit, ONE_STACK_ELEMENT); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; // LOCALS LOAD STACK TRANSITION: ... ==> value case LOCLD: Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Local_LD(LocalsReferences, BCInfoArray[pc].Arguments[0], LocalsSize, &sp, StackLimit); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; // DUP STACK TRANSITION: value ==> value, value case DUP: Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_DUP(&sp, StackLimit); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; // PUSH2 STACK TRANSITION: ... ==> value, value case PUSH2: Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_PUSH(&sp, StackLimit, TWO_STACK_ELEMENTS); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; //( STACK TRANSITION: value ==> ... ) case POP: case SLEEP: case COPOUT: Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_POP(&sp, ONE_STACK_ELEMENT); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; // LOCALS STORE STACK TRANSITION: value ==> ... case LOCST: Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Local_ST(LocalsReferences, BCInfoArray[pc].Arguments[0], LocalsSize, &sp); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; //( STACK TRANSITION: value, value ==> value ) // BIT CLEAR /SET /TEST: case SETBIT: case CLEARBIT: case FLIPBIT: case TESTBIT: case TESTNBIT: // SHIFTs and ROTs: case SHL: case SHR: case USHR: case ROTL: case ROTR: // ARITHMETIC & LOGIC OPs: case ADD: case ADDSOV: case ADDUOV: case SUB: case SUBSOV: case SUBUOV: case IMUL: case IMULSOV: case IMULUOV: case OR: case AND: case XOR: case MOD: // PACKET SCAN case PSCANB: case PSCANW: case PSCANDW: // COMPARISON case CMP: case CMP_S: Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_POP(&sp, TWO_STACK_ELEMENTS); Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_PUSH(&sp, StackLimit, ONE_STACK_ELEMENT); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; //( STACK TRANSITION: value ==> value ) // LOADs case PBLDS: case PBLDU: case PSLDS: case PSLDU: case PILD: case DBLDS: case DBLDU: case DSLDS: case DSLDU: case DILD: case SBLDS: case SBLDU: case SSLDS: case SSLDU: case SILD: case ISBLD: case ISSLD: case ISSBLD: case ISSSLD: case ISSILD: case NEG: case NOT: case BPLOAD_IH: // (1 POP -> 1 PUSH) case IINC_1: case IDEC_1: case IESWAP: case CLZ: Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_POP(&sp, ONE_STACK_ELEMENT); Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_PUSH(&sp, StackLimit, ONE_STACK_ELEMENT); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; // TODO OM: inc e dec... /* case IINC_2: case IINC_3: case IINC_4: case IDEC_2: case IDEC_3: case IDEC_4: break; */ //( STACK TRANSITION: value, value ==> ... ) // STOREs (2 POP) case DBSTR: case DSSTR: case DISTR: case PBSTR: case PSSTR: case PISTR: case SBSTR: case SSSTR: case SISTR: case IBSTR: case ISSTR: case IISTR: Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_POP(&sp, TWO_STACK_ELEMENTS); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; // MASKED COMP STACK TRANSITION: value, value, value ==> value ) case MCMP: Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_POP(&sp, THREE_STACK_ELEMENTS); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_PUSH(&sp, StackLimit, ONE_STACK_ELEMENT); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; // POP_I (i POPs) case POP_I: Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_POP(&sp, BCInfoArray[pc].Arguments[0]); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; // SWAP STACK TRANSITION: value, value ==> value, value) case SWAP: Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_POP(&sp, TWO_STACK_ELEMENTS); Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result |= Stack_PUSH(&sp, StackLimit, TWO_STACK_ELEMENTS); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result,&BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; // MEMCOPY STACK TRANSITION: value, value, value ==> ...) case DPMCPY: case PDMCPY: case DSMCPY: case SDMCPY: case SPMCPY: case PSMCPY: Update_Instr_Stack_Depth(BCInfoArray, pc, sp); result = Stack_POP(&sp, THREE_STACK_ELEMENTS); if (result != 0){ BCInfo->AnalysisFlags |= result; // Analysis_Error(errList, result, pc, sp, BBCount); Analysis_Error(errList, result, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; // INIT INSTRUCTIONS case SSMSIZE: //case LOADE: case STOREE: //exceptions not implemented if (strcmp(segment->Name, ".init") != 0){ BCInfo->AnalysisFlags |= FLAG_INIT_OP_IN_OTHER_SEG; // Analysis_Error(errList, FLAG_INIT_OP_IN_OTHER_SEG, pc, sp, BBCount); Analysis_Error(errList, FLAG_INIT_OP_IN_OTHER_SEG, &BCInfoArray[pc], 0, sp, *BBCount); } BCInfoArray[pc].StackAfter = sp; break; //Packet Instructions STACK TRANSITION: ... ==> ...) /*case SNDPKT: */ case RCVPKT: case DSNDPKT: case DELEXBUF: case COPRUN: case COPPKTOUT: case INFOCLR: case NOP: // NOTHING break; default: //TODO: analyse Bytecode: OTHER instr VERB2(JIT_BUILD_BLOCK_LVL2, "%d --> OPCODE NOT IMPLEMENTED: %s\n",pc, nvmOpCodeTable[BCInfoArray[pc].Opcode].CodeName); BCInfo->AnalysisFlags |= FLAG_OP_NOT_IMPLEMENTED; // Analysis_Error(errList, FLAG_OP_NOT_IMPLEMENTED, pc, sp, BBCount); Analysis_Error(errList, FLAG_OP_NOT_IMPLEMENTED, &BCInfoArray[pc], 0, sp, *BBCount); break; } // Test for memory usage: switch (BCInfoArray[pc].Opcode){ /* case BJFLDEQ: case BJFLDNEQ: case BJFLDLT: case BJFLDLE: case BJFLDGT: case BJFLDGE: case SJFLDEQ: case SJFLDNEQ: case SJFLDLT: case SJFLDLE: case SJFLDGT: case SJFLDGE: case IJFLDEQ: case IJFLDNEQ: case IJFLDLT: case IJFLDLE: case IJFLDGT: case IJFLDGE: */ case JFLDEQ: case JFLDNEQ: case JFLDLT: case JFLDGT: case BPLOAD_IH: case PBLDS: case PBLDU: case PSLDS: case PSLDU: case PILD: case PSCANB: case PSCANW: case PSCANDW: xchBufUse = TRUE; break; case DBLDS: case DBLDU: case DSLDS: case DSLDU: case DILD: datMemUse = TRUE; break; case SBLDS: case SBLDU: case SSLDS: case SSLDU: case SILD: shdMemUse = TRUE; break; case DPMCPY: case PDMCPY: xchBufUse = TRUE; datMemUse = TRUE; break; case DSMCPY: case SDMCPY: shdMemUse = TRUE; datMemUse = TRUE; break; case SPMCPY: case PSMCPY: xchBufUse = TRUE; shdMemUse = TRUE; break; } //current instruction has been visited nvmFLAG_SET(BCInfoArray[pc].Flags, FLAG_VISITED); maxStackDepth=MAX(sp, maxStackDepth); if (BCInfo->AnalysisFlags != 0){ return NULL; } pc++; } BCInfo->MaxStackDepth = maxStackDepth; BCInfo->NumBasicBlocks = *BBCount + 1; BCInfo->LocalsReferences = LocalsReferences; BCInfo->LocalsUse = Get_Locals_Use(LocalsReferences, LocalsSize); BCInfo->DatMemUse = datMemUse; BCInfo->ShdMemUse = shdMemUse; BCInfo->XchBufUse = xchBufUse; return BCInfo; } //tries to match the patterns {RET} and {POP-RET} on the bytecode uint32_t nvmJitIs_Segment_Empty(nvmJitByteCodeInfo *BCInfo) { if (BCInfo->BCInfoArray[0].Opcode == POP){ if (BCInfo->BCInfoArray[1].Opcode == RET) return TRUE; return FALSE; } else if (BCInfo->BCInfoArray[0].Opcode == RET){ return TRUE; } else return FALSE; }
[ [ [ 1, 1537 ] ] ]
f7c398e06a9ce24f27d9a791eeb1dbde70126088
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/Dependencies/Xerces/include/xercesc/util/NetAccessors/libWWW/LibWWWNetAccessor.hpp
1a1a1a9f006221a570601f3a1019011ed05942a8
[]
no_license
svn2github/ngene
b2cddacf7ec035aa681d5b8989feab3383dac012
61850134a354816161859fe86c2907c8e73dc113
refs/heads/master
2023-09-03T12:34:18.944872
2011-07-27T19:26:04
2011-07-27T19:26:04
78,163,390
2
0
null
null
null
null
UTF-8
C++
false
false
1,806
hpp
/* * Copyright 1999-2000,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Id: LibWWWNetAccessor.hpp 191054 2005-06-17 02:56:35Z jberry $ */ #if !defined(LIBWWWNETACCESSOR_HPP) #define LIBWWWNETACCESSOR_HPP #include <xercesc/util/XercesDefs.hpp> #include <xercesc/util/XMLURL.hpp> #include <xercesc/util/BinInputStream.hpp> #include <xercesc/util/XMLNetAccessor.hpp> XERCES_CPP_NAMESPACE_BEGIN // // This class is the wrapper for the libWWW library which provides // support for HTTP and other network protocols, so that URL's using // these protocols can be used in system id's in the XML decl clauses. // class XMLUTIL_EXPORT LibWWWNetAccessor : public XMLNetAccessor { public : LibWWWNetAccessor(); ~LibWWWNetAccessor(); BinInputStream* makeNew(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo=0); const XMLCh* getId() const; private : static const XMLCh fgMyName[]; LibWWWNetAccessor(const LibWWWNetAccessor&); LibWWWNetAccessor& operator=(const LibWWWNetAccessor&); }; // LibWWWNetAccessor inline const XMLCh* LibWWWNetAccessor::getId() const { return fgMyName; } XERCES_CPP_NAMESPACE_END #endif // LIBWWWNETACCESSOR_HPP
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 63 ] ] ]
90319e5a9994d4ad76cb43bed6c00df32a876c10
dadf8e6f3c1adef539a5ad409ce09726886182a7
/airplay/h/toeGeoGpsLocation.h
0ff14ec0f8574c0f03a70d95cfd8ea8857f80db4
[]
no_license
sarthakpandit/toe
63f59ea09f2c1454c1270d55b3b4534feedc7ae3
196aa1e71e9f22f2ecfded1c3da141e7a75b5c2b
refs/heads/master
2021-01-10T04:04:45.575806
2011-06-09T12:56:05
2011-06-09T12:56:05
53,861,788
0
0
null
null
null
null
UTF-8
C++
false
false
627
h
#pragma once #include <toeComponent.h> #include <toeSelfRenderedComponent.h> namespace TinyOpenEngine { class CtoeGeoGpsLocation : public CtoeComponent { protected: public: //Declare managed class IW_MANAGED_DECLARE(CtoeGeoGpsLocation); //Constructor CtoeGeoGpsLocation(); //Desctructor virtual ~CtoeGeoGpsLocation(); //Reads/writes a binary file using @a IwSerialise interface. virtual void Serialise (); #ifdef IW_BUILD_RESOURCES //Parses from text file: parses attribute/value pair. virtual bool ParseAttribute(CIwTextParserITX* pParser, const char* pAttrName); #endif }; }
[ [ [ 1, 25 ] ] ]
e6a307e3a56dc47f863a835afd4af615f96ccae3
1493997bb11718d3c18c6632b6dd010535f742f5
/battleship/win32/battleship.cpp
08ea333562bad5cb461922be4baf2c22e459b1ed
[]
no_license
kovrov/scrap
cd0cf2c98a62d5af6e4206a2cab7bb8e4560b168
b0f38d95dd4acd89c832188265dece4d91383bbb
refs/heads/master
2021-01-20T12:21:34.742007
2010-01-12T19:53:23
2010-01-12T19:53:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,420
cpp
// battleship.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "battleship.h" #include "view.h" #include <assert.h> #include <cstdlib> // game stuff #include "../game/logic.h" #include "../game/ai.h" #include "../game/board.h" // support #include <vector> #include <map> #include <exception> #include <stdlib.h> #include <time.h> #include <boost/foreach.hpp> #define foreach BOOST_FOREACH #define MAX_LOADSTRING 100 #define WIDGET_MARGIN 3 // Global Variables: HINSTANCE hInst; // current instance TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name HWND hwndMapView = NULL; HWND hwndRadarView = NULL; HWND hwndMain = NULL; DWORD g_worker_thread_id = 0; #define MSG_GAME_STATE_CHANGED WM_APP+0 #define MSG_USER_INPUT WM_APP+1 enum { UI_PLAYERMOVE, UI_NEWGAME, UI_QUIT }; void on_new_game() { ::PostThreadMessage(g_worker_thread_id, MSG_USER_INPUT, UI_NEWGAME, 0); } std::vector<board::Ship> filter_inactive(const std::vector<board::Ship>& ships) { std::vector<board::Ship> inactive_ships; inactive_ships.reserve(ships.size()); foreach (const board::Ship& ship, ships) { bool active = false; foreach (const board::ShipSegment& segment, ship.segments) { if (segment.active) { active = true; break; } } if (!active) inactive_ships.push_back(ship); } return inactive_ships; } DWORD WINAPI game_thread(LPVOID lpParameter) { logic::PLAYER_HANDLE player = 0; logic::PLAYER_HANDLE opponent = 1; logic::Game game(player, opponent); std::map<logic::PLAYER_HANDLE, ai::ComputerPlayer> players; srand((unsigned)time(NULL)); MSG msg; while (::GetMessage(&msg, NULL, 0, 0)) { if (MSG_GAME_STATE_CHANGED == msg.message) { switch (game.GetState()) { case logic::BATTLE_STARTED: // temp assert (logic::BATTLE_STARTED == game.GetState()); // setup ships game.Setup(player, ai::setup_ships(10, game.GetConfig())); game.Setup(opponent, ai::setup_ships(10, game.GetConfig())); // HACK!!! TODO: implement state change notification in game library ::PostThreadMessage(g_worker_thread_id, MSG_GAME_STATE_CHANGED, 0, 0); // reset state players[player] = ai::ComputerPlayer(10, game.GetConfig()); players[opponent] = ai::ComputerPlayer(10, game.GetConfig()); break; case logic::PLAYER_TURN: { // update widget SetMapWidgetData(hwndMapView, &game.GetPlayerShips(player), &game.GetPlayerShots(opponent)); SetMapWidgetData(hwndRadarView, &filter_inactive(game.GetPlayerShips(opponent)), &game.GetPlayerShots(player)); logic::PLAYER_HANDLE current_player_id = game.GetCurrentPlayer(); //if (current_player_id == opponent) ::Sleep(500); ai::ComputerPlayer& current_player = players[current_player_id]; board::Pos shot = current_player.Shot(); board::SHOT res = game.Shoot(current_player_id, shot); // HACK!!! TODO: implement state change notification in game library ::PostThreadMessage(g_worker_thread_id, MSG_GAME_STATE_CHANGED, 0, 0); current_player.Track(shot, res); } break; case logic::BATTLE_ENDED: // update widget SetMapWidgetData(hwndMapView, &game.GetPlayerShips(player), &game.GetPlayerShots(opponent)); SetMapWidgetData(hwndRadarView, &game.GetPlayerShips(opponent), &game.GetPlayerShots(player)); //printf("%d win, shots made: %d\n", game.GetCurrentPlayer(), shots_made[game.GetCurrentPlayer()]); break; } } else if (MSG_USER_INPUT == msg.message) { if (UI_PLAYERMOVE == msg.wParam) { if (game.GetState() == logic::PLAYER_TURN && game.GetCurrentPlayer() == player) { board::SHOT res = game.Shoot(player, board::Pos(LOWORD(msg.lParam), HIWORD(msg.lParam))); // HACK!!! TODO: implement state change notification in game library ::PostThreadMessage(g_worker_thread_id, MSG_GAME_STATE_CHANGED, 0, 0); } } else if (UI_NEWGAME == msg.wParam) { // HACK!!! TODO: implement state change notification in game library ::PostThreadMessage(g_worker_thread_id, MSG_GAME_STATE_CHANGED, 0, 0); } } } return 0; } // Forward declarations of functions included in this code module: ATOM RegisterMainWindowClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // TODO: Place code here. MSG msg; HACCEL hAccelTable; // Initialize global strings ::LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); ::LoadString(hInstance, IDC_BATTLESHIP, szWindowClass, MAX_LOADSTRING); RegisterMainWindowClass(hInstance); // Perform application initialization: if (!::InitInstance(hInstance, nCmdShow)) return FALSE; hAccelTable = ::LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_BATTLESHIP)); HANDLE hgame = ::CreateThread(NULL, 0, &game_thread, NULL, 0, &g_worker_thread_id); // Main message loop: while (::GetMessage(&msg, NULL, 0, 0)) { if (!::TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } } ::TerminateThread(hgame, 0); return msg.wParam; } ATOM RegisterMainWindowClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = &WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = ::LoadIcon(hInstance, MAKEINTRESOURCE(IDI_BATTLESHIP)); wcex.hCursor = ::LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = NULL; // no background wcex.lpszMenuName = MAKEINTRESOURCE(IDC_BATTLESHIP); wcex.lpszClassName = szWindowClass; wcex.hIconSm = ::LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); return ::RegisterClassEx(&wcex); } BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { hInst = hInstance; // Store instance handle in our global variable hwndMain = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, // WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); assert (hwndMain); ::SetWindowPos(hwndMain, NULL,0,0,0,0, SWP_NOMOVE|SWP_NOZORDER); // hack to update MINMAXINFO ::ShowWindow(hwndMain, nCmdShow); ::UpdateWindow(hwndMain); return TRUE; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: ::DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: ::DestroyWindow(hWnd); break; case IDM_NEWGAME: on_new_game(); break; default: return ::DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_NOTIFY: if (BSN_SQUARESELECTED == reinterpret_cast<NMHDR*>(lParam)->code) { BSNSquareInfo* si = reinterpret_cast<BSNSquareInfo*>(lParam); ::PostThreadMessage(g_worker_thread_id, MSG_USER_INPUT, UI_PLAYERMOVE, MAKELPARAM(si->pos.x, si->pos.y)); } break; case WM_CREATE: hwndMapView = CreateMapWidget(hWnd); assert (hwndMapView); hwndRadarView = CreateMapWidget(hWnd); assert (hwndRadarView); SetMapWidgetThemeColor(hwndRadarView, SEA_FOREROUND_COLOR, 0xFF60A060); SetMapWidgetThemeColor(hwndRadarView, SEA_BACKGROUND_COLOR, 0xFF80C080); SetMapWidgetThemeColor(hwndRadarView, SHIP_FOREGROUND_COLOR, 0xFFC0F0C0); SetMapWidgetThemeColor(hwndRadarView, SHIP_BACKGROUND_COLOR, 0xFFB0E0B0); SetMapWidgetThemeColor(hwndRadarView, HIT_FOREGROUND_COLOR, 0xFFC0F0C0); SetMapWidgetThemeColor(hwndRadarView, HIT_BACKGROUND_COLOR, 0xFFF0FFF0); break; case WM_DESTROY: ::PostQuitMessage(0); break; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = ::BeginPaint(hWnd, &ps); RECT clientRect; ::GetClientRect(hWnd, &clientRect); HBRUSH hbr = ::GetSysColorBrush(COLOR_APPWORKSPACE); RECT rect = clientRect; rect.bottom = WIDGET_MARGIN; ::FillRect(hdc, &rect, hbr); rect = clientRect; rect.top = rect.bottom - WIDGET_MARGIN; ::FillRect(hdc, &rect, hbr); rect = clientRect; rect.right = WIDGET_MARGIN; ::FillRect(hdc, &rect, hbr); rect = clientRect; rect.left = rect.right - WIDGET_MARGIN; ::FillRect(hdc, &rect, hbr); rect = clientRect; rect.left = rect.right / 2 - WIDGET_MARGIN/2; rect.right = rect.left + WIDGET_MARGIN; ::FillRect(hdc, &rect, hbr); ::EndPaint(hWnd, &ps); } return 0; case WM_SIZE: { int width = LOWORD(lParam); int height = HIWORD(lParam); MINMAXINFO mminfo; ::SendMessage(hwndMapView, WM_GETMINMAXINFO, 0, (LPARAM)&mminfo); int min_size = WIDGET_MARGIN*3 + mminfo.ptMinTrackSize.x*2; int max_size = WIDGET_MARGIN*3 + mminfo.ptMaxTrackSize.x*2; int left_margin = WIDGET_MARGIN; int right_margin = WIDGET_MARGIN; if (width < min_size) // window too small { assert (false); } else if (width > max_size) // window too big { left_margin = (width - max_size)/2 + WIDGET_MARGIN; right_margin = width - left_margin + WIDGET_MARGIN; } ::MoveWindow(hwndMapView, left_margin, WIDGET_MARGIN, width, height, TRUE); RECT rect; ::GetClientRect(hwndMapView, &rect); ::MoveWindow(hwndRadarView, left_margin + rect.right + WIDGET_MARGIN, WIDGET_MARGIN, width, height, TRUE); } return 0; case WM_GETMINMAXINFO: { RECT rectMapView, rectRadarView; if (::GetClientRect(hwndMapView, &rectMapView) && ::GetClientRect(hwndRadarView, &rectRadarView)) { int menu_y = ::GetSystemMetrics(SM_CYMENU); int frame_y = ::GetSystemMetrics(SM_CYSIZEFRAME); // SM_CYFIXEDFRAME int frame_x = ::GetSystemMetrics(SM_CXSIZEFRAME); // SM_CXFIXEDFRAME int caption_y = ::GetSystemMetrics(SM_CYCAPTION); MINMAXINFO* minmaxinfo = reinterpret_cast<MINMAXINFO*>(lParam); minmaxinfo->ptMinTrackSize.x = rectMapView.right + frame_x*2 + rectRadarView.right + WIDGET_MARGIN*3; minmaxinfo->ptMinTrackSize.y = rectMapView.bottom + frame_y*2 + menu_y + caption_y + WIDGET_MARGIN*2; //minmaxinfo->ptMaxTrackSize.x = minmaxinfo->ptMinTrackSize.x; //minmaxinfo->ptMaxTrackSize.y = minmaxinfo->ptMinTrackSize.y; } } break; default: return ::DefWindowProc(hWnd, message, wParam, lParam); } return 0; } // Message handler for about box. INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); switch (message) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { ::EndDialog(hDlg, LOWORD(wParam)); return TRUE; } break; } return FALSE; }
[ [ [ 1, 401 ] ] ]
f9ee5acb8aaeafa2ae3f124d88f4804eb4f22229
8c234510906db9ae4e724c8efb0238892cb3a128
/apps/StereoGR/GROptions.cpp
07e23bcbabad07adc7c5fa3bd951efa29da0a416
[ "BSD-3-Clause" ]
permissive
hcl3210/opencv
7b8b752982afaf402a361eb8475c24e7f4c08671
b34b1c3540716a3dadfd2b9e3bbc4253774c636d
refs/heads/master
2020-05-19T12:45:52.864577
2008-08-20T01:57:54
2008-08-20T01:57:54
177,025
2
0
null
null
null
null
UTF-8
C++
false
false
3,302
cpp
/*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to this license. // If you do not agree to this license, do not download, install, // copy or use the software. // // // Intel License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2000, Intel Corporation, all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistribution's of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistribution's 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. // // * The name of Intel Corporation may not be used to endorse or promote products // derived from this software without specific prior written permission. // // This software is provided by the copyright holders and contributors "as is" and // any express or implied warranties, including, but not limited to, the implied // warranties of merchantability and fitness for a particular purpose are disclaimed. // In no event shall the Intel Corporation or contributors be liable for any direct, // indirect, incidental, special, exemplary, or consequential damages // (including, but not limited to, procurement of substitute goods or services; // loss of use, data, or profits; or business interruption) however caused // and on any theory of liability, whether in contract, strict liability, // or tort (including negligence or otherwise) arising in any way out of // the use of this software, even if advised of the possibility of such damage. // //M*/// GROptions.cpp : implementation file // #include "stdafx.h" #include "stereogr.h" #include "GROptions.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CGROptions property page IMPLEMENT_DYNCREATE(CGROptions, CPropertyPage) CGROptions::CGROptions() : CPropertyPage(CGROptions::IDD) { //{{AFX_DATA_INIT(CGROptions) m_maskImprove = FALSE; m_segThresh = 0; m_frameCount = 0; //}}AFX_DATA_INIT } CGROptions::~CGROptions() { } void CGROptions::DoDataExchange(CDataExchange* pDX) { CPropertyPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CGROptions) DDX_Check(pDX, IDC_MASKIMPROVE, m_maskImprove); DDX_Text(pDX, IDC_SEGTHRESH, m_segThresh); DDX_Text(pDX, IDC_SFRAMECOUNT, m_frameCount); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CGROptions, CPropertyPage) //{{AFX_MSG_MAP(CGROptions) // NOTE: the ClassWizard will add message map macros here //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CGROptions message handlers
[ [ [ 1, 89 ] ] ]
c0c7e8ff096a715a25460763c11ed756d51a057d
4d5ee0b6f7be0c3841c050ed1dda88ec128ae7b4
/src/nvmesh/import/MeshImportMD5.cpp
a5f965826a73e8a4daa8d58143c7ced19498aa4c
[]
no_license
saggita/nvidia-mesh-tools
9df27d41b65b9742a9d45dc67af5f6835709f0c2
a9b7fdd808e6719be88520e14bc60d58ea57e0bd
refs/heads/master
2020-12-24T21:37:11.053752
2010-09-03T01:39:02
2010-09-03T01:39:02
56,893,300
0
1
null
null
null
null
UTF-8
C++
false
false
6,766
cpp
// This code is in the public domain -- [email protected] #include <nvcore/StrLib.h> #include <nvcore/Tokenizer.h> #include <nvmath/Vector.h> #include <nvmesh/animation/Bone.h> #include "MeshImportMD5.h" using namespace nv; namespace { bool parseVector(Tokenizer & parser, float * out, int num) { if (!parser.nextToken() || parser.token() != "(") return false; for (int i = 0; i < num; i++) { if (!parser.nextToken()) return false; out[i] = parser.token().toFloat(); } if (!parser.nextToken() || parser.token() != ")") return false; return true; } bool parseVector3(Tokenizer & parser, Vector3 * vec) { float v[3]; if (!parseVector(parser, v, 3)) return false; *vec = Vector3(v[0], v[1], v[2]); return true; } bool parseVector2(Tokenizer & parser, Vector2 * vec) { float v[2]; if (!parseVector(parser, v, 2)) return false; *vec = Vector2(v[0], v[1]); return true; } } // namespace /// Import a MD5 mesh file. bool MeshImportMD5::import(Stream * stream) { Tokenizer parser(stream); parser.setDelimiters("(){}"); // Reset mesh. m_builder.reset(); const char * name = "???"; // Get version. if (!parser.nextLine() || parser.token() != "MD5Version") { nvDebug("*** Error, invalid MD5 file: '%s'\n", name); return false; } if (!parser.nextToken() || parser.token() != "10") { nvDebug("*** Error, '%s' has an invalid version: %s != 10\n", name, parser.token().toString().str()); return false; } while (parser.nextLine()) { if (parser.token() == "commandline") { parser.nextToken(); nvDebug("--- Command line: \"%s\"\n", parser.token().toString().str()); } else if (parser.token() == "numJoints") { parser.nextToken(); int n = parser.token().toInt(); nvDebug("--- %d joints.\n", n); m_skeleton.boneArray().reserve(n); } else if (parser.token() == "numMeshes") { parser.nextToken(); int n = parser.token().toInt(); nvDebug( "--- %d meshes.\n", n ); } else if (parser.token() == "joints") { if (!parseJoints(parser)) { nvDebug( "*** Error, parsing joints in file '%s'.\n", name ); return false; } } else if (parser.token() == "mesh") { if (!parseMesh(parser)) { nvDebug( "*** Error, parsing mesh in file '%s'.\n", name ); return false; } } else if (parser.token() == "//") { // skip line. } else { nvDebug( "*** Error, unexpected token '%s' in file '%s'.\n", parser.token().toString().str(), name ); return false; } } // Init the mesh in the default pose. m_skeleton.setDefaultPose(); const uint vertexCount = m_skeleton.vertexArray().count(); m_builder.hintPositionCount(vertexCount); for (uint i = 0; i < vertexCount; i++) { m_builder.addPosition(m_skeleton.vertexAt(i).pos); } m_builder.done(); return true; } // Parse joints. bool MeshImportMD5::parseJoints(Tokenizer & parser) { parser.nextToken(true); if (parser.token() != "{") { return false; } while (parser.nextLine()) { if (parser.token() == "}") { // done; return true; } else if (parser.token() == "//") { // skip line. } else { String name = parser.token().toString(); if (!parser.nextToken()) break; int parent = parser.token().toInt(); Vector3 offset; if (!parseVector3(parser, &offset)) break; Vector3 tmp; if (!parseVector3(parser, &tmp)) break; Quaternion rotation; float r = 1.0f - length_squared(tmp); if( r < 0.0f ) { rotation = Quaternion(tmp.x(), tmp.y(), tmp.z(), 0.0f); } else { rotation = Quaternion(tmp.x(), tmp.y(), tmp.z(), sqrtf(r)); } // No need to normalize! //rotation = normalize(rotation); m_skeleton.addAbsoluteBone(name, parent, rotation, offset); } } // @@ Premature end of file! return false; } /// Parse the mesh. bool MeshImportMD5::parseMesh(Tokenizer & parser) { // Count vertices and links before adding this mesh. uint base_vertex = m_skeleton.vertexArray().count(); uint base_link = m_skeleton.linkArray().count(); parser.nextToken(true); if (parser.token() != "{") { return false; } while (parser.nextLine()) { if (parser.token() == "shader") { parser.nextToken(); m_builder.beginMaterial(parser.token().toString()); } else if (parser.token() == "numverts") { parser.nextToken(); int n = parser.token().toInt(); m_builder.hintVertexCount(n); m_builder.hintTexCoordCount(n); m_skeleton.vertexArray().reserve(m_skeleton.vertexArray().count() + n); } else if (parser.token() == "vert") { // skip index. parser.nextToken(); int idx = parser.token().toInt(); Vector2 texcoord; parseVector2(parser, &texcoord); m_builder.addTexCoord(texcoord); Skeleton::Vertex vertex; parser.nextToken(); vertex.link_first = base_link + parser.token().toInt(); parser.nextToken(); vertex.link_num = parser.token().toInt(); m_skeleton.vertexArray().append(vertex); } else if (parser.token() == "numtris") { parser.nextToken(); int n = parser.token().toInt(); m_builder.hintTriangleCount(n); } else if (parser.token() == "tri") { // skip index. parser.nextToken(); int idx = parser.token().toInt(); m_builder.beginPolygon(); parser.nextToken(); idx = base_vertex + parser.token().toInt(); m_builder.addVertex(idx, NIL, idx); parser.nextToken(); idx = base_vertex + parser.token().toInt(); m_builder.addVertex(idx, NIL, idx); parser.nextToken(); idx = base_vertex + parser.token().toInt(); m_builder.addVertex(idx, NIL, idx); m_builder.endPolygon(); } else if (parser.token() == "numweights") { parser.nextToken(); int n = parser.token().toInt(); m_skeleton.linkArray().reserve(m_skeleton.linkArray().count() + n); } else if (parser.token() == "weight") { // skip index. parser.nextToken(); int idx = parser.token().toInt(); Skeleton::Link link; parser.nextToken(); link.bone = parser.token().toInt(); parser.nextToken(); link.weight = parser.token().toFloat(); parseVector3(parser, &link.offset); m_skeleton.linkArray().append(link); } else if (parser.token() == "}") { return true; } else if (parser.token() == "//") { // skip line. } else { nvDebug("*** Error, unexpected token '%s'.\n", parser.token().toString().str()); break; } } // @@ Premature end of file! return false; }
[ "castano@0f2971b0-9fc2-11dd-b4aa-53559073bf4c" ]
[ [ [ 1, 314 ] ] ]
ad5cf98a6c9534d9ca08d5f4a7f618512031bd6f
eda410906c2ec64689d8c0b84f3c2862f469144b
/DropSendCore/data/entities/user.h
6a743282c7b888b5836baa7e2882bed13d209a45
[]
no_license
redbox/Dropsend
640ea157a2caec88aa145f5bdc7fa85db95203a5
8fe4b4478616b9850b55011a506653026a28f7da
refs/heads/master
2020-06-02T20:54:18.301786
2010-09-06T16:16:05
2010-09-06T16:16:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,871
h
#ifndef USER_H #define USER_H #include <QString> #include "./../entitywithid.h" namespace dropsend { namespace data { namespace dao { namespace remoteserver { /// Used for implementing "Abstract factory" design pattern. class RemoteServerUserDAO; } } } } namespace dropsend { namespace data { namespace entities { /** * @class User * @brief Contains information about user. Service default user's model. Data model class. * @see dropsend::data::entities::EntityWithId **/ class User : public EntityWithId { /** * @brief Used for implementing "Abstract factory" design pattern. **/ friend class dao::remoteserver::RemoteServerUserDAO; public: /** * @brief Initializes a new instance of the dropsend::data::entities::User class. **/ User(); /** * @brief Gets account's ID. * @returns Account's ID. **/ int getAccountId() const; /** * @brief Gets user's first name. * @returns User's first name. **/ QString getFirstName() const; /** * @brief Gets user's last name. * @returns User's last name. **/ QString getLastName() const; /** * @brief Checks whether user is owner of account. * @returns True if user is owner of account, False otherwise. **/ bool isOwner() const; /** * @brief Checks whether user has internal account. * @returns True if user has internal account, False otherwise. **/ bool isInternal() const; private: /** * @brief Account's ID **/ int account_id_; /** * @brief User's first name. **/ QString first_name_; /** * @brief User's last name. **/ QString last_name_; /** * @brief Whether user is owner of account. **/ bool is_owner_; /** * @brief Whether user has internal account. **/ bool is_internal_; }; } } } #endif // USER_H
[ [ [ 1, 98 ] ] ]
0709be42058390b2a869c0ad456831468b71b96e
47513f62271d11d9134c6998767149ee330a4e88
/ACM_2_0_45_OSD/libraries/AP_GPS/AP_GPS_UBLOX.cpp
408659d519beb8b32bb6441723d01f222782d89f
[]
no_license
MacDev240/ArduPilotMega_OSD-with-Ublox-3D-DGPS
51e6a6b3678e0ef9b924e7ef664c4a94608041c0
2b7f6a8b01c70a2534bf4454bab5420f18389e29
refs/heads/master
2016-09-06T15:49:48.600420
2011-09-26T20:07:53
2011-09-26T20:07:53
2,436,975
2
0
null
null
null
null
UTF-8
C++
false
false
5,384
cpp
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*- // // u-blox UBX GPS driver for ArduPilot and ArduPilotMega. // Code by Michael Smith, Jordi Munoz and Jose Julio, DIYDrones.com // // This library is free software; you can redistribute it and / or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // #include "AP_GPS_UBLOX.h" #include <stdint.h> // Constructors //////////////////////////////////////////////////////////////// AP_GPS_UBLOX::AP_GPS_UBLOX(Stream *s) : GPS(s) { } // Public Methods ////////////////////////////////////////////////////////////// void AP_GPS_UBLOX::init(void) { // XXX it might make sense to send some CFG_MSG,CFG_NMEA messages to get the // right reporting configuration. _port->flush(); _epoch = TIME_OF_WEEK; idleTimeout = 1200; } // Process bytes available from the stream // // The stream is assumed to contain only messages we recognise. If it // contains other messages, and those messages contain the preamble // bytes, it is possible for this code to fail to synchronise to the // stream immediately. Without buffering the entire message and // re-processing it from the top, this is unavoidable. The parser // attempts to avoid this when possible. // bool AP_GPS_UBLOX::read(void) { uint8_t data; int numc; bool parsed = false; numc = _port->available(); for (int i = 0; i < numc; i++){ // Process bytes received // read the next byte data = _port->read(); switch(_step){ // Message preamble detection // // If we fail to match any of the expected bytes, we reset // the state machine and re-consider the failed byte as // the first byte of the preamble. This improves our // chances of recovering from a mismatch and makes it less // likely that we will be fooled by the preamble appearing // as data in some other message. // case 1: if (PREAMBLE2 == data) { _step++; break; } _step = 0; // FALLTHROUGH case 0: if(PREAMBLE1 == data) _step++; break; // Message header processing // // We sniff the class and message ID to decide whether we // are going to gather the message bytes or just discard // them. // // We always collect the length so that we can avoid being // fooled by preamble bytes in messages. // case 2: _step++; if (CLASS_NAV == data) { _gather = true; // class is interesting, maybe gather _ck_b = _ck_a = data; // reset the checksum accumulators } else { _gather = false; // class is not interesting, discard } break; case 3: _step++; _ck_b += (_ck_a += data); // checksum byte _msg_id = data; if (_gather) { // if class was interesting switch(data) { case MSG_POSLLH: // message is interesting _expect = sizeof(ubx_nav_posllh); break; case MSG_STATUS: _expect = sizeof(ubx_nav_status); break; case MSG_SOL: _expect = sizeof(ubx_nav_solution); break; case MSG_VELNED: _expect = sizeof(ubx_nav_velned); break; default: _gather = false; // message is not interesting } } break; case 4: _step++; _ck_b += (_ck_a += data); // checksum byte _payload_length = data; // payload length low byte break; case 5: _step++; _ck_b += (_ck_a += data); // checksum byte _payload_length += (uint16_t)data; // payload length high byte _payload_counter = 0; // prepare to receive payload if (_payload_length != _expect) _gather = false; break; // Receive message data // case 6: _ck_b += (_ck_a += data); // checksum byte if (_gather) // gather data if requested _buffer.bytes[_payload_counter] = data; if (++_payload_counter == _payload_length) _step++; break; // Checksum and message processing // case 7: _step++; if (_ck_a != data) _step = 0; // bad checksum break; case 8: _step = 0; if (_ck_b != data) break; // bad checksum if (_gather) { parsed = _parse_gps(); // Parse the new GPS packet } } } return parsed; } // Private Methods ///////////////////////////////////////////////////////////// bool AP_GPS_UBLOX::_parse_gps(void) { switch (_msg_id) { case MSG_POSLLH: time = _buffer.posllh.time; longitude = _buffer.posllh.longitude; latitude = _buffer.posllh.latitude; altitude = _buffer.posllh.altitude_msl / 10; break; case MSG_STATUS: fix = (_buffer.status.fix_status & NAV_STATUS_FIX_VALID) && (_buffer.status.fix_type == FIX_3D); break; case MSG_SOL: fix = (_buffer.solution.fix_status & NAV_STATUS_FIX_VALID) && (_buffer.solution.fix_type == FIX_3D); num_sats = _buffer.solution.satellites; hdop = _buffer.solution.position_DOP; break; case MSG_VELNED: speed_3d = _buffer.velned.speed_3d; // cm/s ground_speed = _buffer.velned.speed_2d; // cm/s ground_course = _buffer.velned.heading_2d / 1000; // Heading 2D deg * 100000 rescaled to deg * 100 break; default: return false; } return true; }
[ [ [ 1, 194 ] ] ]
a358abf6b982c16e351daa2306cbf2037b50b15b
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/_Interface/WndMap.cpp
efa3278f4b9a3851757e473e008ab1c3251f5a85
[]
no_license
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UHC
C++
false
false
2,330
cpp
#include "stdafx.h" #include "AppDefine.h" #include "WndMap.h" #include "WorldMap.h" /**************************************************** WndId : APP_MAP - Map ****************************************************/ CWndMap::CWndMap() { } CWndMap::~CWndMap() { } void CWndMap::OnDraw( C2DRender* p2DRender ) { } void CWndMap::OnInitialUpdate() { #if __VER >= 9 // __INSERT_MAP #else CWndNeuz::OnInitialUpdate(); // 여기에 코딩하세요 SetTexture( m_pApp->m_pd3dDevice, MakePath( DIR_ITEM, m_szMapFile), TRUE ); FitTextureSize(); // 윈도를 중앙으로 옮기는 부분. CRect rectRoot = m_pWndRoot->GetLayoutRect(); CRect rectWindow = GetWindowRect(); CPoint point( rectRoot.right - rectWindow.Width(), 110 ); Move( point ); MoveParentCenter(); #endif } // 처음 이 함수를 부르면 윈도가 열린다. BOOL CWndMap::Initialize( CWndBase* pWndParent, DWORD /*dwWndId*/ ) { #if __VER >= 9 // __INSERT_MAP CWorldMap* pWorldMap = CWorldMap::GetInstance(); // 렌더링중이면 끄고 아니면 켠다 if(pWorldMap->IsRender()) pWorldMap->DeleteWorldMap(); else pWorldMap->LoadWorldMap(); return FALSE; #else // Daisy에서 설정한 리소스로 윈도를 연다. return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_MAP, 0, CPoint( 0, 0 ), pWndParent ); #endif } /* 직접 윈도를 열때 사용 BOOL CWndMap::Initialize( CWndBase* pWndParent, DWORD dwWndId ) { CRect rectWindow = m_pWndRoot->GetWindowRect(); CRect rect( 50 ,50, 300, 300 ); SetTitle( _T( "title" ) ); return CWndNeuz::Create( WBS_THICKFRAME | WBS_MOVE | WBS_SOUND | WBS_CAPTION, rect, pWndParent, dwWndId ); } */ BOOL CWndMap::OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase ) { return CWndNeuz::OnCommand( nID, dwMessage, pWndBase ); } void CWndMap::OnSize( UINT nType, int cx, int cy ) \ { CWndNeuz::OnSize( nType, cx, cy ); } void CWndMap::OnLButtonUp( UINT nFlags, CPoint point ) { } void CWndMap::OnRButtonUp( UINT nFlags, CPoint point ) { Destroy(); } void CWndMap::OnLButtonDown( UINT nFlags, CPoint point ) { } BOOL CWndMap::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { return CWndNeuz::OnChildNotify( message, nID, pLResult ); }
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 90 ] ] ]
c8e5c1cc1974c36ad6f70494a0ca9bd47972a560
d81bbe5a784c804f59f643fcbf84be769abf2bc9
/Gosling/src/GosVisualizer.cpp
0c94353000ea6ab6d60d1e1666b0d84e875e22d0
[]
no_license
songuke/goslingviz
9d071691640996ee88171d36f7ca8c6c86b64156
f4b7f71e31429e32b41d7a20e0c151be30634e4f
refs/heads/master
2021-01-10T03:36:25.995930
2010-04-16T08:49:27
2010-04-16T08:49:27
36,341,765
0
0
null
null
null
null
UTF-8
C++
false
false
215
cpp
#include "GosVisualizer.h" namespace Gos { Visualizer::Visualizer(void) : timeElapsed(0) { } Visualizer::~Visualizer(void) { } void Visualizer::update(int delta) { timeElapsed += delta; } }
[ "songuke@00dcdb3d-b287-7056-8bd8-84a1afe327dc" ]
[ [ [ 1, 19 ] ] ]
1508e2e920f7a5aa62b36e55a6ce53af5307ee2c
14a00dfaf0619eb57f1f04bb784edd3126e10658
/Lab1/HalfEdgeMesh.cpp
46991979f877774c1d82a7b47b696c96f086fd14
[]
no_license
SHINOTECH/modanimation
89f842262b1f552f1044d4aafb3d5a2ce4b587bd
43d0fde55cf75df9d9a28a7681eddeb77460f97c
refs/heads/master
2021-01-21T09:34:18.032922
2010-04-07T12:23:13
2010-04-07T12:23:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,614
cpp
/************************************************************************************************* * * Modeling and animation (TNM079) 2007 * Code base for lab assignments. Copyright: * Gunnar Johansson ([email protected]) * Ken Museth ([email protected]) * Michael Bang Nielsen ([email protected]) * Ola Nilsson ([email protected]) * Andreas Sderstrm ([email protected]) * *************************************************************************************************/ #include "HalfEdgeMesh.h" #include "ColorMap.h" #ifdef __APPLE__ #include "GLUT/glut.h" #else #include "GL/glut.h" #endif #include <limits> #include <queue> #include <set> #include <vector> const unsigned int HalfEdgeMesh::BORDER = std::numeric_limits<unsigned int>::max(); const unsigned int HalfEdgeMesh::UNINITIALIZED = std::numeric_limits<unsigned int>::max()-1; bool sortEdges( std::pair<unsigned int, bool> a, std::pair<unsigned int, bool> b) { return a.second>b.second; } HalfEdgeMesh::HalfEdgeMesh() { } HalfEdgeMesh::~HalfEdgeMesh() { } //----------------------------------------------------------------------------- bool HalfEdgeMesh::addTriangle(const Vector3<float> &v1, const Vector3<float> &v2, const Vector3<float> & v3){ // Add the vertices of the face/triangle unsigned int ind1, ind2, ind3; addVertex(v1, ind1); addVertex(v2, ind2); addVertex(v3, ind3); // Add all half-edge pairs unsigned int edgeind1, edgeind2, edgeind3; unsigned int edgeind1pair, edgeind2pair, edgeind3pair; bool newEdge1 = addHalfEdgePair( ind1, ind2, edgeind1, edgeind1pair ); bool newEdge2 = addHalfEdgePair( ind2, ind3, edgeind2, edgeind2pair ); bool newEdge3 = addHalfEdgePair( ind3, ind1, edgeind3, edgeind3pair ); std::vector<std::pair<unsigned int, bool> > edges; edges.push_back( std::make_pair( edgeind1, newEdge1) ); edges.push_back( std::make_pair( edgeind2, newEdge2) ); edges.push_back( std::make_pair( edgeind3, newEdge3) ); // Connect inner ring mEdges.at( edgeind1 ).next = edgeind2; mEdges.at( edgeind1 ).prev = edgeind3; mEdges.at( edgeind2 ).next = edgeind3; mEdges.at( edgeind2 ).prev = edgeind1; mEdges.at( edgeind3 ).next = edgeind1; mEdges.at( edgeind3 ).prev = edgeind2; // Finally, create the face Face f; f.edge = edgeind1; mFaces.push_back( f ); // All half-edges share the same left face (previously added) int index = mFaces.size()-1; mEdges.at( edgeind1 ).face = index; mEdges.at( edgeind2 ).face = index; mEdges.at( edgeind3 ).face = index; // new edges precede existent ones sort( edges.begin(), edges.end(), sortEdges ); for(int i=0,endI=edges.size(); i<endI; i++) { //BORDER EDGE if ( edges.at(i).second ) { //pass the inner edge insertBoundaryEdge( edges.at(i).first ); } //CONNECT TO ANOTHER EDGE else { //pass the pair mergeBoundaryEdge( edges.at(i).first ); } } return true; } //----------------------------------------------------------------------------- bool HalfEdgeMesh::addVertex(const Vector3<float> & v, unsigned int &indx){ std::map<Vector3<float>,unsigned int>::iterator it = mUniqueVerts.find(v); if (it != mUniqueVerts.end()){ indx = (*it).second; // (*it).second == it.second, which to me was not as clear... return false; } mUniqueVerts[v] = indx = mVerts.size(); // op. [ ] constructs a new entry in map Vertex vert; vert.vec = v; mVerts.push_back(vert); return true; } bool HalfEdgeMesh::addHalfEdgePair(unsigned int v1, unsigned int v2, unsigned int &indx1, unsigned int &indx2) { // Search for the HalfEdge pair among existing edges std::vector<HalfEdge>::reverse_iterator iter = mEdges.rbegin(); std::vector<HalfEdge>::reverse_iterator iend = mEdges.rend(); while (iter != iend) { if ((*iter).vert == v1 && mEdges[(*iter).pair].vert == v2) { indx1 = iter.base() - mEdges.begin() - 1; indx2 = (*iter).pair; return false; } iter++; } // If not found, add both half-edges indx1 = mEdges.size(); indx2 = indx1+1; // Create edges and set pair index HalfEdge edge1, edge2; edge1.pair = indx2; edge2.pair = indx1; // Connect the edges to the verts edge1.vert = v1; edge2.vert = v2; // Connect the verts to the edges mVerts[v1].edge = indx1; mVerts[v2].edge = indx2; // Store the edges mEdges.push_back(edge1); mEdges.push_back(edge2); return true; } void HalfEdgeMesh::mergeBoundaryEdge(unsigned int indx) { //Find the previous border int prev(0); int prevPair = mEdges[indx].pair; while( BORDER != mEdges[prevPair].face ) { prev = mEdges[prevPair].prev; prevPair = mEdges[prev].pair; //make sure we don't loop infinitely if( mEdges[indx].face == mEdges[prevPair].face ) { return; } } //Find the next border int next(0); int nextPair = indx; while( BORDER != mEdges[nextPair].face && ( UNINITIALIZED != mEdges[nextPair].face ) ) { next = mEdges[nextPair].next; nextPair = mEdges[next].pair; //make sure we don't loop infinitely if( mEdges[indx].face == mEdges[nextPair].face ) { return; } } //link borders mEdges[prevPair].prev = nextPair; mEdges[nextPair].next = prevPair; } void HalfEdgeMesh::insertBoundaryEdge( unsigned int indx ) { //Set the face of the edge's pair to border int pair = mEdges[indx].pair; mEdges[pair].face = BORDER; //Find the next border int prev(0); int next = indx; while( ( BORDER != mEdges[next].face ) && ( UNINITIALIZED != mEdges[next].face ) ) { prev = mEdges[next].prev; next = mEdges[prev].pair; } //link PAIR of the current with the next mEdges[pair].next = next; mEdges[next].prev = pair; //Find the previous border prev = indx; while( ( BORDER != mEdges[prev].face ) && ( UNINITIALIZED != mEdges[prev].face ) ) { next = mEdges[prev].next; prev = mEdges[next].pair; } //link PAIR of the current with the previous mEdges[pair].prev = prev; mEdges[prev].next = pair; } void HalfEdgeMesh::validate() { std::vector<HalfEdge>::iterator iterEdge = mEdges.begin(); std::vector<HalfEdge>::iterator iterEdgeEnd = mEdges.end(); while (iterEdge != iterEdgeEnd) { if ((*iterEdge).face == UNINITIALIZED || (*iterEdge).next == UNINITIALIZED || (*iterEdge).pair == UNINITIALIZED || (*iterEdge).prev == UNINITIALIZED || (*iterEdge).vert == UNINITIALIZED) std::cerr << "HalfEdge " << iterEdge - mEdges.begin() << " not properly initialized" << std::endl; iterEdge++; } std::cerr << "Done with edge check (checked " << mEdges.size() << " edges)" << std::endl; std::vector<Face>::iterator iterFace = mFaces.begin(); std::vector<Face>::iterator iterFaceEnd = mFaces.end(); while (iterFace != iterFaceEnd) { if ((*iterFace).edge == UNINITIALIZED) std::cerr << "Face " << iterFace - mFaces.begin() << " not properly initialized" << std::endl; iterFace++; } std::cerr << "Done with face check (checked " << mFaces.size() << " faces)" << std::endl; std::vector<Vertex>::iterator iterVertex = mVerts.begin(); std::vector<Vertex>::iterator iterVertexEnd = mVerts.end(); while (iterVertex != iterVertexEnd) { if ((*iterVertex).edge == UNINITIALIZED) std::cerr << "Vertex " << iterVertex - mVerts.begin() << " not properly initialized" << std::endl; iterVertex++; } std::cerr << "Done with vertex check (checked " << mVerts.size() << " vertices)" << std::endl; std::cerr << "Looping through triangle neighborhood of each vertex... "; iterVertex = mVerts.begin(); iterVertexEnd = mVerts.end(); std::vector<unsigned int> foundTriangles; int emptyCount = 0; while (iterVertex != iterVertexEnd) { if (!findNeighbourTriangles(iterVertex - mVerts.begin(), foundTriangles)) emptyCount++; iterVertex++; } std::cerr << std::endl << "Done: " << emptyCount << " isolated vertices found" << std::endl; } //----------------------------------------------------------------------------- bool HalfEdgeMesh::findNeighbourTriangles(const unsigned int vertexIndex, std::vector<unsigned int>& foundTriangles) const { foundTriangles.clear(); unsigned int edge = mVerts.at( vertexIndex ).edge; //go to the previous so we can always proceed in the same way in the loop edge = mEdges[edge].prev; int pair = edge; int next(0); //find the neighbours do { //For non manifold surfaces if( BORDER != mEdges[pair ].face ) { foundTriangles.push_back( mEdges.at( pair ).face ); } next = mEdges[pair].next; pair = mEdges[next].pair; } while( pair != edge ); return !(foundTriangles.size() == 0); } float HalfEdgeMesh::area() { float totalArea(0); unsigned int numTriangles = mFaces.size(); for (unsigned int i = 0; i < numTriangles; i++) { totalArea += calculateFaceNormal( i ).length() / 2.0f; } return totalArea; } float HalfEdgeMesh::volume() { float totalVolume(0); unsigned int numTriangles = mFaces.size(); for (unsigned int i = 0; i < numTriangles; i++) { Vector3<float> normal = calculateFaceNormal( i ); float length = normal.length(); normal.normalize(); int edgeIndex1 = mFaces.at(i).edge; int edgeIndex2 = mEdges.at( edgeIndex1 ).next; int edgeIndex3 = mEdges.at( edgeIndex2 ).next; Vertex v1 = mVerts.at( mEdges.at( edgeIndex1 ).vert ); Vertex v2 = mVerts.at( mEdges.at( edgeIndex2 ).vert ); Vertex v3 = mVerts.at( mEdges.at( edgeIndex3 ).vert ); float area = length / 2.0f; totalVolume += (( v1.vec + v2.vec + v3.vec ) / 3.0f)*normal * area; } return totalVolume/3.0f; } int HalfEdgeMesh::genus() const { int E = mEdges.size() / 2; //half edge is just a half edge int V = mVerts.size(); int F = mFaces.size(); int S = shells(); std::cerr << "Shells: " << S << std::endl; return (E-V-F)/2 + S; } int HalfEdgeMesh::shells() const { int numberOfShells = 0; // std::queue<int> vertexQueue; std::set<int> vertexQueue; std::set<int> vertexSet; //vertexQueue.push( 0 ); vertexQueue.insert(0); std::cout << "Vertices: " << mVerts.size() << std::endl; int v; std::set<int>::iterator position; int totalVerts = mVerts.size(); //Browse vertices until all are inserted to the set while (vertexSet.size() != totalVerts) { //OPTIMIZE! //Search one vertex which is still NOT in the set for (int vertIndex = 0; vertIndex<totalVerts; vertIndex++ ) { if( vertexSet.end() == vertexSet.find( vertIndex )) { vertexQueue.insert(vertIndex); break; } } //fill the current set (shell) while(!vertexQueue.empty()) { // v = vertexQueue.front(); position = vertexQueue.begin(); v = *position; // vertexQueue.pop(); vertexQueue.erase( position ); vertexSet.insert( v ); //std::cout << "Value: " << v << std::endl; //std::cout << "vque: " << vertexQueue.size() << std::endl; //std::cout << "vertset: " << vertexSet.size() << std::endl; std::vector<unsigned int> faces; findNeighbourTriangles(v, faces); for (int i=0,endI=faces.size();i<endI;i++) { std::vector<unsigned int> verts; getTriangleVerts( faces.at(i), verts ); for (int j=0, endJ=verts.size(); j<endJ; j++) { int vj = verts.at(j); if ( vertexSet.end() != vertexSet.find(vj) ) { //Do nothing } else { //vertexQueue.push(vj); vertexQueue.insert(vj); } } } } numberOfShells++; } return numberOfShells; } void HalfEdgeMesh::getTriangleVerts(int aTriangle, std::vector<unsigned int>& aVerts ) const { //mFaces.at( aTriangle ).ha int edge1 = mFaces.at( aTriangle).edge; aVerts.push_back( mEdges.at(edge1).vert ); int edge2 = mEdges.at(edge1).next; aVerts.push_back( mEdges.at(edge2).vert ); int edge3 = mEdges.at(edge2).next; aVerts.push_back( mEdges.at(edge3).vert ); } float HalfEdgeMesh::curvature(const unsigned int vertexIndex, const Vector3<float>& n) { printf("Curvature calculation not implemented for half-edge mesh!\n"); return 0; } void HalfEdgeMesh::calculateFaceNormals() { std::cerr << "calculateFaceNormals() in HalfEdgeMesh.cpp not implemented" << std::endl; unsigned int numTriangles = mFaces.size(); for (unsigned int i = 0; i < numTriangles; i++){ HalfEdge* edge = &mEdges[mFaces[i].edge]; Vector3<float>& p0 = mVerts[edge->vert].vec; edge = &mEdges[edge->next]; Vector3<float>& p1 = mVerts[edge->vert].vec; edge = &mEdges[edge->next]; Vector3<float>& p2 = mVerts[edge->vert].vec; // Calculate face normal Vector3<float> v1 = p1-p0; Vector3<float> v2 = p2-p0; Vector3<float> n = cross(v1,v2); mFaces[i].normal = n.normalize(); // assign normal to face } } void HalfEdgeMesh::calculateVertexNormals() { std::vector<unsigned int> foundTriangles; for (int i=0, endI=mVerts.size(); i<endI; i++) { findNeighbourTriangles(i, foundTriangles ); Vector3<float> normal; int endJ=foundTriangles.size(); for (int j=0; j<endJ; j++) { normal += calculateFaceNormal( foundTriangles[j] ).normalize(); } normal = normal/endJ; mNormals.push_back( normal ); } } Vector3<float> HalfEdgeMesh::calculateFaceNormal( unsigned int aTriangle ) { //For non manifold surfaces if( BORDER == aTriangle ) { printf("calculateFaceNormal: BORDER edge found!\n"); exit(1); } HalfEdge* edge = &mEdges[mFaces[aTriangle].edge]; Vector3<float>& p0 = mVerts[edge->vert].vec; edge = &mEdges[edge->next]; Vector3<float>& p1 = mVerts[edge->vert].vec; edge = &mEdges[edge->next]; Vector3<float>& p2 = mVerts[edge->vert].vec; // Calculate face normal Vector3<float> v1 = p1-p0; Vector3<float> v2 = p2-p0; Vector3<float> n = cross(v1,v2); return n; } //----------------------------------------------------------------------------- void HalfEdgeMesh::draw() { ColorMap colorMap; glMatrixMode(GL_MODELVIEW); // Apply transform glPushMatrix(); // Push modelview matrix onto stack // Convert transform-matrix to format matching GL matrix format GLfloat glMatrix[16]; mTransform.toGLMatrix(glMatrix); // Load transform into modelview matrix glLoadMatrixf(glMatrix); // Draw geometry glBegin(GL_TRIANGLES); const int numTriangles = mFaces.size(); for (int i = 0; i < numTriangles; i++){ HalfEdge* edge = &mEdges[mFaces[i].edge]; Vector3<float>& p0 = mVerts[edge->vert].vec; edge = &mEdges[edge->next]; Vector3<float>& p1 = mVerts[edge->vert].vec; edge = &mEdges[edge->next]; Vector3<float>& p2 = mVerts[edge->vert].vec; if (getShadingFlag() == FLAT_SHADING){ Vector3<float>& n = mFaces[i].normal; Vector3<float> color = colorMap.map(n, -1, 1); glColor3f(color[0],color[1], color[2]); glNormal3f(n[0], n[1], n[2]); glVertex3f(p0[0], p0[1], p0[2]); glVertex3f(p1[0], p1[1], p1[2]); glVertex3f(p2[0], p2[1], p2[2]); } else if (getShadingFlag() == SMOOTH_SHADING){ HalfEdge* edge = &mEdges[mFaces[i].edge]; unsigned int v1 = edge->vert; edge = &mEdges[edge->next]; unsigned int v2 = edge->vert; edge = &mEdges[edge->next]; unsigned int v3 = edge->vert; // Fetching normals - the normal index is the same as the vertex index Vector3<float>& n0 = mNormals[v1]; Vector3<float>& n1 = mNormals[v2]; Vector3<float>& n2 = mNormals[v3]; // Color mapping, maps the normal components to R,G,B. From [-1, 1] to [0,1] respectively Vector3<float> color0 = colorMap.map(n0, -1, 1); Vector3<float> color1 = colorMap.map(n1, -1, 1); Vector3<float> color2 = colorMap.map(n2, -1, 1); glColor3f(color0[0],color0[1], color0[2]); glNormal3f(n0[0], n0[1], n0[2]); glVertex3f(p0[0], p0[1], p0[2]); glColor3f(color1[0],color1[1], color1[2]); glNormal3f(n1[0], n1[1], n1[2]); glVertex3f(p1[0], p1[1], p1[2]); glColor3f(color2[0],color2[1], color2[2]); glNormal3f(n2[0], n2[1], n2[2]); glVertex3f(p2[0], p2[1], p2[2]); } else{ // No normals glVertex3f(p0[0], p0[1], p0[2]); glVertex3f(p1[0], p1[1], p1[2]); glVertex3f(p2[0], p2[1], p2[2]); } } glEnd(); // Restore modelview matrix glPopMatrix(); }
[ "jpjorge@da195381-492e-0410-b4d9-ef7979db4686", "onnepoika@da195381-492e-0410-b4d9-ef7979db4686" ]
[ [ [ 1, 1 ], [ 12, 26 ], [ 32, 32 ], [ 35, 36 ], [ 39, 58 ], [ 63, 64 ], [ 66, 81 ], [ 85, 86 ], [ 88, 94 ], [ 96, 100 ], [ 102, 104 ], [ 107, 111 ], [ 114, 114 ], [ 122, 122 ], [ 125, 127 ], [ 164, 174 ], [ 181, 189 ], [ 196, 221 ], [ 224, 237 ], [ 288, 291 ], [ 294, 297 ], [ 300, 305 ], [ 311, 317 ], [ 320, 321 ], [ 323, 344 ], [ 346, 455 ], [ 460, 460 ], [ 463, 463 ], [ 466, 466 ], [ 469, 483 ], [ 487, 488 ], [ 490, 510 ], [ 518, 536 ], [ 578, 592 ] ], [ [ 2, 11 ], [ 27, 31 ], [ 33, 34 ], [ 37, 38 ], [ 59, 62 ], [ 65, 65 ], [ 82, 84 ], [ 87, 87 ], [ 95, 95 ], [ 101, 101 ], [ 105, 106 ], [ 112, 113 ], [ 115, 121 ], [ 123, 124 ], [ 128, 163 ], [ 175, 180 ], [ 190, 195 ], [ 222, 223 ], [ 238, 287 ], [ 292, 293 ], [ 298, 299 ], [ 306, 310 ], [ 318, 319 ], [ 322, 322 ], [ 345, 345 ], [ 456, 459 ], [ 461, 462 ], [ 464, 465 ], [ 467, 468 ], [ 484, 486 ], [ 489, 489 ], [ 511, 517 ], [ 537, 577 ], [ 593, 623 ] ] ]
43da6467bc5df90c753b25eba7bb42250b68dd6e
4a9370ade4c3484d818765ab15e260cb1537694b
/solver/solver.cpp
54053d38d4bc37d2b813e7186d28966ad0183ff5
[]
no_license
briandore/brian_ED
74fa664d53d0da57354225e0f29d9dbb46ce9b19
1c0b12cd82dc48041d2f8646f0a3fcecbfbb6e7e
refs/heads/master
2021-01-25T03:48:13.084136
2011-06-20T06:13:59
2011-06-20T06:13:59
1,754,120
0
0
null
null
null
null
UTF-8
C++
false
false
8,398
cpp
#include "solver.h" #include "ui_solver.h" solver::solver(QWidget *parent) : QMainWindow(parent), ui(new Ui::solver) { ui->setupUi(this); this->lenX = 0 ; this->lenY = 0; this->init = false; this->min = 3; this->ui->dockWidget->setMinimumSize(100,500); } solver::~solver() { delete ui; } void solver::on_actionLoad_words_triggered() { this->ui->listWidget->clear(); this->list.clear(); QString filename = QFileDialog::getOpenFileName(this,"Lista"); QFile file; file.setFileName(filename); file.open(QFile::ReadOnly); if(file.isOpen()){ while(!file.atEnd()){ QString line = file.readLine().trimmed(); if(!line.isEmpty()) if(!line.contains(" ")) if(!list.contains(line)){ list.append(line.toUpper()); this->lista.addword3(line.toUpper()); } } } this->ui->listWidget->addItems(this->list); qDebug()<<this->list.count(); } void solver::liberar(){ for(int i = 0; i<this->lenY; i++) { free(this->sopa[i]); this->sopa[i] = NULL; } free(this->sopa); this->sopa = NULL; this->lenX = this->lenY = 0; this->init = false; } #include<QLabel> #include<QTableWidgetItem> void solver::on_actionLoad_Soup_triggered() { QString f = QFileDialog::getOpenFileName(this," sopa","Cargar sopa de letras"); if(f.isEmpty()) return; QLabel *l ; QTableWidgetItem *item; QFile file(f); ; if(file.open(QIODevice::ReadOnly)){ QTextStream a(&file); // QString len = a.readLine(); // this->lenX = readLen(len.indexOf("x:"),len); // this->lenY = readLen(len.indexOf("y:"),len); // for(int y = 0; y < this->lenY; y++){ int y = 0; while(!a.atEnd()){ QString i = a.readLine().trimmed(); int at = 0; if(y== 0){ while(this->ui->soup->count() > 0) this->ui->soup->removeItem(this->ui->soup->itemAt(0)); this->lenX = i.length(); this->lenY = lenX;this->crearArray(); } if(y == lenY) break; for(int x = 0; x < this->lenX; x++){ l = new QLabel(); this->ui->soup->addWidget(l,y,x); l->setText(QString(i.at(x)));l->setMinimumSize(12,12); sopa[y][x] = i.at(x); //at ++; // item = new QTableWidgetItem(QString(i.at(x))); //this->ui->lasoup->setItem(y,x,item); } y+=1; } } //imprimir(); } void solver::lookUpwords(QString line,QString arcline){ if(line.length()< this->min) {return;} for(int i = this->min; i<(line.count() +1); i++){ int result = this->lista.lookup3(line.left(i)); if(result == 0)break; if(result == 2){ this->ans.append(line.left(i)); cont++; } } for(int i = this->min; i<(arcline.count()+1); i++){ int result = this->lista.lookup3(arcline.left(i)); if(result == 0)break; if(result == 2){ this->ans.append(arcline.left(i)); cont++; } } lookUpwords(line.mid(1),arcline.mid(1)); } void solver::lookUpInHV(dir d){ QString wordU="", wordD="", wordL="",wordR=""; for(int i = 0; i < this->lenX;i++){ wordU=""; wordD=""; wordL=""; wordR=""; for(int j = 0; j< this->lenY;j++ ){ wordU += sopa[j][i]; wordD.prepend(sopa[j][i]); wordR += sopa[i][j]; wordL.prepend(sopa[i][j]); } // qDebug()<<wordD<<"WordU: "<<wordU<<"wordR: "<<wordR<<"wordL"<<wordL; this->lookUpwords(wordD,wordU); this->lookUpwords(wordR,wordL); } } void solver::lookVerticals(){ this->lookUpInHV(Vertical); } void solver::lookHorizontals(){ this->lookUpInHV(Horizontal); } void solver::lookDiagonal1(){ QString word, arcword, wordL,arcwordL;; for(int i = (this->min-1); i<this->lenY; i++){ word="", arcword="",wordL="", arcwordL="";; for(int j = 1;j<=i; j++ ){ word+= this->sopa[lenY-j][i-j]; arcword.prepend(this->sopa[lenY-j][i-j]); wordL+= this->sopa[i-j][lenX-j]; arcwordL.prepend(this->sopa[i-j][lenX-j]); } this->lookUpwords(word,arcword); this->lookUpwords(wordL,arcwordL); } } void solver::lookDiagonal2(){ QString word, arcword, wordL,arcwordL, word2, arcword2,wordL2, arcwordL2; for(int i = (this->min - 1); i < this->lenY; i++){ word="", arcword="",wordL="", arcwordL=""; word2="", arcword2="",wordL2="", arcwordL2="";; for(int j = 0;j<=i; j++ ){ word+= this->sopa[j][i-j]; arcword.prepend(this->sopa[j][i-j]); if(i < (this->lenY -1)){ wordL+= this->sopa[lenY-1-j][lenX-i+j-1]; arcwordL.prepend(this->sopa[lenY-1-j][lenX-i+j-1]); } word2+= this->sopa[lenY-j -1][i-j]; arcword2.prepend(this->sopa[lenY-j-1][i-j]); if((i-j) != (lenX-j-1)){ wordL2+= this->sopa[i-j][lenX-j-1]; arcwordL2.prepend(this->sopa[i-j][lenX-j-1]); } } // qDebug()<<word<<"arcword: "<<arcword<<"word2: "<<word2<<"arc2"<<arcword2; // qDebug()<<wordL<<"arcwordL: "<<arcwordL<<"wordL2: "<<wordL2<<"arcL2"<<arcwordL2; this->lookUpwords(word,arcword); this->lookUpwords(wordL,arcwordL); this->lookUpwords(word2,arcword2); this->lookUpwords(wordL2,arcwordL2); } } void solver::crearArray(){ if(this->init) this->liberar(); this->sopa = (QChar **) malloc(this->lenY * sizeof(QChar *)); for(int i = 0; i < this->lenY; i++) this->sopa[i] = (QChar *) malloc(this->lenX * sizeof(QChar)); // this->ui->lasoup->clear(); // this->ui->lasoup->setRowCount(this->lenY); // this->ui->lasoup->setColumnCount(this->lenX); this->init = true; } void solver::imprimir(){ QString g=""; for(int i = 0; i < lenY;i++){ qDebug()<<"\n"; for(int j = 0; j < this->lenX; j++) g +=this->sopa[i][j]; qDebug()<<g; } } int solver::readLen(int where, QString num) { QString go = num.mid(where+2,2); qDebug()<<go; return go.toInt(); } #include <QTime> void solver::on_actionSolve_triggered() { if(!this->lenX > 0) return ; QTime time; this->ans.clear(); this->ui->FoundedList->clear(); this->cont = 0; this->min = this->ui->spinBox->value(); time.start(); this->lookHorizontals(); // this->lookVerticals(); this->lookDiagonal2(); // this->lookDiagonal1(); int tim =time.elapsed(); ans.sort(); this->ui->lcdTime->display(tim); this->ui->FoundedList->addItems(this->ans); this->ui->lcdFound->display(this->ans.count()); } void solver::on_actionAbout_triggered() { QString msg = "Proyecto E.D."; msg.append("\nCreado por Brian D, [email protected] para preguntas"); msg.append("\nConsiste en un programa para resolver una sopa de letras de nxn"); msg.append("\nLa eficiencia se debe a que utilize un arbol nario o por lo menos lo simule"); msg.append("\n practicamente es lo que hace google con las busquedas instantaneas, las que no cumplen con las "); msg.append("\ncondicionan se eliminan y si no hay sugerencia se para la busqueda"); msg.append("\n En promedio en mi computadora con KUBUNTU 11.04 se tarda 24 milisegundos con 50 x 50"); msg.append("\nen otros SO puede variar ya que linux le da prioridad a procesamiento y no grafica, lo cual potencializa mi programa"); msg.append("\n PEQUENHO detalle no sirve el limpiar por lo tanto hay cerrarlo y correr de nuevo para cargar otra sopa"); QMessageBox::about(this,"About", msg); }
[ [ [ 1, 282 ] ] ]
1ebe98af597ab3cf943c0b635e531092b28d213c
f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0
/Depend/MyGUI/UnitTests/UnitTest_Layers/ControllerSmoothCaption.h
996fdf32cd3ac091b9fe29b1d30eac761a1129af
[]
no_license
lxinhcn/starworld
79ed06ca49d4064307ae73156574932d6185dbab
86eb0fb8bd268994454b0cfe6419ffef3fc0fc80
refs/heads/master
2021-01-10T07:43:51.858394
2010-09-15T02:38:48
2010-09-15T02:38:48
47,859,019
2
1
null
null
null
null
UTF-8
C++
false
false
1,864
h
/*! @file @author Albert Semenov @date 11/2009 */ #ifndef __CONTROLLER_SMOOTH_CAPTION_H__ #define __CONTROLLER_SMOOTH_CAPTION_H__ #include "MyGUI_Prerequest.h" #include "MyGUI_WidgetDefines.h" #include "MyGUI_ControllerItem.h" namespace demo { class ControllerSmoothCaption : public MyGUI::ControllerItem { MYGUI_RTTI_DERIVED( ControllerSmoothCaption ) public: ControllerSmoothCaption() : mTime(0), mCurrentPosition(0) { } virtual ~ControllerSmoothCaption() { } private: bool addTime(MyGUI::Widget* _widget, float _time) { const float slice = 0.04; mTime += _time; if (mTime > slice) { mTime -= slice; update(_widget); } return true; } void prepareItem(MyGUI::Widget* _widget) { mTime = 0; mCurrentPosition = 0; _widget->eventChangeProperty += MyGUI::newDelegate(this, &ControllerSmoothCaption::notifyChangeProperty); } void update(MyGUI::Widget* _widget) { if (mCurrentPosition < mNeedCaption.size()) { mCurrentPosition ++; MyGUI::StaticText* text = _widget->castType<MyGUI::StaticText>(false); if (text != nullptr) { if (mCurrentPosition == mNeedCaption.size()) text->setCaption(mNeedCaption); else text->setCaption(mNeedCaption.substr(0, mCurrentPosition) + " _"); } } } void notifyChangeProperty(MyGUI::Widget* _sender, const std::string& _key, const std::string& _value) { if (_key == "Caption") { mNeedCaption = _value; mCurrentPosition = 0; MyGUI::StaticText* text = _sender->castType<MyGUI::StaticText>(false); if (text != nullptr) text->setCaption(""); } } private: float mTime; std::string mNeedCaption; size_t mCurrentPosition; }; } #endif // __CONTROLLER_SMOOTH_CAPTION_H__
[ "albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c" ]
[ [ [ 1, 89 ] ] ]
ad330fd98526b77a8a67debbac7bb4f79ff92cfe
fac8de123987842827a68da1b580f1361926ab67
/inc/physics/Common/Base/System/Io/Writer/Crc32/hkCrc32StreamWriter.h
7b3f4f7da7732d2a18463475858d8544785c41a6
[]
no_license
blockspacer/transporter-game
23496e1651b3c19f6727712a5652f8e49c45c076
083ae2ee48fcab2c7d8a68670a71be4d09954428
refs/heads/master
2021-05-31T04:06:07.101459
2009-02-19T20:59:59
2009-02-19T20:59:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,641
h
/* * * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's * prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok. * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement. * */ #ifndef HK_BASE_CRC32STREAMWRITER_H #define HK_BASE_CRC32STREAMWRITER_H #include <Common/Base/hkBase.h> #include <Common/Base/System/Io/Writer/hkStreamWriter.h> class hkCrc32StreamWriter : public hkStreamWriter { public: hkCrc32StreamWriter(hkUint32 startCrc=0); virtual hkBool isOk() const; virtual int write(const void*, int n); hkUint32 getCrc32() const; protected: hkUint32 m_crc32; }; #endif // HK_BASE_CRC32STREAMWRITER_H /* * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529) * * Confidential Information of Havok. (C) Copyright 1999-2008 * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok * Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership * rights, and intellectual property rights in the Havok software remain in * Havok and/or its suppliers. * * Use of this software for evaluation purposes is subject to and indicates * acceptance of the End User licence Agreement for this product. A copy of * the license is included with this software and is also available at * www.havok.com/tryhavok * */
[ "uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4" ]
[ [ [ 1, 45 ] ] ]
fa1362dbf2ecfc50ca996c70bee8e4872a53052b
2bdd10a32ca3dd0977c7f76598af92608f5aa472
/Config.h
4fc454c8350c48f2ec344d43a96ecaca4a60cfc1
[]
no_license
pnarula/Ray-Tracer
6456b604b2f6ad47c625702f191178b0741ee451
61aca7c916310252604dd0dec649d5ce58e41bf5
refs/heads/master
2020-06-12T20:24:28.452458
2011-04-06T16:30:23
2011-04-06T16:30:23
1,577,936
0
0
null
null
null
null
UTF-8
C++
false
false
1,625
h
/* This file belongs to the Ray tracing tutorial of http://www.codermind.com/ It is free to use for educational purpose and cannot be redistributed outside of the tutorial pages. Any further inquiry : mailto:[email protected] */ #ifndef __CONFIG_H #define __CONFIG_H // This is a simple config file parser. // It does what we need no more no less. #include "raytracer.h" #include "SimpleString.h" #pragma warning( push ) #pragma warning( disable : 4512 ) // assignment operator cannot be generated because of the const member. We don't need one. // Some code class Config { private: void * m_pVariables; void * m_pSections; const SimpleString m_sFileName; SimpleString m_sCurrentSection; bool m_bLoaded; public: // When the variable called "sName" doesn't exit, you will get "default" bool GetByNameAsBoolean(const SimpleString & sName, bool bDefault) const; double GetByNameAsFloat(const SimpleString & sName, double fDefault) const; const SimpleString &GetByNameAsString(const SimpleString &sName, const SimpleString & sDefault) const; long GetByNameAsInteger(const SimpleString &sName, long lDefault) const; //vecteur GetByNameAsVector(const SimpleString &sName, const vecteur& vDefault) const; Point GetByNameAsPoint(const SimpleString &sName, const Point& ptDefault) const; // SetSection will return -1 when the section wasn't found. int SetSection(const SimpleString &sName); ~Config(); Config(const SimpleString &sFileName); }; #pragma warning( pop ) #endif //__CONFIG_H
[ [ [ 1, 44 ] ] ]
bc35deb3ee654cdcda1b7c74360d2601fc6e082e
ce262ae496ab3eeebfcbb337da86d34eb689c07b
/SEFoundation/SERendering/SEBindable.h
f76bee9bf6444d5fce804606f964939bfd9c7491
[]
no_license
pizibing/swingengine
d8d9208c00ec2944817e1aab51287a3c38103bea
e7109d7b3e28c4421c173712eaf872771550669e
refs/heads/master
2021-01-16T18:29:10.689858
2011-06-23T04:27:46
2011-06-23T04:27:46
33,969,301
0
0
null
null
null
null
GB18030
C++
false
false
3,559
h
// Swing Engine Version 1 Source Code // Most of techniques in the engine are mainly based on David Eberly's // Wild Magic 4 open-source code.The author of Swing Engine learned a lot // from Eberly's experience of architecture and algorithm. // Several sub-systems are totally new,and others are re-implimented or // re-organized based on Wild Magic 4's sub-systems. // Copyright (c) 2007-2010. All Rights Reserved // // Eberly's permission: // Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2.1 of the License, or (at // your option) any later version. The license is available for reading at // the location: // http://www.gnu.org/copyleft/lgpl.html #ifndef Swing_Bindable_H #define Swing_Bindable_H #include "SEFoundationLIB.h" #include "SEPlatforms.h" #include "SESystem.h" #include "SEAttributes.h" #include "SERenderer.h" namespace Swing { //---------------------------------------------------------------------------- // Description: // Author:Sun Che // Date:20080320 //---------------------------------------------------------------------------- class SE_FOUNDATION_API SEResourceIdentifier { public: // 虚基类,注意析构函数不是虚函数, // 因此被派生后,基类析构行为是未定义的, // 由于此类没有任何数据成员,也没有虚函数, // 从而避免了虚函数表指针的存在, // 这将允许派生类SEVBufferIdentifier首先存储自己的成员变量, // 并且安全的进行如下所示的类型转换操作: // // class SEVBufferIdentifier : public SEResourceIdentifier // { // public: SEAttributes IAttributes; // } // SEVBufferIdentifier* pID = <some identifier>; // SEAttributes& rIAttributes = *(SEAttributes*)pID; ~SEResourceIdentifier(void){} protected: SEResourceIdentifier(void){} }; //---------------------------------------------------------------------------- // Description:所有需要载入显存的资源,如VB,IB,shader程序,texture的基类. // Author:Sun Che // Date:20080320 //---------------------------------------------------------------------------- class SE_FOUNDATION_API SEBindable { public: SEBindable(void); ~SEBindable(void); // 当资源在VRAM中有唯一表示时使用(除了vertex buffers之外的所有资源) SEResourceIdentifier* GetIdentifier(SERenderer* pUser) const; // 当资源在VRAM中有多个表示时使用(vertex buffers) int GetInfoCount(void) const; SEResourceIdentifier* GetIdentifier(int i, SERenderer* pUser) const; void Release(void); private: friend class SERenderer; void OnLoad(SERenderer* pUser, SERenderer::ReleaseFunction oRelease, SEResourceIdentifier* pID); void OnRelease(SERenderer* pUser, SEResourceIdentifier* pID); struct Info { // 资源所绑定的renderer SERenderer* User; // 释放资源时所需的renderer释放函数 SERenderer::ReleaseFunction Release; // 资源在该renderer上的ID SEResourceIdentifier* ID; }; // 可以同时绑定给多个renderer,主要用于绑定一个renderer的多个不同实例 std::vector<Info> m_InfoArray; }; } #endif
[ "[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac" ]
[ [ [ 1, 107 ] ] ]
20848b23aa9db22892b65bb49f817b4edff9dee1
e46cae4635b79c4016ad85562018214a8305de97
/WinArena/DirectDrawWrapper.cpp
d6b9eb61c537631a940ab844f564c59cd1b90ab0
[]
no_license
basecq/opentesarenapp
febea5fddab920d5987f8067420d0b410aa95656
4b6d097d7c40352c62f9f95068e89df44e323832
refs/heads/master
2021-01-18T01:10:14.561315
2009-10-12T14:32:01
2009-10-12T14:32:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
46,068
cpp
///////////////////////////////////////////////////////////////////////////// // // $Header: /WinArena/DirectDrawWrapper.cpp 2 12/31/06 10:47a Lee $ // // File: DirectDrawWrapper.cpp // // ///////////////////////////////////////////////////////////////////////////// #define INITGUID #include <windows.h> #include <stdlib.h> #include <stdio.h> #include "DirectDrawWrapper.h" #define ArraySize(x) (sizeof(x) / sizeof((x)[0])) #define SafeRelease(x) { if (NULL != (x)) { (x)->Release(); (x) = NULL; } } struct DirectDrawError_t { HRESULT HR; char* Message; }; DirectDrawError_t g_DirectDrawErrorTable[] = { { DD_OK, "DD_OK: The request completed successfully." }, { DDERR_ALREADYINITIALIZED, "DDERR_ALREADYINITIALIZED: The object has already been initialized." }, { DDERR_BLTFASTCANTCLIP, "DDERR_BLTFASTCANTCLIP: A DirectDrawClipper object is attached to a source surface that has passed into a call to the IDirectDrawSurface5::BltFast method." }, { DDERR_CANNOTATTACHSURFACE, "DDERR_CANNOTATTACHSURFACE: A surface cannot be attached to another requested surface." }, { DDERR_CANNOTDETACHSURFACE, "DDERR_CANNOTDETACHSURFACE: A surface cannot be detached from another requested surface." }, { DDERR_CANTCREATEDC, "DDERR_CANTCREATEDC: Windows cannot create any more device contexts (DCs), or a DC was requested for a palette-indexed surface when the surface had no palette and the display mode was not palette-indexed (that is, DirectDraw cannot select a proper palette into the DC)." }, { DDERR_CANTDUPLICATE, "DDERR_CANTDUPLICATE: Primary and 3-D surfaces, or surfaces that are implicitly created, cannot be duplicated." }, { DDERR_CANTLOCKSURFACE, "DDERR_CANTLOCKSURFACE: Access to this surface is refused because an attempt was made to lock the primary surface without DCI support." }, { DDERR_CANTPAGELOCK, "DDERR_CANTPAGELOCK: An attempt to page lock a surface failed. Page lock will not work on a display-memory surface or an emulated primary surface." }, { DDERR_CANTPAGEUNLOCK, "DDERR_CANTPAGEUNLOCK: An attempt to page unlock a surface failed. Page unlock will not work on a display-memory surface or an emulated primary surface." }, { DDERR_CLIPPERISUSINGHWND, "DDERR_CLIPPERISUSINGHWND: An attempt was made to set a clip list for a DirectDrawClipper object that is already monitoring a window handle." }, { DDERR_COLORKEYNOTSET, "DDERR_COLORKEYNOTSET: No source color key is specified for this operation." }, { DDERR_CURRENTLYNOTAVAIL, "DDERR_CURRENTLYNOTAVAIL: No support is currently available." }, { DDERR_DCALREADYCREATED, "DDERR_DCALREADYCREATED: A device context (DC) has already been returned for this surface. Only one DC can be retrieved for each surface." }, { DDERR_DEVICEDOESNTOWNSURFACE, "DDERR_DEVICEDOESNTOWNSURFACE: Surfaces created by one DirectDraw device cannot be used directly by another DirectDraw device." }, { DDERR_DIRECTDRAWALREADYCREATED, "DDERR_DIRECTDRAWALREADYCREATED: A DirectDraw object representing this driver has already been created for this process." }, { DDERR_EXCEPTION, "DDERR_EXCEPTION: An exception was encountered while performing the requested operation." }, { DDERR_EXCLUSIVEMODEALREADYSET, "DDERR_EXCLUSIVEMODEALREADYSET: An attempt was made to set the cooperative level when it was already set to exclusive." }, { DDERR_EXPIRED, "DDERR_EXPIRED: The data has expired and is no longer valid." }, { DDERR_GENERIC, "DDERR_GENERIC: There is an undefined error condition." }, { DDERR_HEIGHTALIGN, "DDERR_HEIGHTALIGN: The height of the provided rectangle is not a multiple of the required alignment." }, { DDERR_HWNDALREADYSET, "DDERR_HWNDALREADYSET: The DirectDraw cooperative level window handle has already been set. It cannot be reset while the process has surfaces or palettes created." }, { DDERR_HWNDSUBCLASSED, "DDERR_HWNDSUBCLASSED: DirectDraw is prevented from restoring the state because the DirectDraw cooperative level window handle has been subclassed." }, { DDERR_IMPLICITLYCREATED, "DDERR_IMPLICITLYCREATED: The surface cannot be restored because it is an implicitly created surface." }, { DDERR_INCOMPATIBLEPRIMARY, "DDERR_INCOMPATIBLEPRIMARY: The primary surface creation request does not match the existing primary surface." }, { DDERR_INVALIDCAPS, "DDERR_INVALIDCAPS: One or more of the capability bits passed to the callback function are incorrect." }, { DDERR_INVALIDCLIPLIST, "DDERR_INVALIDCLIPLIST: DirectDraw does not support the provided clip list." }, { DDERR_INVALIDDIRECTDRAWGUID, "DDERR_INVALIDDIRECTDRAWGUID: The globally unique identifier (GUID) passed to the DirectDrawCreate function is not a valid DirectDraw driver identifier." }, { DDERR_INVALIDMODE, "DDERR_INVALIDMODE: DirectDraw does not support the requested mode." }, { DDERR_INVALIDOBJECT, "DDERR_INVALIDOBJECT: DirectDraw received a pointer that was an invalid DirectDraw object." }, { DDERR_INVALIDPARAMS, "DDERR_INVALIDPARAMS: One or more of the parameters passed to the method are incorrect." }, { DDERR_INVALIDPIXELFORMAT, "DDERR_INVALIDPIXELFORMAT: The pixel format was invalid as specified." }, { DDERR_INVALIDPOSITION, "DDERR_INVALIDPOSITION: The position of the overlay on the destination is no longer valid." }, { DDERR_INVALIDRECT, "DDERR_INVALIDRECT: The provided rectangle was invalid." }, { DDERR_INVALIDSTREAM, "DDERR_INVALIDSTREAM: The specified stream contains invalid data." }, { DDERR_INVALIDSURFACETYPE, "DDERR_INVALIDSURFACETYPE: The requested operation could not be performed because the surface was of the wrong type." }, { DDERR_LOCKEDSURFACES, "DDERR_LOCKEDSURFACES: One or more surfaces are locked, causing the failure of the requested operation." }, { DDERR_MOREDATA, "DDERR_MOREDATA: There is more data available than the specified buffer size can hold." }, { DDERR_NO3D, "DDERR_NO3D: No 3-D hardware or emulation is present." }, { DDERR_NOALPHAHW, "DDERR_NOALPHAHW: No alpha acceleration hardware is present or available, causing the failure of the requested operation." }, { DDERR_NOBLTHW, "DDERR_NOBLTHW: No blitter hardware is present." }, { DDERR_NOCLIPLIST, "DDERR_NOCLIPLIST: No clip list is available." }, { DDERR_NOCLIPPERATTACHED, "DDERR_NOCLIPPERATTACHED: No DirectDrawClipper object is attached to the surface object." }, { DDERR_NOCOLORCONVHW, "DDERR_NOCOLORCONVHW: The operation cannot be carried out because no color-conversion hardware is present or available." }, { DDERR_NOCOLORKEY, "DDERR_NOCOLORKEY: The surface does not currently have a color key." }, { DDERR_NOCOLORKEYHW, "DDERR_NOCOLORKEYHW: The operation cannot be carried out because there is no hardware support for the destination color key." }, { DDERR_NOCOOPERATIVELEVELSET, "DDERR_NOCOOPERATIVELEVELSET: A create function is called without the IDirectDraw4::SetCooperativeLevel method being called." }, { DDERR_NODC, "DDERR_NODC: No DC has been created for this surface." }, { DDERR_NODDROPSHW, "DDERR_NODDROPSHW: No DirectDraw raster operation (ROP) hardware is available." }, { DDERR_NODIRECTDRAWHW, "DDERR_NODIRECTDRAWHW: Hardware-only DirectDraw object creation is not possible; the driver does not support any hardware." }, { DDERR_NODIRECTDRAWSUPPORT, "DDERR_NODIRECTDRAWSUPPORT: DirectDraw support is not possible with the current display driver." }, { DDERR_NOEMULATION, "DDERR_NOEMULATION: Software emulation is not available." }, { DDERR_NOEXCLUSIVEMODE, "DDERR_NOEXCLUSIVEMODE: The operation requires the application to have exclusive mode, but the application does not have exclusive mode." }, { DDERR_NOFLIPHW, "DDERR_NOFLIPHW: Flipping visible surfaces is not supported." }, { DDERR_NOFOCUSWINDOW, "DDERR_NOFOCUSWINDOW: An attempt was made to create or set a device window without first setting the focus window." }, { DDERR_NOGDI, "DDERR_NOGDI: No GDI is present." }, { DDERR_NOHWND, "DDERR_NOHWND: Clipper notification requires a window handle, or no window handle has been previously set as the cooperative level window handle." }, { DDERR_NOMIPMAPHW, "DDERR_NOMIPMAPHW: The operation cannot be carried out because no mipmap capable texture mapping hardware is present or available." }, { DDERR_NOMIRRORHW, "DDERR_NOMIRRORHW: The operation cannot be carried out because no mirroring hardware is present or available." }, { DDERR_NONONLOCALVIDMEM, "DDERR_NONONLOCALVIDMEM: An attempt was made to allocate non-local video memory from a device that does not support non-local video memory." }, { DDERR_NOOPTIMIZEHW, "DDERR_NOOPTIMIZEHW: The device does not support optimized surfaces." }, { DDERR_NOOVERLAYDEST, "DDERR_NOOVERLAYDEST: The IDirectDrawSurface5::GetOverlayPosition method is called on an overlay but the IDirectDrawSurface5::UpdateOverlay method has not been called on to establish a destination." }, { DDERR_NOOVERLAYHW, "DDERR_NOOVERLAYHW: The operation cannot be carried out because no overlay hardware is present or available." }, { DDERR_NOPALETTEATTACHED, "DDERR_NOPALETTEATTACHED: No palette object is attached to this surface." }, { DDERR_NOPALETTEHW, "DDERR_NOPALETTEHW: There is no hardware support for 16- or 256-color palettes." }, { DDERR_NORASTEROPHW, "DDERR_NORASTEROPHW: The operation cannot be carried out because no appropriate raster operation hardware is present or available." }, { DDERR_NOROTATIONHW, "DDERR_NOROTATIONHW: The operation cannot be carried out because no rotation hardware is present or available." }, { DDERR_NOSTRETCHHW, "DDERR_NOSTRETCHHW: The operation cannot be carried out because there is no hardware support for stretching." }, { DDERR_NOT4BITCOLOR, "DDERR_NOT4BITCOLOR: The DirectDrawSurface object is not using a 4-bit color palette and the requested operation requires a 4-bit color palette." }, { DDERR_NOT4BITCOLORINDEX, "DDERR_NOT4BITCOLORINDEX: The DirectDrawSurface object is not using a 4-bit color index palette and the requested operation requires a 4-bit color index palette." }, { DDERR_NOT8BITCOLOR, "DDERR_NOT8BITCOLOR: The DirectDrawSurface object is not using an 8-bit color palette and the requested operation requires an 8-bit color palette." }, { DDERR_NOTAOVERLAYSURFACE, "DDERR_NOTAOVERLAYSURFACE: An overlay component is called for a non-overlay surface." }, { DDERR_NOTEXTUREHW, "DDERR_NOTEXTUREHW: The operation cannot be carried out because no texture-mapping hardware is present or available." }, { DDERR_NOTFLIPPABLE, "DDERR_NOTFLIPPABLE: An attempt has been made to flip a surface that cannot be flipped." }, { DDERR_NOTFOUND, "DDERR_NOTFOUND: The requested item was not found." }, { DDERR_NOTINITIALIZED, "DDERR_NOTINITIALIZED: An attempt was made to call an interface method of a DirectDraw object before the object was initialized." }, { DDERR_NOTLOADED, "DDERR_NOTLOADED: The surface is an optimized surface, but it has not yet been allocated any memory." }, { DDERR_NOTLOCKED, "DDERR_NOTLOCKED: An attempt is made to unlock a surface that was not locked." }, { DDERR_NOTPAGELOCKED, "DDERR_NOTPAGELOCKED: An attempt is made to page unlock a surface with no outstanding page locks." }, { DDERR_NOTPALETTIZED, "DDERR_NOTPALETTIZED: The surface being used is not a palette-based surface." }, { DDERR_NOVSYNCHW, "DDERR_NOVSYNCHW: The operation cannot be carried out because there is no hardware support for vertical blank synchronized operations." }, { DDERR_NOZBUFFERHW, "DDERR_NOZBUFFERHW: The operation to create a Z-buffer in display memory or to perform a blit using a Z-buffer cannot be carried out because there is no hardware support for Z-buffers." }, { DDERR_NOZOVERLAYHW, "DDERR_NOZOVERLAYHW: The overlay surfaces cannot be Z-layered based on the Z-order because the hardware does not support Z-ordering of overlays." }, { DDERR_OUTOFCAPS, "DDERR_OUTOFCAPS: The hardware needed for the requested operation has already been allocated." }, { DDERR_OUTOFMEMORY, "DDERR_OUTOFMEMORY: DirectDraw does not have enough memory to perform the operation." }, { DDERR_OUTOFVIDEOMEMORY, "DDERR_OUTOFVIDEOMEMORY: DirectDraw does not have enough display memory to perform the operation." }, { DDERR_OVERLAPPINGRECTS, "DDERR_OVERLAPPINGRECTS: Operation could not be carried out because the source and destination rectangles are on the same surface and overlap each other." }, { DDERR_OVERLAYCANTCLIP, "DDERR_OVERLAYCANTCLIP: The hardware does not support clipped overlays." }, { DDERR_OVERLAYCOLORKEYONLYONEACTIVE, "DDERR_OVERLAYCOLORKEYONLYONEACTIVE: An attempt was made to have more than one color key active on an overlay." }, { DDERR_OVERLAYNOTVISIBLE, "DDERR_OVERLAYNOTVISIBLE: The IDirectDrawSurface5::GetOverlayPosition method is called on a hidden overlay." }, { DDERR_PALETTEBUSY, "DDERR_PALETTEBUSY: Access to this palette is refused because the palette is locked by another thread." }, { DDERR_PRIMARYSURFACEALREADYEXISTS, "DDERR_PRIMARYSURFACEALREADYEXISTS: This process has already created a primary surface." }, { DDERR_REGIONTOOSMALL, "DDERR_REGIONTOOSMALL: The region passed to the IDirectDrawClipper::GetClipList method is too small." }, { DDERR_SURFACEALREADYATTACHED, "DDERR_SURFACEALREADYATTACHED: An attempt was made to attach a surface to another surface while they are already attached." }, { DDERR_SURFACEALREADYDEPENDENT, "DDERR_SURFACEALREADYDEPENDENT: An attempt was made to make a surface a dependency of another surface to which it is already dependent." }, { DDERR_SURFACEBUSY, "DDERR_SURFACEBUSY: Access to the surface is refused because the surface is locked by another thread." }, { DDERR_SURFACEISOBSCURED, "DDERR_SURFACEISOBSCURED: Access to the surface is refused because the surface is obscured." }, { DDERR_SURFACELOST, "DDERR_SURFACELOST: Access to the surface is refused because the surface memory is gone. Call the IDirectDrawSurface5::Restore method on this surface to restore the memory associated with it." }, { DDERR_SURFACENOTATTACHED, "DDERR_SURFACENOTATTACHED: The requested surface is not attached." }, { DDERR_TOOBIGHEIGHT, "DDERR_TOOBIGHEIGHT: The height requested by DirectDraw is too large." }, { DDERR_TOOBIGSIZE, "DDERR_TOOBIGSIZE: The size requested by DirectDraw is too large. However, the individual height and width are valid sizes." }, { DDERR_TOOBIGWIDTH, "DDERR_TOOBIGWIDTH: The width requested by DirectDraw is too large." }, { DDERR_UNSUPPORTED, "DDERR_UNSUPPORTED: The operation is not supported." }, { DDERR_UNSUPPORTEDFORMAT, "DDERR_UNSUPPORTEDFORMAT: The pixel format requested is not supported by DirectDraw." }, { DDERR_UNSUPPORTEDMASK, "DDERR_UNSUPPORTEDMASK: The bitmask in the pixel format requested is not supported by DirectDraw." }, { DDERR_UNSUPPORTEDMODE, "DDERR_UNSUPPORTEDMODE: The display is currently in an unsupported mode." }, { DDERR_VERTICALBLANKINPROGRESS, "DDERR_VERTICALBLANKINPROGRESS: A vertical blank is in progress." }, { DDERR_VIDEONOTACTIVE, "DDERR_VIDEONOTACTIVE: The video port is not active." }, { DDERR_WASSTILLDRAWING, "DDERR_WASSTILLDRAWING: The previous blit operation that is transferring information to or from this surface is incomplete." }, { DDERR_WRONGMODE, "DDERR_WRONGMODE: This surface cannot be restored because it was created in a different mode." }, { DDERR_XALIGN, "DDERR_XALIGN: The provided rectangle was not horizontally aligned on a required boundary." } }; ///////////////////////////////////////////////////////////////////////////// // // constructor // CDirectDrawWrapper::CDirectDrawWrapper(void) : m_pDraw(NULL), m_pClipper(NULL), m_pPrimary(NULL), m_pBackBuffer(NULL), m_RenderIndex(0), m_pPalette(NULL) { m_ErrorMessage[0] = '\0'; m_pRenderBuffer[0] = NULL; m_pRenderBuffer[1] = NULL; m_BlitCount = 0; m_BlitTime = 0.0f; } ///////////////////////////////////////////////////////////////////////////// // // destructor // CDirectDrawWrapper::~CDirectDrawWrapper(void) { SafeRelease(m_pPalette); SafeRelease(m_pRenderBuffer[1]); SafeRelease(m_pRenderBuffer[0]); SafeRelease(m_pBackBuffer); SafeRelease(m_pPrimary); SafeRelease(m_pClipper); SafeRelease(m_pDraw); } ///////////////////////////////////////////////////////////////////////////// // // WriteErrorMessage() // void CDirectDrawWrapper::WriteErrorMessage(char who[], HRESULT hr) { long errorIndex = -1; for (long i = 0; i < ArraySize(g_DirectDrawErrorTable); ++i) { if (g_DirectDrawErrorTable[i].HR == hr) { errorIndex = i; break; } } if (errorIndex != -1) { _snprintf(m_ErrorMessage, ArraySize(m_ErrorMessage), "%s, hr = 0x%08X, %s\n", who, hr, g_DirectDrawErrorTable[errorIndex].Message); } else { _snprintf(m_ErrorMessage, ArraySize(m_ErrorMessage), "%s, hr = 0x%08X, unknown error code\n", who, hr); } OutputDebugString(m_ErrorMessage); } ///////////////////////////////////////////////////////////////////////////// // // Initialize() // bool CDirectDrawWrapper::Initialize(HWND hWindow, DWORD width, DWORD height) { m_ScreenWidth = width; m_ScreenHeight = height; m_RenderWidth = (width == 640) ? 640 : 960; m_RenderHeight = (width == 640) ? 400 : 600; // // Create the main DirectDraw interface. // IDirectDraw *pDraw = NULL; HRESULT hr; hr = DirectDrawCreate(NULL, &pDraw, NULL); if (FAILED(hr)) { WriteErrorMessage("DirectDrawCreate() failed", hr); return false; } hr = pDraw->QueryInterface(IID_IDirectDraw7, (void**)&m_pDraw); SafeRelease(pDraw); if (FAILED(hr)) { _snprintf(m_ErrorMessage, ArraySize(m_ErrorMessage), "QueryInterface(IDirectDraw7) failed, hr = 0x%08X", hr); return false; } // hr = m_pDraw->SetCooperativeLevel(hWindow, DDSCL_NORMAL); hr = m_pDraw->SetCooperativeLevel(hWindow, DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE); if (FAILED(hr)) { WriteErrorMessage("SetCooperativeLevel() failed", hr); return false; } m_pDraw->SetDisplayMode(width, height, 8, 0, 0); PALETTEENTRY palette[256]; hr = m_pDraw->CreatePalette(DDPCAPS_8BIT | DDPCAPS_INITIALIZE, palette, &m_pPalette, NULL); if (FAILED(hr)) { WriteErrorMessage("CreatePalette() failed", hr); return false; } // // Create clipper. // /* hr = m_pDraw->CreateClipper(0, &m_pClipper, NULL); if (FAILED(hr)) { WriteErrorMessage("CreateClipper() failed", hr); return false; } hr = m_pClipper->SetHWnd(0, hWindow); if (FAILED(hr)) { WriteErrorMessage("Clipper->SetHWnd() failed", hr); return false; } */ m_ClearCount = 0; DDSURFACEDESC2 desc; memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; desc.dwBackBufferCount = 2; hr = m_pDraw->CreateSurface(&desc, &m_pPrimary, NULL); if (FAILED(hr)) { WriteErrorMessage("CreateSurface() failed for primary surface", hr); return false; } /* DDSCAPS2 caps; memset(&caps, 0, sizeof(caps)); caps.dwCaps = DDSCAPS_BACKBUFFER; hr = m_pPrimary->GetAttachedSurface(&caps, &m_pBackBuffer); if (FAILED(hr)) { WriteErrorMessage("GetAttachedSurface() failed", hr); return false; } */ hr = m_pPrimary->SetPalette(m_pPalette); if (FAILED(hr)) { WriteErrorMessage("SetPalette() failed", hr); return false; } ClearSurface(m_pPrimary); // m_pBackBuffer->Blt(&rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); // if (FAILED(lpddsprimary->GetAttachedSurface(&ddscaps,&lpddsback))) /* hr = m_pPrimary->SetClipper(m_pClipper); if (FAILED(hr)) { WriteErrorMessage("SetClipper() failed for primary surface", hr); return false; } */ /* memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); desc.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY | DDSCAPS_OFFSCREENPLAIN; desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS; desc.dwWidth = m_RenderWidth; desc.dwHeight = m_RenderHeight; desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); desc.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8; desc.ddpfPixelFormat.dwRGBBitCount = 8; hr = m_pDraw->CreateSurface(&desc, &m_pBackBuffer, NULL); if (FAILED(hr)) { WriteErrorMessage("CreateSurface() failed for back buffer", hr); return false; } m_LockedRenderBuffer = false; memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); desc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN; desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS; desc.dwWidth = m_RenderWidth; desc.dwHeight = m_RenderHeight; desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); desc.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8; desc.ddpfPixelFormat.dwRGBBitCount = 8; hr = m_pDraw->CreateSurface(&desc, &m_pRenderBuffer[0], NULL); if (FAILED(hr)) { WriteErrorMessage("CreateSurface() failed for render buffer", hr); return false; } hr = m_pDraw->CreateSurface(&desc, &m_pRenderBuffer[1], NULL); if (FAILED(hr)) { WriteErrorMessage("CreateSurface() failed for render buffer", hr); return false; } */ m_LockedRenderBuffer = false; return true; } ///////////////////////////////////////////////////////////////////////////// // void Format8bit(DDSURFACEDESC2 &desc) { desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); desc.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8; desc.ddpfPixelFormat.dwRGBBitCount = 8; } ///////////////////////////////////////////////////////////////////////////// // void Format422(DDSURFACEDESC2 &desc) { desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); desc.ddpfPixelFormat.dwFlags = DDPF_FOURCC; desc.ddpfPixelFormat.dwFourCC = 0x59565955; // desc.ddpfPixelFormat.dwFourCC = 0x32595559; // desc.ddpfPixelFormat.dwFourCC = 0x32315659; desc.ddpfPixelFormat.dwYUVBitCount = 16; desc.ddpfPixelFormat.dwYBitMask = 0xFF00FF00; desc.ddpfPixelFormat.dwVBitMask = 0x00FF0000; desc.ddpfPixelFormat.dwUBitMask = 0x000000FF; } ///////////////////////////////////////////////////////////////////////////// // void FormatRGB16(DDSURFACEDESC2 &desc) { desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); desc.ddpfPixelFormat.dwFlags = DDPF_RGB; desc.ddpfPixelFormat.dwRGBBitCount = 16; desc.ddpfPixelFormat.dwRBitMask = 0x0000F800; desc.ddpfPixelFormat.dwGBitMask = 0x000007E0; desc.ddpfPixelFormat.dwBBitMask = 0x0000001F; // desc.ddpfPixelFormat.dwRBitMask = 0x00007C00; // desc.ddpfPixelFormat.dwGBitMask = 0x000003E0; // desc.ddpfPixelFormat.dwBBitMask = 0x0000001F; } ///////////////////////////////////////////////////////////////////////////// // void FormatRGB32(DDSURFACEDESC2 &desc) { desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); desc.ddpfPixelFormat.dwFlags = DDPF_RGB; desc.ddpfPixelFormat.dwRGBBitCount = 32; desc.ddpfPixelFormat.dwRBitMask = 0x00FF0000; desc.ddpfPixelFormat.dwGBitMask = 0x0000FF00; desc.ddpfPixelFormat.dwBBitMask = 0x000000FF; } ///////////////////////////////////////////////////////////////////////////// // void CDirectDrawWrapper::ClearSurface(IDirectDrawSurface7 *pSurface) { DDBLTFX fx; memset(&fx, 0, sizeof(fx)); fx.dwSize = sizeof(fx); fx.dwFillColor = 0; RECT rect; rect.left = 0; rect.top = 0; rect.right = m_ScreenWidth; rect.bottom = m_ScreenHeight; pSurface->Blt(&rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); } ///////////////////////////////////////////////////////////////////////////// // bool CDirectDrawWrapper::LockRenderBuffer(BYTE **ppMemory, DWORD &pitch) { HRESULT hr; if ((false == m_LockedRenderBuffer) && (NULL != m_pPrimary)) { SafeRelease(m_pBackBuffer); DDSCAPS2 caps; memset(&caps, 0, sizeof(caps)); caps.dwCaps = DDSCAPS_BACKBUFFER; hr = m_pPrimary->GetAttachedSurface(&caps, &m_pBackBuffer); if (FAILED(hr)) { WriteErrorMessage("GetAttachedSurface() failed", hr); return false; } if (m_ClearCount++ < 3) { ClearSurface(m_pBackBuffer); } DDSURFACEDESC2 desc; memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); desc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN; desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS; desc.dwWidth = m_RenderWidth; desc.dwHeight = m_RenderHeight; desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); desc.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8; desc.ddpfPixelFormat.dwRGBBitCount = 8; m_RenderIndex = m_RenderIndex ? 0 : 1; // hr = m_pRenderBuffer[m_RenderIndex]->Lock(NULL, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY/* | DDLOCK_NOSYSLOCK*/, NULL); hr = m_pBackBuffer->Lock(NULL, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY/* | DDLOCK_NOSYSLOCK*/, NULL); if (SUCCEEDED(hr)) { *ppMemory = reinterpret_cast<BYTE*>(desc.lpSurface) + (desc.lPitch * ((m_ScreenHeight - m_RenderHeight) / 2)) + ((m_ScreenWidth - m_RenderWidth) / 2); pitch = desc.lPitch; m_LockedRenderBuffer = true; return true; } WriteErrorMessage("Lock() failed for render buffer", hr); } return false; } ///////////////////////////////////////////////////////////////////////////// // void CDirectDrawWrapper::UnlockRenderBuffer(void) { if (m_LockedRenderBuffer) { m_LockedRenderBuffer = false; // m_pRenderBuffer[m_RenderIndex]->Unlock(NULL); m_pBackBuffer->Unlock(NULL); SafeRelease(m_pBackBuffer); } } ///////////////////////////////////////////////////////////////////////////// // void CDirectDrawWrapper::ShowRenderBuffer(void) { RECT srcRect, dstRect; srcRect.left = 0; srcRect.top = 0; srcRect.right = m_RenderWidth; srcRect.bottom = m_RenderHeight; dstRect.left = (m_ScreenWidth - m_RenderWidth) / 2; dstRect.top = (m_ScreenHeight - m_RenderHeight) / 2; dstRect.right = dstRect.left + m_RenderWidth; dstRect.bottom = dstRect.top + m_RenderHeight; m_pPrimary->Flip(NULL, DDFLIP_WAIT); // m_pPrimary->SetPalette(m_pPalette); /* HRESULT hr = m_pBackBuffer->Blt(&srcRect, m_pRenderBuffer[m_RenderIndex], &srcRect, DDBLT_WAIT, NULL); //DDBLT_WAIT if (SUCCEEDED(hr)) { hr = m_pPrimary->Blt(&dstRect, m_pBackBuffer, &srcRect, DDBLT_WAIT, NULL); if (FAILED(hr)) { OutputDebugString("primary failed\n"); WriteErrorMessage("Blt() failed for primary buffer", hr); } } else { OutputDebugString("back failed\n"); WriteErrorMessage("Blt() failed for back buffer", hr); } */ } ///////////////////////////////////////////////////////////////////////////// // void CDirectDrawWrapper::SetPalette(DWORD *pPalette) { if (NULL != m_pPalette) { DWORD palette[256]; for (DWORD i = 0; i < 256; ++i) { register DWORD value = pPalette[i]; palette[i] = (value & 0xFF00FF00) | ((value & 0x000000FF) << 16) | ((value & 0x00FF0000) >> 16); } HRESULT hr = m_pPalette->SetEntries(0, 0, 256, reinterpret_cast<PALETTEENTRY*>(palette)); if (FAILED(hr)) { OutputDebugString("SetPalette failed\n"); } } } ///////////////////////////////////////////////////////////////////////////// // void CDirectDrawWrapper::TestBlit(BYTE *pBuffer, long x, long y) { DDSURFACEDESC2 desc; IDirectDrawSurface7 *pSurface = NULL; IDirectDrawSurface7 *pVidSurface = NULL; // The documentation has instructions for creating a surface from an // existing buffer in system memory, but those instructions are wrong // (or possibly have changed since version 5 of DirectDraw). // // Whatever the reason, setting the DDSD_LPSURFACE flag will cause an // error when attempting to create the surface. Instead, the flags // DDSCAPS_LOCALVIDMEM and DDSCAPS_VIDEOMEMORY need to be set in the // dwCaps field. This was derived via experimentation (looking at // the description struct returned from Lock), so the why-for of this // is unknown. The lpSurface field should still be set to point to // the system memory buffer, and the buffer created will be initialized // with the given image data. // Initialize the surface description. memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); // desc.ddsCaps.dwCaps = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY; desc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY; desc.ddsCaps.dwCaps |= DDSCAPS_OFFSCREENPLAIN; desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS; // desc.dwFlags |= DDSD_LPSURFACE; // desc.dwFlags |= DDSD_PITCH; desc.dwWidth = 320; desc.dwHeight = 240; // desc.lPitch = 320; // desc.lpSurface = pBuffer; Format8bit(desc); // Format422(desc); // FormatRGB16(desc); // FormatRGB32(desc); // Create the surface HRESULT hr = m_pDraw->CreateSurface(&desc, &pSurface, NULL); if (FAILED(hr)) { WriteErrorMessage("CreateSurface(system) failed", hr); return; } desc.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; desc.ddsCaps.dwCaps |= DDSCAPS_OFFSCREENPLAIN; // Format422(desc); Format8bit(desc); __int64 start, stop, freq; QueryPerformanceFrequency((LARGE_INTEGER*)&freq); QueryPerformanceCounter((LARGE_INTEGER*)&start); hr = m_pDraw->CreateSurface(&desc, &pVidSurface, NULL); if (FAILED(hr)) { WriteErrorMessage("CreateSurface(video) failed", hr); pSurface->Release(); return; } else if ((NULL != pSurface) && (NULL != m_pPrimary) && (NULL != pVidSurface)) { /* desc.ddpfPixelFormat.dwFlags = DDPF_FOURCC; desc.ddpfPixelFormat.dwFourCC = 0x59565955; desc.ddpfPixelFormat.dwYUVBitCount = 16; desc.ddpfPixelFormat.dwYBitMask = 0xFF00FF00; desc.ddpfPixelFormat.dwVBitMask = 0x00FF0000; desc.ddpfPixelFormat.dwUBitMask = 0x000000FF; hr = pSurface->SetSurfaceDesc(&desc, 0); if (FAILED(hr)) { WriteErrorMessage("SetSurfaceDesc() failed for test surface", hr); } */ pSurface->SetPalette(m_pPalette); pVidSurface->SetPalette(m_pPalette); m_pPrimary->SetPalette(m_pPalette); // pSurface->Lock(NULL, &desc, DDLOCK_WRITEONLY, NULL); pVidSurface->Lock(NULL, &desc, DDLOCK_WRITEONLY, NULL); memcpy(desc.lpSurface, pBuffer, 320 * 240); // pSurface->Unlock(NULL); pVidSurface->Unlock(NULL); QueryPerformanceCounter((LARGE_INTEGER*)&stop); m_BlitCount += 1; m_BlitTime += float(double(stop - start) / double(freq)); /* memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); desc.dwFlags = DDSD_PIXELFORMAT | DDSD_CAPS; desc.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; desc.ddsCaps.dwCaps |= DDSCAPS_OFFSCREENPLAIN; desc.dwFlags |= DDSD_WIDTH | DDSD_HEIGHT; // desc.dwFlags |= DDSD_PITCH; desc.dwWidth = 320; desc.dwHeight = 240; // desc.lPitch = 320 * 2; // Format422(desc); FormatRGB16(desc); pVidSurface->GetSurfaceDesc(&desc); hr = pVidSurface->SetSurfaceDesc(&desc, 0); if (FAILED(hr)) { WriteErrorMessage("SetSurfaceDesc() failed", hr); } */ RECT srcRect = { 0, 0, 320, 240 }; RECT dstRect = { 0, 0, 320, 240 }; hr = pVidSurface->Blt(&dstRect, pSurface, &srcRect, DDBLT_WAIT, NULL); if (FAILED(hr)) { WriteErrorMessage("secondary->Blt() failed", hr); } else { dstRect.left += x; dstRect.right += x; dstRect.top += y; dstRect.bottom += y; hr = m_pPrimary->Blt(&dstRect, pSurface, &srcRect, DDBLT_WAIT, NULL); // hr = m_pPrimary->Blt(&dstRect, pVidSurface, &srcRect, DDBLT_WAIT, NULL); if (FAILED(hr)) { WriteErrorMessage("primary->Blt() failed", hr); } } pSurface->Release(); pVidSurface->Release(); } } #define TestCaps(word,file,mask) { if (0 != ((mask)&(word))) { fprintf(file, " " #mask "\n"); } } #define Decimalize(x) ((x) / 1000),((x) % 1000) DWORD AlphaBitDepth(DWORD mask) { if (DDBD_1 == mask) { return 1; } if (DDBD_2 == mask) { return 2; } if (DDBD_4 == mask) { return 4; } if (DDBD_8 == mask) { return 8; } return 0; } /* ///////////////////////////////////////////////////////////////////////////// // // LogCapabilities() // void CDirectDrawWrapper::LogCapabilities(DDCAPS &caps, FILE *pFile) { fprintf(pFile, "\nCaps:\n"); LogCaps(caps.dwCaps, pFile); fprintf(pFile, "\nCaps2:\n"); LogCaps2(caps.dwCaps2, pFile); fprintf(pFile, "\nColor-Key Caps:\n"); LogKeyCaps(caps.dwCKeyCaps, pFile); fprintf(pFile, "\nFx Caps:\n"); LogFxCaps(caps.dwFXCaps, pFile); fprintf(pFile, "\nFx Alpha Caps:\n"); LogAlphaCaps(caps.dwFXAlphaCaps, pFile); fprintf(pFile, "\nPalette Caps:\n"); LogPaletteCaps(caps.dwPalCaps, pFile); // TestCaps(caps.dwSVCaps, pFile, DDSVCAPS_ENIGMA); // TestCaps(caps.dwSVCaps, pFile, DDSVCAPS_FLICKER); // TestCaps(caps.dwSVCaps, pFile, DDSVCAPS_REDBLUE); // TestCaps(caps.dwSVCaps, pFile, DDSVCAPS_SPLIT); fprintf(pFile, "\nSystem-Memory to Display-Memory Caps:\n"); LogCaps(caps.dwSVBCaps, pFile); fprintf(pFile, "\nSystem-Memory to Display-Memory Color Key Caps:\n"); LogKeyCaps(caps.dwSVBCKeyCaps, pFile); fprintf(pFile, "\nSystem-Memory to Display-Memory Fx Caps:\n"); LogFxCaps(caps.dwSVBFXCaps, pFile); fprintf(pFile, "\nDisplay-Memory to System-Memory Caps:\n"); LogCaps(caps.dwVSBCaps, pFile); fprintf(pFile, "\nDisplay-Memory to System-Memory Color Key Caps:\n"); LogKeyCaps(caps.dwVSBCKeyCaps, pFile); fprintf(pFile, "\nDisplay-Memory to System-Memory Fx Caps:\n"); LogFxCaps(caps.dwVSBFXCaps, pFile); fprintf(pFile, "\nSystem-Memory to System-Memory Caps:\n"); LogCaps(caps.dwSSBCaps, pFile); fprintf(pFile, "\nSystem-Memory to System-Memory Color Key Caps:\n"); LogKeyCaps(caps.dwSSBCKeyCaps, pFile); fprintf(pFile, "\nSystem-Memory to System-Memory Fx Caps:\n"); LogFxCaps(caps.dwSSBFXCaps, pFile); fprintf(pFile, "\nNon-Local Memory Caps:\n"); LogCaps(caps.dwNLVBCaps, pFile); fprintf(pFile, "\nNon-Local Memory Caps2:\n"); LogCaps2(caps.dwNLVBCaps2, pFile); fprintf(pFile, "\nNon-Local Memory Color-Key Caps:\n"); LogKeyCaps(caps.dwNLVBCKeyCaps, pFile); fprintf(pFile, "\nNon-Local Memory Fx Caps:\n"); LogFxCaps(caps.dwNLVBFXCaps, pFile); fprintf(pFile, "\nMisc:\n"); fprintf(pFile, " dwAlphaBltConstBitDepths = %d\n", AlphaBitDepth(caps.dwAlphaBltConstBitDepths)); fprintf(pFile, " dwAlphaBltPixelBitDepths = %d\n", AlphaBitDepth(caps.dwAlphaBltPixelBitDepths)); fprintf(pFile, " dwAlphaBltSurfaceBitDepths = %d\n", AlphaBitDepth(caps.dwAlphaBltSurfaceBitDepths)); fprintf(pFile, " dwAlphaOverlayConstBitDepths = %d\n", AlphaBitDepth(caps.dwAlphaOverlayConstBitDepths)); fprintf(pFile, " dwAlphaOverlayPixelBitDepths = %d\n", AlphaBitDepth(caps.dwAlphaOverlayPixelBitDepths)); fprintf(pFile, " dwAlphaOverlaySurfaceBitDepths = %d\n", AlphaBitDepth(caps.dwAlphaOverlaySurfaceBitDepths)); fprintf(pFile, " dwVidMemTotal = %d KB\n", caps.dwVidMemTotal / 1024); fprintf(pFile, " dwVidMemFree = %d KB\n", caps.dwVidMemFree / 1024); fprintf(pFile, " dwMaxVisibleOverlays = %d\n", caps.dwMaxVisibleOverlays); fprintf(pFile, " dwCurrVisibleOverlays = %d\n", caps.dwCurrVisibleOverlays); fprintf(pFile, " dwNumFourCCCodes = %d\n", caps.dwNumFourCCCodes); fprintf(pFile, " dwAlignBoundarySrc = %d\n", caps.dwAlignBoundarySrc); fprintf(pFile, " dwAlignSizeSrc = %d\n", caps.dwAlignSizeSrc); fprintf(pFile, " dwAlignBoundaryDest = %d\n", caps.dwAlignBoundaryDest); fprintf(pFile, " dwAlignSizeDest = %d\n", caps.dwAlignSizeDest); fprintf(pFile, " dwAlignStrideAlign = %d\n", caps.dwAlignStrideAlign); fprintf(pFile, " dwMinOverlayStretch = %d.%03d\n", Decimalize(caps.dwMinOverlayStretch)); fprintf(pFile, " dwMaxOverlayStretch = %d.%03d\n", Decimalize(caps.dwMaxOverlayStretch)); fprintf(pFile, " dwMinLiveVideoStretch = %d.%03d\n", Decimalize(caps.dwMinLiveVideoStretch)); fprintf(pFile, " dwMaxLiveVideoStretch = %d.%03d\n", Decimalize(caps.dwMaxLiveVideoStretch)); fprintf(pFile, " dwMinHwCodecStretch = %d.%03d\n", Decimalize(caps.dwMinHwCodecStretch)); fprintf(pFile, " dwMaxHwCodecStretch = %d.%03d\n", Decimalize(caps.dwMaxHwCodecStretch)); fprintf(pFile, " dwAlignStrideAlign = %d\n", caps.dwAlignStrideAlign); fprintf(pFile, " dwMaxVideoPorts = %d\n", caps.dwMaxVideoPorts); fprintf(pFile, " dwCurrVideoPorts = %d\n", caps.dwCurrVideoPorts); if ((caps.dwNumFourCCCodes > 0) && (caps.dwNumFourCCCodes < 128)) { fprintf(pFile, "\nFOURCC codes: %d\n", caps.dwNumFourCCCodes); DWORD count = caps.dwNumFourCCCodes; DWORD fourcc[128]; m_pDraw->GetFourCCCodes(&count, fourcc); for (DWORD i = 0; i < count; ++i) { DWORD block[2]; block[0] = fourcc[i]; block[1] = 0; fprintf(pFile, " 0x%08X = %s\n", block[0], block); } } fprintf(pFile, "\nSurface Caps:\n"); // TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_3D); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_3DDEVICE); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_ALLOCONLOAD); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_ALPHA); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_BACKBUFFER); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_COMPLEX); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_FLIP); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_FRONTBUFFER); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_HWCODEC); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_LIVEVIDEO); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_LOCALVIDMEM); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_MIPMAP); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_MODEX); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_NONLOCALVIDMEM); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_OFFSCREENPLAIN); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_OPTIMIZED); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_OVERLAY); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_OWNDC); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_PALETTE); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_PRIMARYSURFACE); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_PRIMARYSURFACELEFT); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_STANDARDVGAMODE); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_SYSTEMMEMORY); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_TEXTURE); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_VIDEOMEMORY); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_VIDEOPORT); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_VISIBLE); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_WRITEONLY); TestCaps(caps.ddsCaps.dwCaps, pFile, DDSCAPS_ZBUFFER); TestCaps(caps.ddsCaps.dwCaps2, pFile, DDSCAPS2_HARDWAREDEINTERLACE); TestCaps(caps.ddsCaps.dwCaps2, pFile, DDSCAPS2_HINTANTIALIASING); TestCaps(caps.ddsCaps.dwCaps2, pFile, DDSCAPS2_HINTDYNAMIC); TestCaps(caps.ddsCaps.dwCaps2, pFile, DDSCAPS2_HINTSTATIC); TestCaps(caps.ddsCaps.dwCaps2, pFile, DDSCAPS2_OPAQUE); TestCaps(caps.ddsCaps.dwCaps2, pFile, DDSCAPS2_TEXTUREMANAGE); // TestCaps(caps.ddsCaps.dwCaps4, pFile, DDSCAPS4_NONGDIPRIMARY); } void CDirectDrawWrapper::LogCaps(DWORD flags, FILE *pFile) { TestCaps(flags, pFile, DDCAPS_3D); TestCaps(flags, pFile, DDCAPS_ALIGNBOUNDARYDEST); TestCaps(flags, pFile, DDCAPS_ALIGNBOUNDARYSRC); TestCaps(flags, pFile, DDCAPS_ALIGNSIZEDEST); TestCaps(flags, pFile, DDCAPS_ALIGNSIZESRC); TestCaps(flags, pFile, DDCAPS_ALIGNSTRIDE); TestCaps(flags, pFile, DDCAPS_ALPHA); TestCaps(flags, pFile, DDCAPS_BANKSWITCHED); TestCaps(flags, pFile, DDCAPS_BLT); TestCaps(flags, pFile, DDCAPS_BLTCOLORFILL); TestCaps(flags, pFile, DDCAPS_BLTDEPTHFILL); TestCaps(flags, pFile, DDCAPS_BLTFOURCC); TestCaps(flags, pFile, DDCAPS_BLTQUEUE); TestCaps(flags, pFile, DDCAPS_BLTSTRETCH); TestCaps(flags, pFile, DDCAPS_CANBLTSYSMEM); TestCaps(flags, pFile, DDCAPS_CANCLIP); TestCaps(flags, pFile, DDCAPS_CANCLIPSTRETCHED); TestCaps(flags, pFile, DDCAPS_COLORKEY); TestCaps(flags, pFile, DDCAPS_GDI); TestCaps(flags, pFile, DDCAPS_NOHARDWARE); TestCaps(flags, pFile, DDCAPS_OVERLAY); TestCaps(flags, pFile, DDCAPS_OVERLAYCANTCLIP); TestCaps(flags, pFile, DDCAPS_OVERLAYFOURCC); TestCaps(flags, pFile, DDCAPS_OVERLAYSTRETCH); TestCaps(flags, pFile, DDCAPS_PALETTE); TestCaps(flags, pFile, DDCAPS_PALETTEVSYNC); TestCaps(flags, pFile, DDCAPS_READSCANLINE); // TestCaps(flags, pFile, DDCAPS_STEREOVIEW); TestCaps(flags, pFile, DDCAPS_VBI); TestCaps(flags, pFile, DDCAPS_ZBLTS); TestCaps(flags, pFile, DDCAPS_ZOVERLAYS); } void CDirectDrawWrapper::LogCaps2(DWORD flags, FILE *pFile) { TestCaps(flags, pFile, DDCAPS2_AUTOFLIPOVERLAY); TestCaps(flags, pFile, DDCAPS2_CANBOBHARDWARE); TestCaps(flags, pFile, DDCAPS2_CANBOBINTERLEAVED); TestCaps(flags, pFile, DDCAPS2_CANBOBNONINTERLEAVED); TestCaps(flags, pFile, DDCAPS2_CANDROPZ16BIT); TestCaps(flags, pFile, DDCAPS2_CANFLIPODDEVEN); TestCaps(flags, pFile, DDCAPS2_CANRENDERWINDOWED); TestCaps(flags, pFile, DDCAPS2_CERTIFIED); TestCaps(flags, pFile, DDCAPS2_COLORCONTROLPRIMARY); TestCaps(flags, pFile, DDCAPS2_COLORCONTROLOVERLAY); TestCaps(flags, pFile, DDCAPS2_COPYFOURCC); TestCaps(flags, pFile, DDCAPS2_FLIPINTERVAL); TestCaps(flags, pFile, DDCAPS2_FLIPNOVSYNC); TestCaps(flags, pFile, DDCAPS2_NO2DDURING3DSCENE); TestCaps(flags, pFile, DDCAPS2_NONLOCALVIDMEM); TestCaps(flags, pFile, DDCAPS2_NONLOCALVIDMEMCAPS); TestCaps(flags, pFile, DDCAPS2_NOPAGELOCKREQUIRED); TestCaps(flags, pFile, DDCAPS2_PRIMARYGAMMA); TestCaps(flags, pFile, DDCAPS2_VIDEOPORT); TestCaps(flags, pFile, DDCAPS2_WIDESURFACES); } void CDirectDrawWrapper::LogKeyCaps(DWORD flags, FILE *pFile) { TestCaps(flags, pFile, DDCKEYCAPS_DESTBLT); TestCaps(flags, pFile, DDCKEYCAPS_DESTBLTCLRSPACE); TestCaps(flags, pFile, DDCKEYCAPS_DESTBLTCLRSPACEYUV); TestCaps(flags, pFile, DDCKEYCAPS_DESTBLTYUV); TestCaps(flags, pFile, DDCKEYCAPS_DESTOVERLAY); TestCaps(flags, pFile, DDCKEYCAPS_DESTOVERLAYCLRSPACE); TestCaps(flags, pFile, DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV); TestCaps(flags, pFile, DDCKEYCAPS_DESTOVERLAYONEACTIVE); TestCaps(flags, pFile, DDCKEYCAPS_DESTOVERLAYYUV); TestCaps(flags, pFile, DDCKEYCAPS_NOCOSTOVERLAY); TestCaps(flags, pFile, DDCKEYCAPS_SRCBLT); TestCaps(flags, pFile, DDCKEYCAPS_SRCBLTCLRSPACE); TestCaps(flags, pFile, DDCKEYCAPS_SRCBLTCLRSPACEYUV); TestCaps(flags, pFile, DDCKEYCAPS_SRCBLTYUV); TestCaps(flags, pFile, DDCKEYCAPS_SRCOVERLAY); TestCaps(flags, pFile, DDCKEYCAPS_SRCOVERLAYCLRSPACE); TestCaps(flags, pFile, DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV); TestCaps(flags, pFile, DDCKEYCAPS_SRCOVERLAYONEACTIVE); TestCaps(flags, pFile, DDCKEYCAPS_SRCOVERLAYYUV); } void CDirectDrawWrapper::LogFxCaps(DWORD flags, FILE *pFile) { TestCaps(flags, pFile, DDFXCAPS_BLTALPHA); TestCaps(flags, pFile, DDFXCAPS_BLTARITHSTRETCHY); TestCaps(flags, pFile, DDFXCAPS_BLTARITHSTRETCHYN); TestCaps(flags, pFile, DDFXCAPS_BLTFILTER); TestCaps(flags, pFile, DDFXCAPS_BLTMIRRORLEFTRIGHT); TestCaps(flags, pFile, DDFXCAPS_BLTMIRRORUPDOWN); TestCaps(flags, pFile, DDFXCAPS_BLTROTATION); TestCaps(flags, pFile, DDFXCAPS_BLTROTATION90); TestCaps(flags, pFile, DDFXCAPS_BLTSHRINKX); TestCaps(flags, pFile, DDFXCAPS_BLTSHRINKXN); TestCaps(flags, pFile, DDFXCAPS_BLTSHRINKY); TestCaps(flags, pFile, DDFXCAPS_BLTSHRINKYN); TestCaps(flags, pFile, DDFXCAPS_BLTSTRETCHX); TestCaps(flags, pFile, DDFXCAPS_BLTSTRETCHXN); TestCaps(flags, pFile, DDFXCAPS_BLTSTRETCHY); TestCaps(flags, pFile, DDFXCAPS_BLTSTRETCHYN); // TestCaps(flags, pFile, DDFXCAPS_BLTTRANSFORM); TestCaps(flags, pFile, DDFXCAPS_OVERLAYALPHA); TestCaps(flags, pFile, DDFXCAPS_OVERLAYARITHSTRETCHY); TestCaps(flags, pFile, DDFXCAPS_OVERLAYARITHSTRETCHYN); TestCaps(flags, pFile, DDFXCAPS_OVERLAYFILTER); TestCaps(flags, pFile, DDFXCAPS_OVERLAYMIRRORLEFTRIGHT); TestCaps(flags, pFile, DDFXCAPS_OVERLAYMIRRORUPDOWN); TestCaps(flags, pFile, DDFXCAPS_OVERLAYSHRINKX); TestCaps(flags, pFile, DDFXCAPS_OVERLAYSHRINKXN); TestCaps(flags, pFile, DDFXCAPS_OVERLAYSHRINKY); TestCaps(flags, pFile, DDFXCAPS_OVERLAYSHRINKYN); TestCaps(flags, pFile, DDFXCAPS_OVERLAYSTRETCHX); TestCaps(flags, pFile, DDFXCAPS_OVERLAYSTRETCHXN); TestCaps(flags, pFile, DDFXCAPS_OVERLAYSTRETCHY); TestCaps(flags, pFile, DDFXCAPS_OVERLAYSTRETCHYN); // TestCaps(flags, pFile, DDFXCAPS_OVERLAYTRANSFORM); } void CDirectDrawWrapper::LogAlphaCaps(DWORD flags, FILE *pFile) { TestCaps(flags, pFile, DDFXALPHACAPS_BLTALPHAEDGEBLEND); TestCaps(flags, pFile, DDFXALPHACAPS_BLTALPHAPIXELS); TestCaps(flags, pFile, DDFXALPHACAPS_BLTALPHAPIXELSNEG); TestCaps(flags, pFile, DDFXALPHACAPS_BLTALPHASURFACES); TestCaps(flags, pFile, DDFXALPHACAPS_BLTALPHASURFACESNEG); TestCaps(flags, pFile, DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND); TestCaps(flags, pFile, DDFXALPHACAPS_OVERLAYALPHAPIXELS); TestCaps(flags, pFile, DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG); TestCaps(flags, pFile, DDFXALPHACAPS_OVERLAYALPHASURFACES); TestCaps(flags, pFile, DDFXALPHACAPS_OVERLAYALPHASURFACESNEG); } void CDirectDrawWrapper::LogPaletteCaps(DWORD flags, FILE *pFile) { TestCaps(flags, pFile, DDPCAPS_8BIT); TestCaps(flags, pFile, DDPCAPS_8BITENTRIES); TestCaps(flags, pFile, DDPCAPS_ALPHA); TestCaps(flags, pFile, DDPCAPS_ALLOW256); TestCaps(flags, pFile, DDPCAPS_PRIMARYSURFACE); TestCaps(flags, pFile, DDPCAPS_PRIMARYSURFACELEFT); TestCaps(flags, pFile, DDPCAPS_VSYNC); TestCaps(flags, pFile, DDPCAPS_1BIT); TestCaps(flags, pFile, DDPCAPS_2BIT); TestCaps(flags, pFile, DDPCAPS_4BIT); } */
[ [ [ 1, 1035 ] ] ]
f8ee70748184e3fdc5ece73dac320e3812561b1d
502efe97b985c69d6378d9c428c715641719ee03
/src/moaicore/MOAIParticleState.cpp
1ab9431919554b78ed8962797e40884951635718
[]
no_license
neojjang/moai-beta
c3933bca2625bca4f4da26341de6b855e41b9beb
6bc96412d35192246e35bff91df101bd7c7e41e1
refs/heads/master
2021-01-16T20:33:59.443558
2011-09-19T23:45:06
2011-09-19T23:45:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,611
cpp
// Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved. // http://getmoai.com #include "pch.h" #include <moaicore/MOAIDeck.h> #include <moaicore/MOAILogMessages.h> #include <moaicore/MOAIParticleForce.h> #include <moaicore/MOAIParticlePlugin.h> #include <moaicore/MOAIParticleScript.h> #include <moaicore/MOAIParticleState.h> #include <moaicore/MOAIParticleSystem.h> class MOAIDataBuffer; //================================================================// // local //================================================================// //----------------------------------------------------------------// /** @name clearForces @text Removes all particle forces from the state. @in MOAIParticleState self @out nil */ int MOAIParticleState::_clearForces ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIParticleState, "U" ) self->ClearForces (); return 0; } //----------------------------------------------------------------// /** @name pushForce @text Adds a force to the state. @in MOAIParticleState self @in MOAIParticleForce force @out nil */ int MOAIParticleState::_pushForce ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIParticleState, "UU" ) MOAIParticleForce* force = state.GetLuaObject < MOAIParticleForce >( 2 ); if ( force ) { self->PushForce ( *force ); } return 0; } //----------------------------------------------------------------// /** @name setDamping @text Sets damping for particle physics model. @in MOAIParticleState self @in number damping @out nil */ int MOAIParticleState::_setDamping ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIParticleState, "UN" ) self->mDamping = state.GetValue < float >( 2, 0.0f ); return 0; } //----------------------------------------------------------------// /** @name setRenderScript @text Sets the particle script to use for initializing new particles. @in MOAIParticleState self @opt MOAIParticleScript script @out nil */ int MOAIParticleState::_setInitScript ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIParticleState, "U" ) MOAIParticleScript* init = state.GetLuaObject < MOAIParticleScript >( 2 ); if ( init ) { init->Compile (); } self->mInit = init; return 0; } //----------------------------------------------------------------// /** @name setMass @text Sets range of masses (chosen randomly) for particles initialized by the state. @in MOAIParticleState self @in number minMass @opt number maxMass Default value is minMass. @out nil */ int MOAIParticleState::_setMass ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIParticleState, "UN" ) float m0 = state.GetValue < float >( 2, 0.0f ); float m1 = state.GetValue < float >( 3, m0 ); self->mMassRange [ 0 ] = m0; self->mMassRange [ 1 ] = m1; return 0; } //----------------------------------------------------------------// /** @name setNext @text Sets the next state (if any). @in MOAIParticleState self @opt MOAIParticleState next Default value is nil. @out nil */ int MOAIParticleState::_setNext ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIParticleState, "U" ) self->mNext = state.GetLuaObject < MOAIParticleState >( 2 ); return 0; } //----------------------------------------------------------------// /** @name setPlugin @text Sets the particle plugin to use for initializing and updating particles. @in MOAIParticleState self @opt MOAIParticlePlugin plugin @out nil */ int MOAIParticleState::_setPlugin ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIParticleState, "U" ) MOAIParticlePlugin* plugin = state.GetLuaObject < MOAIParticlePlugin >( 2 ); self->mPlugin = plugin; return 0; } //----------------------------------------------------------------// /** @name setRenderScript @text Sets the particle script to use for rendering particles. @in MOAIParticleState self @opt MOAIParticleScript script @out nil */ int MOAIParticleState::_setRenderScript ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIParticleState, "U" ) MOAIParticleScript* render = state.GetLuaObject < MOAIParticleScript >( 2 ); if ( render ) { render->Compile (); } self->mRender = render; return 0; } //----------------------------------------------------------------// /** @name setTerm @text Sets range of terms (chosen randomly) for particles initialized by the state. @in MOAIParticleState self @in number minTerm @opt number maxTerm Default value is minTerm. @out nil */ int MOAIParticleState::_setTerm ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIParticleState, "UN" ) float t0 = state.GetValue < float >( 2, 0.0f ); float t1 = state.GetValue < float >( 3, t0 ); self->mTermRange [ 0 ] = t0; self->mTermRange [ 1 ] = t1; return 0; } //================================================================// // MOAIParticleState //================================================================// //----------------------------------------------------------------// void MOAIParticleState::ClearForces () { while ( this->mForces.Count ()) { ForceNode* forceNode = this->mForces.Head (); this->mForces.PopFront (); forceNode->Data ()->Release (); delete forceNode; } } //----------------------------------------------------------------// void MOAIParticleState::GatherForces ( USVec2D& loc, USVec2D& velocity, float mass, float step ) { USVec2D result; USVec2D acceleration ( 0.0f, 0.0f ); USVec2D offset ( 0.0f, 0.0f ); ForceNode* forceNode = this->mForces.Head (); for ( ; forceNode; forceNode = forceNode->Next ()) { MOAIParticleForce* particleForce = forceNode->Data (); particleForce->Eval ( loc, mass, acceleration, offset ); } velocity.mX += acceleration.mX * step; velocity.mY += acceleration.mY * step; velocity.Scale ( USFloat::Clamp ( 1.0f - ( this->mDamping * step ), 0.0f, 1.0f )); loc.mX += ( velocity.mX + offset.mX ) * step; loc.mY += ( velocity.mY + offset.mY ) * step; } //----------------------------------------------------------------// void MOAIParticleState::InitParticle ( MOAIParticleSystem& system, MOAIParticle& particle ) { if ( this->mInit ) { this->mInit->Run ( system, particle, 0.0f, 0.0f ); } MOAIParticlePlugin* plugin = this->mPlugin; if ( plugin && plugin->mInitFunc ) { plugin->mInitFunc ( particle.mData, &particle.mData [ MOAIParticle::TOTAL_PARTICLE_REG ]); } particle.mAge = 0.0f; particle.mTerm = USFloat::Rand ( this->mTermRange [ 0 ], this->mTermRange [ 1 ]); particle.mMass = USFloat::Rand ( this->mMassRange [ 0 ], this->mMassRange [ 1 ]); particle.mState = this; } //----------------------------------------------------------------// MOAIParticleState::MOAIParticleState () : mDamping ( 0.0f ) { RTTI_BEGIN RTTI_EXTEND ( USLuaObject ) RTTI_END this->mMassRange [ 0 ] = 1.0f; this->mMassRange [ 1 ] = 1.0f; this->mTermRange [ 0 ] = 1.0f; this->mTermRange [ 1 ] = 1.0f; } //----------------------------------------------------------------// MOAIParticleState::~MOAIParticleState () { this->ClearForces (); } //----------------------------------------------------------------// void MOAIParticleState::PushForce ( MOAIParticleForce& force ) { force.Retain (); ForceNode* forceNode = new ForceNode (); forceNode->Data ( &force ); this->mForces.PushBack ( *forceNode ); } //----------------------------------------------------------------// void MOAIParticleState::RegisterLuaClass ( USLuaState& state ) { UNUSED ( state ); } //----------------------------------------------------------------// void MOAIParticleState::RegisterLuaFuncs ( USLuaState& state ) { luaL_Reg regTable [] = { { "clearForces", _clearForces }, { "pushForce", _pushForce }, { "setDamping", _setDamping }, { "setInitScript", _setInitScript }, { "setMass", _setMass }, { "setPlugin", _setPlugin }, { "setNext", _setNext }, { "setRenderScript", _setRenderScript }, { "setTerm", _setTerm }, { NULL, NULL } }; luaL_register ( state, 0, regTable ); } //----------------------------------------------------------------// void MOAIParticleState::ProcessParticle ( MOAIParticleSystem& system, MOAIParticle& particle, float step ) { float t0 = particle.mAge / particle.mTerm; particle.mAge += step; if ( particle.mAge > particle.mTerm ) { particle.mAge = particle.mTerm; } float t1 = particle.mAge / particle.mTerm; float* r = particle.mData; USVec2D loc; USVec2D vel; loc.mX = r [ MOAIParticle::PARTICLE_X ]; loc.mY = r [ MOAIParticle::PARTICLE_Y ]; vel.mX = r [ MOAIParticle::PARTICLE_DX ]; vel.mY = r [ MOAIParticle::PARTICLE_DY ]; this->GatherForces ( loc, vel, particle.mMass, step ); r [ MOAIParticle::PARTICLE_X ] = loc.mX; r [ MOAIParticle::PARTICLE_Y ] = loc.mY; r [ MOAIParticle::PARTICLE_DX ] = vel.mX; r [ MOAIParticle::PARTICLE_DY ] = vel.mY; if ( this->mRender ) { this->mRender->Run ( system, particle, t0, t1 ); } MOAIParticlePlugin* plugin = this->mPlugin; if ( plugin && plugin->mRenderFunc ) { AKUParticleSprite sprite; plugin->mRenderFunc ( particle.mData, &particle.mData [ MOAIParticle::TOTAL_PARTICLE_REG ], &sprite, t0, t1 ); system.PushSprite ( sprite ); } if ( particle.mAge >= particle.mTerm ) { if ( this->mNext ) { this->mNext->InitParticle ( system, particle ); } else { particle.mState = 0; } } }
[ "[email protected]", "Patrick@agile.(none)", "[email protected]" ]
[ [ [ 1, 7 ], [ 9, 10 ], [ 12, 51 ], [ 111, 126 ], [ 188, 204 ], [ 228, 228 ], [ 230, 230 ], [ 239, 239 ], [ 244, 246 ], [ 249, 252 ], [ 259, 286 ], [ 296, 300 ] ], [ [ 8, 8 ], [ 127, 144 ], [ 232, 237 ], [ 292, 292 ], [ 305, 308 ], [ 311, 312 ], [ 330, 332 ], [ 341, 341 ] ], [ [ 11, 11 ], [ 52, 110 ], [ 145, 187 ], [ 205, 227 ], [ 229, 229 ], [ 231, 231 ], [ 238, 238 ], [ 240, 243 ], [ 247, 248 ], [ 253, 258 ], [ 287, 291 ], [ 293, 295 ], [ 301, 304 ], [ 309, 310 ], [ 313, 329 ], [ 333, 340 ], [ 342, 352 ] ] ]
1018a4531c0d9a20fbb57e1cad7c7a80dcbed4c0
3387244856041685a94b72264d41a80ae35c3f80
/include/Mutex.h
364cf353d7e293dc9cb2cace162a02cc8d40ed84
[]
no_license
kinfung0602/ogre-tower-defense
768c9ae0c0972379cfbddf91361cf343b8c76dfb
ce950d36b49ea46e294d936f3cd363bcc73c8468
refs/heads/master
2021-01-10T08:22:05.424893
2011-07-11T01:32:05
2011-07-11T01:32:05
53,152,007
0
0
null
null
null
null
UTF-8
C++
false
false
463
h
#pragma once #define SCOPELOCK(m) MutexLocker locker(m); class Mutex { public: Mutex(void); ~Mutex(void); void lock(void); bool tryLock(void); bool tryLock(int timeout); void unlock(); bool locked(); private: // Disable copying Mutex(const Mutex&) {} Mutex& operator = (const Mutex&) {} private: void* handle; }; class MutexLocker { public: MutexLocker(Mutex*); ~MutexLocker(void); Mutex* m; };
[ [ [ 1, 34 ] ] ]
f108aa5ca87dc5fe839a4b8eb0e78bbd5428b77f
b2155efef00dbb04ae7a23e749955f5ec47afb5a
/source/libOEMsg/OEMsgRenderState.cpp
4413ea1c7a3c2bd457aec1ca0ac28fcb925ab478
[]
no_license
zjhlogo/originengine
00c0bd3c38a634b4c96394e3f8eece86f2fe8351
a35a83ed3f49f6aeeab5c3651ce12b5c5a43058f
refs/heads/master
2021-01-20T13:48:48.015940
2011-04-21T04:10:54
2011-04-21T04:10:54
32,371,356
1
0
null
null
null
null
UTF-8
C++
false
false
1,087
cpp
/*! * \file OEMsgRenderState.cpp * \date 10-29-2010 0:03:49 * * * \author zjhlogo ([email protected]) */ #include <libOEMsg/OEMsgRenderState.h> #include <libOEMsg/OEMsgList.h> COEMsgRenderState::COEMsgRenderState(const COERenderState& RenderState, const tstring& strCommon /* = EMPTY_STRING */) :IOEMsg(OMI_RESTORE_RENDER_STATE) { m_RenderState = RenderState; m_strCommon = strCommon; } COEMsgRenderState::COEMsgRenderState(COEDataBufferRead* pDBRead) :IOEMsg(pDBRead) { FromBuffer(pDBRead); } COEMsgRenderState::~COEMsgRenderState() { // TODO: } bool COEMsgRenderState::FromBuffer(COEDataBufferRead* pDBRead) { pDBRead->Read(&m_RenderState, sizeof(m_RenderState)); // TODO: read string return true; } bool COEMsgRenderState::ToBuffer(COEDataBufferWrite* pDBWrite) { pDBWrite->Write(&m_RenderState, sizeof(m_RenderState)); // TODO: write string return true; } COERenderState& COEMsgRenderState::GetRenderState() { return m_RenderState; } const tstring& COEMsgRenderState::GetCommon() { return m_strCommon; }
[ "zjhlogo@fdcc8808-487c-11de-a4f5-9d9bc3506571" ]
[ [ [ 1, 51 ] ] ]
96c1425f41edcc3e546e90f9f743d232c603fb60
5efdf4f304c39c1aa8a24ab5a9690afad3340c00
/src/HockeyData_2.cpp
fed20c3d932902372d605aa16c82cc824be95871
[]
no_license
asquared/hockeyboard
286f57d8bea282e74425cbe77d915d692398f722
06480cb228dcd6d4792964837e20a1dddea89d1b
refs/heads/master
2016-09-06T11:16:20.947224
2011-01-09T21:23:16
2011-01-09T21:23:16
1,236,086
1
0
null
null
null
null
UTF-8
C++
false
false
9,135
cpp
#include "HockeyData.h" #include "utility.h" int invertTime( unsigned char period, int timeleft, int perlen, int otlen ) { // figure out time until next change of status int out = (period-1) * perlen + ( perlen - timeleft ); // overtime adjust #ifdef LAX if ( period > 4 && otlen < perlen ) out -= (period - 4) * (perlen - otlen); #else if ( period > 3 && otlen < perlen ) out -= (period - 3) * (perlen - otlen); #endif return out; } #ifndef LAX void PenaltyQueue::split_queue() { int inc_time[2]; inc_time[0] = time[0]; inc_time[1] = time[1]; qt[0] = qt[1] = 0; for (unsigned int q = 2; q < MAX_QUEUE; ++q) { if (!qm[q]) return; // end of queue if (inc_time[0] <= inc_time[1]) { qt[0] += qm[q]; inc_time[0] += qm[q] * Q_LEN; } else { qt[1] += qm[q]; inc_time[1] += qm[q] * Q_LEN; } } } #endif // time_mode: // 0: start after previous penalty (previous penalty expired normally) // 1: start now (previous penalty deleted) int PenaltyQueue::pop_queue(int slot, int curr, int time_mode) { qm[slot] = qm[ACTIVE_QUEUE]; if (!time_mode) time[slot] += qm[slot] * Q_LEN; else time[slot] = curr + qm[slot] * Q_LEN; for (int q = ACTIVE_QUEUE+1; q < MAX_QUEUE; ++q) { qm[q-1] = qm[q]; if (!qm[q]) break; } qm[MAX_QUEUE-1] = 0; split_queue(); return qm[slot]; } int PenaltyQueue::push_queue(int min) { for (int q = 0; q < MAX_QUEUE; ++q) { if (qm[q] <= 0) { qm[q] = min; split_queue(); return q; } } return MAX_QUEUE; // queue full } void HockeyData::addPenalty(unsigned char team, unsigned char beginperiod, int begintime, int min) { if (team >= 2) return; int curr = invertTime(beginperiod, begintime, perlen, otlen); unsigned int slot = pq[team].push_queue(min); if ( slot < ACTIVE_QUEUE ) { pq[team].time[slot] = curr + min * Q_LEN; } } /* void HockeyData::addPenaltyToSlot(unsigned char index, unsigned char beginperiod, int begintime, int min) { int curr = invertTime(beginperiod, begintime, otlen); if (index < 0 && index > 3) return; // check index if (pt[index].queue_min[MAX_QUEUE-1] != 0) return; // if queue full // add to queue_min for (int q = 0; q < MAX_QUEUE; ++q) { if (pt[index].queue_min[q] == 0) { pt[index].queue_min[q] = min; // double major if (min == 4 && q <= MAX_QUEUE-2) { pt[index].queue_min[q] = 2; pt[index].queue_min[q+1] = 2; } break; } } // add on any time in earlier penalties to these penalty minutes pt[index].time = curr + min*60*1000 + pt[index].rem_m*60*1000 + pt[index].rem_s*1000; } */ // Delete entire team's penalties void HockeyData::delPenalty(unsigned int team) { if (team >= 0 && team <= 1) { for (int t = 0; t < MAX_QUEUE; ++t) pq[team].qm[t] = 0; } } // Delete single penalty void HockeyData::delPenalty(unsigned int team, unsigned int slot) { if (team >= 2 || slot >= MAX_QUEUE) return; int curr = invertTime(period, clock.read(), perlen, otlen); bool partial = false; #ifndef LAX if (pq[team].qm[slot] >= 4 && !(pq[team].qm[slot] & 1)) { pq[team].qm[slot] -= 2; partial = true; } else if (pq[team].qm[slot] >= 7 && (pq[team].qm[slot] & 1)) { pq[team].qm[slot] -= 5; partial = true; } #endif if (slot < ACTIVE_QUEUE) { if (partial) { //int rem = pq[team].time[slot] - curr; //pq[team].qm[slot] = min( pq[team].qm[slot], rem / (2*Q_LEN) * 2 ); if (pq[team].time[slot] - curr > pq[team].qm[slot] * Q_LEN) { pq[team].time[slot] = curr + pq[team].qm[slot] * Q_LEN; } } else { pq[team].pop_queue(slot, curr, 1); //pq[team].time[slot] = curr + pq[team].qm[slot] * Q_LEN; } } else { if (!partial) { pq[team].qm[slot] = 0; for (int t = slot+1; t < MAX_QUEUE; ++t) pq[team].qm[t-1] = pq[team].qm[t]; } } pq[team].split_queue(); } void HockeyData::delLastPenalty(unsigned int team) { for (int t = MAX_QUEUE - 1; t >= 0; --t) { if (pq[team].qm[t] > 0) { delPenalty(team, t); break; } } } void HockeyData::editQueue(unsigned int team, std::string qstr) { // parse vector<string> vs; int nums[MAX_QUEUE] = { 0 }; IniParser::trim(qstr); IniParser::remove_dup_delim(qstr, " "); IniParser::parsedelim(qstr, " ", vs); for (unsigned int i = 0; i < min(MAX_QUEUE, vs.size()); ++i) { nums[i] = IniParser::parseint(vs[i], 0); } // set int curr = invertTime(period, clock.read(), perlen, otlen); for ( int i = 0; i < MAX_QUEUE; ++i ) { if (nums[i] > 0 && nums[i] < 99) { if (i < ACTIVE_QUEUE) { int new_time = curr + nums[i] * Q_LEN; if (pq[team].qm[i] <= 0 || pq[team].time[i] > new_time) { pq[team].time[i] = new_time; } } pq[team].qm[i] = nums[i]; } else { for (int j = i; j < MAX_QUEUE; ++j) pq[team].qm[j] = 0; break; } } pq[team].split_queue(); } #ifndef LAX void HockeyData::delPenaltyAuto() { unsigned char ac = 0; unsigned char ai; for (int q = 0; q < 2; ++q) { for (int t = 0; t < 2; ++t) { if ( pq[q].active(t) ) { ++ac; ai = (q << 1) + t; } } } if ( ac == 1 ) delPenalty(ai >> 1, ai & 1); } #endif void HockeyData::setPenaltyTime(unsigned int team, unsigned int slot, int per, int time, bool start) { if (team > 1 || slot >= ACTIVE_QUEUE || per < 1 || per > 9 || time < 0 || time > perlen) return; pq[team].time[slot] = invertTime(per, time, perlen, otlen) + (start ? (Q_LEN * pq[team].qm[slot]) : 0); pq[team].split_queue(); } void HockeyData::adjustPenaltyTime(unsigned int team, unsigned int slot, int time) { if (team > 1 || slot >= ACTIVE_QUEUE) return; pq[team].time[slot] += time; pq[team].split_queue(); } void HockeyData::setRemPenaltyTime(unsigned int team, unsigned int slot, int time) { if (team > 1 || slot >= ACTIVE_QUEUE) return; int curr = invertTime(period, clock.read(), perlen, otlen); pq[team].time[slot] = curr + time; pq[team].split_queue(); } void HockeyData::updatePenalty() { int curr = invertTime(period, clock.read(), perlen, otlen); int low = 0x7fffffff; int rem; for (int q = 0; q < 2; ++q) { for (int t = 0; t < ACTIVE_QUEUE; ++t) { register short& qm = pq[q].qm[t]; register unsigned short& qt = pq[q].qt[t]; rem = 0; if (qm != 0) rem = pq[q].time[t] - curr; // update clock // kill combinations (i.e. 4 = 2+2, 7 = 5+2, etc.) /* if (qm >= 4 && qm < 10 && !(qm & 1)) { if (rem <= (qm - 2) * Q_LEN) qm -= 2; } else if (qm >= 7 && (qm & 1)) { if (rem <= (qm - 5) * Q_LEN) qm -= 5; } */ // kill front of queue (and pop the next into the front) at right time if (qt != 0 && rem <= 0) { pq[q].pop_queue(t, curr, 0); //pq[q].time[t] += pq[q].qm[t] * Q_LEN; rem = pq[q].time[t] - curr; } // kill negative time after 5 seconds else if (qt == 0 && rem <= -5000 ) { qm = 0; } // negative minutes (only at end of timer, when only one should be in queue) else if ( rem <= 0 && qm > 0 ) qm = -(qm); else if ( rem > 0 && qm < 0 ) qm = -(qm); // don't show negative time if (qm <= 0 && qt == 0) { pq[q].rem_m[t] = 0; pq[q].rem_s[t] = 0; } else { rem += qt * Q_LEN; // add queued time if ( rem % 1000 == 0 ) rem /= 1000; else rem = (rem + 1000) / 1000; if (rem < low) { low = rem; pt_low_index = q*ACTIVE_QUEUE + t; } pq[q].rem_m[t] = rem / 60; pq[q].rem_s[t] = rem % 60; } } } } void HockeyData::getPenaltyInfo(unsigned short& vis, unsigned short& home, unsigned short& rmin, unsigned short& rsec) { updatePenalty(); #ifdef LAX vis = home = 10; #else vis = home = 5; #endif if ( pq[0].qm[0] > 0 ) --vis; if ( pq[0].qm[1] > 0 ) --vis; if ( pq[1].qm[0] > 0 ) --home; if ( pq[1].qm[1] > 0 ) --home; #ifdef LAX if ( pq[0].qm[2] > 0 ) --vis; if ( pq[1].qm[2] > 0 ) --home; #endif rmin = rsec = 0; #ifdef LAX int q = pt_low_index / 3; int t = pt_low_index % 3; #else int q = pt_low_index >> 1; int t = pt_low_index & 1; #endif rmin = pq[q].rem_m[t]; rsec = pq[q].rem_s[t]; } #ifndef LAX void HockeyData::printPenalties(std::string* disp, freetype::font_data* base) { stringstream ss; for (unsigned int q = 0; q <= 1; ++q) { for (unsigned int t = 0; t < ACTIVE_QUEUE; ++t) { base->print(360.0f + 360.0f*q, 400.0f-20.0f*t, 0, "%d --%2hu:%02hu %2d +%u", t+1, pq[q].rem_m[t], pq[q].rem_s[t], pq[q].qm[t], pq[q].qt[t]); } for (int t = ACTIVE_QUEUE; t < MAX_QUEUE; ++t) { if (pq[q].qm[t] > 0) ss << pq[q].qm[t] << ' '; else break; } base->print(360.0f + 360.0f*q, 360.0f, 0, "Q -- %s", ss.str().c_str()); ss.str(""); //base->print(360.0f + 360.0f*q, 360.0f, 0, // "Q -- %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd", // pq[q].qm[2], pq[q].qm[3], pq[q].qm[4], pq[q].qm[5], pq[q].qm[6], pq[q].qm[7], // pq[q].qm[8], pq[q].qm[9], pq[q].qm[10], pq[q].qm[11], pq[q].qm[12], pq[q].qm[13], // pq[q].qm[14], pq[q].qm[15]); } } #endif
[ "pymlofy@4cf78214-6c29-4fb8-b038-d2ccc4421ee9", "[email protected]" ]
[ [ [ 1, 1 ], [ 3, 144 ], [ 146, 329 ] ], [ [ 2, 2 ], [ 145, 145 ] ] ]
1a799d409356c144b9ffba0e90c80f17dc635817
1e01b697191a910a872e95ddfce27a91cebc57dd
/GrfPutEnv.cpp
7140bae6407740be0b39da1ee6d18273599ba115
[]
no_license
canercandan/codeworker
7c9871076af481e98be42bf487a9ec1256040d08
a68851958b1beef3d40114fd1ceb655f587c49ad
refs/heads/master
2020-05-31T22:53:56.492569
2011-01-29T19:12:59
2011-01-29T19:12:59
1,306,254
7
5
null
null
null
null
IBM852
C++
false
false
1,769
cpp
/* "CodeWorker": a scripting language for parsing and generating text. Copyright (C) 1996-1997, 1999-2010 CÚdric Lemaire This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA To contact the author: [email protected] */ #ifdef WIN32 #pragma warning (disable : 4786) #endif #include "ScpStream.h" #include "CppCompilerEnvironment.h" #include "CGRuntime.h" #include "ExprScriptExpression.h" #include <string> #include "GrfPutEnv.h" namespace CodeWorker { GrfPutEnv::~GrfPutEnv() { delete _pName; delete _pValue; } SEQUENCE_INTERRUPTION_LIST GrfPutEnv::executeInternal(DtaScriptVariable& visibility) { std::string sName = _pName->getValue(visibility); std::string sValue = _pValue->getValue(visibility); return CGRuntime::putEnv(sName, sValue); } void GrfPutEnv::compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const { CW_BODY_INDENT << "CGRuntime::putEnv("; _pName->compileCppString(theCompilerEnvironment); CW_BODY_STREAM << ", "; _pValue->compileCppString(theCompilerEnvironment); CW_BODY_STREAM << ");"; CW_BODY_ENDL; } }
[ "cedric.p.r.lemaire@28b3f5f3-d42e-7560-b87f-5f53cf622bc4" ]
[ [ [ 1, 53 ] ] ]
af2a458eb02ede33bb6b5f893810d0a2020ec13d
672d939ad74ccb32afe7ec11b6b99a89c64a6020
/Graph/Graph3/ChildView.h
a62f6aad27021a7b95f238215c08f19d04f1c492
[]
no_license
cloudlander/legacy
a073013c69e399744de09d649aaac012e17da325
89acf51531165a29b35e36f360220eeca3b0c1f6
refs/heads/master
2022-04-22T14:55:37.354762
2009-04-11T13:51:56
2009-04-11T13:51:56
256,939,313
1
0
null
null
null
null
UTF-8
C++
false
false
1,815
h
// ChildView.h : interface of the CChildView class // ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_CHILDVIEW_H__11BE7F2C_6259_46D2_AEC9_29289F95CBA2__INCLUDED_) #define AFX_CHILDVIEW_H__11BE7F2C_6259_46D2_AEC9_29289F95CBA2__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #define CIRCLE 12 #define LINE 4 #define PI 3.1415926 ///////////////////////////////////////////////////////////////////////////// // CChildView window typedef struct tag3DPoint{ float x; float y; float z; }Point3D; class CChildView : public CWnd { // Construction public: CChildView(); // Attributes public: CBitmap m_Bitmap; CDC m_MemDC; int m_Cx; int m_Cy; Point3D m_Point[CIRCLE][LINE]; bool m_Drawing; // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CChildView) protected: virtual BOOL PreCreateWindow(CREATESTRUCT& cs); //}}AFX_VIRTUAL void Line(CDC* pdc,COLORREF clr,float x1,float y1,float x2,float y2); void Clear(CDC* pdc,COLORREF clrBack); // Implementation public: virtual ~CChildView(); // Generated message map functions protected: //{{AFX_MSG(CChildView) afx_msg void OnPaint(); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnTimer(UINT nIDEvent); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_CHILDVIEW_H__11BE7F2C_6259_46D2_AEC9_29289F95CBA2__INCLUDED_)
[ "xmzhang@5428276e-be0b-f542-9301-ee418ed919ad" ]
[ [ [ 1, 70 ] ] ]
f2ff22d1cf0d7ad30f32c8716426a128baa42a59
6fa6532d530904ba3704da72327072c24adfc587
/SCoder/QtGUI/sources/enterkeypage.cpp
654509632839ad3dfb3fc60d2edd532ca30e73c1
[]
no_license
photoguns/code-hnure
277b1c0a249dae75c66e615986fb1477e6e0f938
92d6ab861a9de3f409c5af0a46ed78c2aaf13c17
refs/heads/master
2020-05-20T08:56:07.927168
2009-05-29T16:49:34
2009-05-29T16:49:34
35,911,792
0
0
null
null
null
null
UTF-8
C++
false
false
1,323
cpp
//////////////////////////////////////////////////////////////////////////////// #include "enterkeypage.h" //////////////////////////////////////////////////////////////////////////////// #include <QLineEdit> #include <QVBoxLayout> #include <QVariant> #include "scoderwizard.h" //////////////////////////////////////////////////////////////////////////////// EnterKeyPage::EnterKeyPage( QWidget* _parent /* = NULL */ ) : QWizardPage(_parent) { // Set title setTitle(tr("Enter key")); setSubTitle(tr("\nThe algorithm you have chosen needs key. Please, enter it")); // Create line edit m_Key = new QLineEdit; // Setup layout QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(m_Key); setLayout(layout); // Create key field registerField("Key*", m_Key); } //////////////////////////////////////////////////////////////////////////////// EnterKeyPage::~EnterKeyPage() { } //////////////////////////////////////////////////////////////////////////////// int EnterKeyPage::nextId() const { return field("IsHideMessageMode").toBool() ? SCoderWizard::SAVE_CONTAINER_PAGE : SCoderWizard::VIEW_TEXT_PAGE; } ////////////////////////////////////////////////////////////////////////////////
[ "[email protected]@8592428e-0b6d-11de-9036-69e38a880166" ]
[ [ [ 1, 55 ] ] ]
b8bf396a668f5e2ba86b2ed184cf77c92cf55d87
78c7ce1de17f51f638f930b0822f8199231c81b7
/network.h
53def8844aba2438354b5c43455a4b19a9b186f4
[]
no_license
eluqm/load-forescasting-ia2
c930debfa0b2404d757e66bb357013f9a912f915
76aa488ecdd7aea3ed019b2018d455599aaeaf4a
refs/heads/master
2020-12-24T18:50:54.365811
2011-08-29T03:13:50
2011-08-29T03:13:50
57,864,571
0
0
null
null
null
null
UTF-8
C++
false
false
1,634
h
#ifndef NETWORK_H #define NETWORK_H #include "layer.h" #include <vector> using namespace std; class Network { public: double net_learning_rate; //Learning rate of network Layer *Layers; //The total layers in network unsigned long net_tot_layers; //Number of layers double *net_inputs; //Input array double *net_outputs;//Output layers unsigned long *net_layers; //Array which tells no. of neurons in each layer //double GetRand(void); Network(); int SetData(double learning_rate,unsigned long layers[],unsigned long tot_layers); int SetInputs(vector<long double> inputs); void RandomizeWB(void); double * GetOutput(void); void Update(void); /* void SetOutputs(double outputs[]){ //Set the values of the output layer for(int i=0;i<net_layers[net_tot_layers-1];i++){ Layers[net_tot_layers-1].Neurons[i].n_value=outputs[i]; //Set the value } } */ double Limiter(double value); double GetRand(void); double SigmaWeightDelta(unsigned long layer_no, unsigned long neuron_no); /*For output layer: Delta = (TargetO - ActualO) * ActualO * (1 - ActualO) Weight = Weight + LearningRate * Delta * Input For hidden layers: Delta = ActualO * (1-ActualO) * Summation(Weight_from_current_to_next AND Delta_of_next) Weight = Weight + LearningRate * Delta * Input */ int Train(vector<long double > inputs,vector<long double > outputs); ~Network(); }; #endif // NETWORK_H
[ [ [ 1, 56 ] ] ]
1b9a8de4ac3e0948dce674bd2100a127a8263ef1
cf98fd401c09dffdd1e7b1aaa91615e9fe64961f
/tags/0.0.0/inc/exception/lasterrorexception.h
178afef098b4ed6f8dd66d20723b9b3e0de58e4c
[]
no_license
BackupTheBerlios/bvr20983-svn
77f4fcc640bd092c3aa85311fecfbea1a3b7677e
4d177c13f6ec110626d26d9a2c2db8af7cb1869d
refs/heads/master
2021-01-21T13:36:43.379562
2009-10-22T00:25:39
2009-10-22T00:25:39
40,663,412
0
0
null
null
null
null
UTF-8
C++
false
false
1,590
h
/* * $Id$ * * Copyright (C) 2008 Dorothea Wachmann * * 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 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ #if !defined(LASTERROREXCEPTION_H) #define LASTERROREXCEPTION_H #include "exception/bvr20983exception.h" namespace bvr20983 { class LastErrorException : public BVR20983Exception { public: LastErrorException(LPCTSTR fileName=NULL,int lineNo=-1) { LastErrorException(::GetLastError(),fileName,lineNo); } LastErrorException(LONG errorNo,LPCTSTR fileName=NULL,int lineNo=-1); ~LastErrorException(); private: bool m_IsLastError; }; // of class LastErrorException } // of namespace bvr20983 #define THROW_LASTERROREXCEPTION(hr) \ if( ERROR_SUCCESS!=hr ) \ { throw LastErrorException(hr,_T(__FILE__), __LINE__); \ } \ #define THROW_LASTERROREXCEPTION1(hr) \ if( 0==hr ) \ { throw LastErrorException(_T(__FILE__), __LINE__); \ } \ #endif // LASTERROREXCEPTION_H
[ "dwachmann@01137330-e44e-0410-aa50-acf51430b3d2" ]
[ [ [ 1, 51 ] ] ]
407f225af01446aeb908a819b28a969c6ff3481d
fdfaf8e8449c5e80d93999ea665db48feaecccbe
/trunk/cg ex2/stdafx.h
a8de63cb94a604b54d7ff947e8d98ccb1badc333
[]
no_license
BackupTheBerlios/glhuji2005-svn
879e60533f820d1bdcfa436fd27894774c27a0b7
3afe113b265704e385c94fabaf99a7d1ad1fdb02
refs/heads/master
2016-09-01T17:25:30.876585
2006-09-03T18:04:19
2006-09-03T18:04:19
40,673,356
0
0
null
null
null
null
UTF-8
C++
false
false
2,013
h
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, // but are changed infrequently #pragma once #ifndef VC_EXTRALEAN #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif // Modify the following defines if you have to target a platform prior to the ones specified below. // Refer to MSDN for the latest info on corresponding values for different platforms. #ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. #define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. #endif #ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. #define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. #endif #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. #endif #ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. #define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. #endif #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit // turns off MFC's hiding of some common and often safely ignored warning messages #define _AFX_ALL_WARNINGS #include <afxwin.h> // MFC core and standard components #include <afxext.h> // MFC extensions #include <afxdisp.h> // MFC Automation classes #include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls #ifndef _AFX_NO_AFXCMN_SUPPORT #include <afxcmn.h> // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT #define _USE_MATH_DEFINES #include <string> #include <vector> #include <map> using namespace std; #include <GL/glut.h> #include "MyTypes.h"
[ "playmobil@c8a6d0be-e207-0410-856a-d97b7f264bab", "itai@c8a6d0be-e207-0410-856a-d97b7f264bab", "dagan@c8a6d0be-e207-0410-856a-d97b7f264bab" ]
[ [ [ 1, 1 ], [ 4, 6 ], [ 28, 28 ], [ 43, 43 ] ], [ [ 2, 3 ], [ 7, 27 ], [ 29, 42 ], [ 44, 46 ], [ 49, 50 ] ], [ [ 47, 48 ] ] ]
fb4a4d493f1e102360760d14a9552d3b91b68423
6bdb3508ed5a220c0d11193df174d8c215eb1fce
/Codes/Halak/PointSequence.h
040e70386941c05c7bd41dae229299617deb27b4
[]
no_license
halak/halak-plusplus
d09ba78640c36c42c30343fb10572c37197cfa46
fea02a5ae52c09ff9da1a491059082a34191cd64
refs/heads/master
2020-07-14T09:57:49.519431
2011-07-09T14:48:07
2011-07-09T14:48:07
66,716,624
0
0
null
null
null
null
UTF-8
C++
false
false
1,682
h
#pragma once #ifndef __HALAK_POINTSEQUENCE_H__ #define __HALAK_POINTSEQUENCE_H__ # include <Halak/FWD.h> # include <Halak/Asset.h> # include <Halak/Point.h> namespace Halak { struct PointKeyframe { typedef Point ValueType; ValueType Value; float Duration; float StartTime; PointKeyframe(); PointKeyframe(ValueType value, float duration); static ValueType Interpolate(const PointKeyframe& k1, const PointKeyframe& k2, float t); }; class PointSequence : public Asset { public: typedef PointKeyframe KeyframeType; public: PointSequence(); virtual ~PointSequence(); void AddKeyframe(const KeyframeType& item); void InsertKeyframe(int index, const KeyframeType& item); void InsertKeyframe(float time, const KeyframeType& item); void RemoveKeyframe(int index); void RemoveKeyframe(float time); void RemoveAllKeyframes(); int GetNumberOfKeyframes(); const KeyframeType& GetKeyframe(int index); const KeyframeType& GetKeyframe(float time); int GetKeyframeIndex(float time); int GetKeyframeIndex(float time, int startIndex); void SetKeyframe(int index, const KeyframeType& item); float GetDuration(); private: SequenceTemplate<KeyframeType>* s; }; } #endif
[ [ [ 1, 55 ] ] ]
5d04ee1b0cede12254306d86732830368cf41fdc
465943c5ffac075cd5a617c47fd25adfe496b8b4
/AIRBORNE.CPP
a17b850653bb2c205f25126199fe32594eb3b7f7
[]
no_license
paulanthonywilson/airtrafficcontrol
7467f9eb577b24b77306709d7b2bad77f1b231b7
6c579362f30ed5f81cabda27033f06e219796427
refs/heads/master
2016-08-08T00:43:32.006519
2009-04-09T21:33:22
2009-04-09T21:33:22
172,292
1
0
null
null
null
null
UTF-8
C++
false
false
1,561
cpp
/* Function definitions for InformationScree */ # include "airborne.h" /***************************************************************************/ AirborneInformation::AirborneInformation (Traffic *Traff_i) : Traff_c (Traff_i), LabelScreen ( AIR_INF_LEFT, AIR_INF_TOP, AIR_INF_RIGHT, AIR_INF_BOTTOM, ATC_TEXT_MODE, AIR_INF_TEXT_COLOUR, AIR_INF_BACK_COLOUR, AIR_INF_LABEL, -1, //label right AIR_INF_BOTTOM - AIR_INF_TOP ) {} /****************************************************************************/ void AirborneInformation::Refresh() { EifIterator AirIt; Plane *CrntPlane; char Id; int Alt; int Head; char DelayAt[3]; DelayableCmnd *DCmnd; int Fuel; char Dest[3]; Label(); SelectScreen(); clrscr(); cprintf (" Dest Head Alt Delyd Fuel"); // 12345678901234567890123456 print guides AirIt = Traff_c->AirborneIterator(); while (!AirIt.Finished()) { CrntPlane = Traff_c->Airborne (AirIt); Id = CrntPlane->Id(); Alt = CrntPlane->CurAlt(); Head = CrntPlane->CurHead().Degrees(); Traff_c->SearchDelayCmnd (CrntPlane); if (Traff_c->IsFoundDelayCmnd()) { DCmnd = Traff_c->FoundDelayCmnd(); LandmarkDesc (DelayAt, DCmnd->At()); } else { *DelayAt = '\0'; } Fuel = CrntPlane->CurFuel(); LandmarkDesc (Dest, CrntPlane->PDest()); cprintf ("\r\n%2c%5s%5d%4d%6s%5d", Id, Dest, Head, Alt, DelayAt, Fuel); AirIt.Forth(); } }
[ [ [ 1, 81 ] ] ]
f34549efccf6bbe858b06078bae46a4b64bd5b2b
f4f8ec5c50bf0411b31379f55b8365d9b82cb61e
/operation-overload/Complex.h
505017ddae366d8b60012f02c95532cc8f300204
[]
no_license
xhbang/cpp-homework
388da7b07ddc296bf67d373c96b7ea134c42ef0c
fb9a21fef40ac042210b662964ca120998ac8bcf
refs/heads/master
2021-01-22T05:20:59.989600
2011-12-05T10:31:14
2011-12-05T10:31:14
2,915,735
0
0
null
null
null
null
GB18030
C++
false
false
2,346
h
#include <iostream> #include <stdlib.h> #include <math.h> using namespace std; class Complex{ double rpart; double ipart; double abs() const; //here the const is must double norm() const; public: Complex(){ rpart=0.0; ipart=0.0; } Complex(const double & ,const double &); //系统内定数据类型数据转换为类的对象 Complex(const double &); //类对象转换为系统其他类型 // operator double(const Complex &x ); //wrong,为什么? operator double(); //right void operator=(const Complex &); friend int operator>(const Complex &c1,const Complex &c2); friend int operator>=(const Complex &c1,const Complex &c2); friend int operator<=(const Complex &c1,const Complex &c2); friend int operator<(const Complex &c1,const Complex &c2); friend int operator==(const Complex &c1,const Complex &c2); friend int operator!=(const Complex &c1,const Complex &c2); void show(); }; Complex::operator double(){ return rpart; } /*wrong 1>r:\temp\complex.h(20) : error C2835: user-defined conversion 'Complex::operator double' takes no formal parameters Complex::operator double(const Complex &x ){ return x.rpart; } */ Complex::Complex(const double &x){ rpart=x; ipart=0; } Complex::Complex(const double &i,const double &j){ rpart=i; ipart=j; } void Complex::operator =(const Complex &c){ rpart=c.rpart; ipart=c.ipart; } double Complex::abs() const{ double answer=sqrt(rpart*rpart+ipart*ipart); return answer; } double Complex::norm() const{ double answer=rpart*rpart+ipart*ipart; return answer; } void Complex::show(){ if(ipart>=0) cout<<rpart<<"+"<<ipart<<"i"<<endl; else cout<<rpart<<"-"<<ipart<<"i"<<endl; } int operator==(const Complex &c1,const Complex &c2){ return c1.rpart ==c2.rpart &&c1.ipart ==c1.ipart ; } int operator!=(const Complex &c1,const Complex &c2){ return c1.rpart !=c2.rpart ||c1.ipart !=c1.ipart ; } int operator<(const Complex &c1,const Complex &c2){ return c1.abs()<c2.abs(); } int operator<=(const Complex &c1,const Complex &c2){ return c1.abs ()<=c2.abs (); } int operator>(const Complex &c1,const Complex &c2){ return c1.abs ()>c2.abs (); } int operator>=(const Complex &c1,const Complex &c2){ return c1.abs ()>=c2.abs (); }
[ [ [ 1, 102 ] ] ]
3ea13ae41a67bdb681ba6c85a7f1160736f8c9ec
92b8c171bcb3ca9c5aa3d3796936e8e9c2d0e7b7
/unstable/3rdparty/unzip.h
c22752a4004b9a53d06065382184ff01ce7d2ad0
[]
no_license
BackupTheBerlios/dboxfe-svn
e5bb9a4e3fd6def8dc19bf49a0b4f7b62a8dadf0
4d481d104fc7b50676212e4dca66632172b6f982
refs/heads/master
2021-01-10T19:44:30.005816
2009-04-04T17:41:54
2009-04-04T17:41:54
40,724,980
0
0
null
null
null
null
UTF-8
C++
false
false
3,704
h
/**************************************************************************** ** Filename: unzip.h ** Last updated [dd/mm/yyyy]: 28/01/2007 ** ** pkzip 2.0 decompression. ** ** Some of the code has been inspired by other open source projects, ** (mainly Info-Zip and Gilles Vollant's minizip). ** Compression and decompression actually uses the zlib library. ** ** Copyright (C) 2007-2008 Angius Fabrizio. All rights reserved. ** ** This file is part of the OSDaB project (http://osdab.sourceforge.net/). ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See the file LICENSE.GPL that came with this software distribution or ** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information. ** **********************************************************************/ #ifndef OSDAB_UNZIP__H #define OSDAB_UNZIP__H #include <QtGlobal> #include <QMap> #include <QDateTime> #include <zlib/zlib.h> class UnzipPrivate; class QIODevice; class QFile; class QDir; class QStringList; class QString; class UnZip { public: enum ErrorCode { Ok, ZlibInit, ZlibError, OpenFailed, PartiallyCorrupted, Corrupted, WrongPassword, NoOpenArchive, FileNotFound, ReadFailed, WriteFailed, SeekFailed, CreateDirFailed, InvalidDevice, InvalidArchive, HeaderConsistencyError, Skip, SkipAll // internal use only }; enum ExtractionOption { //! Extracts paths (default) ExtractPaths = 0x0001, //! Ignores paths and extracts all the files to the same directory SkipPaths = 0x0002 }; Q_DECLARE_FLAGS(ExtractionOptions, ExtractionOption) enum CompressionMethod { NoCompression, Deflated, UnknownCompression }; enum FileType { File, Directory }; typedef struct ZipEntry { ZipEntry(); QString filename; QString comment; quint32 compressedSize; quint32 uncompressedSize; quint32 crc32; QDateTime lastModified; CompressionMethod compression; FileType type; bool encrypted; }; UnZip(); virtual ~UnZip(); bool isOpen() const; ErrorCode openArchive(const QString& filename); ErrorCode openArchive(QIODevice* device); void closeArchive(); QString archiveComment() const; QString formatError(UnZip::ErrorCode c) const; bool contains(const QString& file) const; QStringList fileList() const; QList<ZipEntry> entryList() const; ErrorCode extractAll(const QString& dirname, ExtractionOptions options = ExtractPaths); ErrorCode extractAll(const QDir& dir, ExtractionOptions options = ExtractPaths); ErrorCode extractFile(const QString& filename, const QString& dirname, ExtractionOptions options = ExtractPaths); ErrorCode extractFile(const QString& filename, const QDir& dir, ExtractionOptions options = ExtractPaths); ErrorCode extractFile(const QString& filename, QIODevice* device, ExtractionOptions options = ExtractPaths); ErrorCode extractFiles(const QStringList& filenames, const QString& dirname, ExtractionOptions options = ExtractPaths); ErrorCode extractFiles(const QStringList& filenames, const QDir& dir, ExtractionOptions options = ExtractPaths); void setPassword(const QString& pwd); private: UnzipPrivate* d; }; Q_DECLARE_OPERATORS_FOR_FLAGS(UnZip::ExtractionOptions) #endif // OSDAB_UNZIP__H
[ "chmaster@ab66aab8-02df-0310-b6be-8546509eb979" ]
[ [ [ 1, 144 ] ] ]
df726fb211224f026bfd263ab900f4ae7b65748b
073dfce42b384c9438734daa8ee2b575ff100cc9
/RCF/include/RCF/SerializationProtocol.hpp
f6a10a3abffe1f81ed60ed216a99ad036bddf23a
[]
no_license
r0ssar00/iTunesSpeechBridge
a489426bbe30ac9bf9c7ca09a0b1acd624c1d9bf
71a27a52e66f90ade339b2b8a7572b53577e2aaf
refs/heads/master
2020-12-24T17:45:17.838301
2009-08-24T22:04:48
2009-08-24T22:04:48
285,393
1
0
null
null
null
null
UTF-8
C++
false
false
8,440
hpp
//****************************************************************************** // RCF - Remote Call Framework // Copyright (c) 2005 - 2009, Jarl Lindrud. All rights reserved. // Consult your license for conditions of use. // Version: 1.1 // Contact: jarl.lindrud <at> gmail.com //****************************************************************************** #ifndef INCLUDE_RCF_SERIALIZATIONPROTOCOL_HPP #define INCLUDE_RCF_SERIALIZATIONPROTOCOL_HPP #include <map> #include <string> #include <strstream> #include <RCF/ByteBuffer.hpp> // Serialization protocols #include <RCF/SerializationDefs.hpp> #include <RCF/Protocol/Protocol.hpp> #if defined(RCF_USE_SF_SERIALIZATION) #include <RCF/Protocol/SF.hpp> #endif #if defined(RCF_USE_BOOST_SERIALIZATION) || defined(RCF_USE_BOOST_XML_SERIALIZATION) #include <RCF/Protocol/BoostSerialization.hpp> #endif namespace RCF { RCF_EXPORT bool isSerializationProtocolSupported(int protocol); RCF_EXPORT std::string getSerializationProtocolName(int protocol); class PointerContext { public: template<typename SmartPtr, typename T> SmartPtr get(SmartPtr *, T t) { // TODO: need to use typeid().name() return static_cast<SmartPtr>( mPtrMap[&typeid(SmartPtr)][ static_cast<void *>(t) ] ); } template<typename SmartPtr, typename T> void set(SmartPtr sp, T t) { mPtrMap[&typeid(SmartPtr)][ static_cast<void *>(t) ] = static_cast<void *>(sp); } void clear() { mPtrMap.clear(); } private: std::map< const std::type_info *, std::map<void*, void*> > mPtrMap; }; class Token; class MethodInvocationRequest; class MethodInvocationResponse; class RCF_EXPORT SerializationProtocolIn { public: SerializationProtocolIn(); ~SerializationProtocolIn(); void setSerializationProtocol(int protocol); int getSerializationProtocol() const; void reset(const ByteBuffer &data, int protocol); void clearByteBuffer(); void clear(); void extractSlice(ByteBuffer &byteBuffer, std::size_t len); std::size_t getArchiveLength(); std::size_t getRemainingArchiveLength(); template<typename T> void read(const T *pt) { read(*pt); } template<typename T> void read(T &t) { try { switch (mProtocol) { case 1: mInProtocol1 >> t; break; case 2: mInProtocol2 >> t; break; case 3: mInProtocol3 >> t; break; case 4: mInProtocol4 >> t; break; #ifdef RCF_USE_BOOST_XML_SERIALIZATION case 5: mInProtocol5 >> boost::serialization::make_nvp("Dummy", t); break; #else case 5: mInProtocol5 >> t; break; #endif default: RCF_ASSERT(0)(mProtocol); } } catch(const RCF::Exception &e) { RCF_UNUSED_VARIABLE(e); throw; } catch(const std::exception &e) { std::ostringstream os; os << "Deserialization error, object type: " << typeid(t).name() << ", error type: " << typeid(e).name() << ", error msg: " << e.what(); RCF_THROW( RCF::SerializationException( RcfError_Deserialization, os.str())); } } PointerContext mPointerContext; private: void bindProtocol(); void unbindProtocol(); friend class ClientStub; // TODO friend class RcfSession; // TODO int mProtocol; ByteBuffer mByteBuffer; std::istrstream * mIsPtr; std::vector<char> mIstrVec; Protocol< boost::mpl::int_<1> >::In mInProtocol1; Protocol< boost::mpl::int_<2> >::In mInProtocol2; Protocol< boost::mpl::int_<3> >::In mInProtocol3; Protocol< boost::mpl::int_<4> >::In mInProtocol4; Protocol< boost::mpl::int_<5> >::In mInProtocol5; }; class RCF_EXPORT SerializationProtocolOut { public: SerializationProtocolOut(); void setSerializationProtocol(int protocol); int getSerializationProtocol() const; void clear(); void reset( int protocol, std::size_t margin = 32, ByteBuffer byteBuffer = ByteBuffer()); template<typename T> void write(const T &t) { try { switch (mProtocol) { case 1: mOutProtocol1 << t; break; case 2: mOutProtocol2 << t; break; case 3: mOutProtocol3 << t; break; case 4: mOutProtocol4 << t; break; #ifdef RCF_USE_BOOST_XML_SERIALIZATION case 5: mOutProtocol5 << boost::serialization::make_nvp("Dummy", t); break; #else case 5: mOutProtocol5 << t; break; #endif default: RCF_ASSERT(0)(mProtocol); } } catch(const std::exception &e) { std::ostringstream os; os << "serialization error, object type: " << typeid(t).name() << ", error type: " << typeid(e).name() << ", error msg: " << e.what(); RCF_THROW( RCF::SerializationException( RcfError_Serialization, os.str())); } } void insert(const ByteBuffer &byteBuffer); void extractByteBuffers(); void extractByteBuffers(std::vector<ByteBuffer> &byteBuffers); private: void bindProtocol(); void unbindProtocol(); friend class ClientStub; // TODO friend class RcfSession; // TODO int mProtocol; std::size_t mMargin; boost::shared_ptr<std::ostrstream> mOsPtr; std::vector<std::pair<std::size_t, ByteBuffer> > mByteBuffers; // these need to be below mOsPtr, for good order of destruction Protocol< boost::mpl::int_<1> >::Out mOutProtocol1; Protocol< boost::mpl::int_<2> >::Out mOutProtocol2; Protocol< boost::mpl::int_<3> >::Out mOutProtocol3; Protocol< boost::mpl::int_<4> >::Out mOutProtocol4; Protocol< boost::mpl::int_<5> >::Out mOutProtocol5; }; inline void serializeImpl( SerializationProtocolOut &, const Void &, long int) { } inline void deserializeImpl( SerializationProtocolIn &, Void &, long int) { } template<typename T> void serializeImpl( SerializationProtocolOut &out, const T &t, long int) { out.write(t); } template<typename T> void deserializeImpl( SerializationProtocolIn &in, T &t, long int) { in.read(t); } template<typename T> void serialize( SerializationProtocolOut &out, const T &t) { serializeImpl(out, t, 0); } template<typename T> void deserialize( SerializationProtocolIn &in, T &t) { deserializeImpl(in, t, 0); } } // namespace RCF #endif // ! INCLUDE_RCF_SERIALIZATIONPROTOCOL_HPP
[ [ [ 1, 286 ] ] ]
22d0be953d06d7031d45020df263fdb5c5074fb8
974a20e0f85d6ac74c6d7e16be463565c637d135
/trunk/packages/dCompilerKit/dLittleScriptLanguage/dDAGFunctionStatementFOR.cpp
9a4597e2c56ae10bb8237ddb8a6809949d866862
[]
no_license
Naddiseo/Newton-Dynamics-fork
cb0b8429943b9faca9a83126280aa4f2e6944f7f
91ac59c9687258c3e653f592c32a57b61dc62fb6
refs/heads/master
2021-01-15T13:45:04.651163
2011-11-12T04:02:33
2011-11-12T04:02:33
2,759,246
0
0
null
null
null
null
UTF-8
C++
false
false
3,474
cpp
/* Copyright (c) <2009> <Newton Game Dynamics> * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely */ #include "dLSCstdafx.h" #include "dDAG.h" #include "dDAGExpressionNode.h" #include "dDAGFunctionStatementFOR.h" dInitRtti(dDAGFunctionStatementFOR); dDAGFunctionStatementFOR::dDAGFunctionStatementFOR(dList<dDAG*>& allNodes, dDAGFunctionStatement* const beginStmt, dDAGExpressionNode* const expression, dDAGFunctionStatement* const endStmt, dDAGFunctionStatement* const stmt) :dDAGFunctionStatementFlow(allNodes) ,m_initialStmt(beginStmt) ,m_expression(expression) ,m_endStmt(endStmt) ,m_stmt(stmt) { if (m_initialStmt) { m_initialStmt->AddRef(); } if (m_expression) { m_expression->AddRef(); } if (m_endStmt) { m_endStmt->AddRef(); } if (m_stmt) { m_stmt->AddRef(); } } dDAGFunctionStatementFOR::~dDAGFunctionStatementFOR() { if (m_initialStmt) { m_initialStmt->Release(); } if (m_expression) { m_expression->Release(); } if (m_endStmt) { m_endStmt->Release(); } if (m_stmt) { m_stmt->Release(); } } void dDAGFunctionStatementFOR::ConnectParent(dDAG* const parent) { m_parent = parent; if (m_initialStmt) { m_initialStmt->ConnectParent(this); } if (m_expression) { m_expression->ConnectParent(this); } if (m_endStmt) { m_endStmt->ConnectParent(this); } if (m_stmt) { m_stmt->ConnectParent(this); } } void dDAGFunctionStatementFOR::CompileCIL(dCIL& cil) { if (m_initialStmt) { m_initialStmt->CompileCIL(cil); } dTreeAdressStmt& endStmt = cil.NewStatement()->GetInfo(); endStmt.m_instruction = dTreeAdressStmt::m_goto; endStmt.m_arg0.m_label = cil.NewLabel(); dTRACE_INTRUCTION (&endStmt); dDAGFunctionStatementFlow::CompileCIL(cil); dCIL::dListNode* const startFlow = cil.NewStatement(); dTreeAdressStmt& startLabel = startFlow->GetInfo(); startLabel.m_instruction = dTreeAdressStmt::m_label; startLabel.m_arg0.m_label = cil.NewLabel(); dTRACE_INTRUCTION (&startLabel); if (m_stmt) { m_stmt->CompileCIL(cil); } if (m_endStmt) { m_endStmt->CompileCIL(cil); } dCIL::dListNode* const testFlow = cil.NewStatement(); endStmt.m_jmpTarget = testFlow; dTreeAdressStmt& test = testFlow->GetInfo(); test.m_instruction = dTreeAdressStmt::m_label; test.m_arg0.m_label = endStmt.m_arg0.m_label; dTRACE_INTRUCTION (&test); dCIL::dListNode* expressionNode = NULL; if (m_expression) { m_expression->CompileCIL(cil); expressionNode = cil.NewStatement(); dTreeAdressStmt& stmt = expressionNode->GetInfo(); stmt.m_instruction = dTreeAdressStmt::m_if; stmt.m_operator = dTreeAdressStmt::m_different; stmt.m_arg0.m_label = m_expression->m_result; stmt.m_arg1.m_label = "0"; stmt.m_arg2.m_label = startLabel.m_arg0.m_label; stmt.m_jmpTarget = startFlow; dTRACE_INTRUCTION (&stmt); } else { dTreeAdressStmt& stmt = cil.NewStatement()->GetInfo(); stmt.m_instruction = dTreeAdressStmt::m_goto; stmt.m_arg0.m_label = startLabel.m_arg0.m_label; stmt.m_jmpTarget = startFlow; dTRACE_INTRUCTION (&stmt); } BackPatch (cil); }
[ "[email protected]@b7a2f1d6-d59d-a8fe-1e9e-8d4888b32692" ]
[ [ [ 1, 138 ] ] ]
ff1084c79df049f9dbeb6dfd0a6b62362c30c780
15732b8e4190ae526dcf99e9ffcee5171ed9bd7e
/INC/tcp-newreno.h
dedb0fb88187393bbfd7b799bec3950425b32411
[]
no_license
clovermwliu/whutnetsim
d95c07f77330af8cefe50a04b19a2d5cca23e0ae
924f2625898c4f00147e473a05704f7b91dac0c4
refs/heads/master
2021-01-10T13:10:00.678815
2010-04-14T08:38:01
2010-04-14T08:38:01
48,568,805
0
0
null
null
null
null
UTF-8
C++
false
false
3,798
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: // Georgia Tech Network Simulator - TCP-NewReno Class // George F. Riley. Georgia Tech, Spring 2002 // Implements the NewReno version of TCP // On any timeout, collapse congestion window to one segment // Reduce slowstart threshold to 1/2 current cwnd, and resend // the lowest sequence number in the retx list // // On any triple duplicate ack, resend the seq number requested, // collapse cwnd and slowstart threshold // to 1/2 the current cwnd. #ifndef __tcp_newreno_h__ #define __tcp_newreno_h__ #include "tcp.h" #include "node.h" //#include "application.h" //Doc:ClassXRef class TCPNewReno : public TCP { //Doc:Class Class {\tt TCPNewReno} defines the behavior of the {\em NewReno} //Doc:Class variation of {\em TCP}. The base class functions //Doc:Class {\tt DupAck}, {\tt ReTxTimeout} and {\tt NewAck} //Doc:Class are overridden here, but //Doc:Class all other base class {\tt TCP} functions are used. public: TCPNewReno(); TCPNewReno(Node* n); TCPNewReno(const TCPNewReno&); // Copy constructor L4Protocol* Copy() const; // Create a copy of this protocol public: // Overridden TCP methods //Doc:Method virtual void DupAck(const TCPHeader&, Count_t); // Dup ack received //Doc:Desc Process a duplicate ack. //Doc:Arg1 TCP Header that caused the duplicate ack. //Doc:Arg2 Count of duplicates. //Doc:Method virtual void ReTxTimeout(); // Retransmit timeout //Doc:Desc Process a retransmit timeout. //Doc:Method void NewAck(Seq); //Doc:Desc Process newly acknowledged data. //Doc:Arg1 Sequence number for new ack. private: Seq recover; // High Tx Mark for New Reno Count_t partialAckCount; // Number of partial acks in a row }; #endif
[ "pengelmer@f37e807c-cba8-11de-937e-2741d7931076" ]
[ [ [ 1, 102 ] ] ]
2c1908d829bbc64f608c3e6326cee9fae89ab123
842997c28ef03f8deb3422d0bb123c707732a252
/src/uslsext/USDistance.h
51d6c35c2302b1e4ff4167a7aed292ae35945ec9
[]
no_license
bjorn/moai-beta
e31f600a3456c20fba683b8e39b11804ac88d202
2f06a454d4d94939dc3937367208222735dd164f
refs/heads/master
2021-01-17T11:46:46.018377
2011-06-10T07:33:55
2011-06-10T07:33:55
1,837,561
2
1
null
null
null
null
UTF-8
C++
false
false
967
h
// Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved. // http://getmoai.com #ifndef MATH_DIST_H #define MATH_DIST_H //----------------------------------------------------------------// #include <uslsext/USPlane.h> //================================================================// // USDist //================================================================// namespace USDist { float PointToPlane2D ( const USVec2D& p, const USPlane2D& plane ); float PointToPoint ( const USVec2D& p1, const USVec2D& p2 ); float PointToPointSqrd ( const USVec2D& p1, const USVec2D& p2 ); float SnapToPlane ( USVec3D& p, const USPlane3D& plane ); float SnapToPlane2D ( USVec2D& p, const USPlane2D& plane ); float VecToPlane ( const USVec3D& v, const USPlane3D& p ); float VecToVec ( const USVec3D& v1, const USVec3D& v2 ); float VecToVecSqrd ( const USVec3D& v1, const USVec3D& v2 ); } // namespace USDist #endif
[ "[email protected]", "Patrick@agile.(none)" ]
[ [ [ 1, 14 ], [ 18, 18 ], [ 21, 21 ], [ 25, 28 ] ], [ [ 15, 17 ], [ 19, 20 ], [ 22, 24 ] ] ]
8df26712bb4fdcc02a84b7e9635bffd91afe20b1
671b01c2c51aed8539554f8439d9e747b9b5e965
/Coherent_pot.cpp
b27f939918ab94b5d65d76580c6bc3ce7aebca13
[]
no_license
veal/Nanostructures
2dfe6563e07f59d5af80df4e8deb93f71459b00d
2186f78d037219158f628541e692fd1483176906
refs/heads/master
2020-05-18T01:08:25.105436
2011-10-21T22:30:41
2011-10-21T22:30:41
2,534,106
0
0
null
null
null
null
UTF-8
C++
false
false
14,140
cpp
#include "sys_param.h" void CP_Calculation(Comp Coh_p[N_LAT][N_LAT][N_Band][N_Band], Doub E, int niE, Comp W[N_Com][N_LAT][N_LAT][N_LAT][N_Band][N_Band], Doub vm[2][N_Com][N_LAT][2][N_Band], Doub Pm[2][N_LAT], Doub Cl[N_Com][N_LAT], Comp Hr[Nkp2][N_LAT][N_LAT][N_Band][N_Band], Doub r[N_LAT][3][3], int spin, double *f2) { Comp (*dcp)[N_LAT*N_Band][N_LAT*N_Band] = new Comp[N_LAT][N_LAT*N_Band][N_LAT*N_Band]; Comp (*Wab)[N_LAT][N_Band][N_Band] = new Comp[N_LAT][N_LAT][N_Band][N_Band]; Comp (*G_s)[N_LAT][N_Band][N_Band] = new Comp[N_LAT][N_LAT][N_Band][N_Band]; Comp (*cp1)[N_LAT*N_Band] = new Comp[N_LAT*N_Band][N_LAT*N_Band]; Comp (*cp2)[N_LAT*N_Band] = new Comp[N_LAT*N_Band][N_LAT*N_Band]; Comp (*I1)[N_LAT][N_Band][N_Band] = new Comp[N_LAT][N_LAT][N_Band][N_Band]; Comp (*Im_d)[N_Band] = new Comp[N_Band][N_Band]; Comp (*x1)[N_LAT*N_Band] = new Comp[N_LAT*N_Band][N_LAT*N_Band]; Comp (*x2)[N_LAT*N_Band] = new Comp[N_LAT*N_Band][N_LAT*N_Band]; Comp (*x3)[N_LAT*N_Band] = new Comp[N_LAT*N_Band][N_LAT*N_Band]; Comp (*Wm_D)[2][N_LAT][N_Band][N_Band] = new Comp[2][2][N_LAT][N_Band][N_Band]; bool isCalculated = false; for (int i = 0; i < N_LAT; i++) { for (int i1 = 0; i1 < N_Band; i1++) { I1[i][i][i1][i1] = 1.0; } } for (int i = 0; i < N_Band; i++) { for (int n = 0; n < 2; n++) { for (int n1 = 0; n1 < 2; n1++) { for (int n2 = 0; n2 < N_LAT; n2++) { Wm_D[n][n1][n2][i][i] = vm[n][n1][n2][spin][i]; } } } } for (int i = 0; i < N_Band; i++) { Im_d[i][i] = Comp(0.0, -1.0e-3); } for (int i = 0; i < N_LAT; i++) { for (int j = 0; j < N_Com; j++) { for (int m = 0; m < 2; m++) { for (int i1 = 0; i1 < N_LAT; i1++) { for (int j1 = 0; j1 < N_Band; j1++) { for (int j2 = 0; j2 < N_Band; j2++) { Wab[i][i1][j1][j2] += (real(W[j][i][i1][i1][j1][j2]) + Wm_D[m][j][i][j1][j2]) * Pm[m][i] * Cl[j][i]; } } } } } } for (int i = 0; i < N_LAT; i++) { for (int i1 = 0; i1 < N_LAT; i1++) { for (int j1 = 0; j1 < N_Band; j1++) { for (int j2 = 0; j2 < N_Band; j2++) { Coh_p[i][i1][j1][j2] = Wab[i][i1][j1][j2] + Im_d[j1][j2]; } } } } for (int it = 0; it < MAX_IT; it++) { l_CPA = 1; *f2 = 0.0; for (int i = 0; i < N_LAT; i++) { for (int i1 = 0; i1 < N_LAT; i1++) { for (int j1 = 0; j1 < N_Band; j1++) { for (int j2 = 0; j2 < N_Band; j2++) { Coh_p[i][i1][j1][j2] = Comp (real(Coh_p[i][i1][j1][j2]), -abs(imag(Coh_p[i][i1][j1][j2]))); } } } } // if (!isCalculated) { G_site(G_s, E, Coh_p, Hr, r); // isCalculated = true; // } Comp (*G_temp)[N_LAT*N_Band] = new Comp[N_LAT*N_Band][N_LAT*N_Band]; for (int i1 = 0; i1 < N_LAT; i1++) { for (int i2 = 0; i2 < N_LAT; i2++) { for (int j1 = 0; j1 < N_Band; j1++) { for (int j2 = 0; j2 < N_Band; j2++) { G_temp[i1*N_Band+j1][i2*N_Band+j2] = G_s[i1][i2][j1][j2]; } } } } for (int i = 0; i < N_LAT; i++) { for (int j1 = 0; j1 < N_Band; j1++) { for (int j2 = 0; j2 < N_Band; j2++) { cp1[j1][j2] = 0.0; cp2[j1][j2] = 0.0; } } for (int j = 0; j < N_Com; j++) { for (int m = 0; m < 2; m++) { for (int i1 = 0; i1 < N_LAT; i1++) { for (int j1 = 0; j1 < N_Band; j1++) { for (int j2 = 0; j2 < N_Band; j2++) { x1[i1*N_Band+j1][i1*N_Band+j2] = real(W[j][i][i1][i1][j1][j2]) + Wm_D[m][j][i][j1][j2] - real(Coh_p[i][i1][j1][j2]); } } } matmul(x1, G_temp, x3); for (int i1 = 0; i1 < N_LAT; i1++) { for (int j1 = 0; j1 < N_Band; j1++) { for (int j2 = 0; j2 < N_Band; j2++) { x2[i1*N_Band+j1][i1*N_Band+j2] = I1[i1][i1][j1][j2] - x3[i1*N_Band+j1][i1*N_Band+j2]; } } } cd_Invert((const Comp**) x2, (Comp**) x3, N_LAT*N_Band); // matinv(x2, x3); matmul(x3, x1, x2); for (int i1 = 0; i1 < N_LAT; i1++) { for (int i2 = 0; i2 < N_LAT; i2++) { for (int j1 = 0; j1 < N_Band; j1++) { for (int j2 = 0; j2 < N_Band; j2++) { cp1[i1*N_Band+j1][i2*N_Band+j2] += Pm[m][i] * Cl[j][i] * x2[i1*N_Band+j1][i2*N_Band+j2]; cp2[i1*N_Band+j1][i2*N_Band+j2] += Pm[m][i] * Cl[j][i] * x3[i1*N_Band+j1][i2*N_Band+j2]; } } } } } } // for (int i1 = 0; i1 < N_LAT; i1++) { // for (int j1 = 0; j1 < N_Band; j1++) { // double rratio = abs(Coh_p[i][i1][j1][j1] - cp1[i1*N_Band+j1][i1*N_Band+j1])/ // abs(Coh_p[i][i1][j1][j1]); // if (rratio > 0.0005) // cout << i1 << " " << j1 << " " << cp1[i1*N_Band+j1][i1*N_Band+j1] << " " << Coh_p[i][i1][j1][j1] // << " " << rratio << '\n'; // } // } cd_Invert((const Comp**) cp2, (Comp**) x3, N_LAT*N_Band); // matinv(cp2, x3); matmul(x3, cp1, dcp[i]); for (int i1 = 0; i1 < N_Band; i1++) { for (int j = 0; j < N_Band; j++) { Doub f1 = abs(dcp[i][i1*N_Band+j][i1*N_Band+j])/abs(Coh_p[i][i1][j][j]); //.r*dcp[i][j][j].r+dcp[i][j][j].i*dcp[i][j][j].i); if (f1 > EPS_CP)//.r*Coh_p[i][j][j].r+Coh_p[i][j][j].i*Coh_p[i][j][j].i)) { l_CPA = 0; } if (f1 > (*f2)) { (*f2) = f1; } } } } for (int i = 0; i < N_LAT; i++) { for (int i1 = 0; i1 < N_LAT; i1++) { for (int j1 = 0; j1 < N_Band; j1++) { for (int j2 = 0; j2 < N_Band; j2++) { Coh_p[i][i1][j1][j2] += dcp[i][i1*N_Band+j1][i1*N_Band+j2]; Coh_p[i][i1][j1][j2] = Comp (real(Coh_p[i][i1][j1][j2]), -abs(imag(Coh_p[i][i1][j1][j2]))); } } } } delete[] G_temp; if (l_CPA == 1 && it > 0) { delete [] dcp; delete [] Wab; delete [] G_s; delete [] cp1; delete [] cp2; delete [] I1; delete [] Im_d; delete [] x1; delete [] x2; delete [] x3; delete [] Wm_D; return; } cout << "CP differs from average t in " << *f2 << " times" << '\n'; } if ((*f2) <= 1.0e-1) { l_CPA = 1; } delete [] dcp; delete [] Wab; delete [] G_s; delete [] cp1; delete [] cp2; delete [] I1; delete [] Im_d; delete [] x1; delete [] x2; delete [] x3; delete [] Wm_D; } void C_Ph_calculation(Comp Coh_p[N_LAT][N_Alpha][N_Alpha], Doub E, int niE, Doub Cl[N_Com][N_LAT], Comp Dk[Nkp2][N_LAT][N_LAT][N_Alpha][N_Alpha], Doub r[N_LAT][3][3], Comp Sig_fe[3][3][N_LAT][N_LAT][N_Alpha][N_Alpha]) { int N_E = 360; Doub E_s = -0.02, E_e = 0.02; int Nkph = 200; Doub EPS_CPh = 1e-5; complex<Doub > (*dcp)[N_Alpha][N_Alpha] = new Comp[N_LAT][N_Alpha][N_Alpha]; complex<Doub > (*W)[N_LAT][N_Alpha][N_Alpha] = new Comp[N_Com][N_LAT][N_Alpha][N_Alpha]; complex<Doub > (*Wab)[N_Alpha][N_Alpha] = new Comp[N_LAT][N_Alpha][N_Alpha]; complex<Doub > (*G_s)[N_LAT][N_Alpha][N_Alpha] = new Comp[N_LAT][N_LAT][N_Alpha][N_Alpha]; complex<Doub > (*cp1)[N_Alpha] = new Comp[N_Band][N_Alpha]; complex<Doub > (*cp2)[N_Alpha] = new Comp[N_Alpha][N_Alpha]; complex<Doub > (*I1)[N_Alpha] = new Comp[N_Alpha][N_Alpha]; complex<Doub > (*Im_d)[N_Alpha] = new Comp[N_Alpha][N_Alpha]; complex<Doub > (*x1)[N_Alpha] = new Comp[N_Alpha][N_Alpha]; complex<Doub > (*x2)[N_Alpha] = new Comp[N_Alpha][N_Alpha]; complex<Doub > (*x3)[N_Alpha] = new Comp[N_Alpha][N_Alpha]; Doub f2 = 0.0; l_CPA = 0; for (int i = 0; i < N_Band; i++) { I1[i][i] = 1.0; Im_d[i][i] = (E < 0) ? complex<Doub > (0.0, 1.0e-7) : complex<Doub > (0.0, -1.0e-7); } //**** Define start value for coherent potential ****** Doub koef = 547.5133; for (int i = 0; i < N_Alpha; i++) { for (int il = 0; il < N_LAT; il++) { W[0][il][i][i] = 0; W[1][il][i][i] = -koef * E * E * 3.312862; } } for (int i = 0; i < N_LAT; i++) { for (int j = 0; j < N_Com; j++) { for (int t = 0; t < N_Alpha; t++) { for (int t1 = 0; t1 < N_Alpha; t1++) { Wab[i][t][t1] += Cl[j][i] * W[j][i][t][t1]; } } } for (int t = 0; t < N_Alpha; t++) { for (int t1 = 0; t1 < N_Alpha; t1++) { Coh_p[i][t][t1] = Wab[i][t][t1] + Im_d[t][t1]; } } } for (int it = 0; it < MAX_IT; it++) { l_CPA = 1; for (int i = 0; i < N_LAT; i++) { for (int j1 = 0; j1 < N_Alpha; j1++) { for (int j2 = 0; j2 < N_Alpha; j2++) { Coh_p[i][j1][j2] = (E < 0) ? complex<Doub > (real(Coh_p[i][j1][j2]), fabs(imag(Coh_p[i][j1][j2]))) : complex<Doub > (real(Coh_p[i][j1][j2]), -fabs(imag(Coh_p[i][j1][j2]))); } } } G_phonon(G_s, Dk, E, Coh_p, r); //******* third variant of Soven equation ******** for (int i = 0; i < N_LAT; i++) { for (int j1 = 0; j1 < N_Alpha; j1++) { for (int j2 = 0; j2 < N_Alpha; j2++) { cp1[j1][j2] = 0.0; cp2[j1][j2] = 0.0; } } for (int j = 0; j < N_Com; j++) { for (int b1 = 0; b1 < N_Alpha; b1++) { for (int b2 = 0; b2 < N_Alpha; b2++) { x1[b1][b2] = W[j][i][b1][b2] - Coh_p[i][b1][b2]; } } matmul3(x1, G_s[i][i], x3); for (int j1 = 0; j1 < N_Alpha; j1++) { for (int j2 = 0; j2 < N_Alpha; j2++) { x2[j1][j2] = I1[j1][j2] - x3[j1][j2]; } } matinv3(x2, x3); matmul3(x3, x1, x2); for (int j1 = 0; j1 < N_Alpha; j1++) { for (int j2 = 0; j2 < N_Alpha; j2++) { cp1[j1][j2] += Cl[j][i] * x2[j1][j2]; cp2[j1][j2] += Cl[j][i] * x3[j1][j2]; } } } matinv3(cp2, x3); matmul3(x3, cp1, dcp[i]); for (int j = 0; j < N_Alpha; j++) { Doub f1 = abs(dcp[i][j][j]); //sqrt(dcp[i][j][j].r*dcp[i][j][j].r+dcp[i][j][j].i*dcp[i][j][j].i); // cout << sqrt(dcp[i][j][j].r*dcp[i][j][j].r+dcp[i][j][j].i*dcp[i][j][j].i)/sqrt(Coh_p[i][j][j].r*Coh_p[i][j][j].r+Coh_p[i][j][j].i*Coh_p[i][j][j].i) << '\n'; if (f1 > EPS_CP * abs(Coh_p[i][j][j])) //.r*Coh_p[i][j][j].r+Coh_p[i][j][j].i*Coh_p[i][j][j].i)) { l_CPA = 0; } if (f1 > f2) { f2 = f1; } } } for (int i = 0; i < N_LAT; i++) { for (int j1 = 0; j1 < N_Alpha; j1++) { for (int j2 = 0; j2 < N_Alpha; j2++) { Coh_p[i][j1][j2] += dcp[i][j1][j2]; } } } for (int i = 0; i < N_LAT; i++) { for (int j1 = 0; j1 < N_Alpha; j1++) { for (int j2 = 0; j2 < N_Alpha; j2++) { Coh_p[i][j1][j2] = (E < 0) ? complex<Doub > (real(Coh_p[i][j1][j2]), fabs(imag(Coh_p[i][j1][j2]))) : complex<Doub > (real(Coh_p[i][j1][j2]), -fabs(imag(Coh_p[i][j1][j2]))); } } } if (l_CPA == 1 && it > 0) { delete [] dcp; delete [] W; delete [] Wab; delete [] G_s; delete [] cp1; delete [] cp2; delete [] I1; delete [] Im_d; delete [] x1; delete [] x2; delete [] x3; return; } } if (f2 <= 1.0e-1) { l_CPA = 1; } delete [] dcp; delete [] W; delete [] Wab; delete [] G_s; delete [] cp1; delete [] cp2; delete [] I1; delete [] Im_d; delete [] x1; delete [] x2; delete [] x3; }
[ "veal@veal-desktop.(none)" ]
[ [ [ 1, 344 ] ] ]
271b848fc2d8e524f0a0d555d1319d3247f3f95a
1ac3920c854ebd1f591412d0f93b55a5c2b96521
/GTL Draw/GTL Draw.h
34f6414901196a846c0c5595515e8d2700875747
[]
no_license
vatai/gtldraw
fe1d9181f033dcda833342c4388f0adb0cdbf871
89c288f15cabe4bca348ee93688e995b1a9708bd
refs/heads/master
2020-05-30T23:14:20.159427
2007-05-22T13:39:34
2007-05-22T13:39:34
32,105,809
0
0
null
null
null
null
UTF-8
C++
false
false
647
h
// GTL Draw.h : main header file for the GTL Draw application // #pragma once #ifndef __AFXWIN_H__ #error include 'stdafx.h' before including this file for PCH #endif #include "resource.h" // main symbols // CGTLDrawApp: // See GTL Draw.cpp for the implementation of this class // class CGTLDrawApp : public CWinApp { public: CGTLDrawApp(); // Overrides public: virtual BOOL InitInstance(); // Implementation afx_msg void OnAppAbout(); DECLARE_MESSAGE_MAP() virtual int ExitInstance(); GdiplusStartupInput m_gdiplusStartupInput; ULONG_PTR m_gdiplusToken; }; extern CGTLDrawApp theApp;
[ "emil.vatai@e8fff1a5-fc30-0410-bed7-e1c51b34c90e" ]
[ [ [ 1, 36 ] ] ]
7d52af5fa52c5965d434ba7380a7bb58dd6ea7f9
028d79ad6dd6bb4114891b8f4840ef9f0e9d4a32
/src/drivers/pacman.cpp
109907bb587f06737e22bc11e17650119810c743
[]
no_license
neonichu/iMame4All-for-iPad
72f56710d2ed7458594838a5152e50c72c2fb67f
4eb3d4ed2e5ccb5c606fcbcefcb7c5a662ace611
refs/heads/master
2020-04-21T07:26:37.595653
2011-11-26T12:21:56
2011-11-26T12:21:56
2,855,022
4
0
null
null
null
null
UTF-8
C++
false
false
90,599
cpp
#include "../machine/pacplus.cpp" #include "../machine/theglob.cpp" /*************************************************************************** Pac-Man memory map (preliminary) 0000-3fff ROM 4000-43ff Video RAM 4400-47ff Color RAM 4c00-4fff RAM 8000-9fff ROM (Ms Pac-Man and Ponpoko only) a000-bfff ROM (Ponpoko only) memory mapped ports: read: 5000 IN0 5040 IN1 5080 DSW 1 50c0 DSW 2 (Ponpoko only) see the input_ports definition below for details on the input bits write: 4ff0-4fff 8 pairs of two bytes: the first byte contains the sprite image number (bits 2-7), Y flip (bit 0), X flip (bit 1); the second byte the color 5000 interrupt enable 5001 sound enable 5002 ???? 5003 flip screen 5004 1 player start lamp 5005 2 players start lamp 5006 coin lockout 5007 coin counter 5040-5044 sound voice 1 accumulator (nibbles) (used by the sound hardware only) 5045 sound voice 1 waveform (nibble) 5046-5049 sound voice 2 accumulator (nibbles) (used by the sound hardware only) 504a sound voice 2 waveform (nibble) 504b-504e sound voice 3 accumulator (nibbles) (used by the sound hardware only) 504f sound voice 3 waveform (nibble) 5050-5054 sound voice 1 frequency (nibbles) 5055 sound voice 1 volume (nibble) 5056-5059 sound voice 2 frequency (nibbles) 505a sound voice 2 volume (nibble) 505b-505e sound voice 3 frequency (nibbles) 505f sound voice 3 volume (nibble) 5060-506f Sprite coordinates, x/y pairs for 8 sprites 50c0 Watchdog reset I/O ports: OUT on port $0 sets the interrupt vector Make Trax driver Make Trax protection description: Make Trax has a "Special" chip that it uses for copy protection. The following chart shows when reads and writes may occur: AAAAAAAA AAAAAAAA 11111100 00000000 <- address bits 54321098 76543210 xxx1xxxx 01xxxxxx - read data bits 4 and 7 xxx1xxxx 10xxxxxx - read data bits 6 and 7 xxx1xxxx 11xxxxxx - read data bits 0 through 5 xxx1xxxx 00xxx100 - write to Special xxx1xxxx 00xxx101 - write to Special xxx1xxxx 00xxx110 - write to Special xxx1xxxx 00xxx111 - write to Special In practical terms, it reads from Special when it reads from location $5040-$50FF. Note that these locations overlap our inputs and Dip Switches. Yuk. I don't bother trapping the writes right now, because I don't know how to interpret them. However, comparing against Crush Roller gives most of the values necessary on the reads. Instead of always reading from $5040, $5080, and $50C0, the Make Trax programmers chose to read from a wide variety of locations, probably to make debugging easier. To us, it means that for the most part we can just assign a specific value to return for each address and we'll be OK. This falls apart for the following addresses: $50C0, $508E, $5090, and $5080. These addresses should return multiple values. The other ugly thing happening is in the ROMs at $3AE5. It keeps checking for different values of $50C0 and $5080, and weird things happen if it gets the wrong values. The only way I've found around these is to patch the ROMs using the same patches Crush Roller uses. The only thing to watch with this is that changing the ROMs will break the beginning checksum. That's why we use the rom opcode decode function to do our patches. Incidentally, there are extremely few differences between Crush Roller and Make Trax. About 98% of the differences appear to be either unused bytes, the name of the game, or code related to the protection. I've only spotted two or three actual differences in the games, and they all seem minor. If anybody cares, here's a list of disassembled addresses for every read and write to the Special chip (not all of the reads are specifically for checking the Special bits, some are for checking player inputs and Dip Switches): Writes: $0084, $012F, $0178, $023C, $0C4C, $1426, $1802, $1817, $280C, $2C2E, $2E22, $3205, $3AB7, $3ACC, $3F3D, $3F40, $3F4E, $3F5E Reads: $01C8, $01D2, $0260, $030E, $040E, $0416, $046E, $0474, $0560, $0568, $05B0, $05B8, $096D, $0972, $0981, $0C27, $0C2C, $0F0A, $10B8, $10BE, $111F, $1127, $1156, $115E, $11E3, $11E8, $18B7, $18BC, $18CA, $1973, $197A, $1BE7, $1C06, $1C9F, $1CAA, $1D79, $213D, $2142, $2389, $238F, $2AAE, $2BF4, $2E0A, $39D5, $39DA, $3AE2, $3AEA, $3EE0, $3EE9, $3F07, $3F0D Notes: - The mystery items in Ali Baba don't work correctly because of protection ***************************************************************************/ #include "driver.h" #include "vidhrdw/generic.h" int pacman_vh_start(void); void pacman_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom); WRITE_HANDLER( pengo_flipscreen_w ); void pengo_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh); extern unsigned char *pengo_soundregs; WRITE_HANDLER( pengo_sound_enable_w ); WRITE_HANDLER( pengo_sound_w ); extern void pacplus_decode(void); void theglob_init_machine(void); READ_HANDLER( theglob_decrypt_rom ); static int speedcheat = 0; /* a well known hack allows to make Pac Man run at four times */ /* his usual speed. When we start the emulation, we check if the */ /* hack can be applied, and set this flag accordingly. */ void pacman_init_machine(void) { unsigned char *RAM = memory_region(REGION_CPU1); /* check if the loaded set of ROMs allows the Pac Man speed hack */ if ((RAM[0x180b] == 0xbe && RAM[0x1ffd] == 0x00) || (RAM[0x180b] == 0x01 && RAM[0x1ffd] == 0xbd)) speedcheat = 1; else speedcheat = 0; } static int pacman_interrupt(void) { unsigned char *RAM = memory_region(REGION_CPU1); /* speed up cheat */ if (speedcheat) { if (readinputport(4) & 1) /* check status of the fake dip switch */ { /* activate the cheat */ RAM[0x180b] = 0x01; RAM[0x1ffd] = 0xbd; } else { /* remove the cheat */ RAM[0x180b] = 0xbe; RAM[0x1ffd] = 0x00; } } return interrupt(); } static WRITE_HANDLER( pacman_leds_w ) { osd_led_w(offset,data); } static WRITE_HANDLER( alibaba_sound_w ) { /* since the sound region in Ali Baba is not contiguous, translate the offset into the 0-0x1f range */ if (offset < 0x10) pengo_sound_w(offset, data); else if (offset < 0x20) spriteram_2[offset - 0x10] = data; else pengo_sound_w(offset - 0x10, data); } static READ_HANDLER( alibaba_mystery_1_r ) { // The return value determines what the mystery item is. Each bit corresponds // to a question mark return rand() & 0x0f; } static READ_HANDLER( alibaba_mystery_2_r ) { static int mystery = 0; // The single bit return value determines when the mystery is lit up. // This is certainly wrong mystery++; return (mystery >> 10) & 1; } static WRITE_HANDLER( pacman_coin_lockout_global_w ) { coin_lockout_global_w(offset, ~data & 0x01); } static struct MemoryReadAddress readmem[] = { { 0x0000, 0x3fff, MRA_ROM }, { 0x4000, 0x47ff, MRA_RAM }, /* video and color RAM */ { 0x4c00, 0x4fff, MRA_RAM }, /* including sprite codes at 4ff0-4fff */ { 0x5000, 0x503f, input_port_0_r }, /* IN0 */ { 0x5040, 0x507f, input_port_1_r }, /* IN1 */ { 0x5080, 0x50bf, input_port_2_r }, /* DSW1 */ { 0x50c0, 0x50ff, input_port_3_r }, /* DSW2 */ { 0x8000, 0xbfff, MRA_ROM }, /* Ms. Pac-Man / Ponpoko only */ { -1 } /* end of table */ }; static struct MemoryWriteAddress writemem[] = { { 0x0000, 0x3fff, MWA_ROM }, { 0x4000, 0x43ff, videoram_w, &videoram, &videoram_size }, { 0x4400, 0x47ff, colorram_w, &colorram }, { 0x4c00, 0x4fef, MWA_RAM }, { 0x4ff0, 0x4fff, MWA_RAM, &spriteram, &spriteram_size }, { 0x5000, 0x5000, interrupt_enable_w }, { 0x5001, 0x5001, pengo_sound_enable_w }, { 0x5002, 0x5002, MWA_NOP }, { 0x5003, 0x5003, pengo_flipscreen_w }, { 0x5004, 0x5005, pacman_leds_w }, // { 0x5006, 0x5006, pacman_coin_lockout_global_w }, this breaks many games { 0x5007, 0x5007, coin_counter_w }, { 0x5040, 0x505f, pengo_sound_w, &pengo_soundregs }, { 0x5060, 0x506f, MWA_RAM, &spriteram_2 }, { 0x50c0, 0x50c0, watchdog_reset_w }, { 0x8000, 0xbfff, MWA_ROM }, /* Ms. Pac-Man / Ponpoko only */ { 0xc000, 0xc3ff, videoram_w }, /* mirror address for video ram, */ { 0xc400, 0xc7ef, colorram_w }, /* used to display HIGH SCORE and CREDITS */ { 0xffff, 0xffff, MWA_NOP }, /* Eyes writes to this location to simplify code */ { -1 } /* end of table */ }; static struct MemoryReadAddress alibaba_readmem[] = { { 0x0000, 0x3fff, MRA_ROM }, { 0x4000, 0x47ff, MRA_RAM }, /* video and color RAM */ { 0x4c00, 0x4fff, MRA_RAM }, /* including sprite codes at 4ef0-4eff */ { 0x5000, 0x503f, input_port_0_r }, /* IN0 */ { 0x5040, 0x507f, input_port_1_r }, /* IN1 */ { 0x5080, 0x50bf, input_port_2_r }, /* DSW1 */ { 0x50c0, 0x50c0, alibaba_mystery_1_r }, { 0x50c1, 0x50c1, alibaba_mystery_2_r }, { 0x8000, 0x8fff, MRA_ROM }, { 0x9000, 0x93ff, MRA_RAM }, { 0xa000, 0xa7ff, MRA_ROM }, { -1 } /* end of table */ }; static struct MemoryWriteAddress alibaba_writemem[] = { { 0x0000, 0x3fff, MWA_ROM }, { 0x4000, 0x43ff, videoram_w, &videoram, &videoram_size }, { 0x4400, 0x47ff, colorram_w, &colorram }, { 0x4ef0, 0x4eff, MWA_RAM, &spriteram, &spriteram_size }, { 0x4c00, 0x4fff, MWA_RAM }, { 0x5000, 0x5000, watchdog_reset_w }, { 0x5004, 0x5005, pacman_leds_w }, { 0x5006, 0x5006, pacman_coin_lockout_global_w }, { 0x5007, 0x5007, coin_counter_w }, { 0x5040, 0x506f, alibaba_sound_w, &pengo_soundregs }, /* the sound region is not contiguous */ { 0x5060, 0x506f, MWA_RAM, &spriteram_2 }, /* actually at 5050-505f, here to point to free RAM */ { 0x50c0, 0x50c0, pengo_sound_enable_w }, { 0x50c1, 0x50c1, pengo_flipscreen_w }, { 0x50c2, 0x50c2, interrupt_enable_w }, { 0x8000, 0x8fff, MWA_ROM }, { 0x9000, 0x93ff, MWA_RAM }, { 0xa000, 0xa7ff, MWA_ROM }, { 0xc000, 0xc3ff, videoram_w }, /* mirror address for video ram, */ { 0xc400, 0xc7ef, colorram_w }, /* used to display HIGH SCORE and CREDITS */ { -1 } /* end of table */ }; static struct IOWritePort writeport[] = { { 0x00, 0x00, interrupt_vector_w }, /* Pac-Man only */ { -1 } /* end of table */ }; static struct IOWritePort vanvan_writeport[] = { { 0x01, 0x01, SN76496_0_w }, { 0x02, 0x02, SN76496_1_w }, { -1 } }; static struct IOWritePort dremshpr_writeport[] = { { 0x06, 0x06, AY8910_write_port_0_w }, { 0x07, 0x07, AY8910_control_port_0_w }, { -1 } }; static struct MemoryReadAddress theglob_readmem[] = { { 0x0000, 0x3fff, MRA_BANK1 }, { 0x4000, 0x47ff, MRA_RAM }, /* video and color RAM */ { 0x4c00, 0x4fff, MRA_RAM }, /* including sprite codes at 4ff0-4fff */ { 0x5000, 0x503f, input_port_0_r }, /* IN0 */ { 0x5040, 0x507f, input_port_1_r }, /* IN1 */ { 0x5080, 0x50bf, input_port_2_r }, /* DSW1 */ { 0x50c0, 0x50ff, input_port_3_r }, /* DSW2 */ { -1 } /* end of table */ }; static struct IOReadPort theglob_readport[] = { { 0x00, 0xff, theglob_decrypt_rom }, /* Switch protection logic */ { -1 } /* end of table */ }; INPUT_PORTS_START( pacman ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_BITX( 0x10, 0x10, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Rack Test", KEYCODE_F1, IP_JOY_NONE ) PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_SERVICE( 0x10, IP_ACTIVE_LOW ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_DIPNAME(0x80, 0x80, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x80, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) PORT_START /* DSW 1 */ PORT_DIPNAME( 0x03, 0x01, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x03, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x01, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) PORT_DIPNAME( 0x0c, 0x08, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x00, "1" ) PORT_DIPSETTING( 0x04, "2" ) PORT_DIPSETTING( 0x08, "3" ) PORT_DIPSETTING( 0x0c, "5" ) PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x00, "10000" ) PORT_DIPSETTING( 0x10, "15000" ) PORT_DIPSETTING( 0x20, "20000" ) PORT_DIPSETTING( 0x30, "None" ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Difficulty ) ) PORT_DIPSETTING( 0x40, "Normal" ) PORT_DIPSETTING( 0x00, "Hard" ) PORT_DIPNAME( 0x80, 0x80, "Ghost Names" ) PORT_DIPSETTING( 0x80, "Normal" ) PORT_DIPSETTING( 0x00, "Alternate" ) PORT_START /* DSW 2 */ PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_START /* FAKE */ /* This fake input port is used to get the status of the fire button */ /* and activate the speedup cheat if it is. */ PORT_BITX( 0x01, 0x00, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Speedup Cheat", KEYCODE_LCONTROL, JOYCODE_1_BUTTON1 ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) ) INPUT_PORTS_END /* Ms. Pac-Man input ports are identical to Pac-Man, the only difference is */ /* the missing Ghost Names dip switch. */ INPUT_PORTS_START( mspacman ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_BITX( 0x10, 0x10, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Rack Test", KEYCODE_F1, IP_JOY_NONE ) PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_SERVICE( 0x10, IP_ACTIVE_LOW ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x80, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) PORT_START /* DSW 1 */ PORT_DIPNAME( 0x03, 0x01, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x03, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x01, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) PORT_DIPNAME( 0x0c, 0x08, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x00, "1" ) PORT_DIPSETTING( 0x04, "2" ) PORT_DIPSETTING( 0x08, "3" ) PORT_DIPSETTING( 0x0c, "5" ) PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x00, "10000" ) PORT_DIPSETTING( 0x10, "15000" ) PORT_DIPSETTING( 0x20, "20000" ) PORT_DIPSETTING( 0x30, "None" ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Difficulty ) ) PORT_DIPSETTING( 0x40, "Normal" ) PORT_DIPSETTING( 0x00, "Hard" ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* DSW 2 */ PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_START /* FAKE */ /* This fake input port is used to get the status of the fire button */ /* and activate the speedup cheat if it is. */ PORT_BITX( 0x01, 0x00, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Speedup Cheat", KEYCODE_LCONTROL, JOYCODE_1_BUTTON1 ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) ) INPUT_PORTS_END INPUT_PORTS_START( maketrax ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_DIPNAME( 0x10, 0x00, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x10, DEF_STR( Cocktail ) ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) /* Protection */ PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) /* Protection */ PORT_START /* DSW 1 */ PORT_DIPNAME( 0x03, 0x01, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x03, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x01, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x00, "3" ) PORT_DIPSETTING( 0x04, "4" ) PORT_DIPSETTING( 0x08, "5" ) PORT_DIPSETTING( 0x0c, "6" ) PORT_DIPNAME( 0x10, 0x10, "First Pattern" ) PORT_DIPSETTING( 0x10, "Easy" ) PORT_DIPSETTING( 0x00, "Hard" ) PORT_DIPNAME( 0x20, 0x20, "Teleport Holes" ) PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED ) /* Protection */ PORT_START /* DSW 2 */ PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END INPUT_PORTS_START( mbrush ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_DIPNAME( 0x10, 0x00, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x10, DEF_STR( Cocktail ) ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) /* Protection in Make Trax */ PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) /* Protection in Make Trax */ PORT_START /* DSW 1 */ PORT_DIPNAME( 0x03, 0x01, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x03, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x01, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) PORT_DIPNAME( 0x0c, 0x08, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x00, "1" ) PORT_DIPSETTING( 0x04, "2" ) PORT_DIPSETTING( 0x08, "3" ) PORT_DIPSETTING( 0x0c, "4" ) PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED ) /* Protection in Make Trax */ PORT_START /* DSW 2 */ PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END INPUT_PORTS_START( paintrlr ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_DIPNAME( 0x10, 0x00, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x10, DEF_STR( Cocktail ) ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) /* Protection in Make Trax */ PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) /* Protection in Make Trax */ PORT_START /* DSW 1 */ PORT_DIPNAME( 0x03, 0x01, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x03, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x01, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x00, "3" ) PORT_DIPSETTING( 0x04, "4" ) PORT_DIPSETTING( 0x08, "5" ) PORT_DIPSETTING( 0x0c, "6" ) PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED ) /* Protection in Make Trax */ PORT_START /* DSW 2 */ PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END INPUT_PORTS_START( ponpoko ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN3 ) /* The 2nd player controls are used even in upright mode */ PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER2 ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 ) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER2 ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_START /* DSW 1 */ PORT_DIPNAME( 0x03, 0x01, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x01, "10000" ) PORT_DIPSETTING( 0x02, "30000" ) PORT_DIPSETTING( 0x03, "50000" ) PORT_DIPSETTING( 0x00, "None" ) PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, "0" ) PORT_DIPSETTING( 0x04, "1" ) PORT_DIPSETTING( 0x08, "2" ) PORT_DIPSETTING( 0x0c, "3" ) PORT_DIPNAME( 0x30, 0x20, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x00, "2" ) PORT_DIPSETTING( 0x10, "3" ) PORT_DIPSETTING( 0x20, "4" ) PORT_DIPSETTING( 0x30, "5" ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x40, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_START /* DSW 2 */ PORT_DIPNAME( 0x0f, 0x01, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x04, "A 3/1 B 3/1" ) PORT_DIPSETTING( 0x0e, "A 3/1 B 1/2" ) PORT_DIPSETTING( 0x0f, "A 3/1 B 1/4" ) PORT_DIPSETTING( 0x02, "A 2/1 B 2/1" ) PORT_DIPSETTING( 0x0d, "A 2/1 B 1/1" ) PORT_DIPSETTING( 0x07, "A 2/1 B 1/3" ) PORT_DIPSETTING( 0x0b, "A 2/1 B 1/5" ) PORT_DIPSETTING( 0x0c, "A 2/1 B 1/6" ) PORT_DIPSETTING( 0x01, "A 1/1 B 1/1" ) PORT_DIPSETTING( 0x06, "A 1/1 B 4/5" ) PORT_DIPSETTING( 0x05, "A 1/1 B 2/3" ) PORT_DIPSETTING( 0x0a, "A 1/1 B 1/3" ) PORT_DIPSETTING( 0x08, "A 1/1 B 1/5" ) PORT_DIPSETTING( 0x09, "A 1/1 B 1/6" ) PORT_DIPSETTING( 0x03, "A 1/2 B 1/2" ) PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) ) /* Most likely unused */ PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) /* Most likely unused */ PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x40, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) /* Most likely unused */ PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) INPUT_PORTS_END INPUT_PORTS_START( eyes ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_SERVICE( 0x10, IP_ACTIVE_LOW ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_START /* DSW 1 */ PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x01, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) PORT_DIPNAME( 0x0c, 0x08, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x0c, "2" ) PORT_DIPSETTING( 0x08, "3" ) PORT_DIPSETTING( 0x04, "4" ) PORT_DIPSETTING( 0x00, "5" ) PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x30, "50000" ) PORT_DIPSETTING( 0x20, "75000" ) PORT_DIPSETTING( 0x10, "100000" ) PORT_DIPSETTING( 0x00, "125000" ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x40, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) /* Not accessed */ PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_START /* DSW 2 */ PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END INPUT_PORTS_START( mrtnt ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_SERVICE( 0x10, IP_ACTIVE_LOW ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_START /* DSW 1 */ PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x01, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) PORT_DIPNAME( 0x0c, 0x08, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x0c, "2" ) PORT_DIPSETTING( 0x08, "3" ) PORT_DIPSETTING( 0x04, "4" ) PORT_DIPSETTING( 0x00, "5" ) PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x30, "75000" ) PORT_DIPSETTING( 0x20, "100000" ) PORT_DIPSETTING( 0x10, "125000" ) PORT_DIPSETTING( 0x00, "150000" ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x40, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_START /* DSW 2 */ PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END INPUT_PORTS_START( lizwiz ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY ) PORT_SERVICE( 0x10, IP_ACTIVE_LOW ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER2 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) PORT_START /* DSW 1 */ PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x01, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) PORT_DIPNAME( 0x0c, 0x08, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x0c, "2" ) PORT_DIPSETTING( 0x08, "3" ) PORT_DIPSETTING( 0x04, "4" ) PORT_DIPSETTING( 0x00, "5" ) PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x30, "75000" ) PORT_DIPSETTING( 0x20, "100000" ) PORT_DIPSETTING( 0x10, "125000" ) PORT_DIPSETTING( 0x00, "150000" ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Difficulty ) ) PORT_DIPSETTING( 0x40, "Normal" ) PORT_DIPSETTING( 0x00, "Hard" ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_START /* DSW 2 */ PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END INPUT_PORTS_START( theglob ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x80, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) PORT_START /* DSW 1 */ PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x03, "3" ) PORT_DIPSETTING( 0x02, "4" ) PORT_DIPSETTING( 0x01, "5" ) PORT_DIPSETTING( 0x00, "6" ) PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Difficulty ) ) PORT_DIPSETTING( 0x1c, "Easiest" ) PORT_DIPSETTING( 0x18, "Very Easy" ) PORT_DIPSETTING( 0x14, "Easy" ) PORT_DIPSETTING( 0x10, "Normal" ) PORT_DIPSETTING( 0x0c, "Difficult" ) PORT_DIPSETTING( 0x08, "Very Difficult" ) PORT_DIPSETTING( 0x04, "Very Hard" ) PORT_DIPSETTING( 0x00, "Hardest" ) PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_START /* DSW 2 */ PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED ) INPUT_PORTS_END INPUT_PORTS_START( vanvan ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) /* The 2nd player controls are used even in upright mode */ PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* DSW 1 */ PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x01, DEF_STR( Cocktail ) ) PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) ) PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x30, "3" ) PORT_DIPSETTING( 0x20, "4" ) PORT_DIPSETTING( 0x10, "5" ) PORT_DIPSETTING( 0x00, "6" ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Coin_A ) ) PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x40, DEF_STR( 1C_1C ) ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Coin_B ) ) PORT_DIPSETTING( 0x80, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x00, DEF_STR( 1C_3C ) ) PORT_START /* DSW 2 */ PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) ) PORT_BITX( 0x02, 0x00, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", KEYCODE_F1, IP_JOY_NONE ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x02, DEF_STR( On ) ) PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x04, DEF_STR( On ) ) PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x08, DEF_STR( On ) ) PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x10, DEF_STR( On ) ) PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x20, DEF_STR( On ) ) PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) INPUT_PORTS_END INPUT_PORTS_START( vanvans ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) /* The 2nd player controls are used even in upright mode */ PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* DSW 1 */ PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x01, DEF_STR( Cocktail ) ) PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) ) PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x30, "3" ) PORT_DIPSETTING( 0x20, "4" ) PORT_DIPSETTING( 0x10, "5" ) PORT_DIPSETTING( 0x00, "6" ) PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0xc0, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x80, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x40, DEF_STR( 1C_3C ) ) PORT_START /* DSW 2 */ PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) ) PORT_BITX( 0x02, 0x00, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", KEYCODE_F1, IP_JOY_NONE ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x02, DEF_STR( On ) ) PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x04, DEF_STR( On ) ) PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x08, DEF_STR( On ) ) PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x10, DEF_STR( On ) ) PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x20, DEF_STR( On ) ) PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x40, DEF_STR( On ) ) PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x80, DEF_STR( On ) ) INPUT_PORTS_END INPUT_PORTS_START( dremshpr ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_START /* DSW 1 */ PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x01, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) ) PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x08, "30000" ) PORT_DIPSETTING( 0x04, "50000" ) PORT_DIPSETTING( 0x00, "70000" ) PORT_DIPSETTING( 0x0c, "None" ) PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x30, "3" ) PORT_DIPSETTING( 0x20, "4" ) PORT_DIPSETTING( 0x10, "5" ) PORT_DIPSETTING( 0x00, "6" ) PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0xc0, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x80, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x40, DEF_STR( 1C_3C ) ) PORT_START /* DSW 2 */ //PORT_BITX( 0x01, 0x00, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", IP_KEY_NONE, IP_JOY_NONE ) //PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) /* turning this on crashes puts the */ //PORT_DIPSETTING( 0x01, DEF_STR( On ) ) /* emulated machine in an infinite loop once in a while */ // PORT_DIPNAME( 0xff, 0x00, DEF_STR( Unused ) ) PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNUSED ) INPUT_PORTS_END INPUT_PORTS_START( alibaba ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY ) PORT_BITX(0x10, 0x10, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Rack Test", KEYCODE_F1, IP_JOY_NONE ) PORT_DIPSETTING(0x10, DEF_STR( Off ) ) PORT_DIPSETTING(0x00, DEF_STR( On ) ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x80, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) PORT_START /* DSW 1 */ PORT_DIPNAME( 0x03, 0x01, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x03, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x01, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x00, DEF_STR( Free_Play ) ) PORT_DIPNAME( 0x0c, 0x08, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x00, "1" ) PORT_DIPSETTING( 0x04, "2" ) PORT_DIPSETTING( 0x08, "3" ) PORT_DIPSETTING( 0x0c, "5" ) PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x00, "10000" ) PORT_DIPSETTING( 0x10, "15000" ) PORT_DIPSETTING( 0x20, "20000" ) PORT_DIPSETTING( 0x30, "None" ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Difficulty ) ) PORT_DIPSETTING( 0x40, "Normal" ) PORT_DIPSETTING( 0x00, "Hard" ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) INPUT_PORTS_END static struct GfxLayout tilelayout = { 8,8, /* 8*8 characters */ 256, /* 256 characters */ 2, /* 2 bits per pixel */ { 0, 4 }, /* the two bitplanes for 4 pixels are packed into one byte */ { 8*8+0, 8*8+1, 8*8+2, 8*8+3, 0, 1, 2, 3 }, /* bits are packed in groups of four */ { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, 16*8 /* every char takes 16 bytes */ }; static struct GfxLayout spritelayout = { 16,16, /* 16*16 sprites */ 64, /* 64 sprites */ 2, /* 2 bits per pixel */ { 0, 4 }, /* the two bitplanes for 4 pixels are packed into one byte */ { 8*8, 8*8+1, 8*8+2, 8*8+3, 16*8+0, 16*8+1, 16*8+2, 16*8+3, 24*8+0, 24*8+1, 24*8+2, 24*8+3, 0, 1, 2, 3 }, { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8 }, 64*8 /* every sprite takes 64 bytes */ }; static struct GfxDecodeInfo gfxdecodeinfo[] = { { REGION_GFX1, 0, &tilelayout, 0, 32 }, { REGION_GFX2, 0, &spritelayout, 0, 32 }, { -1 } /* end of array */ }; static struct namco_interface namco_interface = { 3072000/32, /* sample rate */ 3, /* number of voices */ 100, /* playback volume */ REGION_SOUND1 /* memory region */ }; static struct SN76496interface sn76496_interface = { 2, { 1789750, 1789750 }, /* 1.78975 Mhz ? */ { 75, 75 } }; static struct AY8910interface dremshpr_ay8910_interface = { 1, /* 1 chip */ 14318000/8, /* 1.78975 MHz ??? */ { 50 }, { 0 }, { 0 }, { 0 }, { 0 } }; static struct MachineDriver machine_driver_pacman = { /* basic machine hardware */ { { CPU_Z80, 18432000/6, /* 3.072 Mhz */ readmem,writemem,0,writeport, pacman_interrupt,1 } }, 60, 2500, /* frames per second, vblank duration */ 1, /* single CPU, no need for interleaving */ pacman_init_machine, /* video hardware */ 36*8, 28*8, { 0*8, 36*8-1, 0*8, 28*8-1 }, gfxdecodeinfo, 16, 4*32, pacman_vh_convert_color_prom, VIDEO_TYPE_RASTER | VIDEO_SUPPORTS_DIRTY, 0, pacman_vh_start, generic_vh_stop, pengo_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_NAMCO, &namco_interface } } }; static struct MachineDriver machine_driver_theglob = { /* basic machine hardware */ { { CPU_Z80, 18432000/6, /* 3.072 Mhz */ theglob_readmem,writemem,theglob_readport,writeport, pacman_interrupt,1 } }, 60, 2500, /* frames per second, vblank duration */ 1, /* single CPU, no need for interleaving */ theglob_init_machine, /* video hardware */ 36*8, 28*8, { 0*8, 36*8-1, 0*8, 28*8-1 }, gfxdecodeinfo, 16, 4*32, pacman_vh_convert_color_prom, VIDEO_TYPE_RASTER, 0, pacman_vh_start, generic_vh_stop, pengo_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_NAMCO, &namco_interface } } }; static struct MachineDriver machine_driver_vanvan = { /* basic machine hardware */ { { CPU_Z80, 18432000/6, /* 3.072 Mhz */ readmem,writemem,0,vanvan_writeport, nmi_interrupt,1 } }, 60, 2500, /* frames per second, vblank duration */ 1, /* single CPU, no need for interleaving */ 0, /* video hardware */ 36*8, 28*8, { 0*8, 36*8-1, 0*8, 28*8-1 }, gfxdecodeinfo, 16, 4*32, pacman_vh_convert_color_prom, VIDEO_TYPE_RASTER | VIDEO_SUPPORTS_DIRTY, 0, pacman_vh_start, generic_vh_stop, pengo_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_SN76496, &sn76496_interface } } }; static struct MachineDriver machine_driver_dremshpr = { /* basic machine hardware */ { { CPU_Z80, 18432000/6, /* 3.072 Mhz */ readmem,writemem,0,dremshpr_writeport, nmi_interrupt,1 } }, 60, 2500, /* frames per second, vblank duration */ 1, /* single CPU, no need for interleaving */ 0, /* video hardware */ 36*8, 28*8, { 0*8, 36*8-1, 0*8, 28*8-1 }, gfxdecodeinfo, 16, 4*32, pacman_vh_convert_color_prom, VIDEO_TYPE_RASTER | VIDEO_SUPPORTS_DIRTY, 0, pacman_vh_start, generic_vh_stop, pengo_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_AY8910, &dremshpr_ay8910_interface } } }; static struct MachineDriver machine_driver_alibaba = { /* basic machine hardware */ { { CPU_Z80, 18432000/6, /* 3.072 Mhz */ alibaba_readmem,alibaba_writemem,0,0, interrupt,1 } }, 60, 2500, /* frames per second, vblank duration */ 1, /* single CPU, no need for interleaving */ 0, /* video hardware */ 36*8, 28*8, { 0*8, 36*8-1, 0*8, 28*8-1 }, gfxdecodeinfo, 16, 4*32, pacman_vh_convert_color_prom, VIDEO_TYPE_RASTER | VIDEO_SUPPORTS_DIRTY, 0, pacman_vh_start, generic_vh_stop, pengo_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_NAMCO, &namco_interface } } }; /*************************************************************************** Game driver(s) ***************************************************************************/ ROM_START( pacman ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "namcopac.6e", 0x0000, 0x1000, 0xfee263b3 ) ROM_LOAD( "namcopac.6f", 0x1000, 0x1000, 0x39d1fc83 ) ROM_LOAD( "namcopac.6h", 0x2000, 0x1000, 0x02083b03 ) ROM_LOAD( "namcopac.6j", 0x3000, 0x1000, 0x7a36fe55 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5e", 0x0000, 0x1000, 0x0c944964 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5f", 0x0000, 0x1000, 0x958fedf9 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( npacmod ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "namcopac.6e", 0x0000, 0x1000, 0xfee263b3 ) ROM_LOAD( "namcopac.6f", 0x1000, 0x1000, 0x39d1fc83 ) ROM_LOAD( "namcopac.6h", 0x2000, 0x1000, 0x02083b03 ) ROM_LOAD( "npacmod.6j", 0x3000, 0x1000, 0x7d98d5f5 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5e", 0x0000, 0x1000, 0x0c944964 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5f", 0x0000, 0x1000, 0x958fedf9 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( pacmanjp ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "pacman.6e", 0x0000, 0x1000, 0xc1e6ab10 ) ROM_LOAD( "pacman.6f", 0x1000, 0x1000, 0x1a6fb2d4 ) ROM_LOAD( "pacman.6h", 0x2000, 0x1000, 0xbcdd1beb ) ROM_LOAD( "prg7", 0x3000, 0x0800, 0xb6289b26 ) ROM_LOAD( "prg8", 0x3800, 0x0800, 0x17a88c13 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "chg1", 0x0000, 0x0800, 0x2066a0b7 ) ROM_LOAD( "chg2", 0x0800, 0x0800, 0x3591b89d ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5f", 0x0000, 0x1000, 0x958fedf9 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( pacmanm ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "pacman.6e", 0x0000, 0x1000, 0xc1e6ab10 ) ROM_LOAD( "pacman.6f", 0x1000, 0x1000, 0x1a6fb2d4 ) ROM_LOAD( "pacman.6h", 0x2000, 0x1000, 0xbcdd1beb ) ROM_LOAD( "pacman.6j", 0x3000, 0x1000, 0x817d94e3 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5e", 0x0000, 0x1000, 0x0c944964 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5f", 0x0000, 0x1000, 0x958fedf9 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( pacmod ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "pacmanh.6e", 0x0000, 0x1000, 0x3b2ec270 ) ROM_LOAD( "pacman.6f", 0x1000, 0x1000, 0x1a6fb2d4 ) ROM_LOAD( "pacmanh.6h", 0x2000, 0x1000, 0x18811780 ) ROM_LOAD( "pacmanh.6j", 0x3000, 0x1000, 0x5c96a733 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacmanh.5e", 0x0000, 0x1000, 0x299fb17a ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5f", 0x0000, 0x1000, 0x958fedf9 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( hangly ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "hangly.6e", 0x0000, 0x1000, 0x5fe8610a ) ROM_LOAD( "hangly.6f", 0x1000, 0x1000, 0x73726586 ) ROM_LOAD( "hangly.6h", 0x2000, 0x1000, 0x4e7ef99f ) ROM_LOAD( "hangly.6j", 0x3000, 0x1000, 0x7f4147e6 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5e", 0x0000, 0x1000, 0x0c944964 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5f", 0x0000, 0x1000, 0x958fedf9 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( hangly2 ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "hangly.6e", 0x0000, 0x1000, 0x5fe8610a ) ROM_LOAD( "hangly2.6f", 0x1000, 0x0800, 0x5ba228bb ) ROM_LOAD( "hangly2.6m", 0x1800, 0x0800, 0xbaf5461e ) ROM_LOAD( "hangly.6h", 0x2000, 0x1000, 0x4e7ef99f ) ROM_LOAD( "hangly2.6j", 0x3000, 0x0800, 0x51305374 ) ROM_LOAD( "hangly2.6p", 0x3800, 0x0800, 0x427c9d4d ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacmanh.5e", 0x0000, 0x1000, 0x299fb17a ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5f", 0x0000, 0x1000, 0x958fedf9 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( puckman ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "puckman.6e", 0x0000, 0x1000, 0xa8ae23c5 ) ROM_LOAD( "pacman.6f", 0x1000, 0x1000, 0x1a6fb2d4 ) ROM_LOAD( "puckman.6h", 0x2000, 0x1000, 0x197443f8 ) ROM_LOAD( "puckman.6j", 0x3000, 0x1000, 0x2e64a3ba ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5e", 0x0000, 0x1000, 0x0c944964 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5f", 0x0000, 0x1000, 0x958fedf9 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( pacheart ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "pacheart.pg1", 0x0000, 0x0800, 0xd844b679 ) ROM_LOAD( "pacheart.pg2", 0x0800, 0x0800, 0xb9152a38 ) ROM_LOAD( "pacheart.pg3", 0x1000, 0x0800, 0x7d177853 ) ROM_LOAD( "pacheart.pg4", 0x1800, 0x0800, 0x842d6574 ) ROM_LOAD( "pacheart.pg5", 0x2000, 0x0800, 0x9045a44c ) ROM_LOAD( "pacheart.pg6", 0x2800, 0x0800, 0x888f3c3e ) ROM_LOAD( "pacheart.pg7", 0x3000, 0x0800, 0xf5265c10 ) ROM_LOAD( "pacheart.pg8", 0x3800, 0x0800, 0x1a21a381 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacheart.ch1", 0x0000, 0x0800, 0xc62bbabf ) ROM_LOAD( "chg2", 0x0800, 0x0800, 0x3591b89d ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacheart.ch3", 0x0000, 0x0800, 0xca8c184c ) ROM_LOAD( "pacheart.ch4", 0x0800, 0x0800, 0x1b1d9096 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( piranha ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "pr1.cpu", 0x0000, 0x1000, 0xbc5ad024 ) ROM_LOAD( "pacman.6f", 0x1000, 0x1000, 0x1a6fb2d4 ) ROM_LOAD( "pr3.cpu", 0x2000, 0x1000, 0x473c379d ) ROM_LOAD( "pr4.cpu", 0x3000, 0x1000, 0x63fbf895 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pr5.cpu", 0x0000, 0x0800, 0x3fc4030c ) ROM_LOAD( "pr7.cpu", 0x0800, 0x0800, 0x30b9a010 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pr6.cpu", 0x0000, 0x0800, 0xf3e9c9d5 ) ROM_LOAD( "pr8.cpu", 0x0800, 0x0800, 0x133d720d ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( pacplus ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "pacplus.6e", 0x0000, 0x1000, 0xd611ef68 ) ROM_LOAD( "pacplus.6f", 0x1000, 0x1000, 0xc7207556 ) ROM_LOAD( "pacplus.6h", 0x2000, 0x1000, 0xae379430 ) ROM_LOAD( "pacplus.6j", 0x3000, 0x1000, 0x5a6dff7b ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacplus.5e", 0x0000, 0x1000, 0x022c35da ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacplus.5f", 0x0000, 0x1000, 0x4de65cdd ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "pacplus.7f", 0x0000, 0x0020, 0x063dd53a ) ROM_LOAD( "pacplus.4a", 0x0020, 0x0100, 0xe271a166 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( mspacman ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "boot1", 0x0000, 0x1000, 0xd16b31b7 ) ROM_LOAD( "boot2", 0x1000, 0x1000, 0x0d32de5e ) ROM_LOAD( "boot3", 0x2000, 0x1000, 0x1821ee0b ) ROM_LOAD( "boot4", 0x3000, 0x1000, 0x165a9dd8 ) ROM_LOAD( "boot5", 0x8000, 0x1000, 0x8c3e6de6 ) ROM_LOAD( "boot6", 0x9000, 0x1000, 0x368cb165 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "5e", 0x0000, 0x1000, 0x5c281d01 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "5f", 0x0000, 0x1000, 0x615af909 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( mspacatk ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "boot1", 0x0000, 0x1000, 0xd16b31b7 ) ROM_LOAD( "mspacatk.2", 0x1000, 0x1000, 0x0af09d31 ) ROM_LOAD( "boot3", 0x2000, 0x1000, 0x1821ee0b ) ROM_LOAD( "boot4", 0x3000, 0x1000, 0x165a9dd8 ) ROM_LOAD( "mspacatk.5", 0x8000, 0x1000, 0xe6e06954 ) ROM_LOAD( "mspacatk.6", 0x9000, 0x1000, 0x3b5db308 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "5e", 0x0000, 0x1000, 0x5c281d01 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "5f", 0x0000, 0x1000, 0x615af909 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( pacgal ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "boot1", 0x0000, 0x1000, 0xd16b31b7 ) ROM_LOAD( "boot2", 0x1000, 0x1000, 0x0d32de5e ) ROM_LOAD( "pacman.7fh", 0x2000, 0x1000, 0x513f4d5c ) ROM_LOAD( "pacman.7hj", 0x3000, 0x1000, 0x70694c8e ) ROM_LOAD( "boot5", 0x8000, 0x1000, 0x8c3e6de6 ) ROM_LOAD( "boot6", 0x9000, 0x1000, 0x368cb165 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "5e", 0x0000, 0x1000, 0x5c281d01 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "pacman.5ef", 0x0000, 0x0800, 0x65a3ee71 ) ROM_LOAD( "pacman.5hj", 0x0800, 0x0800, 0x50c7477d ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s129.4a", 0x0020, 0x0100, 0x63efb927 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( crush ) ROM_REGION( 2*0x10000, REGION_CPU1 ) /* 64k for code + 64k for opcode copy to hack protection */ ROM_LOAD( "crushkrl.6e", 0x0000, 0x1000, 0xa8dd8f54 ) ROM_LOAD( "crushkrl.6f", 0x1000, 0x1000, 0x91387299 ) ROM_LOAD( "crushkrl.6h", 0x2000, 0x1000, 0xd4455f27 ) ROM_LOAD( "crushkrl.6j", 0x3000, 0x1000, 0xd59fc251 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "maketrax.5e", 0x0000, 0x1000, 0x91bad2da ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "maketrax.5f", 0x0000, 0x1000, 0xaea79f55 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "crush.4a", 0x0020, 0x0100, 0x2bc5d339 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( crush2 ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "tp1", 0x0000, 0x0800, 0xf276592e ) ROM_LOAD( "tp5a", 0x0800, 0x0800, 0x3d302abe ) ROM_LOAD( "tp2", 0x1000, 0x0800, 0x25f42e70 ) ROM_LOAD( "tp6", 0x1800, 0x0800, 0x98279cbe ) ROM_LOAD( "tp3", 0x2000, 0x0800, 0x8377b4cb ) ROM_LOAD( "tp7", 0x2800, 0x0800, 0xd8e76c8c ) ROM_LOAD( "tp4", 0x3000, 0x0800, 0x90b28fa3 ) ROM_LOAD( "tp8", 0x3800, 0x0800, 0x10854e1b ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "tpa", 0x0000, 0x0800, 0xc7617198 ) ROM_LOAD( "tpc", 0x0800, 0x0800, 0xe129d76a ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "tpb", 0x0000, 0x0800, 0xd1899f05 ) ROM_LOAD( "tpd", 0x0800, 0x0800, 0xd35d1caf ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "crush.4a", 0x0020, 0x0100, 0x2bc5d339 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( crush3 ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "unkmol.4e", 0x0000, 0x0800, 0x49150ddf ) ROM_LOAD( "unkmol.6e", 0x0800, 0x0800, 0x21f47e17 ) ROM_LOAD( "unkmol.4f", 0x1000, 0x0800, 0x9b6dd592 ) ROM_LOAD( "unkmol.6f", 0x1800, 0x0800, 0x755c1452 ) ROM_LOAD( "unkmol.4h", 0x2000, 0x0800, 0xed30a312 ) ROM_LOAD( "unkmol.6h", 0x2800, 0x0800, 0xfe4bb0eb ) ROM_LOAD( "unkmol.4j", 0x3000, 0x0800, 0x072b91c9 ) ROM_LOAD( "unkmol.6j", 0x3800, 0x0800, 0x66fba07d ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "unkmol.5e", 0x0000, 0x0800, 0x338880a0 ) ROM_LOAD( "unkmol.5h", 0x0800, 0x0800, 0x4ce9c81f ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "unkmol.5f", 0x0000, 0x0800, 0x752e3780 ) ROM_LOAD( "unkmol.5j", 0x0800, 0x0800, 0x6e00d2ac ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "crush.4a", 0x0020, 0x0100, 0x2bc5d339 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( maketrax ) ROM_REGION( 2*0x10000, REGION_CPU1 ) /* 64k for code + 64k for opcode copy to hack protection */ ROM_LOAD( "maketrax.6e", 0x0000, 0x1000, 0x0150fb4a ) ROM_LOAD( "maketrax.6f", 0x1000, 0x1000, 0x77531691 ) ROM_LOAD( "maketrax.6h", 0x2000, 0x1000, 0xa2cdc51e ) ROM_LOAD( "maketrax.6j", 0x3000, 0x1000, 0x0b4b5e0a ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "maketrax.5e", 0x0000, 0x1000, 0x91bad2da ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "maketrax.5f", 0x0000, 0x1000, 0xaea79f55 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "crush.4a", 0x0020, 0x0100, 0x2bc5d339 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( mbrush ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "mbrush.6e", 0x0000, 0x1000, 0x750fbff7 ) ROM_LOAD( "mbrush.6f", 0x1000, 0x1000, 0x27eb4299 ) ROM_LOAD( "mbrush.6h", 0x2000, 0x1000, 0xd297108e ) ROM_LOAD( "mbrush.6j", 0x3000, 0x1000, 0x6fd719d0 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "tpa", 0x0000, 0x0800, 0xc7617198 ) ROM_LOAD( "mbrush.5h", 0x0800, 0x0800, 0xc15b6967 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "mbrush.5f", 0x0000, 0x0800, 0xd5bc5cb8 ) /* copyright sign was removed */ ROM_LOAD( "tpd", 0x0800, 0x0800, 0xd35d1caf ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "crush.4a", 0x0020, 0x0100, 0x2bc5d339 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( paintrlr ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "paintrlr.1", 0x0000, 0x0800, 0x556d20b5 ) ROM_LOAD( "paintrlr.5", 0x0800, 0x0800, 0x4598a965 ) ROM_LOAD( "paintrlr.2", 0x1000, 0x0800, 0x2da29c81 ) ROM_LOAD( "paintrlr.6", 0x1800, 0x0800, 0x1f561c54 ) ROM_LOAD( "paintrlr.3", 0x2000, 0x0800, 0xe695b785 ) ROM_LOAD( "paintrlr.7", 0x2800, 0x0800, 0x00e6eec0 ) ROM_LOAD( "paintrlr.4", 0x3000, 0x0800, 0x0fd5884b ) ROM_LOAD( "paintrlr.8", 0x3800, 0x0800, 0x4900114a ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "tpa", 0x0000, 0x0800, 0xc7617198 ) ROM_LOAD( "mbrush.5h", 0x0800, 0x0800, 0xc15b6967 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "mbrush.5f", 0x0000, 0x0800, 0xd5bc5cb8 ) /* copyright sign was removed */ ROM_LOAD( "tpd", 0x0800, 0x0800, 0xd35d1caf ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "crush.4a", 0x0020, 0x0100, 0x2bc5d339 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( ponpoko ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "ppokoj1.bin", 0x0000, 0x1000, 0xffa3c004 ) ROM_LOAD( "ppokoj2.bin", 0x1000, 0x1000, 0x4a496866 ) ROM_LOAD( "ppokoj3.bin", 0x2000, 0x1000, 0x17da6ca3 ) ROM_LOAD( "ppokoj4.bin", 0x3000, 0x1000, 0x9d39a565 ) ROM_LOAD( "ppoko5.bin", 0x8000, 0x1000, 0x54ca3d7d ) ROM_LOAD( "ppoko6.bin", 0x9000, 0x1000, 0x3055c7e0 ) ROM_LOAD( "ppoko7.bin", 0xa000, 0x1000, 0x3cbe47ca ) ROM_LOAD( "ppokoj8.bin", 0xb000, 0x1000, 0x04b63fc6 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "ppoko9.bin", 0x0000, 0x1000, 0xb73e1a06 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "ppoko10.bin", 0x0000, 0x1000, 0x62069b5d ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( ponpokov ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "ppoko1.bin", 0x0000, 0x1000, 0x49077667 ) ROM_LOAD( "ppoko2.bin", 0x1000, 0x1000, 0x5101781a ) ROM_LOAD( "ppoko3.bin", 0x2000, 0x1000, 0xd790ed22 ) ROM_LOAD( "ppoko4.bin", 0x3000, 0x1000, 0x4e449069 ) ROM_LOAD( "ppoko5.bin", 0x8000, 0x1000, 0x54ca3d7d ) ROM_LOAD( "ppoko6.bin", 0x9000, 0x1000, 0x3055c7e0 ) ROM_LOAD( "ppoko7.bin", 0xa000, 0x1000, 0x3cbe47ca ) ROM_LOAD( "ppoko8.bin", 0xb000, 0x1000, 0xb39be27d ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "ppoko9.bin", 0x0000, 0x1000, 0xb73e1a06 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "ppoko10.bin", 0x0000, 0x1000, 0x62069b5d ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s126.4a", 0x0020, 0x0100, 0x3eb3a8e4 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( eyes ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "d7", 0x0000, 0x1000, 0x3b09ac89 ) ROM_LOAD( "e7", 0x1000, 0x1000, 0x97096855 ) ROM_LOAD( "f7", 0x2000, 0x1000, 0x731e294e ) ROM_LOAD( "h7", 0x3000, 0x1000, 0x22f7a719 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "d5", 0x0000, 0x1000, 0xd6af0030 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "e5", 0x0000, 0x1000, 0xa42b5201 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s129.4a", 0x0020, 0x0100, 0xd8d78829 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( eyes2 ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "g38201.7d", 0x0000, 0x1000, 0x2cda7185 ) ROM_LOAD( "g38202.7e", 0x1000, 0x1000, 0xb9fe4f59 ) ROM_LOAD( "g38203.7f", 0x2000, 0x1000, 0xd618ba66 ) ROM_LOAD( "g38204.7h", 0x3000, 0x1000, 0xcf038276 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "g38205.5d", 0x0000, 0x1000, 0x03b1b4c7 ) /* this one has a (c) sign */ ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "e5", 0x0000, 0x1000, 0xa42b5201 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "82s123.7f", 0x0000, 0x0020, 0x2fc650bd ) ROM_LOAD( "82s129.4a", 0x0020, 0x0100, 0xd8d78829 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( mrtnt ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "tnt.1", 0x0000, 0x1000, 0x0e836586 ) ROM_LOAD( "tnt.2", 0x1000, 0x1000, 0x779c4c5b ) ROM_LOAD( "tnt.3", 0x2000, 0x1000, 0xad6fc688 ) ROM_LOAD( "tnt.4", 0x3000, 0x1000, 0xd77557b3 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "tnt.5", 0x0000, 0x1000, 0x3038cc0e ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "tnt.6", 0x0000, 0x1000, 0x97634d8b ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "mrtnt08.bin", 0x0000, 0x0020, 0x00000000 ) ROM_LOAD( "mrtnt04.bin", 0x0020, 0x0100, 0x00000000 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m" , 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( lizwiz ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "6e.cpu", 0x0000, 0x1000, 0x32bc1990 ) ROM_LOAD( "6f.cpu", 0x1000, 0x1000, 0xef24b414 ) ROM_LOAD( "6h.cpu", 0x2000, 0x1000, 0x30bed83d ) ROM_LOAD( "6j.cpu", 0x3000, 0x1000, 0xdd09baeb ) ROM_LOAD( "wiza", 0x8000, 0x1000, 0xf6dea3a6 ) ROM_LOAD( "wizb", 0x9000, 0x1000, 0xf27fb5a8 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "5e.cpu", 0x0000, 0x1000, 0x45059e73 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "5f.cpu", 0x0000, 0x1000, 0xd2469717 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "7f.cpu", 0x0000, 0x0020, 0x7549a947 ) ROM_LOAD( "4a.cpu", 0x0020, 0x0100, 0x5fdca536 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m" , 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( theglob ) ROM_REGION( 0x20000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "glob.u2", 0x0000, 0x2000, 0x829d0bea ) ROM_LOAD( "glob.u3", 0x2000, 0x2000, 0x31de6628 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "glob.5e", 0x0000, 0x1000, 0x53688260 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "glob.5f", 0x0000, 0x1000, 0x051f59c7 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "glob.7f", 0x0000, 0x0020, 0x1f617527 ) ROM_LOAD( "glob.4a", 0x0020, 0x0100, 0x28faa769 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m" , 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( beastf ) ROM_REGION( 0x20000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "bf-u2.bin", 0x0000, 0x2000, 0x3afc517b ) ROM_LOAD( "bf-u3.bin", 0x2000, 0x2000, 0x8dbd76d0 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "beastf.5e", 0x0000, 0x1000, 0x5654dc34 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "beastf.5f", 0x0000, 0x1000, 0x1b30ca61 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "glob.7f", 0x0000, 0x0020, 0x1f617527 ) ROM_LOAD( "glob.4a", 0x0020, 0x0100, 0x28faa769 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m" , 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( jumpshot ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "6e", 0x0000, 0x1000, 0xf00def9a ) ROM_LOAD( "6f", 0x1000, 0x1000, 0xf70deae2 ) ROM_LOAD( "6h", 0x2000, 0x1000, 0x894d6f68 ) ROM_LOAD( "6j", 0x3000, 0x1000, 0xf15a108a ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "5e", 0x0000, 0x1000, 0xd9fa90f5 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "5f", 0x0000, 0x1000, 0x2ec711c1 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "prom.7f", 0x0000, 0x0020, 0x872b42f3 ) ROM_LOAD( "prom.4a", 0x0020, 0x0100, 0x0399f39f ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END ROM_START( vanvan ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "van1.bin", 0x0000, 0x1000, 0x00f48295 ) ROM_LOAD( "van-2.51", 0x1000, 0x1000, 0xdf58e1cb ) ROM_LOAD( "van-3.52", 0x2000, 0x1000, 0x15571e24 ) ROM_LOAD( "van4.bin", 0x3000, 0x1000, 0xf8b37ed5 ) ROM_LOAD( "van5.bin", 0x8000, 0x1000, 0xb8c1e089 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "van-20.18", 0x0000, 0x1000, 0x60efbe66 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "van-21.19", 0x0000, 0x1000, 0x5dd53723 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "6331-1.6", 0x0000, 0x0020, 0xce1d9503 ) ROM_LOAD( "6301-1.37", 0x0020, 0x0100, 0x4b803d9f ) ROM_END ROM_START( vanvans ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "van-1.50", 0x0000, 0x1000, 0xcf1b2df0 ) ROM_LOAD( "van-2.51", 0x1000, 0x1000, 0xdf58e1cb ) ROM_LOAD( "van-3.52", 0x2000, 0x1000, 0x15571e24 ) ROM_LOAD( "van-4.53", 0x3000, 0x1000, 0xb724cbe0 ) ROM_LOAD( "van-5.39", 0x8000, 0x1000, 0xdb67414c ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "van-20.18", 0x0000, 0x1000, 0x60efbe66 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "van-21.19", 0x0000, 0x1000, 0x5dd53723 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "6331-1.6", 0x0000, 0x0020, 0xce1d9503 ) ROM_LOAD( "6301-1.37", 0x0020, 0x0100, 0x4b803d9f ) ROM_END ROM_START( dremshpr ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "red_1.50", 0x0000, 0x1000, 0x830c6361 ) ROM_LOAD( "red_2.51", 0x1000, 0x1000, 0xd22551cc ) ROM_LOAD( "red_3.52", 0x2000, 0x1000, 0x0713a34a ) ROM_LOAD( "red_4.53", 0x3000, 0x1000, 0xf38bcaaa ) ROM_LOAD( "red_5.39", 0x8000, 0x1000, 0x6a382267 ) ROM_LOAD( "red_6.40", 0x9000, 0x1000, 0x4cf8b121 ) ROM_LOAD( "red_7.41", 0xa000, 0x1000, 0xbd4fc4ba ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "red-20.18", 0x0000, 0x1000, 0x2d6698dc ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "red-21.19", 0x0000, 0x1000, 0x38c9ce9b ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "6331-1.6", 0x0000, 0x0020, 0xce1d9503 ) ROM_LOAD( "6301-1.37", 0x0020, 0x0100, 0x39d6fb5c ) ROM_END ROM_START( alibaba ) ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */ ROM_LOAD( "6e", 0x0000, 0x1000, 0x38d701aa ) ROM_LOAD( "6f", 0x1000, 0x1000, 0x3d0e35f3 ) ROM_LOAD( "6h", 0x2000, 0x1000, 0x823bee89 ) ROM_LOAD( "6k", 0x3000, 0x1000, 0x474d032f ) ROM_LOAD( "6l", 0x8000, 0x1000, 0x5ab315c1 ) ROM_LOAD( "6m", 0xa000, 0x0800, 0x438d0357 ) ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "5e", 0x0000, 0x0800, 0x85bcb8f8 ) ROM_LOAD( "5h", 0x0800, 0x0800, 0x38e50862 ) ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "5f", 0x0000, 0x0800, 0xb5715c86 ) ROM_LOAD( "5k", 0x0800, 0x0800, 0x713086b3 ) ROM_REGION( 0x0120, REGION_PROMS ) ROM_LOAD( "alibaba.7f", 0x0000, 0x0020, 0x00000000 ) /* missing */ ROM_LOAD( "alibaba.4a", 0x0020, 0x0100, 0x00000000 ) ROM_REGION( 0x0200, REGION_SOUND1 ) /* sound PROMs */ ROM_LOAD( "82s126.1m", 0x0000, 0x0100, 0xa9cc86bf ) ROM_LOAD( "82s126.3m", 0x0100, 0x0100, 0x77245b66 ) /* timing - not used */ ROM_END static READ_HANDLER( maketrax_special_port2_r ) { int pc,data; pc = cpu_getpreviouspc(); data = input_port_2_r(offset); if ((pc == 0x1973) || (pc == 0x2389)) return data | 0x40; switch (offset) { case 0x01: case 0x04: data |= 0x40; break; case 0x05: data |= 0xc0; break; default: data &= 0x3f; break; } return data; } static READ_HANDLER( maketrax_special_port3_r ) { int pc; pc = cpu_getpreviouspc(); if ( pc == 0x040e) return 0x20; if ((pc == 0x115e) || (pc == 0x3ae2)) return 0x00; switch (offset) { case 0x00: return 0x1f; case 0x09: return 0x30; case 0x0c: return 0x00; default: return 0x20; } } static void maketrax_rom_decode(void) { unsigned char *rom = memory_region(REGION_CPU1); int diff = memory_region_length(REGION_CPU1) / 2; /* patch protection using a copy of the opcodes so ROM checksum */ /* tests will not fail */ memory_set_opcode_base(0,rom+diff); memcpy(rom+diff,rom,diff); rom[0x0415 + diff] = 0xc9; rom[0x1978 + diff] = 0x18; rom[0x238e + diff] = 0xc9; rom[0x3ae5 + diff] = 0xe6; rom[0x3ae7 + diff] = 0x00; rom[0x3ae8 + diff] = 0xc9; rom[0x3aed + diff] = 0x86; rom[0x3aee + diff] = 0xc0; rom[0x3aef + diff] = 0xb0; } static void init_maketrax(void) { /* set up protection handlers */ install_mem_read_handler(0, 0x5080, 0x50bf, maketrax_special_port2_r); install_mem_read_handler(0, 0x50c0, 0x50ff, maketrax_special_port3_r); maketrax_rom_decode(); } static void init_ponpoko(void) { int i, j; unsigned char *RAM, temp; /* The gfx data is swapped wrt the other Pac-Man hardware games. */ /* Here we revert it to the usual format. */ /* Characters */ RAM = memory_region(REGION_GFX1); for (i = 0;i < memory_region_length(REGION_GFX1);i += 0x10) { for (j = 0; j < 8; j++) { temp = RAM[i+j+0x08]; RAM[i+j+0x08] = RAM[i+j+0x00]; RAM[i+j+0x00] = temp; } } /* Sprites */ RAM = memory_region(REGION_GFX2); for (i = 0;i < memory_region_length(REGION_GFX2);i += 0x20) { for (j = 0; j < 8; j++) { temp = RAM[i+j+0x18]; RAM[i+j+0x18] = RAM[i+j+0x10]; RAM[i+j+0x10] = RAM[i+j+0x08]; RAM[i+j+0x08] = RAM[i+j+0x00]; RAM[i+j+0x00] = temp; } } } static void eyes_decode(unsigned char *data) { int j; unsigned char swapbuffer[8]; for (j = 0; j < 8; j++) { swapbuffer[j] = data[(j >> 2) + (j & 2) + ((j & 1) << 2)]; } for (j = 0; j < 8; j++) { char ch = swapbuffer[j]; data[j] = (ch & 0x80) | ((ch & 0x10) << 2) | (ch & 0x20) | ((ch & 0x40) >> 2) | (ch & 0x0f); } } static void init_eyes(void) { int i; unsigned char *RAM; /* CPU ROMs */ /* Data lines D3 and D5 swapped */ RAM = memory_region(REGION_CPU1); for (i = 0; i < 0x4000; i++) { RAM[i] = (RAM[i] & 0xc0) | ((RAM[i] & 0x08) << 2) | (RAM[i] & 0x10) | ((RAM[i] & 0x20) >> 2) | (RAM[i] & 0x07); } /* Graphics ROMs */ /* Data lines D4 and D6 and address lines A0 and A2 are swapped */ RAM = memory_region(REGION_GFX1); for (i = 0;i < memory_region_length(REGION_GFX1);i += 8) eyes_decode(&RAM[i]); RAM = memory_region(REGION_GFX2); for (i = 0;i < memory_region_length(REGION_GFX2);i += 8) eyes_decode(&RAM[i]); } static void init_pacplus(void) { pacplus_decode(); } /* rom parent machine inp init */ GAME( 1980, pacman, 0, pacman, pacman, 0, ROT90, "Namco", "PuckMan (Japan set 1)" ) GAME( 1980, pacmanjp, pacman, pacman, pacman, 0, ROT90, "Namco", "PuckMan (Japan set 2)" ) GAME( 1980, pacmanm, pacman, pacman, pacman, 0, ROT90, "[Namco] (Midway license)", "Pac-Man (Midway)" ) GAME( 1981, npacmod, pacman, pacman, pacman, 0, ROT90, "Namco", "PuckMan (harder?)" ) GAME( 1981, pacmod, pacman, pacman, pacman, 0, ROT90, "[Namco] (Midway license)", "Pac-Man (Midway, harder)" ) GAME( 1981, hangly, pacman, pacman, pacman, 0, ROT90, "hack", "Hangly-Man (set 1)" ) GAME( 1981, hangly2, pacman, pacman, pacman, 0, ROT90, "hack", "Hangly-Man (set 2)" ) GAME( 1980, puckman, pacman, pacman, pacman, 0, ROT90, "hack", "New Puck-X" ) GAME( 1981, pacheart, pacman, pacman, pacman, 0, ROT90, "hack", "Pac-Man (Hearts)" ) GAME( 1981, piranha, pacman, pacman, mspacman, 0, ROT90, "hack", "Piranha" ) GAME( 1982, pacplus, 0, pacman, pacman, pacplus, ROT90, "[Namco] (Midway license)", "Pac-Man Plus" ) GAME( 1981, mspacman, 0, pacman, mspacman, 0, ROT90, "bootleg", "Ms. Pac-Man" ) GAME( 1981, mspacatk, mspacman, pacman, mspacman, 0, ROT90, "hack", "Ms. Pac-Man Plus" ) GAME( 1981, pacgal, mspacman, pacman, mspacman, 0, ROT90, "hack", "Pac-Gal" ) GAME( 1981, crush, 0, pacman, maketrax, maketrax, ROT90, "Kural Samno Electric", "Crush Roller (Kural Samno)" ) GAME( 1981, crush2, crush, pacman, maketrax, 0, ROT90, "Kural Esco Electric", "Crush Roller (Kural Esco - bootleg?)" ) GAME( 1981, crush3, crush, pacman, maketrax, eyes, ROT90, "Kural Electric", "Crush Roller (Kural - bootleg?)" ) GAME( 1981, maketrax, crush, pacman, maketrax, maketrax, ROT270, "[Kural] (Williams license)", "Make Trax" ) GAME( 1981, mbrush, crush, pacman, mbrush, 0, ROT90, "bootleg", "Magic Brush" ) GAME( 1981, paintrlr, crush, pacman, paintrlr, 0, ROT90, "bootleg", "Paint Roller" ) GAME( 1982, ponpoko, 0, pacman, ponpoko, ponpoko, ROT0, "Sigma Ent. Inc.", "Ponpoko" ) GAME( 1982, ponpokov, ponpoko, pacman, ponpoko, ponpoko, ROT0, "Sigma Ent. Inc. (Venture Line license)", "Ponpoko (Venture Line)" ) GAME( 1982, eyes, 0, pacman, eyes, eyes, ROT90, "Digitrex Techstar (Rock-ola license)", "Eyes (Digitrex Techstar)" ) GAME( 1982, eyes2, eyes, pacman, eyes, eyes, ROT90, "Techstar Inc. (Rock-ola license)", "Eyes (Techstar Inc.)" ) GAME( 1983, mrtnt, 0, pacman, mrtnt, eyes, ROT90, "Telko", "Mr. TNT" ) GAME( 1985, lizwiz, 0, pacman, lizwiz, 0, ROT90, "Techstar (Sunn license)", "Lizard Wizard" ) GAME( 1983, theglob, 0, theglob, theglob, 0, ROT90, "Epos Corporation", "The Glob" ) GAME( 1984, beastf, theglob, theglob, theglob, 0, ROT90, "Epos Corporation", "Beastie Feastie" ) GAMEX(????, jumpshot, 0, pacman, pacman, 0, ROT90, "<unknown>", "Jump Shot", GAME_NOT_WORKING ) /* not working, encrypted */ GAME( 1982, dremshpr, 0, dremshpr, dremshpr, 0, ROT270, "Sanritsu", "Dream Shopper" ) GAME( 1983, vanvan, 0, vanvan, vanvan, 0, ROT270, "Karateco", "Van Van Car" ) GAME( 1983, vanvans, vanvan, vanvan, vanvans, 0, ROT270, "Sanritsu", "Van Van Car (Sanritsu)" ) GAME( 1982, alibaba, 0, alibaba, alibaba, 0, ROT90, "Sega", "Ali Baba and 40 Thieves" )
[ [ [ 1, 2356 ] ] ]
67c112cec3d5959ffda05ecfd95a6408d323787c
b8ac0bb1d1731d074b7a3cbebccc283529b750d4
/Code/controllers/RecollectionBenchmark/behaviours/GoToGarbage.cpp
f186253349b03d0d997e3818d156118d0a5a8eed
[]
no_license
dh-04/tpf-robotica
5efbac38d59fda0271ac4639ea7b3b4129c28d82
10a7f4113d5a38dc0568996edebba91f672786e9
refs/heads/master
2022-12-10T18:19:22.428435
2010-11-05T02:42:29
2010-11-05T02:42:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,654
cpp
#include "GoToGarbage.h" // class's header file #include <list> namespace behaviours { // class constructor GoToGarbage::GoToGarbage(vision::IGarbageRecognition * gr, robotapi::IDifferentialWheels * wheels) : AbstractBehaviour("Go to Garbage") { this->gr = gr; this->wheels = wheels; } // class destructor GoToGarbage::~GoToGarbage() { // insert your code here } void GoToGarbage::sense(){ bool garbagePresent = this->gr->thereIsGarbage(); if ( ! garbagePresent ) return; std::list<vision::Garbage*> gs = this->gr->getGarbageList(); // Calculate nearest garbage and angle to it this->currentGarbage = this->gr->getClosestGarbage(gs); double angleToGarbage = this->gr->angleTo(currentGarbage); if ( fabs(angleToGarbage) < behaviours::BehavioursParameters::getParameter(GO_TO_GARBAGE_ANGLE_TOLE) ) setStimulusPresent(); } void GoToGarbage::action(){ // Get distance to garbage ( it is supposed to be in front of the robot) double distanceToGarbage = this->gr->distanceTo(currentGarbage); double speed = this->calculateSpeed(distanceToGarbage); // Go forward till the garbage is about to leave the screen( with bias ) this->wheels->setSpeed(speed,speed); } double GoToGarbage::calculateSpeed(double distanceToGarbage){ double coeff = distanceToGarbage/(this->gr->getMaximumDistance() - this->gr->getMinimumDistance()); return behaviours::BehavioursParameters::getParameter(GO_TO_GARBAGE_MIN_SPD) * ( 1 - coeff ) + coeff * behaviours::BehavioursParameters::getParameter(GO_TO_GARBAGE_MAX_SPD); } }
[ "guicamest@d69ea68a-f96b-11de-8cdf-e97ad7d0f28a", "nachogoni@d69ea68a-f96b-11de-8cdf-e97ad7d0f28a", "nuldiego@d69ea68a-f96b-11de-8cdf-e97ad7d0f28a" ]
[ [ [ 1, 6 ], [ 8, 23 ], [ 25, 29 ], [ 31, 44 ], [ 46, 48 ] ], [ [ 7, 7 ], [ 24, 24 ] ], [ [ 30, 30 ], [ 45, 45 ] ] ]
3df9a8e68536a659241f30f88c0a049c2094e00b
3daaefb69e57941b3dee2a616f62121a3939455a
/mgllib/src/2d/MglTexture2.h
ffa23420debde665420f9c74af8ed7fc913b6f07
[]
no_license
myun2ext/open-mgl-legacy
21ccadab8b1569af8fc7e58cf494aaaceee32f1e
8faf07bad37a742f7174b454700066d53a384eae
refs/heads/master
2016-09-06T11:41:14.108963
2009-12-28T12:06:58
2009-12-28T12:06:58
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
1,088
h
////////////////////////////////////////////////////////// // // MglTexture2 - テクスチャ管理クラス // // なお、CreateTextureFromFile() で作成されたテクスチャは // 三角形を二枚組み合わせた四角形であるのでこの事に注意されたし! #ifndef __MglTexture2_H__ #define __MglTexture2_H__ //#include "MglD3dTexture.h" #include "MglDxTexture.h" //#include "MglVertexManager.h" #include "Mgl3dSquare.h" // クラス宣言 class DLL_EXP CMglTexture2 : public CMglD3dTexture { protected: CMglGraphicManager* m_myudg; // DGクラスへのポインタを格納 // Direct3D系 _MGL_IDirect3DDevice* d3d; // D3DDeviceへのポインタ // 内部メソッド(チェック用) void InitCheck() { if ( m_myudg == NULL ) Init( GetDefaultGd() ); } public: // コンストラクタ・デストラクタ CMglTexture2(); virtual ~CMglTexture2(){ Release(); } // 初期化と開放 void Init( CMglGraphicManager* in_myudg=GetDefaultGd() ); void Release(); }; #endif//__MglTexture2_H__
[ "myun2@6d62ff88-fa28-0410-b5a4-834eb811a934" ]
[ [ [ 1, 42 ] ] ]
81f252f526ea021c70a3b0aa2ae06877acd6bfe1
794e836e421d42388b87f295cfe0c3056c392845
/trunk/src/compiler/Linker.h
0e80ad055a3710d96897116d6cf37a59fc5abaa7
[ "BSD-3-Clause" ]
permissive
BackupTheBerlios/bf-dev-svn
e892779b283458510ad00b17696baf3898a061b2
1afb8c5679fecf15cb0cfe8e7447df1cc3e4e9c4
refs/heads/master
2021-01-25T05:35:41.850282
2006-06-21T18:24:12
2006-06-21T18:24:12
40,672,917
0
0
null
null
null
null
UTF-8
C++
false
false
350
h
#ifndef __LINKER_H__ #define __LINKER_H__ __LINKER_H__ #include <string> #include "NasmNotFound.h" #include "Architecture.h" class Linker { public: Linker(); Linker(std::string file, Architecture &arch); virtual ~Linker(); void link() throw(NasmNotFound); private: std::string file; Architecture *arch; }; #endif
[ "wolmo@cef5e46f-a703-0410-a4eb-a1b77d141377" ]
[ [ [ 1, 24 ] ] ]
d5a0f1dc0449542770997b0efbbaf5b95d79b659
4b0f51aeecddecf3f57a29ffa7a184ae48f1dc61
/CleanProject/Include/TaskManager.h
a01ce7b15a4f24aa651fcd20507d3ef83ba3ba51
[]
no_license
bahao247/apeengine2
56560dbf6d262364fbc0f9f96ba4231e5e4ed301
f2617b2a42bdf2907c6d56e334c0d027fb62062d
refs/heads/master
2021-01-10T14:04:02.319337
2009-08-26T08:23:33
2009-08-26T08:23:33
45,979,392
0
1
null
null
null
null
ISO-8859-10
C++
false
false
2,028
h
/*! @file @author Pablo Nuņez @date 13/2009 @module *//* This file is part of the Nebula Engine. Nebula Engine is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Nebula Engine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Nebula Engine. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _TASK_MANAGER_H #define _TASK_MANAGER_H #include "EnginePrerequisites.h" namespace Nebula { class ITask; class NebulaDllPrivate TaskManager : public Ogre::Singleton<TaskManager>, public ITask { public: TaskManager(); virtual ~TaskManager(); static TaskManager& getSingleton(void); static TaskManager* getSingletonPtr(void); /** Execute Task. @return Task Response. */ int execute(); bool addTask(ITask* t); void suspendTask(ITask* t); void resumeTask(ITask* t); void removeTask(ITask* t); void killAllTasks(); std::map<const std::string, GameObject*> getGameObjects(); GameObject* getGameObject(const std::string &id); void deleteGameObject(const std::string &id); GameObject* addGameObject(GameObject *go); void clearGameObjects(); void updateGameObjects(); void setupGameObjects(); bool setAllBindings(); private: bool start(); void onSuspend(); void update(); void onResume(); void stop(); //Set Lua bindings void setBindings(); std::list< ITask* > taskList; std::list< ITask* > pausedTaskList; std::map<const std::string, GameObject*> mGOs; }; } //end namespace #endif
[ "pablosn@06488772-1f9a-11de-8b5c-13accb87f508" ]
[ [ [ 1, 85 ] ] ]
5cc09e3aace94f1782aefeedaf9066c501123983
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestnote/inc/bctestnoteview.h
94b7e42845fbb0ec20a503bab5b3936a638207b3
[]
no_license
SymbianSource/oss.FCL.sftools.ana.compatanamdw
a6a8abf9ef7ad71021d43b7f2b2076b504d4445e
1169475bbf82ebb763de36686d144336fcf9d93b
refs/heads/master
2020-12-24T12:29:44.646072
2010-11-11T14:03:20
2010-11-11T14:03:20
72,994,432
0
0
null
null
null
null
UTF-8
C++
false
false
1,906
h
/* * Copyright (c) 2006 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: Declares test bc for note control view. * */ #ifndef C_CBCTESTNOTEVIEW_H #define C_CBCTESTNOTEVIEW_H #include <aknview.h> class CBCTestNoteContainer; class CBCTestUtil; const TUid KBCTestNoteViewId = { 1 }; /** * Application View class */ class CBCTestNoteView : public CAknView { public: // Constructors and destructor /** * Symbian static 2nd constructor */ static CBCTestNoteView* NewL(); /** * dtor */ virtual ~CBCTestNoteView(); // from CAknView /** * Return view Id. */ TUid Id() const; /** * From CAknView, HandleCommandL. * @param aCommand Command to be handled. */ void HandleCommandL( TInt aCommand ); protected: // from CAknView /** * When view is activated, do something */ void DoActivateL( const TVwsViewId&, TUid, const TDesC8& ); /** * When view is deactivated, do something */ void DoDeactivate(); private: // constructor /** * C++ default constructor */ CBCTestNoteView(); /** * symbian 2nd ctor */ void ConstructL(); private: // data /** * pointor to the BC Test framework utility. * own */ CBCTestUtil* iTestUtil; /** * pointor to the container. * own */ CBCTestNoteContainer* iContainer; }; #endif // C_CBCTESTNOTEVIEW_H
[ "none@none" ]
[ [ [ 1, 102 ] ] ]
1ad8fbe4fd8a165fe7582839856a8443f683b104
cf579692f2e289563160b6a218fa5f1b6335d813
/XBtool/ColorDlg/ColourPopup.h
a4e8eac86fbd076627abf66d9c8934bd91d2a19b
[]
no_license
opcow/XBtool
a7451971de3296e1ce5632b0c9d95430f6d3b223
718a7fbf87e08c12c0c829dd2e2c0d6cee967cbe
refs/heads/master
2021-01-16T21:02:17.759102
2011-03-09T23:36:54
2011-03-09T23:36:54
1,461,420
8
2
null
null
null
null
UTF-8
C++
false
false
4,451
h
#ifndef COLOURPOPUP_INCLUDED #define COLOURPOPUP_INCLUDED #pragma once #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 // ColourPopup.h : header file // // Written by Chris Maunder ([email protected]) // Extended by Alexander Bischofberger ([email protected]) // Copyright (c) 1998. // // This code may be used in compiled form in any way you desire. This // file may be redistributed unmodified by any means PROVIDING it is // not sold for profit without the authors written consent, and // providing that this notice and the authors name is included. If // the source code in this file is used in any commercial application // then a simple email would be nice. // // This file is provided "as is" with no expressed or implied warranty. // The author accepts no liability if it causes any damage whatsoever. // It's free - so you get what you pay for. // CColourPopup messages #define CPN_SELCHANGE WM_USER + 1001 // Colour Picker Selection change #define CPN_DROPDOWN WM_USER + 1002 // Colour Picker drop down #define CPN_CLOSEUP WM_USER + 1003 // Colour Picker close up #define CPN_SELENDOK WM_USER + 1004 // Colour Picker end OK #define CPN_SELENDCANCEL WM_USER + 1005 // Colour Picker end (cancelled) // forward declaration class CColourPicker; // To hold the colours and their names typedef struct { COLORREF crColour; TCHAR *szName; } ColourTableEntry; ///////////////////////////////////////////////////////////////////////////// // CColourPopup window class CColourPopup : public CWnd { // Construction public: CColourPopup(); CColourPopup(CPoint p, COLORREF crColour, CWnd* pParentWnd, LPCTSTR szDefaultText = NULL, LPCTSTR szCustomText = NULL); void Initialise(); // Attributes public: // Operations public: BOOL Create(CPoint p, COLORREF crColour, CWnd* pParentWnd, LPCTSTR szDefaultText = NULL, LPCTSTR szCustomText = NULL); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CColourPopup) public: virtual BOOL PreTranslateMessage(MSG* pMsg); //}}AFX_VIRTUAL // Implementation public: virtual ~CColourPopup(); protected: BOOL GetCellRect(int nIndex, const LPRECT& rect); void FindCellFromColour(COLORREF crColour); void SetWindowSize(); void CreateToolTips(); void ChangeSelection(int nIndex); void EndSelection(int nMessage); void DrawCell(CDC* pDC, int nIndex); COLORREF GetColour(int nIndex) { return m_crColours[nIndex].crColour; } LPCTSTR GetColourName(int nIndex) { return m_crColours[nIndex].szName; } int GetIndex(int row, int col) const; int GetRow(int nIndex) const; int GetColumn(int nIndex) const; // protected attributes protected: static ColourTableEntry m_crColours[]; int m_nNumColours; int m_nNumColumns, m_nNumRows; int m_nBoxSize, m_nMargin; int m_nCurrentSel; int m_nChosenColourSel; CString m_strDefaultText; CString m_strCustomText; CRect m_CustomTextRect, m_DefaultTextRect, m_WindowRect; CFont m_Font; CPalette m_Palette; COLORREF m_crInitialColour, m_crColour; CToolTipCtrl m_ToolTip; CWnd* m_pParent; BOOL m_bChildWindowVisible; // Generated message map functions protected: //{{AFX_MSG(CColourPopup) afx_msg void OnNcDestroy(); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnPaint(); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg BOOL OnQueryNewPalette(); afx_msg void OnPaletteChanged(CWnd* pFocusWnd); afx_msg void OnKillFocus(CWnd* pNewWnd); afx_msg void OnActivateApp(BOOL bActive, DWORD ThreadID); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. #endif // !defined(AFX_COLOURPOPUP_H__D0B75902_9830_11D1_9C0F_00A0243D1382__INCLUDED_)
[ [ [ 1, 129 ] ] ]
71beaf78ff30840ba755eb69bf7ae87e12b3b24a
08d0c8fae169c869d3c24c7cdfb4cbcde4976658
/IoCompletionPort.cpp
1bb6936db4fcd0330af1f89e0300e97134b96185
[]
no_license
anelson/asynciotest
6b24615b69007cb4fa4b1a5e31dd933b638838ff
e79cea40e1595468401488accc27229a4aedd899
refs/heads/master
2016-09-09T19:35:15.153615
2010-11-07T18:40:56
2010-11-07T18:40:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,028
cpp
#include "StdAfx.h" #include "IoCompletionPort.h" #include "Logger.h" IoCompletionPort::IoCompletionPort(void) { m_iocp = ::CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, NULL, 0); if (!m_iocp) { Logger::ErrorWin32(::GetLastError(), _T("Failed to create IOCP")); } } IoCompletionPort::~IoCompletionPort(void) { if (m_iocp) { ::CloseHandle(m_iocp); m_iocp = NULL; } } bool IoCompletionPort::AssociateHandle(HANDLE handle, ULONG_PTR pCompletionKey /* = NULL */) { if (!::CreateIoCompletionPort(handle, m_iocp, pCompletionKey, 0)) { Logger::ErrorWin32(::GetLastError(), _T("Unable to associate handle with IOCP")); return false; } return true; } DWORD IoCompletionPort::GetQueuedCompletionStatus(LPDWORD lpBytesTransferred, PULONG_PTR lpCompletionKey, LPOVERLAPPED* lpOverlapped) { BOOL result = ::GetQueuedCompletionStatus(m_iocp, lpBytesTransferred, lpCompletionKey, lpOverlapped, INFINITE); if (!result) { return ::GetLastError(); } return 0; }
[ [ [ 1, 42 ] ] ]
d3f885ccc503998fffca7cd98d7c26a21fad1b8a
b505ef7eb1a6c58ebcb73267eaa1bad60efb1cb2
/source/graphics/color/color_p08.cpp
1d9c592da163a9a931a994d15ae6818935f22f08
[]
no_license
roxygen/maid2
230319e05d6d6e2f345eda4c4d9d430fae574422
455b6b57c4e08f3678948827d074385dbc6c3f58
refs/heads/master
2021-01-23T17:19:44.876818
2010-07-02T02:43:45
2010-07-02T02:43:45
38,671,921
0
0
null
null
null
null
UTF-8
C++
false
false
466
cpp
#include"color_p08.h" namespace Maid { // パレットポインタの実体 // PIXELFORMAT の ePIXELFORMAT_P8---- が増えたらここも増やす // すんごくダサイ(・Д・;) COLOR_A08R08G08B08I* COLOR_P08A08R08G08B08I::s_CLUTLIST_Src; COLOR_A08R08G08B08I* COLOR_P08A08R08G08B08I::s_CLUTLIST_Dst; COLOR_X08R08G08B08I* COLOR_P08X08R08G08B08I::s_CLUTLIST_Src; COLOR_X08R08G08B08I* COLOR_P08X08R08G08B08I::s_CLUTLIST_Dst; }
[ [ [ 1, 16 ] ] ]
fb4a00e16eab3891f4ac323bbaaedecb67f5659c
5236606f2e6fb870fa7c41492327f3f8b0fa38dc
/nsrpc/src/sao/Proxy.cpp
3d3367590402846d7383ff39b0d7951fe3c08227
[]
no_license
jcloudpld/srpc
aa8ecf4ffc5391b7183b19d217f49fb2b1a67c88
f2483c8177d03834552053e8ecbe788e15b92ac0
refs/heads/master
2021-01-10T08:54:57.140800
2010-02-08T07:03:00
2010-02-08T07:03:00
44,454,693
0
0
null
null
null
null
UTF-8
C++
false
false
276
cpp
#include "stdafx.h" #include "Scheduler.h" #include <nsrpc/sao/Proxy.h> namespace nsrpc { namespace sao { void Proxy::schedule(MethodRequest* method) { assert(method != 0); scheduler_.schedule(method); } } // namespace sao } // namespace nsrpc
[ "kcando@6d7ccee0-1a3b-0410-bfa1-83648d9ec9a4" ]
[ [ [ 1, 19 ] ] ]
a4f43d5298165a108c3c97949aa75451c1b6469a
1cc5720e245ca0d8083b0f12806a5c8b13b5cf98
/archive/3046/c.cpp
aa93a795a1c9e0bd1e68871c1c10b0b684d3c817
[]
no_license
Emerson21/uva-problems
399d82d93b563e3018921eaff12ca545415fd782
3079bdd1cd17087cf54b08c60e2d52dbd0118556
refs/heads/master
2021-01-18T09:12:23.069387
2010-12-15T00:38:34
2010-12-15T00:38:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
974
cpp
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; void st() { int tot = 0; char pal[2000][30]; int len[2000]; while(true) { if(!cin.getline(pal[tot],25)) break; if(strlen(pal[tot])==0 || pal[tot][0]=='\n' || pal[tot][0]=='\r') break; len[tot] = strlen(pal[tot]); if(pal[ tot++; } int i,j,k,l1,l2,m,n; for(i=0;i!=tot;i++) { l1 = len[i]; k = 0; for(j=0;j!=tot;j++) { /* if(i==j) continue; n = l1; if(n>len[j]) n = len[j]; for(m=0;m!=n;m++) { if(pal[i][m]!=pal[j][m]) break; } if(k<m) { k = m; //cout << "ig: " << k << " com " << pal[j] << endl; }*/ } cout << pal[i] << endl; cout << " "; // printf("%s ",pal[i]); // for(m=0;m!=k;m++) putchar(pal[i][m]); putchar('\n'); } } int main() { int n; scanf("%d ",&n); while(n--) { st(); if(n) cout << endl; } return 0; }
[ [ [ 1, 68 ] ] ]
1d154c492757ae2d0278387d47ff2c6cf0472d7b
79636d9a11c4ac53811d55ef0f432f68ab62944f
/smart-darkgdk/Game.h
d4ab10a50a1cee5cd3dbf50dea41845f076e01c2
[ "MIT" ]
permissive
endel/smart-darkgdk
44d90a1afcd71deebef65f47dc54586df4ae4736
6235288b8aab505577223f9544a6e5a7eb6bf6cd
refs/heads/master
2021-01-19T10:58:29.387767
2009-06-26T16:44:15
2009-06-26T16:44:15
32,123,434
0
0
null
null
null
null
UTF-8
C++
false
false
2,582
h
#pragma once #include "DarkGDK.h" //definitions #include "include/ObjectType.h" #include "include/Core.h" //classes #include "include/CommonObject.h" #include "include/Sprite.h" #include "include/Camera.h" #include "include/Image.h" #include "include/Mesh.h" #include "include/Limb.h" #include "include/Matrix.h" #include "include/Matrix4.h" #include "include/Object.h" #include "include/Light.h" #include "include/Effect.h" #include "include/PixelShader.h" #include "include/VertexShader.h" #include "include/Music.h" #include "include/Sound.h" #include "include/Particles.h" #include "include/Sprite.h" #include "include/Terrain.h" //smart classes #include "include/Lives.h" //static classes #include "include/BSP.h" #include "include/Key.h" #include "include/String.h" #include "include/Mouse.h" #include "include/Joystick.h" #include "include/Fog.h" #include "include/FTP.h" #include "include/Mathf.h" #include "include/Transition.h" //std classes #include <vector> #include <string> #include <map> #include <math.h> using namespace std; #define random(x) dbRnd(x) #define SIN(x) sin((double)(x)) #define COS(x) cos((double)(x)) //game class Game { public: //public vars static int OBJECT_ID; static int SPRITE_ID; static int IMAGE_ID; static int LIMB_ID; static int MESH_ID; static int MATRIX_ID; static int MATRIX4_ID; static int CAMERA_ID; static int LIGHT_ID; static int VERTEXSHADER_ID; static int PIXELSHADER_ID; static int EFFECT_ID; static int MUSIC_ID; static int SOUND_ID; static int PARTICLES_ID; static int TERRAIN_ID; static MouseClickState MOUSE_STATE; static MouseClick LAST_MOUSE_CLICK; static MouseClick MOUSE_CLICK; //public methods Game(void); static int getObjectId(); static int getSpriteId(); static int getImageId(); static int getMeshId(); static int getLimbId(); static int getMatrixId(); static int getMatrix4Id(); static int getCameraId(); static int getLightId(); static int getVertexShaderId(); static int getPixelShaderId(); static int getEffectId(); static int getMusicId(); static int getSoundId(); static int getParticlesId(); static int getTerrainId(); static MouseClick getLastMouseClick(); static int width(); static int height(); //utils static void init(char* title,int w,int h,int syncRate=60); static void setResolution(int w,int h); static bool loop(); static void refresh(); static void setBackdropColor(int r,int g,int b); static void setDir(char* dir); };
[ "endel.dreyer@0995f060-2c81-11de-ae9b-2be1a451ffb1", "[email protected]@0995f060-2c81-11de-ae9b-2be1a451ffb1" ]
[ [ [ 1, 40 ], [ 42, 114 ] ], [ [ 41, 41 ] ] ]
c5a244338326c05b4afa9d0dcd143dc6bcfa8327
03d1f3dd8c9284b93890648d65a1589276ef505f
/VisualSPH/Render11/Settings.cpp
13c3444ce4e332fd9056c69706db66e543951a43
[]
no_license
shadercoder/photonray
18271358ca7f20a3c4a6326164d292774bfc3f53
e0bbad33bc9c03e094036748f965100023aa0287
refs/heads/master
2021-01-10T04:20:14.592834
2011-05-07T21:09:43
2011-05-07T21:09:43
45,577,179
0
0
null
null
null
null
UTF-8
C++
false
false
756
cpp
#include "DXUT.h" #include "Settings.h" Settings::Settings(void) { } Settings::~Settings(void) { } void Settings::loadFromFile(char* fileName) { ifstream fin (fileName); fin >> pathToFolder; fin >> patternString; fin >> firstFrame >> lastFrame >> stepFrame; fin >> cameraPos.x >> cameraPos.y >> cameraPos.z; fin >> cameraLookAt.x >> cameraLookAt.y >> cameraLookAt.z; fin >> screenWidth >> screenHeight; fin >> volumeResolution; string _renderState; fin >> _renderState; if (_renderState.compare(_METABALLS) == 0) { renderState = METABALLS; } else if (_renderState.compare(_PARTICLES) == 0) { renderState = PARTICLES; } else { printf("render type must be specified\n"); } fin.close(); }
[ [ [ 1, 38 ] ] ]
29292898405dd425548a249ca61bec08bfdc222d
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/functional/hash/map.hpp
9c982dffa38083f97955fb6a3bafc058497d03e1
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
665
hpp
// Copyright Daniel James 2005-2006. Use, modification, and distribution are // subject to 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) // Based on Peter Dimov's proposal // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf // issue 6.18. #if !defined(BOOST_FUNCTIONAL_HASH_MAP_HPP) #define BOOST_FUNCTIONAL_HASH_MAP_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #warning "boost/functional/hash/map.hpp is deprecated, use boost/functional/hash.hpp instead." #include <boost/functional/hash.hpp> #endif
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 22 ] ] ]
f2e9b73af9e0c51b552604a3bd40bb107a753fc2
b24759bb01b002d42d51c93cb8f02eb681ca1542
/src/LibKopul/KPLC++/srcs/FunctionList.cpp
96b9c5c2a5adb5c38f29e53b63c417415ef7f12f
[]
no_license
LionelAuroux/kopul
272745e6343bf8ca4db73eff76df08c2fab2600b
dc169ca347878e3d11b84371a734acf10230ff4f
refs/heads/master
2020-12-24T15:58:07.863503
2011-12-28T10:37:44
2011-12-28T10:37:44
32,329,849
0
0
null
null
null
null
UTF-8
C++
false
false
5,740
cpp
#include "FunctionList.h" using namespace kpl; /* * FunctionPair */ template <typename T> FunctionPair<T>::FunctionPair() { encode = NULL; decode = NULL; } template <typename T> FunctionPair<T>::FunctionPair(const T& _encode, const T& _decode) : encode(_encode), decode(_decode) { } template <typename T> FunctionPair<T>::FunctionPair(const FunctionPair<T>& oldPair) { encode = oldPair.encode; decode = oldPair.decode; } template <typename T> FunctionPair<T>::~FunctionPair() { } template <typename T> FunctionPair<T>& FunctionPair<T>::operator = (const FunctionPair<T>& oldPair) { encode = oldPair.encode; decode = oldPair.decode; return (*this); } template <typename T> T FunctionPair<T>::operator [] (FUNCTIONTYPE type) const { if (type == ENCODE) return (this->encode); if (type == DECODE) return (this->decode); return (NULL); } /* * FunctionList */ template <typename T> FunctionList<T>::FunctionList(llvm::Module *module, const std::vector<Type *> &listType) { llvm::ExecutionEngine *exec = llvm::EngineBuilder(module).create(); llvm::Module::iterator itb = module->begin(); llvm::Module::iterator ite = module->end(); void *pfencode; void *pfdecode; this->_module = module; this->_nbBytesWriteAdr = (char *)exec->getOrEmitGlobalVariable(static_cast<const llvm::GlobalVariable *>(module->getValueSymbolTable().lookup("_nbBytesWrite"))); this->_nbBytesReadAdr = (char *)exec->getOrEmitGlobalVariable(static_cast<const llvm::GlobalVariable *>(module->getValueSymbolTable().lookup("_nbBytesRead"))); for (unsigned int i = 0; itb != ite; ++itb, ++i) { pfencode = exec->recompileAndRelinkFunction(itb); ++itb; pfdecode = exec->recompileAndRelinkFunction(itb); this->_mapFunctions[static_cast<Type *>(listType[i]->Clone())] = FunctionPair<T>((T)pfencode, (T)pfdecode); } } template <typename T> FunctionList<T>::~FunctionList() { for (typename std::map<Type *, FunctionPair<T> >::iterator it = this->_mapFunctions.begin(); it != this->_mapFunctions.end(); ++it) delete (it->first); delete (this->_module); } template <typename T> const FunctionPair<T>& FunctionList<T>::operator [] (const Type *type) const { for (typename std::map<Type *, FunctionPair<T> >::const_iterator it = this->_mapFunctions.begin(); it != this->_mapFunctions.end(); ++it) { if (it->first->Equals(*type)) return (it->second); } return (this->_end); } template <typename T> const FunctionPair<T>& FunctionList<T>::operator [] (const Type &type) const { for (typename std::map<Type *, FunctionPair<T> >::const_iterator it = this->_mapFunctions.begin(); it != this->_mapFunctions.end(); ++it) { if (it->first->Equals(type)) { return (it->second); } } return (this->_end); } template <typename T> const FunctionPair<T>& FunctionList<T>::operator [] (const std::string &name) const { for (typename std::map<Type *, FunctionPair<T> >::const_iterator it = this->_mapFunctions.begin(); it != this->_mapFunctions.end(); ++it) { if (it->first->GetName() == name) return (it->second); } return (this->_end); } template <typename T> const FunctionPair<T>& FunctionList<T>::operator [] (unsigned int i) const { for (typename std::map<Type *, FunctionPair<T> >::const_iterator it = this->_mapFunctions.begin(); it != this->_mapFunctions.end(); ++it, --i) { if (i == 0) return (it->second); } return (this->_end); } template <typename T> const FunctionPair<T>& FunctionList<T>::Get(const Type *type) const { for (typename std::map<Type *, FunctionPair<T> >::const_iterator it = this->_mapFunctions.begin(); it != this->_mapFunctions.end(); ++it) { if (it->first->Equals(*type)) return (it->second); } return (this->_end); } template <typename T> const FunctionPair<T>& FunctionList<T>::Get(const Type &type) const { for (typename std::map<Type *, FunctionPair<T> >::const_iterator it = this->_mapFunctions.begin(); it != this->_mapFunctions.end(); ++it) { if (it->first->Equals(type)) { return (it->second); } } return (this->_end); } template <typename T> const FunctionPair<T>& FunctionList<T>::Get(const std::string &name) const { for (typename std::map<Type *, FunctionPair<T> >::const_iterator it = this->_mapFunctions.begin(); it != this->_mapFunctions.end(); ++it) { if (it->first->GetName() == name) return (it->second); } return (this->_end); } template <typename T> const FunctionPair<T>& FunctionList<T>::Get(unsigned int i) const { for (typename std::map<Type *, FunctionPair<T> >::const_iterator it = this->_mapFunctions.begin(); it != this->_mapFunctions.end(); ++it, --i) { if (i == 0) return (it->second); } return (this->_end); } template <typename T> int FunctionList<T>::GetNbBytesWrite() const { return ((int)*this->_nbBytesWriteAdr); } template <typename T> int FunctionList<T>::GetNbBytesRead() const { return ((int)*this->_nbBytesReadAdr); } template class FunctionList<int (*)(char **, ...)>; template class FunctionList<int (*)(int, ...)>; template class FunctionPair<int (*)(char **, ...)>; template class FunctionPair<int (*)(int, ...)>;
[ "sebastien.deveza@39133846-08c2-f29e-502e-0a4191c0ae44" ]
[ [ [ 1, 193 ] ] ]
095c7977b63d87a66141763047eadeedb8829d35
eaa64a4b73fe76125d34177c33e1aadedfaf4e46
/src/SampleConsumerImplFactory.hpp
d69acb1f7a26306bcc244280de960d6a4ca14157
[ "Apache-2.0" ]
permissive
brianfcoleman/libvideocapture
1d856f3f8658a7d834fad5d094927783092897bc
3357c0d31603c94890960676a38253275a52c1b3
refs/heads/master
2020-04-28T01:55:24.483921
2010-10-10T20:23:32
2010-10-10T20:23:32
35,434,467
0
1
null
null
null
null
UTF-8
C++
false
false
1,295
hpp
#ifndef VIDEO_CAPTURE_SAMPLE_CONSUMER_IMPL_FACTORY_H #define VIDEO_CAPTURE_SAMPLE_CONSUMER_IMPL_FACTORY_H #include "SampleConsumerImpl.hpp" namespace VideoCapture { template<typename Sample> class SampleConsumerImplFactory { public: typedef Sample SampleType; typedef SampleType& SampleRef; typedef SampleConsumerImpl<SampleType> SampleConsumerImplType; typedef typename SampleConsumerImplType::SampleConsumerCallback SampleConsumerCallback; typedef typename SampleConsumerImplType::SampleSinkType SampleSinkType; typedef SampleConsumerImplType ProcessorType; SampleConsumerImplFactory( const SampleSinkType& sampleSink, const SampleConsumerCallback& sampleConsumerCallback) : m_sampleSink(sampleSink), m_sampleConsumerCallback(sampleConsumerCallback) { } SampleConsumerImplType createSampleConsumer() const { SampleConsumerImplType sampleConsumer( m_sampleSink, m_sampleConsumerCallback); return sampleConsumer; } SampleConsumerImplType operator()() const { return createSampleConsumer(); } private: SampleSinkType m_sampleSink; SampleConsumerCallback m_sampleConsumerCallback; }; } // VideoCapture #endif // VIDEO_CAPTURE_SAMPLE_CONSUMER_IMPL_FACTORY_H
[ [ [ 1, 44 ] ] ]
6310cd2670fe9ac00ee82b95ebac09f3f679b52d
b822313f0e48cf146b4ebc6e4548b9ad9da9a78e
/KylinSdk/Client/Source/CollapsarFactor.cpp
8d602683b0f9151c91ce23c40b25bc22f9f03c6a
[]
no_license
dzw/kylin001v
5cca7318301931bbb9ede9a06a24a6adfe5a8d48
6cec2ed2e44cea42957301ec5013d264be03ea3e
refs/heads/master
2021-01-10T12:27:26.074650
2011-05-30T07:11:36
2011-05-30T07:11:36
46,501,473
0
0
null
null
null
null
UTF-8
C++
false
false
837
cpp
#include "cltpch.h" #include "CollapsarFactor.h" #include "ClRegisterClass.h" namespace Kylin { BtImplementRTTI(CollapsarFactor, Factor, id_collapsar_factor); Implement_Event_Handler(CollapsarFactor, Factor) { {NULL, NULL} }; CollapsarFactor::CollapsarFactor() { } KBOOL CollapsarFactor::Init( const PropertySet& kProp ) { if (!Factor::Init(kProp)) return false; return true; } KVOID CollapsarFactor::Tick( KFLOAT fElapsed ) { Factor::Tick(fElapsed); } KVOID CollapsarFactor::BindEffect( PropertySet kProp ) { } KVOID CollapsarFactor::PostSpawn() { Factor::PostSpawn(); } KVOID CollapsarFactor::PostDestroy() { Factor::PostDestroy(); } KVOID CollapsarFactor::EndTime( KCSTR& sClass,KCSTR& sName, KANY aUserData ) { } }
[ [ [ 1, 58 ] ] ]
d32bdf01aa341ab6f74e99604acca4443b567b11
0f8559dad8e89d112362f9770a4551149d4e738f
/Wall_Destruction/Helpers/MathHelper.h
4bab40b964c10245e481f0842e0b85485c9a9063
[]
no_license
TheProjecter/olafurabertaymsc
9360ad4c988d921e55b8cef9b8dcf1959e92d814
456d4d87699342c5459534a7992f04669e75d2e1
refs/heads/master
2021-01-10T15:15:49.289873
2010-09-20T12:58:48
2010-09-20T12:58:48
45,933,002
0
0
null
null
null
null
UTF-8
C++
false
false
2,946
h
#ifndef MATH_HELPER_H #define MATH_HELPER_H #include <D3DX10.h> #include "Structs.h" class MathHelper { public: static D3DXVECTOR3 Perpendicular(D3DXVECTOR3 v); static D3DXVECTOR3 Dimensions(D3DXVECTOR3 p1, D3DXVECTOR3 p2, D3DXVECTOR3 p3, D3DXVECTOR3 p4); static int Round(float x); static D3DXVECTOR3 GetElongatedMajorClipPlane(D3DXVECTOR3 originalClipPlane); static D3DXVECTOR3 GetElongatedMinorClipPlane(D3DXVECTOR3 originalClipPlane); static int Sign(float x); static bool D3DXVECTOR3Equals(D3DXVECTOR3 vec, float x, float y, float z); /*static bool Facing(D3DXVECTOR3 p1, D3DXVECTOR3 p2, D3DXVECTOR3 n2); static bool Facing(D3DXVECTOR3 n1, D3DXVECTOR3 n2); */ static bool Facing(D3DXVECTOR3 v1, D3DXVECTOR3 v2, D3DXVECTOR3 n2); static short HalfSpaceTest(const D3DXVECTOR3& vecTestPoint, const D3DXVECTOR3& vecNormal, const D3DXVECTOR3& vecPointOnPlane); static bool SameDirection(D3DXVECTOR3 n1, D3DXVECTOR3 n2); static float GetAngleBetweenVectors(D3DXVECTOR3 v1, D3DXVECTOR3 v2, bool betweenPiAndMinusPi); static float GetPlaneAngle(D3DXVECTOR3 planeNormal, D3DXVECTOR3 planeCentre, D3DXVECTOR3 referenceVector, D3DXVECTOR3 v); static float GetAngleBetweenVectors( D3DXVECTOR3 v1, D3DXVECTOR3 v2, D3DXVECTOR3 planeNormal ); static float Get3DAngle(ProjectStructs::SURFEL* surfel, D3DXVECTOR3 point, D3DXVECTOR3 zeroAnglePoint); static D3DXVECTOR3 ProjectVectorToPlane(D3DXVECTOR3 planeNormal, D3DXVECTOR3 planeCentre, D3DXVECTOR3 v); //static D3DXVECTOR3 GetYawPitchRoll(D3DXVECTOR3 p1, D3DXVECTOR3 p2); static float Get3DAngleBetween3Points(D3DXVECTOR3 centre, D3DXVECTOR3 p1, D3DXVECTOR3 p2); static void DisplaceSurfel(ProjectStructs::SURFEL* surfel, D3DXVECTOR3 surfacePos); static bool isCounterClockwise(D3DXVECTOR3 p0, D3DXVECTOR3 p1, D3DXVECTOR3 p2); static float GetOverlapPercentage(ProjectStructs::SURFEL* surfel1, ProjectStructs::SURFEL* surfel2); static bool Intersection(ProjectStructs::SURFEL* surfel1, ProjectStructs::SURFEL* surfel2); static bool Intersection(ProjectStructs::SURFEL* surfel1, ProjectStructs::SURFEL* surfel2, float percentage); // method taken from http://www.johndcook.com/IEEE_exceptions_in_cpp.html static bool IsFiniteNumber(float x){ return (x <= FLT_MAX && x >= -FLT_MAX); } static D3DXMATRIX GetIdentity(){ if(I._11 == 0.0f) D3DXMatrixIdentity(&I); return I; } static D3DXMATRIX Get3x3Identity(){ if(I3BY3._11 == 0.0f){ D3DXMatrixIdentity(&I3BY3); I3BY3._44 = 0.0f; } return I3BY3; } static D3DXVECTOR3 GetZeroVector(){ return zero; } static D3DXVECTOR3 GetClipPlane( D3DXVECTOR3 clipPlane1, D3DXVECTOR3 clipPlane2 ); static bool IsCorner(D3DXVECTOR3 clipPlane); private: static D3DXVECTOR3 temp; static D3DXVECTOR3 temp1; static D3DXVECTOR3 temp2; static D3DXVECTOR3 temp3; static D3DXMATRIX I, I3BY3; static D3DXVECTOR3 zero; }; #endif
[ [ [ 1, 76 ] ] ]
187b0ae4906f4efc5e1bd6928df4f80ec1d15813
7b32ec66568e9afc4bea9ffec8f54b9646958890
/ mariogame/source code/win 32 api/MarioGame/MonsterOld.cpp
6ce3e8741fba4164ff7369d72fc0f286b96d0399
[]
no_license
Dr-Hydrolics/mariogame
47056e4247bcad6da75d0ab8954cda144ee4e499
8611287742690dd1dd51a865202a73535cefbec4
refs/heads/master
2016-08-13T00:17:40.387527
2010-05-13T13:02:24
2010-05-13T13:02:24
43,435,945
0
0
null
null
null
null
UTF-8
C++
false
false
22,956
cpp
#include "StdAfx.h" #include "Monster.h" #include "ObjectManager.h" #include "GTimer.h" CMonster1::CMonster1(int x, int y, int w, int h, LPCTSTR bmSrpiteName,int fd,float sp) { mDirection = fd; mType = TMONSTER; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mCurFrame = 0; mCurDelay = 0; mDelayCount = 3; mFrameCount = 3; mJumpDirect=0; mJump=1; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSrpiteName); mXMove = 1; mYMove = 8; mSpeed =sp; oldmove = CGTimer::Time(); mHealth = 1; mStart = 0; } int CMonster1::DoAction(/*CScreen* scr, */IObjectManager* objMan) //di dung chuong ngai vat thi quay lai , di xuong bac thang,xuong ho. { if(mHealth<=0) return -1; int moveX=0; if(abs(mXPos - objMan->GetMarioPos().x) < 500 ) mStart = 1; if(mStart == 1) { int i = CheckCollision(objMan); if(i == -1) return -1; // Roi xuong vuc sau if (GetBit(i,3)!=1 ) { mYPos=mYPos+mYMove; moveX=0; } else { moveX = (CGTimer::Time()-oldmove)*mSpeed; oldmove=CGTimer::Time(); moveX=mXMove; } if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1) { mAnimation->FlipFrame(); mDirection = DIRLEFT; mXPos=mXPos-moveX; } else { mXPos=mXPos+moveX; } } if(mDirection==DIRLEFT) { if (GetBit(i,1)==1) // bi can ben trai { mAnimation->FlipFrame(); mDirection = DIRRIGHT; mXPos=mXPos+moveX; } else { mXPos=mXPos-moveX; if(mXPos<0) { mXPos=0; mDirection=DIRRIGHT; mAnimation->FlipFrame(); } } } } NextFrame(); /*if(mXPos%80==0 && moveX!=0) { IMonster* obj = NULL; obj = new CMonsterClub(this->mXPos,this->mYPos+5,26,23,_T("axe.bmp"), this->Direction(), 0.1); objMan->AddMonster(obj); }*/ return 1; } CMonster2::CMonster2(int x, int y, int w, int h, LPCTSTR bmSrpiteName,int fd,float sp)//nhay theo qui dao , di gap chuong ngao vat quay { mDirection=fd; mType = TMONSTER; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mCurFrame = 0; mCurDelay = 0; mDelayCount = 4; mFrameCount = 3; mJumpDirect=1; mJump=1; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSrpiteName); mXMove = 1; mYMove = 5; mXpos1=mXPos; mYpos1=mYPos; mSpeed = sp; oldmove=CGTimer::Time(); mHealth = 1; } int CMonster2::DoAction(/*CScreen* scr, */IObjectManager* objMan) //nhay theo qui dao ,gap chuong ngai vat trai phai de quay lai ,duong chuong ngai vat tren thi co lai//lao xuong ho { if(mHealth<=0) return -1; int moveX = (CGTimer::Time()-oldmove)*mSpeed; oldmove=CGTimer::Time(); mYMove=2*moveX; int moveY=0; if(abs(mXPos - objMan->GetMarioPos().x) < 500) { int i= CheckCollision(objMan); if(i == -1) return -1; // Roi xuong vuc sau if(mJumpDirect==1 ) { if(mYpos1-mYPos>=100||GetBit(i,2)==1) { mJumpDirect=0; } else mYPos=mYPos -mYMove; } else { if( GetBit(i,3)==1) { mJumpDirect=1; mYpos1=mYPos; mXpos1=mXPos; } else mYPos=mYPos + mYMove; } if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1) { mAnimation->FlipFrame(); mDirection = DIRLEFT; mXPos=mXPos-moveX; } else { mXPos=mXPos+moveX; } } if(mDirection==DIRLEFT) { if (GetBit(i,1)==1) // bi can ben trai { mAnimation->FlipFrame(); mDirection = DIRRIGHT; mXPos=mXPos+moveX; } else { mXPos=mXPos-moveX; if(mXPos<0) { mXPos=0; mDirection=DIRRIGHT; mAnimation->FlipFrame(); } } } } NextFrame(); return 1; } CMonster8::CMonster8(int x, int y, int w, int h, LPCTSTR bmSpriteName,int fd,float sp)//nhay theo qui dao , di gap chuong ngao vat quay { mDirection=fd; mType = TMONSTER; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mCurFrame = 0; mCurDelay = 0; mDelayCount = 3; mFrameCount = 3; mJumpDirect=1; mJump=1; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSpriteName); mXMove = 1; mYMove = 5; mXpos1=mXPos; mYpos1=mYPos; mSpeed = sp; oldmove=CGTimer::Time(); mHealth = 1; } int CMonster8::DoAction(/*CScreen* scr, */IObjectManager* objMan) //nhay theo qui dao ,gap chuong ngai vat trai phai de quay lai ,duong chuong ngai vat tren thi co lai , chay tren 1 khoang xac dinh //dat tren cac thanh gach , co khoang di chuyen bang do dai thanh. { if(mHealth<=0) return -1; int moveX = (CGTimer::Time()-oldmove)*mSpeed; oldmove=CGTimer::Time(); mYMove=2*moveX; int moveY=0; if(abs(mXPos - objMan->GetMarioPos().x) < 500) { int i= CheckCollision(objMan); if(i == -1) return -1; // Roi xuong vuc sau if(mJumpDirect==1 ) { if(mYpos1-mYPos>=100||GetBit(i,2)==1) { mJumpDirect=0; } else mYPos=mYPos -mYMove; } else { if( GetBit(i,3)==1) { mJumpDirect=1; mYpos1=mYPos; mXpos1=mXPos; } else mYPos=mYPos + mYMove; } if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1||abs(mXPos-mXpos1)>=100) { mAnimation->FlipFrame(); mDirection = DIRLEFT; mXPos=mXPos-moveX; } else { mXPos=mXPos+moveX; } } if(mDirection==DIRLEFT) { if (GetBit(i,1)==1||abs(mXPos-mXpos1)>=100) // bi can ben trai { mAnimation->FlipFrame(); mDirection = DIRRIGHT; mXPos=mXPos+moveX; } else { mXPos=mXPos-moveX; if(mXPos<0) { mXPos=0; mDirection=DIRRIGHT; mAnimation->FlipFrame(); } } } } NextFrame(); return 1; } CMonster3::CMonster3(int x, int y, int w, int h, LPCTSTR bmSrpiteName,int fd,float sp) { mDirection=fd; mType = TMONSTER; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mCurFrame = 0; mCurDelay = 0; mDelayCount = 2; mFrameCount = 3; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSrpiteName); mXMove = 5; mYMove = 1; mJumpDirect=0; mJump=1; mSpeed=sp; oldmove=CGTimer::Time(); mHealth = 1; mStart = 1; } int CMonster3::DoAction(/*CScreen* scr, */IObjectManager* objMan) // di dung chuong ngai vat trai ,phai quay lai , khi gap ho hay bac thang thi quay lai(phai xd chinh xac vi tri dung) { if(mHealth<=0) return -1; mXMove = (CGTimer::Time()-oldmove)*mSpeed; oldmove=CGTimer::Time(); int i = CheckCollision(objMan); if(i == -1) return -1; // Roi xuong vuc sau if(GetBit(i,3)!=1) { if(mDirection==DIRLEFT) { mDirection=DIRRIGHT; mAnimation->FlipFrame(); mXPos=mXPos+mXMove + 3; } else { mDirection=DIRLEFT; mAnimation->FlipFrame(); mXPos=mXPos-mXMove ; } int k = CheckCollision(objMan); if(GetBit(k,3)!=1) return -1; } if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1) { mAnimation->FlipFrame(); mDirection = DIRLEFT; mXPos=mXPos-mXMove-3 ; } else { mXPos=mXPos+mXMove; } } else//(mDirection==DIRLEFT) { if (GetBit(i,1)==1) // bi can ben trai { mAnimation->FlipFrame(); mDirection = DIRRIGHT; mXPos=mXPos+mXMove +3; } else { mXPos=mXPos-mXMove; if(mXPos<0) { mXPos=0; mDirection=DIRRIGHT; mAnimation->FlipFrame(); } } } NextFrame(); return 1; } CMonster4::CMonster4(int x, int y, int w, int h, LPCTSTR bmSrpiteName,int fd,float sp) // di leo chuong ngai vat , xuong doc, dung chuong ngai vat cao thi quay lai { mType = TMONSTER; mFamily = FANIMATEMOVABLE; mDirection = fd; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mCurFrame = 0; mCurDelay = 0; mDelayCount = 4; mFrameCount = 3; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSrpiteName); mXMove = 1; mYMove = 1; mJumpDirect=0; mJump=1; mSpeed=sp; oldmove=CGTimer::Time(); mHealth = 1; } int CMonster4::DoAction(/*CScreen* scr, */IObjectManager* objMan) { if(mHealth<=0) return -1; int moveX=0; if(abs(mXPos - objMan->GetMarioPos().x) < 500) { int i = CheckCollision(objMan); if (GetBit(i,3)!=1&& GetBit(i,0)!=1&&GetBit(i,1)!=1) { mYPos=mYPos+mYMove; moveX=0; } else { moveX = (CGTimer::Time()-oldmove)*mSpeed; } if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1) { mYPos=mYPos - 50; if(GetBit(CheckCollision(objMan),0)==1) { mAnimation->FlipFrame(); mDirection = DIRLEFT; mXPos=mXPos-mXMove; mYPos=mYPos + 50; } else { mYPos=mYPos+50; mYPos=mYPos -mYMove; mXPos=mXPos+3; int k = CheckCollision(objMan); if( GetBit(k,1)==1 ) mXPos=mXPos-3; } } else { mXPos=mXPos+moveX; } } if(mDirection==DIRLEFT) { if(GetBit(i,1)==1) { mYPos=mYPos - 50 ; if(GetBit(CheckCollision(objMan),1)==1) { mAnimation->FlipFrame(); mDirection = DIRRIGHT; mXPos=mXPos+mXMove; mYPos=mYPos + 50; } else { mYPos=mYPos+50; mYPos=mYPos -mYMove; mXPos=mXPos-3; int k = CheckCollision(objMan); if( GetBit(k,0)==1 ) mXPos=mXPos+3; } } else { mXPos=mXPos-moveX; if(mXPos<0) { mXPos=0; mDirection=DIRRIGHT; mAnimation->FlipFrame(); } } } } oldmove=CGTimer::Time(); NextFrame(); return 1; } CMonster5::CMonster5(int x, int y, int w, int h, LPCTSTR bmSrpiteName,int fd,float sp) { mDirection = fd; mType = TMONSTER; mFamily = FANIMATEMOVABLE; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mCurFrame = 0; mCurDelay = 0; mDelayCount = 4; mFrameCount = 3; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSrpiteName); // mLastMoveTime = timeGetTime(); // mSpeed = 24; mXMove = 1; mYMove = 1; mJumpDirect=1; mJump=1; mSpeed=sp; oldmove=CGTimer::Time(); mXpos1=x; mYpos1=y; mHealth = 1; } int CMonster5::DoAction(/*CScreen* scr, */IObjectManager* objMan) // bay lo lung theo qui dao tai vi tri y ban dau , neu dung chuong ngai vat thi quay lai , neu vuot qua khoang 50 thi quay lai { if(mHealth<=0) return -1; mXMove = (CGTimer::Time()-oldmove)*mSpeed; oldmove=CGTimer::Time(); mYMove=mXMove; int i = CheckCollision(objMan); { if(mJumpDirect==1 ) { if(mYpos1-mYPos>=50||GetBit(i,2)==1) { mJumpDirect=0; } else mYPos=mYPos -mYMove; } else { if(mYpos1-mYPos<=3) { mJumpDirect=1; } else mYPos=mYPos + mYMove; } if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1||abs(mXPos-mXpos1)>150) { mAnimation->FlipFrame(); mDirection = DIRLEFT; mXPos=mXPos-mXMove -3; } else { mXPos=mXPos+mXMove; } } else//(mDirection==DIRLEFT) { if (GetBit(i,1)==1||abs(mXPos-mXpos1)>150) // bi can ben trai { mAnimation->FlipFrame(); mDirection = DIRRIGHT; mXPos=mXPos+mXMove+3; } else { mXPos=mXPos-mXMove; if(mXPos<0) { mXPos=0; mDirection=DIRRIGHT; mAnimation->FlipFrame(); } } } } NextFrame(); return 1; } CMonster6::CMonster6(int x, int y, int w, int h, LPCTSTR bmSrpiteName,int fd,float sp) { mDirection = fd; mType = TMONSTER; mFamily = FANIMATEMOVABLE; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mCurFrame = 0; mCurDelay = 0; mDelayCount = 4; mFrameCount = 3; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSrpiteName); // mLastMoveTime = timeGetTime(); // mSpeed = 24; mXMove = 1; mYMove = 1; mJumpDirect=1; mJump=1; mSpeed=sp; oldmove=CGTimer::Time(); mXpos1=x; mYpos1=y; mHealth = 1; } int CMonster6::DoAction(/*CScreen* scr, */IObjectManager* objMan) // bay lo lung theo qui dao tai vi tri y ban dau , neu dung chuong ngai vat thi quay lai { if(mHealth<=0) return -1; mXMove = (CGTimer::Time()-oldmove)*mSpeed; oldmove=CGTimer::Time(); mYMove=mXMove; int i = CheckCollision(objMan); if(abs(mXPos - objMan->GetMarioPos().x) < 500) { if(mJumpDirect==1 ) { if(mYpos1-mYPos>=50||GetBit(i,2)==1) { mJumpDirect=0; } else mYPos=mYPos -mYMove; } else { if(mYpos1-mYPos<=3) { mJumpDirect=1; } else mYPos=mYPos + mYMove; } if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1) { mAnimation->FlipFrame(); mDirection = DIRLEFT; mXPos=mXPos-mXMove; } else { mXPos=mXPos+mXMove; } } if(mDirection==DIRLEFT) { if (GetBit(i,1)==1) // bi can ben trai { mAnimation->FlipFrame(); mDirection = DIRRIGHT; mXPos=mXPos+mXMove; } else { mXPos=mXPos-mXMove; if(mXPos<0) { mXPos=0; mDirection=DIRRIGHT; mAnimation->FlipFrame(); } } } } NextFrame(); return 1; } CMonster7::CMonster7(int x, int y, int w, int h, LPCTSTR bmSrpiteName,int fd,float sp) { mDirection = fd; mType = TMONSTER; mFamily = FANIMATEMOVABLE; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mCurFrame = 0; mCurDelay = 0; mDelayCount = 4; mFrameCount = 3; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSrpiteName); // mLastMoveTime = timeGetTime(); // mSpeed = 24; mXMove = 1; mYMove = 1; mJumpDirect=1; mJump=1; mSpeed=sp; oldmove=CGTimer::Time(); mXpos1=x; mYpos1=y; mHealth = 1; } int CMonster7::DoAction(/*CScreen* scr, */IObjectManager* objMan) // bay lo lung theo hinh quat quanh vi tri y ban dau , neu dung chuong ngai vat thi quay lai , chieu dai quat co dinh { if(mHealth<=0) return -1; mXMove = (CGTimer::Time()-oldmove)*mSpeed; oldmove=CGTimer::Time(); mYMove=mXMove*mXMove/8;; int i = CheckCollision(objMan); if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1||abs(mXPos -mXpos1) >=250) { mAnimation->FlipFrame(); mDirection = DIRLEFT; mXPos=mXPos-mXMove-3; } else { mXPos=mXPos + mXMove; if(mXPos -mXpos1 >=0) { mYPos =mYPos - mYMove ; } else { mYPos =mYPos +mYMove ; } } } if(mDirection==DIRLEFT) { if (GetBit(i,1)==1||abs(mXPos-mXpos1)>=250) // bi can ben trai { mAnimation->FlipFrame(); mDirection = DIRRIGHT; mXPos=mXPos+mXMove+3; } else { mXPos=mXPos -mXMove; if(mXPos -mXpos1 >=0) { mYPos =mYPos + mYMove ; } else { mYPos =mYPos - mYMove ; } if(mXPos<0) { mXPos=0; mDirection=DIRRIGHT; mAnimation->FlipFrame(); } } } NextFrame(); return 1; } CMonsterClubB1::CMonsterClubB1(int x, int y, int w, int h, LPCTSTR bmSrpiteName,int fd,int jd,float sp) { mSpeed=sp; oldmove=CGTimer::Time(); mDirection = fd; mType = TMONSTERCLUB; mFamily = FANIMATEMOVABLE; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mXMove = 1; mYMove = 1; mCurFrame = 0; mCurDelay = 0; mDelayCount = 4; mFrameCount = 3; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSrpiteName); // mLastMoveTime = timeGetTime(); // mSpeed = 24; mJumpDirect=jd; mJump=1; } int CMonsterClubB1::DoAction(/*CScreen* scr, */IObjectManager* objMan) { mYMove= (CGTimer::Time()-oldmove)*mSpeed; oldmove=CGTimer::Time(); int i = CheckCollision(objMan); if(mJumpDirect==1) { if (GetBit(i,2)==1) { mJumpDirect=0; } else mYPos=mYPos-mYMove; } if(mJumpDirect==0) { if (GetBit(i,3)==1) { return -1; } else mYPos=mYPos+mYMove; } NextFrame(); return 1; } CMonsterB1::CMonsterB1(int x, int y, int w, int h, LPCTSTR bmSrpiteName, int fd,float sp) { mDirection = fd; mType = TMONSTER; mFamily = FANIMATEMOVABLE; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mXMove = 1; mYMove = 1; mCurFrame = 0; mCurDelay = 0; mDelayCount = 4; mFrameCount = 3; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSrpiteName); // mLastMoveTime = timeGetTime(); // mSpeed = 24; mJumpDirect=0; mJump=1; mSpeed=sp; oldmove=CGTimer::Time(); mHealth = 10; } int CMonsterB1::DoAction(/*CScreen* scr, */IObjectManager* objMan) { if(mHealth<=0) return -1; mXMove = (CGTimer::Time()-oldmove)*mSpeed; oldmove=CGTimer::Time(); if(abs(mXPos - objMan->GetMarioPos().x) < 500 ) { int i = CheckCollision(objMan); if(GetBit(i,3)!=1) { if(mDirection==DIRLEFT) { mDirection=DIRRIGHT; mAnimation->FlipFrame(); mXPos=mXPos+mXMove +5; } else { mDirection=DIRLEFT; mAnimation->FlipFrame(); mXPos=mXPos-mXMove-5; } } if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1) { mAnimation->FlipFrame(); mDirection = DIRLEFT; mXPos=mXPos-mXMove; } else mXPos=mXPos+mXMove; } if(mDirection==DIRLEFT) { if (GetBit(i,1)==1) // bi can ben trai { mAnimation->FlipFrame(); mDirection = DIRRIGHT; mXPos=mXPos+mXMove; } else { mXPos=mXPos-mXMove; if(mXPos<0) { mXPos=0; mDirection=DIRRIGHT; mAnimation->FlipFrame(); } } } if(mXPos%50==0) { IMonster* obj = NULL; obj = new CMonsterClub(mXPos,mYPos,24,32,_T("Monster04.bmp"),mDirection,1); objMan->AddMonster(obj); } if( mXPos%50==0) { IMonster* obj = NULL; obj = new CMonsterClubB1(mXPos,mYPos +3 ,24,32,_T("Monster04.bmp"),1,1,1); objMan->AddMonster(obj); } } NextFrame(); return 1; } CMonsterB2::CMonsterB2(int x, int y, int w, int h, LPCTSTR bmSrpiteName,int fd,float sp) { mSpeed=sp; oldmove=CGTimer::Time(); mDirection = fd; mType = TMONSTER; mFamily = FANIMATEMOVABLE; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mXMove = 1; mYMove = 1; mCurFrame = 0; mCurDelay = 0; mDelayCount = 4; mFrameCount = 3; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSrpiteName); mJumpDirect=0; mJump=1; mHealth = 10; } int CMonsterB2::DoAction(IObjectManager* objMan) { if(mHealth<=0) return -1; mXMove = (CGTimer::Time()-oldmove)*mSpeed; oldmove=CGTimer::Time(); if(abs(mXPos - objMan->GetMarioPos().x) < 500) { int i = CheckCollision(objMan); if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1) { mAnimation->FlipFrame(); mDirection = DIRLEFT; mXPos=mXPos-mXMove; } else mXPos=mXPos+mXMove; } if(mDirection==DIRLEFT) { if (GetBit(i,1)==1) // bi can ben trai { mAnimation->FlipFrame(); mDirection = DIRRIGHT; mXPos=mXPos+mXMove; } else { mXPos=mXPos-mXMove; if(mXPos<0) { mXPos=0; mDirection=DIRRIGHT; mAnimation->FlipFrame(); } } } if( mXPos % 30 ==0 ) { IMonster* obj = NULL; obj = new CMonsterClubB1(mXPos,mYPos +3 ,25,25,_T("club.bmp"),1,0,0.5); objMan->AddMonster(obj); } } NextFrame(); return 1; } CMonsterB3::CMonsterB3(int x, int y, int w, int h, LPCTSTR bmSrpiteName,int fd,float sp)//nhay theo qui dao , di gap chuong ngao vat quay { mSpeed=sp; oldmove=CGTimer::Time(); mDirection=fd; mType = TMONSTER; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mCurFrame = 0; mCurDelay = 0; mDelayCount = 4; mFrameCount = 3; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, mFrameCount, mDelayCount, bmSrpiteName); mXMove = 1; mYMove = 5; mJumpDirect=1; mJump=1; mXpos1=mXPos; mYpos1=mYPos; mHealth = 20; } int CMonsterB3::DoAction(/*CScreen* scr, */IObjectManager* objMan)//nhay theo qui dao ,gap chuong ngai vat trai phai de quay lai ,duong chuong ngai vat tren thi co lai { if(mHealth<=0) return -1; mXMove = (CGTimer::Time()-oldmove)*mSpeed; oldmove=CGTimer::Time(); int moveX=mXMove; mYMove = 1.5*mXMove; int flag=0; if(abs(mXPos - objMan->GetMarioPos().x) < 500) { int i= CheckCollision(objMan); if(i == -1) return -1; // Roi xuong vuc sau if(mJumpDirect==1 ) { if(mYpos1-mYPos>=200||GetBit(i,2)==1) { mJumpDirect=0; } else mYPos=mYPos -mYMove; } else { if( GetBit(i,3)==1) { flag=1; mJumpDirect=1; mYpos1=mYPos; mXpos1=mXPos; } else mYPos=mYPos + mYMove; } if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1) { mAnimation->FlipFrame(); mDirection = DIRLEFT; mXPos=mXPos-moveX; } else { mXPos=mXPos+moveX; } } if(mDirection==DIRLEFT) { if (GetBit(i,1)==1) // bi can ben trai { mAnimation->FlipFrame(); mDirection = DIRRIGHT; mXPos=mXPos+moveX; } else { mXPos=mXPos-moveX; if(mXPos<0) { mXPos=0; mDirection=DIRRIGHT; mAnimation->FlipFrame(); } } } } NextFrame(); if(flag==1 ) { IMonster* obj = NULL; obj = new CMonsterClub(mXPos,mYPos,25,25,_T("club.bmp"),mDirection,0.1); objMan->AddMonster(obj); } if(flag==0&&mXPos%30==0) { IMonster* obj = NULL; obj = new CMonsterClubB1(mXPos,mYPos +3 ,25,25,_T("club.bmp"),1,0,0.1); objMan->AddMonster(obj); } return 1; } CMonsterClub::CMonsterClub(int x, int y, int w, int h, LPCTSTR bmSrpiteName,int fd, float sp) { mFamily = FANIMATEMOVABLE; mType = TMONSTERCLUB; mDirection = fd; mXPos = x; mYPos = y; mWidth = w; mHeight = h; mAnimation = new Sprite(mXPos, mYPos, mWidth, mHeight, 1, 3, 6, bmSrpiteName); if(fd == DIRLEFT) mAnimation->FlipFrame(); mXMove = 5; mYMove = 1; mCurFrame = 0; mCurDelay = 0; mDelayCount = 3; mFrameCount = 3; mXPos1=x; mYPos1=y; mSpeed = sp; oldmove=CGTimer::Time(); } int CMonsterClub::DoAction(/*CScreen* scr, */IObjectManager* objMan) { mXMove = (CGTimer::Time()-oldmove)*mSpeed; oldmove=CGTimer::Time(); int i = CheckCollision(objMan); if(mDirection==DIRRIGHT) { if(GetBit(i,0)==1) { return -1; } else if(abs(mXPos-mXPos1)>=400 ) { return -1; } else { mXPos=mXPos+mXMove; } } if(mDirection==DIRLEFT) { if (GetBit(i,1)==1) // bi can ben trai { return -1; } else { if(abs(mXPos-mXPos1)>=400 ) { return -1; } else mXPos=mXPos-mXMove; } } NextFrame(); return 1; }
[ "moonlight2708@0b8e3906-489a-11de-8001-7f2440edb24e" ]
[ [ [ 1, 1194 ] ] ]
abc6d541cf42842eb4cee0371c5268aaa720038c
0b66a94448cb545504692eafa3a32f435cdf92fa
/tags/0.3/cbear.berlios.de/windows/com/implementation.hpp
cdde751e5bd0b89d5018ecd938fb7d5d1e84f669
[ "MIT" ]
permissive
BackupTheBerlios/cbear-svn
e6629dfa5175776fbc41510e2f46ff4ff4280f08
0109296039b505d71dc215a0b256f73b1a60b3af
refs/heads/master
2021-03-12T22:51:43.491728
2007-09-28T01:13:48
2007-09-28T01:13:48
40,608,034
0
0
null
null
null
null
UTF-8
C++
false
false
12,091
hpp
/* The MIT License Copyright (c) 2005 C Bear (http://cbear.berlios.de) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef CBEAR_BERLIOS_DE_WINDOWS_COM_IMPLEMENTATION_HPP_INCLUDED #define CBEAR_BERLIOS_DE_WINDOWS_COM_IMPLEMENTATION_HPP_INCLUDED // std::map #include <map> // boost::mutex #include <boost/thread/mutex.hpp> // boost::condition #include <boost/thread/condition.hpp> #include <cbear.berlios.de/atomic/main.hpp> #include <cbear.berlios.de/windows/com/hresult.hpp> #include <cbear.berlios.de/windows/com/object.hpp> #include <cbear.berlios.de/windows/com/uint.hpp> #include <cbear.berlios.de/windows/com/lcid.hpp> #include <cbear.berlios.de/windows/com/itypelib.hpp> #include <cbear.berlios.de/range/sub_range.hpp> #include <cbear.berlios.de/intrusive/list.hpp> namespace cbear_berlios_de { namespace windows { namespace com { class group; namespace detail { class implementation_counter; class basic_interface_info: public intrusive::node<basic_interface_info> { public: virtual const com::uuid &get_uuid() = 0; virtual iunknown::internal_type get_pointer() = 0; }; template<class Interface> class interface_info: public basic_interface_info { public: virtual const com::uuid &get_uuid() { return uuid::of<Interface>(); } interface_info() {} private: // Against VC warnings. interface_info(const interface_info &); interface_info operator=(const interface_info &); }; class implementation_info { protected: implementation_info(): Group(0) {} template<class Interface> void add_interface(interface_info<Interface> *P) { this->List.push_back(*P); } typedef intrusive::list<basic_interface_info> list_type; hresult::internal_type query_interface( const uuid::internal_type &Uuid, void **PP) { for( range::sub_range<list_type>::type R(this->List); !R.empty(); ++R.begin()) { if(R.front().get_uuid().internal()==Uuid) { iunknown::internal_policy::construct_copy( *reinterpret_cast<iunknown::internal_type *>(PP), R.front().get_pointer()); return hresult::s_ok; } } *PP = 0; return hresult::e_nointerface; } com::group &group() const { return *this->Group; } private: com::group *Group; list_type List; friend class detail::implementation_counter; }; } template<class Base, class Interface, class Parent> class implementation_base: public implementation<Base, Parent>, private detail::interface_info<Interface> { public: implementation_base() { detail::implementation_info::add_interface<Interface>(this); } private: iunknown::internal_type get_pointer() { return static_cast<Interface *>(this); } }; template<class Base, class Interface> class implementation: public implementation_base<Base, Interface, iunknown::interface_type> { }; template<class Base> class implementation<Base, IUnknown>: public implementation_base<Base, IUnknown, detail::implementation_info> { public: implementation() {} private: // Against VC warnings. implementation(const implementation &); implementation &operator=(const implementation &); }; template<class Base> class implementation<Base, detail::implementation_info>: protected virtual detail::implementation_info, public Base { public: implementation() {} private: // Against VC warnings. implementation(const implementation &); implementation &operator=(const implementation &); }; typedef LPOLESTR lpolestr_t; typedef DISPID dispid_t; typedef WORD word_t; typedef DISPPARAMS dispparams_t; typedef VARIANT variant_t; typedef EXCEPINFO excepinfo_t; template<class Base> class implementation<Base, ::IDispatch>: public implementation_base<Base, ::IDispatch, ::IUnknown> { public: implementation() { for( range::sub_range<com::group::typelibs_type>::type R( this->group().typelibs); !R.empty(); ++R.begin()) { try { this->TypeInfo = R.front().GetTypeInfoOfGuid<Base>(); return; } catch(com::exception &) { } } } hresult::internal_type __stdcall GetTypeInfoCount( internal_result<out, uint_t>::type _result) { wrap<out, uint_t>(_result) = 1; return hresult::s_ok; } hresult::internal_type __stdcall GetTypeInfo( uint_t iTInfo, lcid_t, internal_result<out, itypeinfo>::type ppTInfo) { if(iTInfo != 0) return hresult::disp_e_badindex; wrap<out, itypeinfo>(ppTInfo) = this->TypeInfo; return hresult::s_ok; } hresult::internal_type __stdcall GetIDsOfNames( const uuid::internal_type &, lpolestr_t *rgszNames, uint_t cNames, lcid_t, dispid_t *rgDispId) { return ::DispGetIDsOfNames( internal<in>(this->TypeInfo), rgszNames, cNames, rgDispId); } HRESULT __stdcall Invoke( dispid_t dispidMember, const uuid::internal_type &, lcid_t, word_t wFlags, dispparams_t * pdispparams, variant_t * pvarResult, excepinfo_t * pexcepinfo, uint_t * puArgErr) { return DispInvoke( (Base *)this, internal<in>(TypeInfo), dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr); } private: itypeinfo TypeInfo; }; typedef BOOL bool_t; template<class Base> class implementation<Base, ::IClassFactory>: public implementation_base<Base, ::IClassFactory, ::IUnknown> { public: hresult::internal_type __stdcall CreateInstance( internal_result<in, iunknown>::type Outer, const uuid::internal_type &Uuid, void **ppObject) { // Cannot aggregate. if(Outer) return hresult::class_e_noaggregation; return QueryInterface(Uuid, ppObject); } hresult::internal_type __stdcall LockServer(bool_t fLock) { if(fLock!=FALSE) this->AddRef(); else this->Release(); return hresult::s_ok; } }; namespace detail { class implementation_counter; template<class T> class implementation_instance; } class group: boost::noncopyable { public: group() {} ~group() { this->wait(); } void wait() { boost::mutex::scoped_lock Lock(this->ConditionMutex); if(this->Value.read()!=0) this->Condition.wait(Lock); } template<class T> struct new_result { typedef object<detail::implementation_instance<T> > type; }; template<class T> typename new_result<T>::type new_() { return new_result<T>::type(new detail::implementation_instance<T>(*this)); }; template<class T, class P> typename new_result<T>::type new_(const P &X) { return new_result<T>::type(new detail::implementation_instance<T>( *this, X)); } template<class T, class P1, class P2> typename new_result<T>::type new_(const P1 &X1, const P2 &X2) { return new_result<T>::type(new detail::implementation_instance<T>( *this, X1, X2)); } template<class T, class P1, class P2, class P3> typename new_result<T>::type new_(const P1 &X1, const P2 &X2, const P3 &X3) { return new_result<T>::type(new detail::implementation_instance<T>( *this, X1, X2, X3)); } template<class T, class P1, class P2, class P3, class P4> typename new_result<T>::type new_( const P1 &X1, const P2 &X2, const P3 &X3, const P4 &X4) { return new_result<T>::type(new detail::implementation_instance<T>( *this, X1, X2, X3, X4)); } template<class T, class P1, class P2, class P3, class P4, class P5> typename new_result<T>::type new_( const P1 &X1, const P2 &X2, const P3 &X3, const P4 &X4, const P5 &X5) { return new_result<T>::type(new detail::implementation_instance<T>( *this, X1, X2, X3, X4, X5)); } typedef std::vector<itypelib> typelibs_type; typelibs_type typelibs; int size() { return this->Value.read(); } private: void increment() { boost::mutex::scoped_lock Lock(this->ConditionMutex); this->Value.increment(); } void decrement() { boost::mutex::scoped_lock Lock(this->ConditionMutex); if(this->Value.decrement()==0) { this->Condition.notify_one(); } } boost::mutex ConditionMutex; boost::condition Condition; atomic::wrap<int> Value; friend class detail::implementation_counter; itypelib TypeLib; }; template<class Base> class implementation<Base, ::ISupportErrorInfo>: public implementation_base<Base, ::ISupportErrorInfo, ::IUnknown> { public: hresult::internal_type __stdcall InterfaceSupportsErrorInfo(const IID &) { return hresult::s_ok; } implementation() {} private: // Against VC warnings. implementation(const implementation &); implementation &operator=(const implementation &); }; typedef object< ::ISupportErrorInfo> isupporterrorinfo; namespace detail { class implementation_counter: private atomic::wrap<ulong_t>, private virtual implementation_info { protected: typedef atomic::wrap<ulong_t>::internal_type internal_type; implementation_counter(com::group &Group) { this->Group = &Group; this->Group->increment(); } virtual ~implementation_counter() { this->Group->decrement(); } internal_type add_ref() { return this->increment(); } internal_type release() { internal_type Result = this->decrement(); if(!Result) delete this; return Result; } private: implementation_counter(const implementation_counter &); implementation_counter &operator=(const implementation_counter &); }; template<class T> class implementation_instance: private implementation_counter, public T, public isupporterrorinfo::implementation_type { public: // IUnknown ulong_t __stdcall AddRef() { return implementation_counter::add_ref(); } ulong_t __stdcall Release() { return implementation_counter::release(); } hresult::internal_type __stdcall QueryInterface( const uuid::internal_type &U, void **PP) { return implementation_info::query_interface(U, PP); } private: friend class group; implementation_instance(com::group &Group): implementation_counter(Group) {} template<class P> implementation_instance(com::group &Group, const P &X): implementation_counter(Group), T(X) { } template<class P1, class P2> implementation_instance(com::group &Group, const P1 &X1, const P2 &X2): implementation_counter(Group), T(X1, X2) { } template<class P1, class P2, class P3> implementation_instance( com::group &Group, const P1 &X1, const P2 &X2, const P3 &X3): implementation_counter(Group), T(X1, X2, X3) { } template<class P1, class P2, class P3, class P4> implementation_instance( com::group &Group, const P1 &X1, const P2 &X2, const P3 &X3, const P4 &X4): implementation_counter(Group), T(X1, X2, X3, X4) { } template<class P1, class P2, class P3, class P4, class P5> implementation_instance( com::group &Group, const P1 &X1, const P2 &X2, const P3 &X3, const P4 &X4, const P5 &X5): implementation_counter(Group), T(X1, X2, X3, X4, X5) { } }; } } } } #endif
[ "sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838" ]
[ [ [ 1, 504 ] ] ]
b77ff9009da7bf580435c1a505c8d20ed5efc5ea
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/os/mm/icl/T_ImageDecoder/inc/T_ImageDecoderServer.h
18d661fe43fdffffbdc6cb2b6c70b3fc282f8564
[]
no_license
SymbianSource/oss.FCL.sftools.ana.compatanamdw
a6a8abf9ef7ad71021d43b7f2b2076b504d4445e
1169475bbf82ebb763de36686d144336fcf9d93b
refs/heads/master
2020-12-24T12:29:44.646072
2010-11-11T14:03:20
2010-11-11T14:03:20
72,994,432
0
0
null
null
null
null
UTF-8
C++
false
false
1,218
h
/* * Copyright (c) 2007-2008 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: * */ #if (!defined __T_IMAGE_DECODER_SERVER_H__) #define __T_IMAGE_DECODER_SERVER_H__ // EPOC Includes #include <testblockcontroller.h> #include <testserver2.h> class CT_ImageDecoderServer : public CTestServer2 { private: class CT_ImageDecoderBlock : public CTestBlockController { public: inline CT_ImageDecoderBlock(); inline ~CT_ImageDecoderBlock(); inline CDataWrapper* CreateDataL(const TDesC& aData); }; public: inline ~CT_ImageDecoderServer(); inline void DeleteActiveSchedulerL(); static CT_ImageDecoderServer* NewL(); inline CTestBlockController* CreateTestBlock(); protected: inline CT_ImageDecoderServer(); }; #include "T_ImageDecoderServer.inl" #endif /* __T_IMAGE_DECODER_SERVER_H__ */
[ "none@none" ]
[ [ [ 1, 53 ] ] ]
320a3afbb1c7a479fc7fbddfd1dedc8edd038cd1
fd4a071ba9d8f0abf82e7a4d2cb41f48b9339b51
/GuiItemCmd.h
5804f2f19cdd50e575c24df493bacee1504fcf6e
[]
no_license
rafalka/rs232testng
c4a6e4c1777ee92b2d67056739b2524569f5be5d
634d38cf8745841cf0509fb10c1faf6943516cbc
refs/heads/master
2020-05-18T17:14:51.166302
2011-01-12T22:00:01
2011-01-12T22:00:01
37,258,102
0
0
null
null
null
null
UTF-8
C++
false
false
1,448
h
/****************************************************************************** * @file GuiItemCmd.h * * @brief * * @date 22-11-2010 * @author Rafal Kukla ****************************************************************************** * Copyright (C) 2010 Rafal Kukla ( [email protected] ) * This file is a part of rs232testng project and is released * under the terms of the license contained in the file LICENSE ****************************************************************************** */ #ifndef GUIITEMCMD_H_ #define GUIITEMCMD_H_ #include <stdexcept> #include <QIcon> #include <QString> #include <QtGui/QComboBox> /* * */ class GuiItemCmd { public: const static QString ItemSeparator; const static QIcon NoIcon; const static QVariant NoParam; virtual void doWith(const QString& itemName = ItemSeparator, const QIcon& itemIcon = NoIcon, const QVariant& userParam = NoParam)=0; }; #endif /* GUIITEMCMD_H_ */ class ComboItemAddCmd: public GuiItemCmd { private: QComboBox* obj; ComboItemAddCmd(){}; public: ComboItemAddCmd(QComboBox* dest):obj(dest) { if (!dest) throw std::runtime_error("ComboItemAddCmd: NULL object passed"); }; virtual void doWith(const QString& itemName, const QIcon& itemIcon, const QVariant& userParam ); };
[ "rkdevel@ef62a7f8-4c9b-1a64-55d9-32abd1026911" ]
[ [ [ 1, 49 ] ] ]
32a9af7ad69cba57efd70210a6e6803edf040910
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/multi_index/detail/iter_adaptor.hpp
27435b36e096555925ff7db8b81c5598c7122555
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
ISO-8859-1
C++
false
false
6,292
hpp
/* Copyright 2003-2005 Joaquín M López Muñoz. * 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/multi_index for library home page. */ #ifndef BOOST_MULTI_INDEX_DETAIL_ITER_ADAPTOR_HPP #define BOOST_MULTI_INDEX_DETAIL_ITER_ADAPTOR_HPP #if defined(_MSC_VER)&&(_MSC_VER>=1200) #pragma once #endif #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */ #include <boost/mpl/apply.hpp> #include <boost/multi_index/detail/prevent_eti.hpp> #include <boost/operators.hpp> namespace boost{ namespace multi_index{ namespace detail{ /* Poor man's version of boost::iterator_adaptor. Used instead of the * original as compile times for the latter are significantly higher. * The interface is not replicated exactly, only to the extent necessary * for internal consumption. */ class iter_adaptor_access { public: template<class Class> static typename Class::reference dereference(const Class& x) { return x.dereference(); } template<class Class> static bool equal(const Class& x,const Class& y) { return x.equal(y); } template<class Class> static void increment(Class& x) { x.increment(); } template<class Class> static void decrement(Class& x) { x.decrement(); } template<class Class> static void advance(Class& x,typename Class::difference_type n) { x.advance(n); } template<class Class> static typename Class::difference_type distance_to( const Class& x,const Class& y) { return x.distance_to(y); } }; template<typename Category> struct iter_adaptor_selector; template<class Derived,class Base> class forward_iter_adaptor_base: public forward_iterator_helper< Derived, typename Base::value_type, typename Base::difference_type, typename Base::pointer, typename Base::reference> { public: typedef typename Base::reference reference; reference operator*()const { return iter_adaptor_access::dereference(final()); } friend bool operator==(const Derived& x,const Derived& y) { return iter_adaptor_access::equal(x,y); } Derived& operator++() { iter_adaptor_access::increment(final()); return final(); } private: Derived& final(){return *static_cast<Derived*>(this);} const Derived& final()const{return *static_cast<const Derived*>(this);} }; template<> struct iter_adaptor_selector<std::forward_iterator_tag> { template<class Derived,class Base> struct apply { typedef forward_iter_adaptor_base<Derived,Base> type; }; }; template<class Derived,class Base> class bidirectional_iter_adaptor_base: public bidirectional_iterator_helper< Derived, typename Base::value_type, typename Base::difference_type, typename Base::pointer, typename Base::reference> { public: typedef typename Base::reference reference; reference operator*()const { return iter_adaptor_access::dereference(final()); } friend bool operator==(const Derived& x,const Derived& y) { return iter_adaptor_access::equal(x,y); } Derived& operator++() { iter_adaptor_access::increment(final()); return final(); } Derived& operator--() { iter_adaptor_access::decrement(final()); return final(); } private: Derived& final(){return *static_cast<Derived*>(this);} const Derived& final()const{return *static_cast<const Derived*>(this);} }; template<> struct iter_adaptor_selector<std::bidirectional_iterator_tag> { template<class Derived,class Base> struct apply { typedef bidirectional_iter_adaptor_base<Derived,Base> type; }; }; template<class Derived,class Base> class random_access_iter_adaptor_base: public random_access_iterator_helper< Derived, typename Base::value_type, typename Base::difference_type, typename Base::pointer, typename Base::reference> { public: typedef typename Base::reference reference; typedef typename Base::difference_type difference_type; reference operator*()const { return iter_adaptor_access::dereference(final()); } friend bool operator==(const Derived& x,const Derived& y) { return iter_adaptor_access::equal(x,y); } friend bool operator<(const Derived& x,const Derived& y) { return iter_adaptor_access::distance_to(x,y)>0; } Derived& operator++() { iter_adaptor_access::increment(final()); return final(); } Derived& operator--() { iter_adaptor_access::decrement(final()); return final(); } Derived& operator+=(difference_type n) { iter_adaptor_access::advance(final(),n); return final(); } Derived& operator-=(difference_type n) { iter_adaptor_access::advance(final(),-n); return final(); } friend difference_type operator-(const Derived& x,const Derived& y) { return iter_adaptor_access::distance_to(y,x); } private: Derived& final(){return *static_cast<Derived*>(this);} const Derived& final()const{return *static_cast<const Derived*>(this);} }; template<> struct iter_adaptor_selector<std::random_access_iterator_tag> { template<class Derived,class Base> struct apply { typedef random_access_iter_adaptor_base<Derived,Base> type; }; }; template<class Derived,class Base> struct iter_adaptor_base { typedef iter_adaptor_selector< typename Base::iterator_category> selector; typedef typename prevent_eti< selector, typename mpl::apply2< selector,Derived,Base>::type >::type type; }; template<class Derived,class Base> class iter_adaptor:public iter_adaptor_base<Derived,Base>::type { protected: iter_adaptor(){} explicit iter_adaptor(const Base& b_):b(b_){} const Base& base_reference()const{return b;} Base& base_reference(){return b;} private: Base b; }; } /* namespace multi_index::detail */ } /* namespace multi_index */ } /* namespace boost */ #endif
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 273 ] ] ]
1a3f039605c4421cb28cce2c80dae8e0991a9da7
9c62af23e0a1faea5aaa8dd328ba1d82688823a5
/dependencies/OgreNewt_153/src/OgreNewt_RayCast.cpp
e1c38af16bc5be3ff0d7bfffd24fc354a60e2be3
[]
no_license
jacmoe/dsa-hl-svn
55b05b6f28b0b8b216eac7b0f9eedf650d116f85
97798e1f54df9d5785fb206c7165cd011c611560
refs/heads/master
2021-04-22T12:07:43.389214
2009-11-27T22:01:03
2009-11-27T22:01:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,933
cpp
#include "OgreNewt_RayCast.h" namespace OgreNewt { Raycast::Raycast() {} Raycast::~Raycast() {} void Raycast::go(const OgreNewt::World* world, const Ogre::Vector3& startpt, const Ogre::Vector3& endpt ) { // perform the raycast! NewtonWorldRayCast( world->getNewtonWorld(), (float*)&startpt, (float*)&endpt, OgreNewt::Raycast::newtonRaycastFilter, this, OgreNewt::Raycast::newtonRaycastPreFilter ); } float _CDECL Raycast::newtonRaycastFilter(const NewtonBody* body, const float* hitNormal, int collisionID, void* userData, float intersectParam) { // get our object! Raycast* me = (Raycast*)userData; Body* bod = (Body*)NewtonBodyGetUserData( body ); Ogre::Vector3 normal = Ogre::Vector3( hitNormal[0], hitNormal[1], hitNormal[2] ); if (me->userCallback( bod, intersectParam, normal, collisionID )) return intersectParam; else return 1.1; } unsigned _CDECL Raycast::newtonRaycastPreFilter(const NewtonBody *body, const NewtonCollision *collision, void* userData) { // get our object! Raycast* me = (Raycast*)userData; Body* bod = (Body*)NewtonBodyGetUserData( body ); if (me->userPreFilterCallback( bod )) return 1; else return 0; } //-------------------------------- BasicRaycast::BasicRaycastInfo::BasicRaycastInfo() { mBody = NULL; mDistance = -1.0; mNormal = Ogre::Vector3::ZERO; } BasicRaycast::BasicRaycastInfo::~BasicRaycastInfo() {} BasicRaycast::BasicRaycast(const OgreNewt::World* world, const Ogre::Vector3& startpt, const Ogre::Vector3& endpt, bool sorted ) : Raycast() { go( world, startpt, endpt ); if (sorted) { std::sort(mRayList.begin(), mRayList.end()); } } BasicRaycast::~BasicRaycast() {} int BasicRaycast::getHitCount() const { return (int)mRayList.size(); } BasicRaycast::BasicRaycastInfo BasicRaycast::getFirstHit() const { //return the closest hit... BasicRaycast::BasicRaycastInfo ret; Ogre::Real dist = 10000.0; RaycastInfoList::const_iterator it; for (it = mRayList.begin(); it != mRayList.end(); it++) { if (it->mDistance < dist) { dist = it->mDistance; ret = (*it); } } return ret; } BasicRaycast::BasicRaycastInfo BasicRaycast::getInfoAt( unsigned int hitnum ) const { BasicRaycast::BasicRaycastInfo ret; if ((hitnum < 0) || (hitnum > mRayList.size())) return ret; ret = mRayList.at(hitnum); return ret; } bool BasicRaycast::userCallback( OgreNewt::Body* body, Ogre::Real distance, const Ogre::Vector3& normal, int collisionID ) { // create a new infor object. BasicRaycast::BasicRaycastInfo newinfo; newinfo.mBody = body; newinfo.mDistance = distance; newinfo.mNormal = normal; newinfo.mCollisionID = collisionID; mRayList.push_back( newinfo ); return false; } } // end NAMESPACE OgreNewt
[ "blakharaz@4c79e8ff-cfd4-0310-af45-a38c79f83013", "natoka@4c79e8ff-cfd4-0310-af45-a38c79f83013" ]
[ [ [ 1, 4 ], [ 125, 125 ] ], [ [ 5, 124 ], [ 126, 126 ] ] ]
23c4e25126581fb5693c4c83c1d116f9cb1c4a31
073dfce42b384c9438734daa8ee2b575ff100cc9
/RCF/include/RCF/SerializationDefs.hpp
c590131e45e3340a688ddf4ecebbd084de7efa10
[]
no_license
r0ssar00/iTunesSpeechBridge
a489426bbe30ac9bf9c7ca09a0b1acd624c1d9bf
71a27a52e66f90ade339b2b8a7572b53577e2aaf
refs/heads/master
2020-12-24T17:45:17.838301
2009-08-24T22:04:48
2009-08-24T22:04:48
285,393
1
0
null
null
null
null
UTF-8
C++
false
false
810
hpp
//****************************************************************************** // RCF - Remote Call Framework // Copyright (c) 2005 - 2009, Jarl Lindrud. All rights reserved. // Consult your license for conditions of use. // Version: 1.1 // Contact: jarl.lindrud <at> gmail.com //****************************************************************************** #ifndef INCLUDE_RCF_SERIALIZATIONDEFS_HPP #define INCLUDE_RCF_SERIALIZATIONDEFS_HPP // NB: Any code that uses the RCF_USE_SF_SERIALIZATION/RCF_USE_BOOST_SERIALIZATION macros, // needs to include this file first. #if !defined(RCF_USE_SF_SERIALIZATION) && !defined(RCF_USE_BOOST_SERIALIZATION) && !defined(RCF_USE_BOOST_XML_SERIALIZATION) #define RCF_USE_SF_SERIALIZATION #endif #endif // ! INCLUDE_RCF_SERIALIZATIONDEFS_HPP
[ [ [ 1, 20 ] ] ]
d0f2036b11e472c75fcc096a210bbd49242386b0
256022d2e1ae66e89ba06804690f5bae09914c86
/pa3/nehe/Model.h
4ba02fe182f43a9ea1ce73018a047638d78c2441
[]
no_license
elingg/cognitive-dissonance
d7a6da49d48cb3119aa20541a9504b2cfc09703b
156a869cf9605632a33e65303fecad09fa625c51
refs/heads/master
2021-01-01T17:57:42.187178
2009-03-21T06:51:21
2009-03-21T06:51:21
40,203,227
0
0
null
null
null
null
UTF-8
C++
false
false
1,967
h
/* Model.h Abstract base class for a model. The specific extended class will render the given model. Author: Brett Porter Email: [email protected] Website: http://www.geocities.com/brettporter/ Copyright (C)2000, Brett Porter. All Rights Reserved. This file may be used only as long as this copyright notice remains intact. */ #ifndef MODEL_H #define MODEL_H #ifdef __APPLE__ #include <Carbon/Carbon.h> #include <GLUT/glut.h> #include <OpenGL/glext.h> #else #include <GL/gl.h> #include <GL/glu.h> #include <GL/glut.h> #include <GL/glext.h> #include <stdio.h> #endif class Model { public: // Mesh struct Mesh { int m_materialIndex; int m_numTriangles; int *m_pTriangleIndices; }; // Material properties struct Material { float m_ambient[4], m_diffuse[4], m_specular[4], m_emissive[4]; float m_shininess; GLuint m_texture; char *m_pTextureFilename; }; // Triangle structure struct Triangle { float m_vertexNormals[3][3]; float m_s[3], m_t[3]; int m_vertexIndices[3]; }; // Vertex structure struct Vertex { char m_boneID; // for skeletal animation float m_location[3]; }; public: /* Constructor. */ Model(); /* Destructor. */ virtual ~Model(); /* Load the model data into the private variables. filename Model filename */ virtual bool loadModelData( const char *filename ) = 0; /* Draw the model. */ void draw(); /* Called if OpenGL context was lost and we need to reload textures, display lists, etc. */ void reloadTextures(); protected: // Meshes used int m_numMeshes; Mesh *m_pMeshes; // Materials used int m_numMaterials; Material *m_pMaterials; // Triangles used int m_numTriangles; Triangle *m_pTriangles; // Vertices Used int m_numVertices; Vertex *m_pVertices; }; #endif // ndef MODEL_H
[ "AlecMGo@257f2f30-e9bf-11dd-b00f-9fabb4b2ff13" ]
[ [ [ 1, 105 ] ] ]
d5a1f4814a2ac613cb6ed5a50e23020067f29cc3
f55dee0ea7c9d5ff1b48c20231bd256e8eeedbbb
/World Server/clan.cpp
e43a7df26f78d64e9e49e6b1522769c47bb01832
[]
no_license
trebor57/osprose-official
e998c8625e8e96d96af02bf2f95a05d4d45021cc
afe0e7b9b32216c7d6423f964769acdc7a99f36a
refs/heads/master
2020-04-04T19:26:22.231668
2010-05-16T10:58:32
2010-05-16T10:58:32
32,129,832
0
0
null
null
null
null
UTF-8
C++
false
false
10,033
cpp
/* Rose Online Server Emulator Copyright (C) 2006,2007 OSRose Team http://www.osrose.net 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. developed with Main erose/hrose source server + some change from the original eich source */ #include "worldserver.h" // Clan Manager bool CWorldServer::pakClanManager ( CPlayer* thisclient, CPacket* P ) { int action = GETBYTE((*P),0); switch(action) { case 0xfa://new member added { MYSQL_ROW row; int charid = GETWORD((*P),1); int clanid = GETWORD((*P),3); Log(MSG_INFO, "Adding member %d to clan %d", charid, clanid); CPlayer* otherclient = GetClientByCID ( charid ); if(otherclient==NULL) { Log(MSG_ERROR, "Char with id %d doesn't exist", charid); return true; } MYSQL_RES *result = DB->QStore("SELECT logo,back,name,grade FROM list_clan where id=%i", clanid); if(result==NULL) return true; if(mysql_num_rows(result)!=1) { Log(MSG_WARNING, "Invalid clan %i", clanid ); DB->QFree( ); return true; } row = mysql_fetch_row(result); otherclient->Clan->logo = atoi(row[0]); otherclient->Clan->back = atoi(row[1]); strcpy(otherclient->Clan->clanname,row[2]); otherclient->Clan->grade = atoi(row[3]); DB->QFree( ); otherclient->Clan->clanid=clanid; otherclient->Clan->clanrank=1; BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x35 );//funcion ADDWORD ( pak, otherclient->clientid );//client id ADDWORD ( pak, clanid );//? ADDWORD ( pak, 0x0000 ); ADDWORD ( pak, otherclient->Clan->back ); ADDWORD ( pak, otherclient->Clan->logo ); ADDBYTE ( pak, otherclient->Clan->grade ); ADDBYTE ( pak, otherclient->Clan->clanrank ); ADDSTRING ( pak, otherclient->Clan->clanname ); ADDBYTE ( pak, 0x00 ); SendToVisible( &pak, otherclient ); } break; case 0xfb://Member Kicked { char nick[30]; memcpy( nick, &P->Buffer[1], P->Size ); CPlayer* otherclient = GetClientByCharName( nick ); if(otherclient!=NULL) { otherclient->Clan->clanid=0; otherclient->Clan->clanrank=1; otherclient->Clan->back=0; otherclient->Clan->logo=0; otherclient->Clan->grade=0; strcpy(otherclient->Clan->clanname,""); BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x35 ); ADDWORD ( pak, otherclient->clientid ); ADDQWORD ( pak, 0 ); ADDWORD ( pak, 0x0001 ); SendToVisible( &pak, otherclient ); } } break; case 0xfc://member change rank { char nick[30]; int newrank = GETBYTE((*P),1); memcpy( nick, &P->Buffer[2], P->Size ); CPlayer* otherclient = GetClientByCharName( nick ); if(otherclient!=NULL) { otherclient->Clan->clanrank = newrank; } } break; case 0xfd://disorg { unsigned int clanid = GETWORD((*P),1); unsigned int charid = GETWORD((*P),3); CPlayer* tclient = GetClientByCID( charid ); if(tclient == NULL) return true; tclient->Clan->clanid = 0; tclient->Clan->clanrank = 1; tclient->Clan->grade = 0; tclient->Clan->back = 0; tclient->Clan->logo = 0; memset( &tclient->Clan->clanname, '\0', 17 ); BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x35 ); ADDWORD ( pak, tclient->clientid ); ADDQWORD ( pak, 0 ); ADDWORD ( pak, 0x0001 ); SendToVisible( &pak, tclient ); } break; case 0xfe://Member Leave { char nick[17]; memcpy( nick, &P->Buffer[1], P->Size ); CPlayer* otherclient = GetClientByCharName(nick); if(otherclient!=NULL) { otherclient->Clan->clanid=0; otherclient->Clan->clanrank=0; otherclient->Clan->back=0; otherclient->Clan->logo=0; otherclient->Clan->grade=0; strcpy(otherclient->Clan->clanname,""); BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x35 ); ADDWORD ( pak, otherclient->clientid ); ADDQWORD ( pak, 0 ); ADDWORD ( pak, 0x0001 ); SendToVisible( &pak, otherclient ); } } break; case 0xff: // update clan mark { unsigned int clanid = GETWORD((*P),1); unsigned int clanlogo = GETDWORD((*P), 3 ); for(unsigned int i=0;i<ClientList.size();i++) { if(ClientList.at(i)->player==NULL) continue; CPlayer* player = (CPlayer*)ClientList.at(i)->player; if(player->Clan->clanid==clanid) { player->Clan->back = 0; player->Clan->logo = clanlogo; BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x35 );//funcion ADDWORD ( pak, player->clientid );//cleint id ADDWORD ( pak, clanid ); ADDWORD ( pak, 0x0000 );//? ADDWORD ( pak, player->Clan->back );//? ADDWORD ( pak, player->Clan->logo );//? ADDBYTE ( pak, player->Clan->grade ); ADDBYTE ( pak, player->Clan->clanrank ); ADDSTRING ( pak, player->Clan->clanname ); ADDBYTE ( pak, 0x00 ); SendToVisible( &pak, player ); } } } break; default: Log( MSG_INFO, "Clan manager unknow action %i", action ); } return true; } // Create a new clan bool CWorldServer::pakCreateClan ( CPlayer* thisclient, CPacket* P ) { if(thisclient->CharInfo->Zulies<1000000) return true; thisclient->CharInfo->Zulies -= 1000000; MYSQL_ROW row; int background = GETWORD((*P),1); int icon = GETWORD((*P),3); char *name = ""; char *slogan = ""; name=(char*)&P->Buffer[5]; slogan=(char*)&P->Buffer[strlen(name)+6]; //Check if name already exists MYSQL_RES *result = DB->QStore("SELECT name FROM list_clan WHERE name='%s'", name); if(result==NULL) return true; if ( mysql_num_rows( result ) > 0 ) { BEGINPACKET( pak, 0x07e0 ); ADDWORD ( pak, 0x42 ); thisclient->client->SendPacket( &pak ); DB->QFree( ); return true; } DB->QFree( ); //Check if user can create a clan if( thisclient->Clan->clanid != 0 ) { BEGINPACKET( pak, 0x07e0 ); ADDWORD ( pak, 0x44 ); thisclient->client->SendPacket( &pak ); return true; } //Add clan to sql table DB->QExecute( "INSERT into list_clan (logo,back,name,cp,grade,slogan,news) values (%i,%i,'%s',0,1,'%s','')", icon,background,name,slogan); thisclient->Clan->clanid = mysql_insert_id(DB->Mysql); thisclient->Clan->clanrank = 6; thisclient->Clan->logo = icon; thisclient->Clan->back = background; strncpy(thisclient->Clan->clanname,name,16); thisclient->Clan->grade = 1; //Update user clan information DB->QExecute( "UPDATE characters set clanid=%i,clan_rank=6 where id=%i", thisclient->Clan->clanid,thisclient->CharInfo->charid); //load clan info in char server BEGINPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0xfa ); //action to update clan informacion (charserver) ADDWORD ( pak, thisclient->Clan->clanid ); ADDWORD ( pak, thisclient->CharInfo->charid ); ADDWORD ( pak, thisclient->clientid ); SendISCPacket( &pak ); //Send to other players RESETPACKET( pak, 0x7e0 ); ADDBYTE ( pak, 0x35 ); ADDWORD ( pak, thisclient->clientid ); ADDWORD ( pak, thisclient->Clan->clanid); ADDWORD ( pak, 0x0000 );//??? ADDWORD ( pak, background ); ADDWORD ( pak, icon ); ADDBYTE ( pak, 0x01 );//clan grade ADDBYTE ( pak, 0x06 );//clan rank ADDSTRING ( pak, name ); ADDBYTE ( pak, 0x00 ); SendToVisible( &pak, thisclient ); return true; }
[ "lmameps@3c0ee055-4d62-4915-5d54-7a338cdfeaf6" ]
[ [ [ 1, 252 ] ] ]
a34a448fbac9be359f2b4373af8491b36d0cc6c6
8ed2d5373cf825846b4d60b901eec6fdecc207ab
/ClassWizard/VFC_Core/codeparser.h
ca1094e253e200a0b210429e1d39195206ec3311
[]
no_license
clonly/visualfc
73c9b279ed4d07c59ebf7d81ec78bcbbe6db7d1d
1ccb987d0e66c83c2eeff690fa0aaf4e41f7c763
refs/heads/master
2021-01-20T01:03:11.715001
2010-06-02T06:23:10
2010-06-02T06:23:10
40,166,330
1
0
null
null
null
null
GB18030
C++
false
false
27,888
h
#ifndef _CODEPARSER_H__ #define _CODEPARSER_H__ //Code::Blocks Common #include "./cbparser/parserthread.h" //WTLHelper Common #include "./resources/reshelper.h" #include "./resources/Resources.h" // #include "./winx_event.h" #include "./win32_notify.h" #include "./wtl_event.h" inline CString get_file_name(const CString & filename) { int i = filename.ReverseFind(_T('\\')); if (i != -1) { return filename.Right(filename.GetLength()-i-1); } return _T(""); } inline CString get_file_ext(const CString & filename) { int i = filename.ReverseFind(_T('.')); if (i != -1) { return filename.Right(filename.GetLength()-i); } return _T(""); } inline CString get_file_title(const CString & filename) { int i = filename.ReverseFind(_T('.')); if (i != -1) { return filename.Left(i); } return _T(""); } //type: void process(CResDialog*) template <typename Array, typename FUNC> bool HelperEnumArray(Array & ar, FUNC & Process) { for (size_t i = 0; i < ar.GetCount(); i++) { Process(&ar[i]); } return true; } struct parser_win32res { CResources m_Res; // parser enum { IDD = IDD_MAINDLG }; CString GetClassEnumIDD(Token * tkcls) { for (size_t i = 0; i < tkcls->m_Children.GetCount(); i++) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenKind == tkEnum && tk->m_Children.GetCount() ==1) { Token * tkidd = tk->m_Children[0]; if (tkidd->m_Name == _T("IDD")) { return (LPCTSTR)(tkidd->m_Args); } } } return _T(""); } // 1. enum { IDD = IDD_MAINDLG }; // 2. CMainDlg : public winx::ModelDialog<CMainDlg, IDD_MAINDLG> CResDialog * GetResDialog(Token * tkcls) { CString id = GetClassEnumIDD(tkcls); for (size_t i = 0; i < m_Res.m_Dialogs.GetCount(); i++) { CResDialog & dlg = m_Res.m_Dialogs[i]; if ((!id.IsEmpty() && id == dlg.m_ID) || (tkcls->m_AncestorsString.Find(dlg.m_ID) != -1) ) { return &dlg; } } return NULL; } // CResMenu * GetResDialogMenu(LPCTSTR menuID) { for (size_t i = 0; i < m_Res.m_Menus.GetCount(); i++) { const CResMenu & menu = m_Res.m_Menus.GetAt(i); if (menu.m_ID == menuID) { return (CResMenu*)&menu; } } return NULL; } //type: void process(CResDialog*) template <typename FUNC> bool EnumResDialog(FUNC & Process) { Helper::EnumArray(m_Res.m_Dialogs,Process); return true; } //type: void process(CResMenu*) template <typename FUNC> bool EnumResMenu(FUNC & Process) { for (size_t i = 0; i < m_Res.m_Menus.GetCount(); i++) { Process(&m_Res.m_Menus[i]); } return true; } //type void process(const ResControl*) template <typename FUNC> bool EnumResDialogControl(const CResDialog * dlg, FUNC & Process) { for (size_t i = 0; i < dlg->GetCount(); i++) { if (dlg->GetAt(i).m_ID != _T("IDC_STATIC")) Process(&dlg->GetAt(i)); } return true; } //type void process(const CResMenu*) template <typename FUNC> bool EnumResMenuItem(const CResMenu * menu, FUNC & Process) { for (size_t i = 0; i < menu->GetCount(); i++) { if (!menu->m_ID.IsEmpty()) Process(&menu->GetAt(i)); } for (size_t j = 0; j < menu->m_SubMenus.GetCount(); j++) { const CResMenu & subMenu = menu->m_SubMenus.GetAt(j); for (size_t k = 0; k < subMenu.GetCount(); k++) { if (!subMenu.GetAt(k).m_ID.IsEmpty()) Process(&subMenu.GetAt(k)); } } return true; } bool LoadRes(LPCTSTR lpszResource,bool bAppend = false) { return m_Res.Load(lpszResource,bAppend); } }; struct insert_point { CSimpleArray<CString> array; int line; bool bcpp; insert_point(bool _bcpp = false) : bcpp(_bcpp) { } void AddNewLine() { array.Add((CString)_T("")); } void AddLine(LPCTSTR lpszLine = _T(""), int ntab = 0) { CString tab; for (int i = 0; i < ntab; i++) tab += _T("\t"); array.Add(tab+(CString)lpszLine); } CString GetText(int ntab = 0) { CString tab; for (int i = 0; i < ntab; i++) tab += _T("\t"); CString text; for (int i = 0; i < array.GetSize(); i++) { text += _T("\r\n"); text += tab; text += array[i]; } return text; } }; struct project_dsp { CString project_name; CString active_file; }; class codeparser { public: CResources m_Res; TokensArray m_Tokens; winx_event_config m_winxev; wtl_event_config m_wtlev; win32_notify_config m_notify; ~codeparser() { WX_CLEAR_ARRAY(m_Tokens); m_Tokens.Clear(); m_Res.Clear(); } public: Token * AddTokenMappingArgs1(Token * tkcls, LPCTSTR name, LPCTSTR args1) { Token * tk = new Token(); tk->m_Name = name; tk->m_TokenKind = tkMapping; tk->m_TokenUpdate = tuAddnew; tk->m_Args = _T("("); tk->m_Args += args1; tk->m_Args += _T(")"); if (tkcls) { tk->m_pParent = tkcls; tkcls->AddChild(tk); } m_Tokens.Add(tk); return tk; } Token * AddTokenMappingArgs2(Token * tkcls, LPCTSTR name, LPCTSTR args1, LPCTSTR args2) { Token * tk = new Token(); tk->m_Name = name; tk->m_TokenKind = tkMapping; tk->m_TokenUpdate = tuAddnew; tk->m_Args = _T("("); tk->m_Args += args1; tk->m_Args += _T(", "); tk->m_Args += args2; tk->m_Args += _T(")"); if (tkcls) { tk->m_pParent = tkcls; tkcls->AddChild(tk); } m_Tokens.Add(tk); return tk; } Token * AddTokenMappingArgs3(Token * tkcls, LPCTSTR name, LPCTSTR args1, LPCTSTR args2, LPCTSTR args3) { Token * tk = new Token(); tk->m_Name = name; tk->m_TokenKind = tkMapping; tk->m_TokenUpdate = tuAddnew; tk->m_Args = _T("("); tk->m_Args += args1; tk->m_Args += _T(", "); tk->m_Args += args2; tk->m_Args += _T(", "); tk->m_Args += args3; tk->m_Args += _T(")"); if (tkcls) { tk->m_pParent = tkcls; tkcls->AddChild(tk); } m_Tokens.Add(tk); return tk; } Token * AddTokenMappingArgs4(Token * tkcls, LPCTSTR name, LPCTSTR args1, LPCTSTR args2, LPCTSTR args3, LPCTSTR args4) { Token * tk = new Token(); tk->m_Name = name; tk->m_TokenKind = tkMapping; tk->m_TokenUpdate = tuAddnew; tk->m_Args = _T("("); tk->m_Args += args1; tk->m_Args += _T(", "); tk->m_Args += args2; tk->m_Args += _T(", "); tk->m_Args += args3; tk->m_Args += _T(", "); tk->m_Args += args4; tk->m_Args += _T(")"); if (tkcls) { tk->m_pParent = tkcls; tkcls->AddChild(tk); } m_Tokens.Add(tk); return tk; } Token * AddTokenArgs2(Token * tkcls, LPCTSTR name, LPCTSTR args1, LPCTSTR args2 = NULL, LPCTSTR args3 = NULL, TokenKind = tkMapping) { Token * tk = new Token(); tk->m_Name = name; tk->m_TokenKind = tkMapping; tk->m_TokenUpdate = tuAddnew; tk->m_Args = _T("("); tk->m_Args += args1; if (lstrlen(args2) != 0) { tk->m_Args += _T(", "); tk->m_Args += args2; } if (lstrlen(args3) != 0) { tk->m_Args += _T(", "); tk->m_Args += args3; } tk->m_Args += _T(")"); if (tkcls) { tk->m_pParent = tkcls; tkcls->AddChild(tk); } m_Tokens.Add(tk); return tk; } Token * AddTokenVarible(Token * tkcls, LPCTSTR type, LPCTSTR var) { Token * tk = new Token(); tk->m_Name = var; tk->m_Type = type; tk->m_TokenKind = tkVariable; tk->m_TokenUpdate = tuAddnew; if (tkcls) { tk->m_pParent = tkcls; tkcls->AddChild(tk); } m_Tokens.Add(tk); return tk; } Token * FindTokenVarible(Token * tkcls, LPCTSTR var) { for (size_t i = 0; i < tkcls->m_Children.GetCount(); i++) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenKind == tkVariable && (CString)(LPCTSTR)tk->m_Name == (CString)var) { return tk; } } return NULL; } bool RemoveToken(Token * tk) { Token * tkcls = tk->m_pParent; if (tk->m_TokenUpdate == tuAddnew) { if (tkcls) tkcls->RemoveChild(tk); m_Tokens.Remove(tk); return true; } else if (tk->m_TokenUpdate == tuNormal) { tk->m_TokenUpdate = tuRemove; return true; } return false; } //type bool ask(Token*) template <typename FUNC> bool WinxRemoveNotifyToken(Token * tk, FUNC & AskRemove) { //is addnew token remove it if (tk->m_TokenUpdate == tuAddnew) { if (tk->m_pParent != NULL) { tk->m_pParent->RemoveChild(tk); } m_Tokens.Remove(tk); return true; } //is extern token set flag remove else if (tk->m_TokenUpdate == tuNormal) { if (AskRemove(tk) == true) { tk->m_TokenUpdate = tuRemove; return true; } } return false; } bool WinxRemoveDialogResizeToken(Token * tk) { Token * tkcls = tk->m_pParent; if (tk->m_TokenUpdate == tuAddnew) { if (tkcls) tkcls->RemoveChild(tk); m_Tokens.Remove(tk); return true; } else if (tk->m_TokenUpdate == tuNormal) { tk->m_TokenUpdate = tuRemove; return true; } return false; } Token * WinxAddDialogResizeToken(Token * tkcls, LPCTSTR id, LPCTSTR dlsz) { Token * tk = new Token(); tk->m_Name = _T("WINX_DLGRESIZE"); tk->m_TokenKind = tkMapping; tk->m_TokenUpdate = tuAddnew; tk->m_Args = _T("("); tk->m_Args += id; tk->m_Args += _T(","); tk->m_Args += dlsz; tk->m_Args += _T(")"); if (tkcls) { tk->m_pParent = tkcls; tkcls->AddChild(tk); } m_Tokens.Add(tk); return tk; } Token * AddDialogFontToken(Token * tkcls, LPCTSTR name, LPCTSTR id, LOGFONT & lf, bool bdlg) { CString font; font.Format(_T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,_T(\"%s\")"), lf.lfHeight, lf.lfWidth, lf.lfEscapement, lf.lfOrientation, lf.lfWeight, lf.lfItalic, lf.lfUnderline, lf.lfStrikeOut, lf.lfCharSet, lf.lfOutPrecision, lf.lfClipPrecision, lf.lfQuality, lf.lfPitchAndFamily, lf.lfFaceName); Token * tk = new Token(); tk->m_Name = name; tk->m_TokenKind = tkMapping; tk->m_TokenUpdate = tuAddnew; tk->m_Args = _T("("); if (bdlg == false) { tk->m_Args += id; tk->m_Args += _T(","); } tk->m_Args += font; tk->m_Args += _T(")"); if (tkcls) { tk->m_pParent = tkcls; tkcls->AddChild(tk); } m_Tokens.Add(tk); return tk; } Token * WinxAddDialogFontToken(Token * tkcls, LPCTSTR id, LOGFONT & lf, int flag) { CString font; font.Format(_T("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,_T(\"%s\")"), lf.lfHeight, lf.lfWidth, lf.lfEscapement, lf.lfOrientation, lf.lfWeight, lf.lfItalic, lf.lfUnderline, lf.lfStrikeOut, lf.lfCharSet, lf.lfOutPrecision, lf.lfClipPrecision, lf.lfQuality, lf.lfPitchAndFamily, lf.lfFaceName); Token * tk = new Token(); if (flag == 0) tk->m_Name = _T("WINX_DLGFONT_EX"); else tk->m_Name = _T("WINX_DLGFONT_DIALOG_EX"); tk->m_TokenKind = tkMapping; tk->m_TokenUpdate = tuAddnew; tk->m_Args = _T("("); if (flag == 0) { tk->m_Args += id; tk->m_Args += _T(","); } tk->m_Args += font; tk->m_Args += _T(")"); if (tkcls) { tk->m_pParent = tkcls; tkcls->AddChild(tk); } m_Tokens.Add(tk); return tk; } bool WinxRemoveDialogFontToken(Token * tk) { Token * tkcls = tk->m_pParent; if (tk->m_TokenUpdate == tuAddnew) { if (tkcls) tkcls->RemoveChild(tk); m_Tokens.Remove(tk); return true; } else if (tk->m_TokenUpdate == tuNormal) { tk->m_TokenUpdate = tuRemove; return true; } return false; } Token * WinxAddNotifyToken(win32_notify_code * wnc, Token * tkcls, LPCTSTR id, LPCTSTR func, bool bMenu) { Token * tk = new Token(); if (wnc->code == _T("COMMAND")) { tk->m_Name = _T("WINX_CMD"); tk->m_TokenKind = tkMapping; tk->m_TokenUpdate = tuAddnew; tk->m_Args = _T("("); tk->m_Args += id; tk->m_Args += _T(","); tk->m_Args += func; tk->m_Args += _T(")"); tk->m_String = _T("void "); tk->m_String += func; tk->m_String += _T("(HWND hWnd)"); } else if (wnc->kind == wkCOMMAND) { tk->m_Name = _T("WINX_CMD_EX"); tk->m_Args = _T("("); tk->m_Args += id; tk->m_Args += _T(","); tk->m_Args += wnc->code; tk->m_Args += _T(","); tk->m_Args += func; tk->m_Args += _T(")"); tk->m_String = _T("void "); tk->m_String += func; tk->m_String += _T("(HWND hWnd)"); } else if (wnc->kind == wkNOTIFY) { tk->m_Name = _T("WINX_NOTIFY"); tk->m_Args = _T("("); tk->m_Args += id; tk->m_Args += _T(","); tk->m_Args += wnc->code; tk->m_Args += _T(","); tk->m_Args += func; tk->m_Args += _T(")"); tk->m_String = _T("void "); tk->m_String += func; tk->m_String += _T("(HWND hWnd, LPNMHDR pnmh, LRESULT* pResult)"); } tk->m_TokenKind = tkMapping; tk->m_TokenUpdate = tuAddnew; //save m_String is func name if (tkcls) { tk->m_pParent = tkcls; tkcls->AddChild(tk); } m_Tokens.Add(tk); return tk; } Token * WinxAddEventToken(winx_event * ev, Token * tkcls) { //is remove reset flag normal for (size_t i = 0; i < tkcls->m_Children.GetCount(); i++) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenKind == tkFunction && (CString)(LPCTSTR)tk->m_Name == ev->name) { if (tk->m_TokenUpdate == tuRemove) { tk->m_TokenUpdate = tuNormal; } return tk; } } //add new token Token * tk = new Token(); tk->m_Name = ev->name; if (tkcls) { tk->m_pParent = tkcls; tkcls->AddChild(tk); } tk->m_TokenKind = tkFunction; tk->m_Scope = tsPublic; tk->m_TokenUpdate = tuAddnew; tk->m_Data = (void*)ev; m_Tokens.Add(tk); return tk; } //type bool ask(Token*) template <typename FUNC> bool WinxRemoveEventToken(Token * tk_ev, FUNC & AskRemove) { Token * tkcls = tk_ev->m_pParent; for (size_t i = 0; i < tkcls->m_Children.GetCount(); i++) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenKind == tkFunction && tk->m_Name == tk_ev->m_Name ) { if (tk->m_TokenUpdate == tuAddnew) { if (tk->m_pParent != NULL) { tk->m_pParent->RemoveChild(tk); } m_Tokens.Remove(tk); return true; } else if (tk->m_TokenUpdate == tuNormal) { if (AskRemove(tk) == true) { tk->m_TokenUpdate = tuRemove; return true; } } } } return false; } bool WinxIsEventToken(Token * tk) { for (int i = 0; i < m_winxev.m_items.GetSize(); i++) { winx_event & ev = m_winxev.m_items[i]; if (ev.name == CString((LPCTSTR)tk->m_Name)) { return true; } } return false; } bool WinxIsCmdToken(Token * tk) { } bool WinxIsNotifyToken(Token * tk) { } bool WinxIsDlszToken(Token * tk) { } bool WinxIsMessageToken(Token * tk) { if (tk->m_TokenKind != tkMapping) return false; if ( tk->m_Name == _T("WINX_CMD") || tk->m_Name == _T("WINX_CMD_EX") || tk->m_Name == _T("WINX_CMD_NOARG") || tk->m_Name == _T("WINX_CMD_RANGE") || tk->m_Name == _T("WINX_CMD_NOTIFY") || tk->m_Name == _T("WINX_SYSCMD") || tk->m_Name == _T("WINX_NOTIFY") || tk->m_Name == _T("WINX_NOTIFY_RANGE") ) { return true; } return false; } CString WinxGetNotifyTokenFuncitonName(Token * tk) { CString tmp = (LPCTSTR) tk->m_Args; tmp.TrimLeft(_T("(")); tmp.TrimRight(_T(")")); CAtlArray<CString> array; CutString(tmp,array,_T(",")); if (array.GetCount() == 0) return _T(""); for (int i = array.GetCount()-1; i >= 0; i++) { CString text = array[i]; text.TrimLeft(); text.TrimRight(); if (!text.IsEmpty()) return text; } return _T(""); } //type: void process(Token*) template <typename FUNC> bool EnumWinxEventToken(Token * tkcls, FUNC & Process) { for (size_t i = 0; i < tkcls->m_Children.GetCount(); i++) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenKind == tkFunction && WinxIsEventToken(tk)) { Process(tk); } } return true; } //type: void process(Token*) template <typename FUNC> bool EnumWinxDialogResizeToken(Token * tkcls, FUNC & Process) { for (size_t i = 0; i < tkcls->m_Children.GetCount(); i++) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenKind == tkMapping && tk->m_TokenUpdate != tuRemove && tk->m_Name == _T("WINX_DLGRESIZE")) { Process(tk); } } return true; } //type: void process(Token*, int flag) template <typename FUNC> bool EnumWinxDialogFontToken(Token * tkcls, FUNC & Process) { for (size_t i = 0; i < tkcls->m_Children.GetCount(); i++) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenKind == tkMapping && tk->m_TokenUpdate != tuRemove && ( tk->m_Name == _T("WINX_DLGFONT") || tk->m_Name == _T("WINX_DLGFONT_EX")) ) // tk->m_Name == _T("WINX_DLGFONT_DIALOG") || // tk->m_Name == _T("WINX_DLGFONT_DIALOG_EX") ) { Process(tk, 0); } else if (tk->m_TokenKind == tkMapping && tk->m_TokenUpdate != tuRemove && ( tk->m_Name == _T("WINX_DLGFONT_DIALOG") || tk->m_Name == _T("WINX_DLGFONT_DIALOG_EX")) ) { Process(tk,1); } } return true; } //type: void process(Token*) template <typename FUNC> bool EnumProjectClass(FUNC & Process) { for (size_t i = 0; i < m_Tokens.GetCount(); i++) { Token * tk = m_Tokens[i]; if (tk->m_TokenKind == tkClass) { Process(tk); } } return true; } //type: void process(Token*) template <typename FUNC> bool EnumWinxMessageToken(Token * tkcls, FUNC & Process) { for (size_t i = 0; i < tkcls->m_Children.GetCount(); i++) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenKind == tkMapping) { if (tk->m_Name == _T("WINX_CMD") || tk->m_Name == _T("WINX_CMD_EX") || tk->m_Name == _T("WINX_CMD_NOARG") || tk->m_Name == _T("WINX_CMD_RANGE") || tk->m_Name == _T("WINX_CMD_NOTIFY") || tk->m_Name == _T("WINX_SYSCMD") || tk->m_Name == _T("WINX_NOTIFY") || tk->m_Name == _T("WINX_NOTIFY_RANGE") ) { Process(tk); } } } return true; } //type: void process(Token*) template <typename FUNC> bool EnumWinxProperty(Token * tkcls, FUNC & Process) { for (size_t i = 0; i < tkcls->m_Children.GetCount(); i++) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenKind == tkMapping) { if (tk->m_Name == _T("WINX_CMD") || tk->m_Name == _T("WINX_CMD_EX") || tk->m_Name == _T("WINX_CMD_NOARG") || tk->m_Name == _T("WINX_CMD_RANGE") || tk->m_Name == _T("WINX_CMD_NOTIFY") || tk->m_Name == _T("WINX_SYSCMD") || tk->m_Name == _T("WINX_NOTIFY") || tk->m_Name == _T("WINX_NOTIFY_RANGE") || tk->m_Name == _T("WINX_UPDATEUI")) { continue; } else { Process(tk); } } } return true; } /* bool EnumControlNofity(win32_notify * wn, QLib::Event<void,win32_notify_code*> & Process) { if (wn == NULL) { return false; } for (int i = 0; i < wn->codes.GetSize(); i++) { Process(&wn->codes[i]); } return true; } */ template <typename FUNC> bool EnumControlNofity(win32_notify * wn, FUNC & Process) { if (wn == NULL) { return false; } for (int i = 0; i < wn->codes.GetSize(); i++) { Process(&wn->codes[i]); } return true; } CString GetClassEnumIDD(Token * tkcls) { for (size_t i = 0; i < tkcls->m_Children.GetCount(); i++) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenKind == tkEnum && tk->m_Children.GetCount() ==1) { Token * tkidd = tk->m_Children[0]; if (tkidd->m_Name == _T("IDD")) { return (LPCTSTR)(tkidd->m_Args); } } } return _T(""); } CResDialog * GetResDialog(Token * tkcls) { CString id = GetClassEnumIDD(tkcls); for (size_t i = 0; i < m_Res.m_Dialogs.GetCount(); i++) { CResDialog & dlg = m_Res.m_Dialogs[i]; if ((!id.IsEmpty() && id == dlg.m_ID) || (tkcls->m_AncestorsString.Find(dlg.m_ID) != -1) ) { return &dlg; } } return NULL; } CResMenu * GetResDialogMenu(LPCTSTR menuID) { for (size_t i = 0; i < m_Res.m_Menus.GetCount(); i++) { const CResMenu & menu = m_Res.m_Menus.GetAt(i); if (menu.m_ID == menuID) { return (CResMenu*)&menu; } } return NULL; } win32_notify * GetResControlNotify(ResControl * ctrl) { return m_notify.get_notify_by_res(ctrl->m_Type); } win32_notify * GetResMenuNotify() { return m_notify.get_notify_by_name(_T("menu")); } Token * GetFirstTokenByName(Token * tkcls, LPCTSTR head, TokenKind kind = tkMapping) { for (size_t i = 0; i < tkcls->m_Children.GetCount(); i++) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenKind == kind && tk->m_TokenUpdate == tuNormal) { if (tk->m_Name == head) { return tk; } } } return NULL; } //type: void process(CResDialog*) template <typename FUNC> bool EnumResDialog(FUNC & Process) { for (size_t i = 0; i < m_Res.m_Dialogs.GetCount(); i++) { Process(&m_Res.m_Dialogs[i]); } // HelperEnumArray(m_Res.m_Dialogs,Process); return true; } //type: void process(CResMenu*) template <typename FUNC> bool EnumResMenu(FUNC & Process) { for (size_t i = 0; i < m_Res.m_Menus.GetCount(); i++) { Process(&m_Res.m_Menus[i]); } return true; } //type void process(const ResContron*) template <typename FUNC> bool EnumResDialogControl(const CResDialog * dlg, FUNC & Process) { for (size_t i = 0; i < dlg->GetCount(); i++) { if (dlg->GetAt(i).m_ID != _T("IDC_STATIC")) Process(&dlg->GetAt(i)); } return true; } //type void process(const CResMenu*) template <typename FUNC> bool EnumResMenuItem(const CResMenu * menu, FUNC & Process) { for (size_t i = 0; i < menu->GetCount(); i++) { if (!menu->m_ID.IsEmpty()) { Process(&menu->GetAt(i)); } } for (size_t j = 0; j < menu->m_SubMenus.GetCount(); j++) { const CResMenu & subMenu = menu->m_SubMenus.GetAt(j); for (size_t k = 0; k < subMenu.GetCount(); k++) { if (!subMenu.GetAt(k).m_ID.IsEmpty()) Process(&subMenu.GetAt(k)); } } return true; } //type void process(const winx_event*) template <typename FUNC> bool EnumWinxEventList(FUNC & Process) { for (int i = 0; i < m_winxev.m_items.GetSize(); i++) { Process(&m_winxev.m_items[i]); } return true; } bool LoadRes(LPCTSTR lpszResource,bool bAppend = false) { return m_Res.Load(lpszResource,bAppend); } bool LoadCode(LPCTSTR lpszFileName, bool bAppend = false) { if (bAppend == false) m_Tokens.Clear(); wxEvtHandler ev; ParserThreadOptions op; op.useBuffer = false; op.bufferSkipBlocks = false; op.wantPreprocessor = false; bool flag; bool bRet = false; ParserThread * th = new ParserThread(&ev,&flag,lpszFileName,true,op,&m_Tokens); bRet = th->Parse(); delete th; return bRet; } bool LoadSources(CSimpleArray<CString> & source) { m_Tokens.Clear(); m_Res.Clear(); CString file; CSimpleArray<CString> ar1,ar2; int i = 0; for (i = 0; i < source.GetSize(); i++) { CString & tmp = source[i]; if (tmp.Left(1) == _T("\"")) { file = tmp; file.TrimLeft(_T("\"")); file.TrimRight(_T("\"")); } else file = tmp; CString & ext = get_file_ext(file); if (ext.CompareNoCase(_T(".rc")) == 0) { LoadRes(file,true); } else if (ext.CompareNoCase(_T(".h")) == 0 || ext.CompareNoCase(_T(".hxx")) == 0 || ext.CompareNoCase(_T(".hpp")) == 0) { ar1.Add(file); } else if ( ext.CompareNoCase(_T(".cpp")) == 0 || ext.CompareNoCase(_T(".cxx")) == 0 || ext.CompareNoCase(_T(".c")) == 0 ) { ar2.Add(file); } } //frist parser .h for (i = 0; i < ar1.GetSize(); i++) { LoadCode(ar1[i],true); } //then parser .cpp for (i = 0; i < ar2.GetSize(); i++) { LoadCode(ar2[i],true); } return true; } //load vs60 dsp file and parser file void ClearDSP() { WX_CLEAR_ARRAY(m_Tokens); m_Tokens.Clear(); m_Res.Clear(); } //insert token Token * GetLastTokenByScope(Token * tkcls, TokenScope Scope) { for (size_t i = tkcls->m_Children.GetCount()-1; i--; i >= 0) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenUpdate != tuAddnew && tk->m_Scope == Scope ) { return tk; } } return NULL; } Token * GetFirstTokenByScope(Token * tkcls, TokenScope Scope) { for (size_t i = 0; i < tkcls->m_Children.GetCount() ; i++) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenUpdate != tuAddnew && tk->m_Scope == Scope ) { return tk; } } return NULL; } //parser token and process winx kind token void WinxParserKindToken() { for (size_t i = 0; i < m_Tokens.GetCount(); i++) { Token * tk = m_Tokens[i]; if (tk->m_TokenKind == tkClass) { WinxParserKindTokenHelper(tk); } } } void WinxParserKindTokenHelper(Token * tkcls) { Token * cmd = new Token(); cmd->m_TokenKind = tkWinxCmd; Token * syscmd = new Token(); syscmd->m_TokenKind = tkWinxSyscmd; Token * notify = new Token(); notify->m_TokenKind = tkWinxNotify; Token * update = new Token(); update->m_TokenKind = tkWinxUpdate; for (size_t i = 0; i < tkcls->m_Children.GetCount(); i++) { Token * tk = tkcls->m_Children[i]; if (tk->m_TokenKind != tkMapping) continue; if (tk->m_Name == _T("WINX_CMDS_BEGIN") || tk->m_Name == _T("WINX_CMDS_END") || tk->m_Name == _T("WINX_CMDS_BEGIN_EX") || tk->m_Name == _T("WINX_CMDS_END_EX") || tk->m_Name == _T("WINX_CMD") || tk->m_Name == _T("WINX_CMD_EX") || tk->m_Name == _T("WINX_CMD_NOARG") || tk->m_Name == _T("WINX_CMD_RANGE") || tk->m_Name == _T("WINX_CMD_NOTIFY") ) { tk->m_pParent = cmd; cmd->AddChild(tk); } else if (tk->m_Name == _T("WINX_SYSCMD_BEGIN") || tk->m_Name == _T("WINX_SYSCMD_END") || tk->m_Name == _T("WINX_SYSCMD") ) { tk->m_pParent = syscmd; syscmd->AddChild(tk); } else if (tk->m_Name == _T("WINX_NOTIFY_BEGIN") || tk->m_Name == _T("WINX_NOTIFY_END") || tk->m_Name == _T("WINX_NOTIFY") || tk->m_Name == _T("WINX_NOTIFY_RANGE") ) { tk->m_pParent = notify; notify->AddChild(tk); } else if (tk->m_Name == _T("WINX_UPDATEUI_BEGIN") || tk->m_Name == _T("WINX_UPDATEUI_END") || tk->m_Name == _T("WINX_UPDATEUI") ) { tk->m_pParent = update; update->AddChild(tk); } } cmd->m_pParent = tkcls; syscmd->m_pParent = tkcls; notify->m_pParent = tkcls; update->m_pParent = tkcls; tkcls->AddChild(cmd); tkcls->AddChild(syscmd); tkcls->AddChild(notify); tkcls->AddChild(update); m_Tokens.Add(cmd); m_Tokens.Add(syscmd); m_Tokens.Add(notify); m_Tokens.Add(update); } }; /* //member function type enum mf_type { mf_event, mf_virtual, mf_command, mf_notify }; struct MemberFunction { CString function; mf_type type; CString GetType() { switch(type) { case mf_event: return _T("EVENT"); case mf_virtual: return _T("VIRTUAL"); case mf_command: return _T("COMMAND"); case mf_notify: return _T("NOTIFY"); } return _T(""); } }; //元素,类,资源ID struct cf_object { }; //重载消息 struct cf_message { }; //消息映射 struct cf_mapping { }; */ #endif
[ "visualfc@a5e9189f-f13e-0410-9239-ddc9d5dcfb73", "free2000fly@a5e9189f-f13e-0410-9239-ddc9d5dcfb73" ]
[ [ [ 1, 353 ], [ 355, 607 ], [ 609, 666 ], [ 668, 702 ], [ 704, 1232 ] ], [ [ 354, 354 ], [ 608, 608 ], [ 667, 667 ], [ 703, 703 ] ] ]
800b96000b8cc0feb0c185305da7faea52af5581
3bf3c2da2fd334599a80aa09420dbe4c187e71a0
/UI.cpp
93de77d59b638f42db4a6bd46a88eafca71991e9
[]
no_license
xiongchiamiov/virus-td
31b88f6a5d156a7b7ee076df55ddce4e1c65ca4f
a7b24ce50d07388018f82d00469cb331275f429b
refs/heads/master
2020-12-24T16:50:11.991795
2010-06-10T05:05:48
2010-06-10T05:05:48
668,821
1
0
null
null
null
null
UTF-8
C++
false
false
32,200
cpp
#include "UI.h" #include "Player.h" #include <stdlib.h> #define info_font GLUT_BITMAP_HELVETICA_10 #define info_font_height 12 #define info_font_bold GLUT_BITMAP_HELVETICA_12 #define info_font_bold_height 14 extern MyVector camera, newCam; extern Camera cam; extern int GH, GW; extern Player p1; extern std::vector<Button *> buttons; extern bool clicked; bool placingTower; GLdouble worldX, worldY, worldZ; //variables to hold world x,y,z coordinates extern int tlx, tly, ulx, uly; extern Player p1; int curBtn = -1; GLfloat mx,my; bool mouse_down = false; int test = 0; GLuint panel_tex; GLuint panel_tex2; GLuint panel_tex3; GLuint button_tex[18]; GLuint info_tex[10]; GLuint tower_gui_tex; GLuint tower_gui_btn[7]; bool towerSelected = false; Tower *towerSelect = NULL; struct { GLfloat width; GLfloat height; GLfloat pos[2]; GLfloat btn_pos[2]; GLfloat btn_wid; GLfloat btn_hei; } tower_select; Button::Button(int bNum, GLfloat bColor[3], GameObject * obj) { buttonNumber = bNum; color[0] = bColor[0]; color[1] = bColor[1]; color[2] = bColor[2]; gameObj = obj; } Button::~Button(void) { } void Button::drawButton(int width, int height, GLuint bIcon) { glColor3f( color[0],color[1],color[2] ); drawRectangle(0, 0, width, height, bIcon); } int Button::getButtonNumber() { return buttonNumber; } void Button::setButtonNumer(int num) { buttonNumber = num; } void Button::setButtonColor(GLfloat newColor[3]) { color[0] = newColor[0]; color[1] = newColor[1]; color[2] = newColor[2]; } GameObject * Button::getObject() { return gameObj; } void Button::setObject(GameObject * gObj){ gameObj = gObj; } void initializeUI() { panel_tex = LoadTexture("GUI.bmp"); panel_tex2 = LoadTexture("GUI2.bmp"); panel_tex3 = LoadTexture("GUI3.bmp"); tower_gui_tex = LoadTexture("tower_gui.bmp"); tower_gui_btn[0] = LoadHQTexture("tower_gui_btn_sell.bmp"); tower_gui_btn[1] = LoadHQTexture("tower_gui_btn_upgrade.bmp"); tower_gui_btn[2] = LoadHQTexture("tower_gui_btn_closest.bmp"); tower_gui_btn[3] = LoadHQTexture("tower_gui_btn_leasthealth.bmp"); tower_gui_btn[4] = LoadHQTexture("tower_gui_btn_mosthealth.bmp"); tower_gui_btn[5] = LoadHQTexture("tower_gui_btn_faster.bmp"); tower_gui_btn[6] = LoadHQTexture("tower_gui_btn_slowest.bmp"); // Unit Icons button_tex[0] = LoadHQTexture("BossUnit.bmp"); button_tex[1] = LoadHQTexture("Button.bmp"); button_tex[2] = LoadHQTexture("Button.bmp"); button_tex[3] = LoadHQTexture("StrongUnit3.bmp"); button_tex[4] = LoadHQTexture("StrongUnit2.bmp"); button_tex[5] = LoadHQTexture("StrongUnit.bmp"); button_tex[6] = LoadHQTexture("FastUnit.bmp"); button_tex[7] = LoadHQTexture("BasicUnit.bmp"); button_tex[8] = LoadHQTexture("FastUnit2.bmp"); // Tower Icons button_tex[9] = LoadHQTexture("Button.bmp"); button_tex[10] = LoadHQTexture("Button.bmp"); button_tex[11] = LoadHQTexture("Button.bmp"); button_tex[12] = LoadHQTexture("WallTower.bmp"); button_tex[13] = LoadHQTexture("TrapTower.bmp"); button_tex[14] = LoadHQTexture("StrongTower.bmp"); button_tex[15] = LoadHQTexture("FastTower.bmp"); button_tex[16] = LoadHQTexture("FreezeTower.bmp"); button_tex[17] = LoadHQTexture("BasicTower.bmp"); //button_tex = LoadTexture("SecurityIcons1.bmp"); info_tex[0] = LoadTexture("info_tlcorner.bmp"); info_tex[1] = LoadTexture("info_trcorner.bmp"); info_tex[2] = LoadTexture("info_brcorner.bmp"); info_tex[3] = LoadTexture("info_blcorner.bmp"); info_tex[4] = LoadTexture("info_tlcorner.bmp"); info_tex[5] = LoadTexture("info_middle.bmp"); info_tex[6] = LoadTexture("info_left.bmp"); info_tex[7] = LoadTexture("info_right.bmp"); info_tex[8] = LoadTexture("info_top.bmp"); info_tex[9] = LoadTexture("info_bottom.bmp"); tower_select.width = 64; tower_select.height = 256; tower_select.pos[0] = GW - 63; tower_select.pos[1] = tower_select.height - 134; tower_select.btn_wid = 48; tower_select.btn_hei = 48; tower_select.btn_pos[0] = 8; tower_select.btn_pos[1] = tower_select.height - tower_select.btn_hei - 10; } void resetUIPosition(void) { tower_select.width = 64; tower_select.height = 256; tower_select.pos[0] = GW - 63; tower_select.pos[1] = tower_select.height - 134; tower_select.btn_wid = 48; tower_select.btn_hei = 48; tower_select.btn_pos[0] = 8; tower_select.btn_pos[1] = tower_select.height - tower_select.btn_hei - 10; } void resetUI(void) { towerSelected = false; towerSelect = NULL; clicked = false; placingTower = false; test = -1; } int bin(int num){/* start bin */ int binary = 0; int place = 0; while (num != 0) { binary = binary + (num%2 * pow(10.0f, place)); num = num /2; place = place + 1; } return binary; } bool towerSelectOverButton(int mx, int my, int i) { if(mx < tower_select.pos[0] + tower_select.btn_pos[0] || mx > tower_select.pos[0] + tower_select.btn_pos[0] + tower_select.btn_wid) return false; if(my < tower_select.pos[1] + tower_select.btn_pos[1] - (i * (tower_select.btn_hei + 8)) || my > tower_select.pos[1] + tower_select.btn_pos[1] + tower_select.btn_hei - (i * (tower_select.btn_hei + 8))) return false; return true; } bool towerSelectInPanel(int mx, int my) { if(mx < tower_select.pos[0] || mx > tower_select.pos[0] + tower_select.width) return false; if(my < tower_select.pos[1] || my > tower_select.pos[1] + tower_select.height) return false; return true; } void handleTowerSelectClick(int mx, int my) { if(!towerSelected) return; if(towerSelectOverButton(mx,my,0)) { towerSelect->setTargetMode((target_mode)((towerSelect->getTargetMode() + 1) % 5)); } else if(towerSelectOverButton(mx,my,1)) { p1.sellTower(towerSelect->getGridX(),towerSelect->getGridY()); towerSelected = false; towerSelect = NULL; } else if(towerSelectOverButton(mx,my,2)) { p1.upgradeTower(towerSelect->getGridX(),towerSelect->getGridY()); towerSelected = false; towerSelect = NULL; } } void drawTowerSelectInfo(int mx, int my, int btnNumb) { glDisable(GL_LIGHTING); glColor3f(1.0,1.0,1.0); const int sep = 12; char title[100]; char title2[100]; char info[400]; if(btnNumb == 0) { int t = (int)towerSelect->getTargetMode(); const char *mode = (t == 0 ? "Lowest Health" : (t == 1 ? "Highest Health" : (t == 2 ? "Fastest" : (t == 3 ? "Slowest" : "Closest")))); const char *curMode = t == 0 ? "Closest" : t == 1 ? "Lowest Health" : t == 2 ? "Highest Health" : t == 3 ? "Fastest" : "Slowest"; sprintf(title2,"Switch To: %s",mode); sprintf(title,"Current Mode: %s",curMode); if(t == 0) sprintf(info,"In Closest Mode, your tower will attack\nthe closest enemy to itself"); else if (t == 1) sprintf(info,"In Lowest Health Mode, your tower will attack\nthe enemywith the lowest amount of health"); else if (t == 2) sprintf(info,"In Highest Health Mode, your tower will attack\nthe enemy with the highest amount of health"); else if (t == 3) sprintf(info,"In Fastest Mode, your tower will prefer to attack\nfaster units"); else if (t == 4) sprintf(info,"In Slowest Mode, your tower will prefer to attack\nslower units"); } else if(btnNumb == 1) { int sellValue(0); switch(towerSelect->getType()){ case T_BASIC: sellValue = tower_cost::BASIC; break; case T_FREEZE: sellValue = tower_cost::FREEZE; break; case T_FAST: sellValue = tower_cost::FAST; break; case T_SLOW: sellValue = tower_cost::SLOW; break; case T_TRAP: sellValue = tower_cost::TRAP; break; case T_WALL: sellValue = tower_cost::WALL; break; } sellValue = (sellValue * (towerSelect->getStage()+1))/2; sprintf(title,"Sell Tower"); sprintf(title2,"Refund Value: %d bytes",sellValue); sprintf(info,"Sell your tower back to clear up the grid or\nmake a quick profit"); } else { int buyValue(0); switch(towerSelect->getType()){ case T_BASIC: buyValue = tower_cost::BASIC; break; case T_FREEZE: buyValue = tower_cost::FREEZE; break; case T_FAST: buyValue = tower_cost::FAST; break; case T_SLOW: buyValue = tower_cost::SLOW; break; case T_TRAP: buyValue = tower_cost::TRAP; break; case T_WALL: buyValue = tower_cost::WALL; break; } sprintf(title,"Upgrade Tower"); sprintf(title2,"Upgrade Cost: %d bytes",buyValue); sprintf(info,"Upgrade your tower to make it even more powerful\nagainst your enemies"); } int len = 1; for(char* c = &info[0]; *c != '\0'; c++) { if (*c == '\n') len++; } float w = (float)max((double)getBitmapStringWidth(info_font,info),80.0); float h = 2*sep + 4 + len*info_font_height; int yp = my + h + (btnNumb*64.0); float xp = mx - w/2; if(xp + w + 16 > GW) xp = GW - w - 16; else if (xp < 16) xp = 16; glColor3f(1.0,1.0,1.0); renderBitmapString(xp, yp, info_font_bold, title); yp -= (sep+2); renderBitmapString(xp, yp, info_font_bold, title2); yp -= (sep + 4); renderBitmapString(xp, yp, info_font, info); yp = my + h + (btnNumb*64.0); glPushMatrix(); glTranslatef(0,0,0.1); //Draw Corners //TL drawRectangle(xp - 8,yp + 2,16,16,info_tex[3]); //TR drawRectangle(xp + w - 8,yp + 2,16,16,info_tex[2]); //BR drawRectangle(xp + w - 8,yp + 2 - h,16,16,info_tex[1]); //BL drawRectangle(xp - 8,yp + 2 - h,16,16,info_tex[0]); //Top drawRectangle(xp - 8 + 16,yp + 2,w - 16,16,info_tex[9]); //Bottom drawRectangle(xp - 8 + 16,yp + 2 - h,w - 16,16,info_tex[8]); //Left drawRectangle(xp - 8,yp + 2 + 16 - h,16,h - 16,info_tex[6]); //Right drawRectangle(xp + w - 8,yp + 2 + 16 - h,16,h - 16,info_tex[7]); //Middle drawRectangle(xp - 8 + 16,yp + 2 + 16 - h,w - 16,h - 16,info_tex[5]); glPopMatrix(); glEnable(GL_LIGHTING); } void drawTowerSelect(int mx, int my) { if(!towerSelected) return; glColor3f(1.0,1.0,1.0); glPushMatrix(); glTranslatef(0.0,0.0,-0.01); drawRectangle(tower_select.pos[0],tower_select.pos[1],64,256,tower_gui_tex); glPopMatrix(); glPushMatrix(); GLfloat cVal = 0.6; if(towerSelectOverButton(mx,my,0)) { if(mouse_down) cVal = 0.3; else { drawTowerSelectInfo(mx,my,0); cVal = 1.0; } } glColor3f(cVal,cVal,cVal); drawRectangle(tower_select.pos[0] + tower_select.btn_pos[0],tower_select.pos[1] + tower_select.btn_pos[1],48,48,tower_gui_btn[2 + (int)towerSelect->getTargetMode()]); glTranslatef(0.0,-tower_select.btn_hei-8.0,0.0); if(towerSelectOverButton(mx,my,1)) { if(mouse_down) cVal = 0.3; else { drawTowerSelectInfo(mx,my,1); cVal = 1.0; } } else cVal = 0.6; glColor3f(cVal,cVal,cVal); drawRectangle(tower_select.pos[0] + tower_select.btn_pos[0],tower_select.pos[1] + tower_select.btn_pos[1],48,48,tower_gui_btn[0]); glTranslatef(0.0,-tower_select.btn_hei-8.0,0.0); if(towerSelectOverButton(mx,my,2)) { if(mouse_down) cVal = 0.3; else { drawTowerSelectInfo(mx,my,2); cVal = 1.0; } } else cVal = 0.6; glColor3f(cVal,cVal,cVal); drawRectangle(tower_select.pos[0] + tower_select.btn_pos[0],tower_select.pos[1] + tower_select.btn_pos[1],48,48,tower_gui_btn[1]); glPopMatrix(); } void renderUI(int w, int h,Player* p, Player* opp, float time_left, GLuint mode) { if(towerSelected && towerSelect != NULL && towerSelect->isDead()) { towerSelected = false; towerSelect = NULL; } int bNumber = 0; setOrthographicProjection(w, h); glPushMatrix(); glLoadIdentity(); // Draws left Panel + 9 Buttons glPushMatrix(); glColor4f( 1.0, 1.0, 1.0, 1.0 ); drawPanel(200, 200, panel_tex); for (int i = 0; i < 3; i++) { if (i == 0) { glTranslatef(0, 5, 0.01); } else { glTranslatef(0, 65, 0); } glPushMatrix(); glTranslatef(5, 0, 0); buttons.at(bNumber)->drawButton(50, 50, button_tex[bNumber]); bNumber++; glTranslatef(65, 0, 0); buttons.at(bNumber)->drawButton(50, 50, button_tex[bNumber]); bNumber++; glTranslatef(65, 0, 0); buttons.at(bNumber)->drawButton(50, 50, button_tex[bNumber]); bNumber++; glPopMatrix(); } glPopMatrix(); // Draws right panel + 9 buttons glPushMatrix(); //setMaterial(Black); glTranslatef(w - 200, 0, 0); glColor4f( 1.0, 1.0, 1.0, 1.0 ); drawPanel(200, 200, panel_tex2); glTranslatef(140, 0, 0); //setMaterial(Teal); for (int i = 0; i < 3; i++) { if (i == 0) { glTranslatef(0, 5, 0.01); } else { glTranslatef(0, 65, 0); } glPushMatrix(); glTranslatef(5, 0, 0); buttons.at(bNumber)->drawButton(50, 50, button_tex[bNumber]); bNumber++; glTranslatef(-65, 0, 0); buttons.at(bNumber)->drawButton(50, 50, button_tex[bNumber]); bNumber++; glTranslatef(-65, 0, 0); buttons.at(bNumber)->drawButton(50, 50, button_tex[bNumber]); bNumber++; glPopMatrix(); } glPopMatrix(); glPushMatrix(); glLoadIdentity(); glPushMatrix(); glTranslatef(200.0,0.0,0.0); glColor3f(1.0,1.0,1.0); drawPanel(w - 400.0, 128, panel_tex3); glPopMatrix(); if(towerSelected) { drawTowerSelect(mx,my); } glDisable(GL_LIGHTING); //Shared by text and tower select GUI char str[200]; const int yp = 92; const int xp = 212; glColor3f(0.0,1.0,1.0); sprintf( str, "Lives: %d", p->getLives() ); renderBitmapString(xp, yp, GLUT_BITMAP_9_BY_15 , str); glColor3f(1.0,1.0,0.0); sprintf( str, "Income: %d", p->getIncome() ); renderBitmapString(xp, yp - 22.0, GLUT_BITMAP_9_BY_15 , str); sprintf( str, "Bytes: %d", p->getResources() ); renderBitmapString(xp, yp - 2*22.0, GLUT_BITMAP_9_BY_15 , str); //sprintf( str, "Next Byte Deposit In: %2.0f", ceil(time_left) ); glColor3f(0.0,1.0,0.0); sprintf( str, "Next Byte Deposit In: %04d", bin(ceil(time_left))); renderBitmapString(xp, yp - 3*22, GLUT_BITMAP_9_BY_15 , str); glColor3f(1.0,0.0,0.0); sprintf( str, "Enemy Lives: %d", opp->getLives() ); renderBitmapString(w - 338, yp, GLUT_BITMAP_9_BY_15 , str); //renderBitmapString(1.0 * GW / 4.0, H - 25, GLUT_BITMAP_TIMES_ROMAN_24 , "Time until next wave:"); //renderBitmapString(1.0 * GW / 4.0, 20.0, GLUT_BITMAP_TIMES_ROMAN_24 , "Currency:"); if(curBtn != -1) drawInfoPanel(mx,my,GW,GH,curBtn); glEnable(GL_LIGHTING); glPopMatrix(); glPopMatrix(); resetPerspectiveProjection(); } void setOrthographicProjection(int w, int h) { // switch to projection mode glMatrixMode(GL_PROJECTION); // save previous matrix which contains the //settings for the perspective projection glPushMatrix(); // reset matrix glLoadIdentity(); // set a 2D orthographic projection glOrtho(0, w, 0, h, -5, 5); // invert the y axis, down is positive // glScalef(1, -1, 1); // mover the origin from the bottom left corner // to the upper left corner // glTranslatef(0, -h, 0); glMatrixMode(GL_MODELVIEW); } void resetPerspectiveProjection() { glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } /* * param xp: x start point * param yp: y start point * param w: width * param h: height */ void drawRectangle(float xp, float yp, float w, float h, GLuint texture) { glDisable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); glBegin(GL_QUADS); glTexCoord2f(0.0,0.0); glVertex2f(xp,yp); glTexCoord2f(1.0,0.0); glVertex2f(xp+w,yp); glTexCoord2f(1.0,1.0); glVertex2f(xp+w,yp+h); glTexCoord2f(0.0,1.0); glVertex2f(xp,yp+h); glEnd(); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); } void drawMouseBox(bool click) { if (click) { double xForm, yForm; glPushMatrix(); setMaterial(Teal); xForm = (worldX );//+ cam.getCamX() - newCam.getX()); yForm = (worldZ );//+ cam.getCamZ() - newCam.getZ() + 0.5); // tly and tlx increment in 0.5 not 1 // tlx and tly are the actual draw line location tlx = xForm * 2 + 7; // weird offset tly = yForm/*((int)worldZ + cam.getCamZ() - newCam.getZ())*/ * 2 + 15; ulx = tlx; uly = tly; glTranslatef(xForm, (int)worldY, yForm); if (test <= 17 && test >= 12/* 11 to 9 missing */) { // tower on cursor buttons.at(test)->getObject()->draw(); } /*else if (test == 8 && test) { // unit on cursor buttons.at(test)->getObject()->draw(); }*/ glPopMatrix(); } } void drawPanel(int w, int h, GLuint texture) { drawRectangle(0, 0, w, h, texture); } /* info_tex[0] = LoadTexture("info_tlcorner.bmp"); info_tex[1] = LoadTexture("info_trcorner.bmp"); info_tex[2] = LoadTexture("info_brcorner.bmp"); info_tex[3] = LoadTexture("info_blcorner.bmp"); info_tex[4] = LoadTexture("info_tlcorner.bmp"); info_tex[5] = LoadTexture("info_middle.bmp"); info_tex[6] = LoadTexture("info_left.bmp"); info_tex[7] = LoadTexture("info_right.bmp"); info_tex[8] = LoadTexture("info_top.bmp"); info_tex[9] = LoadTexture("info_bottom.bmp"); */ void drawInfoPanel(GLfloat x, GLfloat y, GLfloat GW, GLfloat GH, int buttonNumber) { glColor3f(1.0,1.0,1.0); char name[80]; const int sep = 12; /* Button number layout 6 7 8 17 16 15 3 4 5 14 13 12 0 1 2 11 10 9 */ if(buttonNumber < 0 || buttonNumber > 17 || buttonNumber == 2 || buttonNumber == 1 || buttonNumber == 11 || buttonNumber == 10 || buttonNumber == 9) { return; } if(buttonNumber >= 0 && buttonNumber <= 17) { /* Button Number layout changed if the following button conversion was not commented out . 11 10 9 0 1 2 14 13 12 3 4 5 17 16 15 6 7 8 //////// buttonNumber = 8 - (buttonNumber - 9); //////// */ strcpy(name,getObjectName(buttonNumber)); // strcat(name," Tower"); char desc[400]; char cost[30]; char damageheatlh[30]; char speed[30]; strcpy(desc,getObjectDescription(buttonNumber)); int len = 1; for(char* c = &desc[0]; *c != '\0'; c++) { if (*c == '\n') len++; } sprintf( cost, "Cost: %d", getObjectCost(buttonNumber) ); if(buttonNumber <= 8) { sprintf( damageheatlh, "Health: %d", getObjectDamageHealth(buttonNumber) ); } else { sprintf( damageheatlh, "Damage: %d", getObjectDamageHealth(buttonNumber) ); } sprintf( speed, "Speed: %d", getObjectSpeed(buttonNumber) ); //float w = (float)getBitmapStringWidth(info_font_bold,name); float w = (float)max((double)getBitmapStringWidth(info_font,desc),80.0); float h = 4*sep + 4 + len*info_font_height; int yp = y + h; float xp = x - w/2; if(xp + w + 16 > GW) xp = GW - w - 16; else if (xp < 16) xp = 16; glColor3f(1.0,1.0,1.0); renderBitmapString(xp, yp, info_font_bold, name); yp -= sep; renderBitmapString(xp, yp, info_font, cost); yp -= sep; renderBitmapString(xp, yp, info_font, damageheatlh); yp -= sep; renderBitmapString(xp, yp, info_font, speed); yp -= (sep + 4); renderBitmapString(xp, yp, info_font, desc); yp = y + h; glPushMatrix(); glTranslatef(0,0,0.1); //Draw Corners //TL drawRectangle(xp - 8,yp + 2,16,16,info_tex[3]); //TR drawRectangle(xp + w - 8,yp + 2,16,16,info_tex[2]); //BR drawRectangle(xp + w - 8,yp + 2 - h,16,16,info_tex[1]); //BL drawRectangle(xp - 8,yp + 2 - h,16,16,info_tex[0]); //Top drawRectangle(xp - 8 + 16,yp + 2,w - 16,16,info_tex[9]); //Bottom drawRectangle(xp - 8 + 16,yp + 2 - h,w - 16,16,info_tex[8]); //Left drawRectangle(xp - 8,yp + 2 + 16 - h,16,h - 16,info_tex[6]); //Right drawRectangle(xp + w - 8,yp + 2 + 16 - h,16,h - 16,info_tex[7]); //Middle drawRectangle(xp - 8 + 16,yp + 2 + 16 - h,w - 16,h - 16,info_tex[5]); glPopMatrix(); } } void mouseClick(int button, int state, int x, int y) { int click = determineClickedButton(x, GH - y); if (button == GLUT_RIGHT_BUTTON && clicked && test >= 9 && test <= 17) { clicked = false; placingTower = false; } else if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { mouse_down = true; /* !!!!!! remember to invert y with (GH - y) so that it is on the bottom instead of the top */ //fprintf(stderr, "click: x: %d y: %d\n", x, GH- y); if (clicked == true) { if (test >= 9 && test <= 17 && click == -1) { p1.placeTower(tlx, tly, test); placingTower = false; } clicked = false; } else { if (click >= 9 && click <= 17) { placingTower = true; clicked = true; } else if (!towerSelectInPanel(x,GH-y)) { GLuint id = checkTowerClick(x, y); //printf("Clicked: %d\n", id); if(id != INT_MAX && id > 0) { std::list<Tower*> tList = p1.getTowerList(); std::list<Tower*>::iterator i = tList.begin(); for(int j = 1; j < id; ++j) i++; towerSelect = *(i); towerSelected = true; } else { towerSelected = false; towerSelect = NULL; } } } test = click; if (test != -1) { GLfloat col[] = {0.6,0.6,0.6}; buttons.at(test)->setButtonColor(col); } } else if (button == GLUT_LEFT_BUTTON && state == GLUT_UP) { mouse_down = false; if (test != -1) { GLfloat col[] = {1.0,1.0,1.0}; buttons.at(test)->setButtonColor(col); if (click >= 0 && click <= 8) { p1.spawnUnit(click); clicked = false; } } else if (towerSelectInPanel(x,GH-y)) { handleTowerSelectClick(x,GH-y); } } glutPostRedisplay(); } GLuint checkTowerClick(int x, int y) { std::list<Tower*> tList = p1.getTowerList(); if(tList.size() == 0) return 0; // PICKING const int BUFSIZE = 512; GLuint selectBuf[BUFSIZE]; /* gl selection code */ startPicking(x, y, selectBuf, BUFSIZE); gluLookAt(cam.getCamX(), cam.getCamY(), cam.getCamZ(), cam.getLookAtX(), cam.getLookAtY(), cam.getLookAtZ(), 0.0, 1.0, 0.0); // FIX: for some reason cant do p1.pGrid.draw(true, GL_SELECT); //Fixed =) //p1.draw(true, GL_SELECT); // GL_RENDER for normal, GL_SELECT for picking. glPushMatrix(); MyVector p = p1.getPosition(); glTranslatef(p.getX(), p.getY(), p.getZ()); //p1.pGrid.draw(true,GL_SELECT); std::list<Tower*>::iterator i; int id = 1; for(i = tList.begin(); i != tList.end(); ++i){ if(!(*i)->isDead() && !p1.cull(*i)){ (*i)->draw(id,GL_SELECT); } id++; } glPopMatrix(); int hits = stopPicking(); return processTowerHits(hits,selectBuf); } void mouseMotion(int x, int y) { mx = x; my = GH - y; if (clicked && test >= 9 && test <= 17) { #if 0 // Mouse clicking using gluUnProject GLint viewport[4]; //var to hold the viewport info GLdouble modelview[16]; //var to hold the modelview info GLdouble projection[16]; //var to hold the projection matrix info GLdouble nearv[3], farv[3]; //variables to hold screen x,y,z coordinates glGetDoublev( GL_MODELVIEW_MATRIX, modelview ); //get the modelview info glGetDoublev( GL_PROJECTION_MATRIX, projection ); //get the projection matrix info glGetIntegerv( GL_VIEWPORT, viewport ); //get the viewport info //get the world coordinates from the screen coordinates // Everything below may break if window or camera changes direction gluUnProject( x, viewport[1] + viewport[3] - y, 0.95, modelview, projection, viewport, &nearv[0], &nearv[1], &nearv[2]); gluUnProject( x, viewport[1] + viewport[3] - y, 0.976, modelview, projection, viewport, &farv[0], &farv[1], &farv[2]); //cout << "nearv[0]: " << nearv[0] << " nearv[1]: " << nearv[1] << " nearv[2]: " << nearv[2] << endl; //cout << "farv[0]: " << farv[0] << " farv[1]: " << farv[1] << " farv[2]: " << farv[2] << endl; // GLfloat xt = (nearv[0] - z) / (nearv[0] - farv[0]); // yt = (nearv[1] - z) / (nearv[1] - farv[1]); worldX = nearv[0] + (farv[0] - nearv[0]) * ((float)x / (float)GW), worldZ = nearv[1] + (farv[1] - nearv[1]) * ((float)y / (float)GH); float xTemp, yTemp; // everythign below reorients the screen so there is -0.5x to 0.5x and -0.5 y to 0.5y // then it calculates mouse position xTemp = x - (GW / 2); yTemp = (GH - y) - (GH / 3.2); if (xTemp <= (GW / 2.5) && xTemp >= 0) { xTemp = (GW / 2.5); } if (xTemp >= -(GW / 2) && xTemp < 0) { xTemp = -(GW / 2); } if (yTemp <= (GH / 3.2) && yTemp >= 0) { yTemp = (GH / 3.2); } if (yTemp >= -(GH / 3.4) && yTemp < 0) { yTemp = -(GH / 3.4); } if (xTemp >= 0) { worldX = (nearv[0] * ((float)xTemp / ((float)GW / 2))); } else { worldX = -(nearv[0] * ((float)xTemp / ((float)GW / 2))); } if (yTemp >= 0) { worldZ = -(farv[1] * ((float)yTemp / ((float)GH / 2))); } else { worldZ = (farv[1] * ((float)yTemp / ((float)GH / 2))); } worldY = 0; // fprintf(stderr, "xTemp: %f yTemp: %f %.2lf, %.2lf\n", xTemp, yTemp, worldX, worldZ); #endif // PICKING const int BUFSIZE = 512; GLuint selectBuf[BUFSIZE]; /* gl selection code */ startPicking(x + 16, y + 16, selectBuf, BUFSIZE); gluLookAt(cam.getCamX(), cam.getCamY(), cam.getCamZ(), cam.getLookAtX(), cam.getLookAtY(), cam.getLookAtZ(), 0.0, 1.0, 0.0); // FIX: for some reason cant do p1.pGrid.draw(true, GL_SELECT); //Fixed =) //p1.draw(true, GL_SELECT); // GL_RENDER for normal, GL_SELECT for picking. glPushMatrix(); MyVector p = p1.getPosition(); glTranslatef(p.getX(), p.getY(), p.getZ()); p1.pGrid.draw(true,GL_SELECT); glPopMatrix(); int hits = stopPicking(); processHits(hits,selectBuf); } int btn = determineClickedButton(x,GH- y); if(curBtn != -1 && btn != curBtn) { GLfloat col[] = {0.8,0.8,0.8}; buttons.at(curBtn)->setButtonColor(col); } if(btn != -1) { GLfloat col[] = {1.0,1.0,1.0}; buttons.at(btn)->setButtonColor(col); } curBtn = btn; glutPostRedisplay(); } void startPicking(int cursorX, int cursorY, GLuint buffer[], int buffSize) { GLint viewport[4]; glGetIntegerv(GL_VIEWPORT,viewport); glSelectBuffer(buffSize, buffer); (void) glRenderMode(GL_SELECT); glInitNames(); glPushName(0); glPushMatrix(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // 3 and 4th parameters define the pick ray granularity gluPickMatrix((GLdouble)cursorX, (GLdouble)viewport[3]-cursorY, 0.01, 0.01, viewport); gluPerspective(45.0, 1.0 * viewport[2] / viewport[3], 1.0, 100.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } GLint stopPicking(void) { GLint hits; GLint viewport[4]; glGetIntegerv(GL_VIEWPORT,viewport); // restoring the original projection matrix glPopMatrix(); glFlush(); // returning to normal rendering mode hits = glRenderMode(GL_RENDER); // if there are hits process them glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0, 1.0 * viewport[2] / viewport[3], 1.0, 100.0); return hits; } void processHits(GLint hits, GLuint buffer[]) { // this function goes through the selection hit list of object names int i; GLuint *ptr, *closestPtr; GLfloat closestFront = 0.0; //printf("hits = %d\n", hits); if(hits==0) { // printf("You have not selected any object.\n"); // if the grid uses -INT_MAX this value must be changed worldX = -INT_MAX; // this value is just to ensure we really cant place anything on the grid. worldZ = -INT_MAX; // this value is just to ensure we really cant place anything on the grid. worldY = 10; // invalid location draws tower at a location higher than camera limit } ptr = (GLuint *) buffer; for(i=0; i<hits; i++) { ptr++; // printf(" front at %g\n",(float) *ptr/0x7fffffff); if (closestFront == 0.0 || ((float) *ptr/0x7fffffff < closestFront)) { closestFront = (float) *ptr/0x7fffffff; closestPtr = ptr+2; } ptr++; // printf(" back at = %g\n",(float) *ptr/0x7fffffff); ptr++; if(ptr) { // printf("You have picked the %d.\n", *ptr); // cout << "x: " << (*ptr % GRID_WIDTH * GRID_SIZE * 2) << " y: " << (*ptr / GRID_WIDTH * GRID_SIZE * 2) << endl; worldX = ((*ptr % GRID_WIDTH) * (GRID_SIZE * 2) - ((GRID_WIDTH / 2) * (GRID_SIZE * 2))); worldZ = ((*ptr / GRID_WIDTH) * (GRID_SIZE * 2) - ((GRID_HEIGHT / 2) * (GRID_SIZE * 2))); worldY = 0; } else { worldX = -INT_MAX; // this value is just to ensure we really cant place anything on the grid. worldZ = -INT_MAX; // this value is just to ensure we really cant place anything on the grid. worldY = 10; // invalid location draws tower at a location higher than camera limit } // draw at a set location when tower placing is at an incorrect location if (*ptr >= GRID_HEIGHT * GRID_WIDTH) { worldX = -INT_MAX; // this value is just to ensure we really cant place anything on the grid. worldZ = -INT_MAX; // this value is just to ensure we really cant place anything on the grid. worldY = 10; // invalid location draws tower at a location higher than camera limit } ptr++; } // printf("**************************************************************\n"); } GLuint processTowerHits(GLint hits, GLuint buffer[]) { // this function goes through the selection hit list of object names int i; GLuint *ptr, *closestPtr; GLfloat closestFront = 0.0; //printf("hits = %d\n", hits); if(hits==0) { //printf("You have not selected any object.\n"); // if the grid uses -INT_MAX this value must be changed worldX = -INT_MAX; // this value is just to ensure we really cant place anything on the grid. worldZ = -INT_MAX; // this value is just to ensure we really cant place anything on the grid. worldY = 10; // invalid location draws tower at a location higher than camera limit } ptr = (GLuint *) buffer; for(i=0; i<hits; i++) { ptr++; //printf(" front at %g\n",(float) *ptr/0x7fffffff); if (closestFront == 0.0 || ((float) *ptr/0x7fffffff < closestFront)) { closestFront = (float) *ptr/0x7fffffff; closestPtr = ptr+2; } ptr++; //printf(" back at = %g\n",(float) *ptr/0x7fffffff); ptr++; if(ptr) { // printf("You have picked the %d.\n", *ptr); //cout << "You selected: " << *ptr << endl; return *ptr; } ptr++; } return 0; //printf("**************************************************************\n"); } /* * This function takes the window coordinates of a mouse click * and determiens which GUI button was clicked. * (This function may break if window size is changed) * * @return the button number (0 - 17) or -1 if there is no button. */ int determineClickedButton(int mouseX, int mouseY) { int buttonNum = 0; /* Option 1: button number layout 6 7 8 17 16 15 3 4 5 14 13 12 0 1 2 11 10 9 */ for (int i = 65; i <= 195; i+=65) { for (int j = 65; j <= 195; j+=65) { if (mouseY <= i && mouseX <= j) { return buttonNum; } else { buttonNum++; } } } for (int i = 65; i <= 195; i+=65) { for (int j = GW - 65; j >= GW - 195; j-=65) { if (mouseY <= i && mouseX >= j) { return buttonNum; } else { buttonNum++; } } } return -1; } void renderBitmapString(float x, float y, void *font,char *string) { glPushMatrix(); char *c; glRasterPos3f(x, y, 0.1); for (c=string; *c != '\0'; c++) { if(*c == '\n') { y -= info_font_height; glRasterPos3f(x, y, 0.1); } else glutBitmapCharacter(font, *c); } glPopMatrix(); } int getBitmapStringWidth(void *font,char *string) { int w = 0; int maxW = 0; char *c; for (c=string; *c != '\0'; c++) { if(*c == '\n') { if(w > maxW) maxW = w; w = 0; } else w += glutBitmapWidth(font, *c); } if(w > maxW) return w; return maxW; } float p2w_x(int x){ float scale = ((float)2 / GH); float transform = (-1 * ((float)GW / GH)) + (1 / (float)GH); return ((scale * x) + transform); } float p2w_y(int y){ float scale = ((float) 2 / GH); float transform = (1 / (float) GH) + (-1); return ((y * scale) + transform); }
[ "kehung@05766cc9-4f33-4ba7-801d-bd015708efd9", "tcasella@05766cc9-4f33-4ba7-801d-bd015708efd9", "agonza40@05766cc9-4f33-4ba7-801d-bd015708efd9" ]
[ [ [ 1, 4 ], [ 10, 10 ], [ 12, 12 ], [ 14, 15 ], [ 17, 19 ], [ 23, 23 ], [ 27, 27 ], [ 33, 33 ], [ 50, 55 ], [ 58, 60 ], [ 62, 62 ], [ 64, 64 ], [ 66, 67 ], [ 72, 74 ], [ 76, 78 ], [ 80, 81 ], [ 142, 142 ], [ 210, 211 ], [ 384, 384 ], [ 391, 394 ], [ 400, 400 ], [ 493, 508 ], [ 510, 511 ], [ 513, 522 ], [ 529, 529 ], [ 548, 550 ], [ 574, 575 ], [ 578, 579 ], [ 605, 605 ], [ 614, 614 ], [ 621, 621 ], [ 627, 627 ], [ 634, 634 ], [ 686, 686 ], [ 793, 795 ], [ 799, 799 ], [ 861, 862 ], [ 901, 906 ], [ 908, 910 ], [ 912, 913 ], [ 922, 923 ], [ 926, 927 ], [ 929, 929 ], [ 932, 932 ], [ 934, 935 ], [ 940, 943 ], [ 951, 951 ], [ 953, 953 ], [ 963, 963 ], [ 971, 971 ], [ 976, 976 ], [ 996, 996 ], [ 1041, 1043 ], [ 1050, 1050 ], [ 1081, 1083 ], [ 1114, 1116 ], [ 1120, 1122 ], [ 1126, 1126 ] ], [ [ 5, 9 ], [ 13, 13 ], [ 16, 16 ], [ 20, 22 ], [ 24, 26 ], [ 28, 32 ], [ 34, 49 ], [ 56, 57 ], [ 61, 61 ], [ 63, 63 ], [ 65, 65 ], [ 68, 71 ], [ 75, 75 ], [ 79, 79 ], [ 82, 141 ], [ 143, 209 ], [ 212, 383 ], [ 385, 390 ], [ 395, 399 ], [ 401, 492 ], [ 509, 509 ], [ 512, 512 ], [ 523, 528 ], [ 530, 547 ], [ 551, 573 ], [ 576, 577 ], [ 580, 604 ], [ 606, 613 ], [ 615, 620 ], [ 622, 626 ], [ 628, 633 ], [ 635, 685 ], [ 687, 753 ], [ 755, 756 ], [ 758, 765 ], [ 767, 768 ], [ 770, 772 ], [ 774, 792 ], [ 796, 798 ], [ 800, 860 ], [ 863, 900 ], [ 907, 907 ], [ 911, 911 ], [ 914, 921 ], [ 924, 925 ], [ 928, 928 ], [ 930, 931 ], [ 933, 933 ], [ 936, 939 ], [ 944, 950 ], [ 952, 952 ], [ 954, 962 ], [ 964, 970 ], [ 972, 975 ], [ 977, 995 ], [ 997, 1040 ], [ 1044, 1049 ], [ 1051, 1080 ], [ 1084, 1113 ], [ 1117, 1119 ], [ 1123, 1125 ] ], [ [ 11, 11 ], [ 754, 754 ], [ 757, 757 ], [ 766, 766 ], [ 769, 769 ], [ 773, 773 ] ] ]
b8361ce63a742a05ed65596895906ddf1d16a372
b14d5833a79518a40d302e5eb40ed5da193cf1b2
/cpp/extern/crypto++/5.2.1/wait.cpp
06493d657277f044914673416beea2143d04e2ab
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-cryptopp" ]
permissive
andyburke/bitflood
dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf
fca6c0b635d07da4e6c7fbfa032921c827a981d6
refs/heads/master
2016-09-10T02:14:35.564530
2011-11-17T09:51:49
2011-11-17T09:51:49
2,794,411
1
0
null
null
null
null
UTF-8
C++
false
false
8,516
cpp
// wait.cpp - written and placed in the public domain by Wei Dai #include "pch.h" #include "wait.h" #include "misc.h" #ifdef SOCKETS_AVAILABLE #ifdef USE_BERKELEY_STYLE_SOCKETS #include <errno.h> #include <sys/types.h> #include <sys/time.h> #include <unistd.h> #endif #define TRACE_WAIT 0 #if TRACE_WAIT #include "hrtimer.h" #endif NAMESPACE_BEGIN(CryptoPP) unsigned int WaitObjectContainer::MaxWaitObjects() { #ifdef USE_WINDOWS_STYLE_SOCKETS return MAXIMUM_WAIT_OBJECTS * (MAXIMUM_WAIT_OBJECTS-1); #else return FD_SETSIZE; #endif } WaitObjectContainer::WaitObjectContainer() #if CRYPTOPP_DETECT_NO_WAIT : m_sameResultCount(0), m_timer(Timer::MILLISECONDS) #endif { Clear(); } void WaitObjectContainer::Clear() { #ifdef USE_WINDOWS_STYLE_SOCKETS m_handles.clear(); #else m_maxFd = 0; FD_ZERO(&m_readfds); FD_ZERO(&m_writefds); #endif m_noWait = false; } void WaitObjectContainer::SetNoWait() { #if CRYPTOPP_DETECT_NO_WAIT if (-1 == m_lastResult && m_timer.ElapsedTime() > 1000) { if (m_sameResultCount > m_timer.ElapsedTime()) try {throw 0;} catch (...) {} // possible no-wait loop, break in debugger m_timer.StartTimer(); } #endif m_noWait = true; } #ifdef USE_WINDOWS_STYLE_SOCKETS struct WaitingThreadData { bool waitingToWait, terminate; HANDLE startWaiting, stopWaiting; const HANDLE *waitHandles; unsigned int count; HANDLE threadHandle; DWORD threadId; DWORD* error; }; WaitObjectContainer::~WaitObjectContainer() { try // don't let exceptions escape destructor { if (!m_threads.empty()) { HANDLE threadHandles[MAXIMUM_WAIT_OBJECTS]; unsigned int i; for (i=0; i<m_threads.size(); i++) { WaitingThreadData &thread = *m_threads[i]; while (!thread.waitingToWait) // spin until thread is in the initial "waiting to wait" state Sleep(0); thread.terminate = true; threadHandles[i] = thread.threadHandle; } PulseEvent(m_startWaiting); ::WaitForMultipleObjects(m_threads.size(), threadHandles, TRUE, INFINITE); for (i=0; i<m_threads.size(); i++) CloseHandle(threadHandles[i]); CloseHandle(m_startWaiting); CloseHandle(m_stopWaiting); } } catch (...) { } } void WaitObjectContainer::AddHandle(HANDLE handle) { #if CRYPTOPP_DETECT_NO_WAIT if (m_handles.size() == m_lastResult && m_timer.ElapsedTime() > 1000) { if (m_sameResultCount > m_timer.ElapsedTime()) try {throw 0;} catch (...) {} // possible no-wait loop, break in debugger m_timer.StartTimer(); } #endif m_handles.push_back(handle); } DWORD WINAPI WaitingThread(LPVOID lParam) { std::auto_ptr<WaitingThreadData> pThread((WaitingThreadData *)lParam); WaitingThreadData &thread = *pThread; std::vector<HANDLE> handles; while (true) { thread.waitingToWait = true; ::WaitForSingleObject(thread.startWaiting, INFINITE); thread.waitingToWait = false; if (thread.terminate) break; if (!thread.count) continue; handles.resize(thread.count + 1); handles[0] = thread.stopWaiting; std::copy(thread.waitHandles, thread.waitHandles+thread.count, handles.begin()+1); DWORD result = ::WaitForMultipleObjects(handles.size(), &handles[0], FALSE, INFINITE); if (result == WAIT_OBJECT_0) continue; // another thread finished waiting first, so do nothing SetEvent(thread.stopWaiting); if (!(result > WAIT_OBJECT_0 && result < WAIT_OBJECT_0 + handles.size())) { assert(!"error in WaitingThread"); // break here so we can see which thread has an error *thread.error = ::GetLastError(); } } return S_OK; // return a value here to avoid compiler warning } void WaitObjectContainer::CreateThreads(unsigned int count) { unsigned int currentCount = m_threads.size(); if (currentCount == 0) { m_startWaiting = ::CreateEvent(NULL, TRUE, FALSE, NULL); m_stopWaiting = ::CreateEvent(NULL, TRUE, FALSE, NULL); } if (currentCount < count) { m_threads.resize(count); for (unsigned int i=currentCount; i<count; i++) { m_threads[i] = new WaitingThreadData; WaitingThreadData &thread = *m_threads[i]; thread.terminate = false; thread.startWaiting = m_startWaiting; thread.stopWaiting = m_stopWaiting; thread.waitingToWait = false; thread.threadHandle = CreateThread(NULL, 0, &WaitingThread, &thread, 0, &thread.threadId); } } } bool WaitObjectContainer::Wait(unsigned long milliseconds) { if (m_noWait || m_handles.empty()) { #if CRYPTOPP_DETECT_NO_WAIT if (-1 == m_lastResult) m_sameResultCount++; else { m_lastResult = -1; m_sameResultCount = 0; } #endif return true; } if (m_handles.size() > MAXIMUM_WAIT_OBJECTS) { // too many wait objects for a single WaitForMultipleObjects call, so use multiple threads static const unsigned int WAIT_OBJECTS_PER_THREAD = MAXIMUM_WAIT_OBJECTS-1; unsigned int nThreads = (m_handles.size() + WAIT_OBJECTS_PER_THREAD - 1) / WAIT_OBJECTS_PER_THREAD; if (nThreads > MAXIMUM_WAIT_OBJECTS) // still too many wait objects, maybe implement recursive threading later? throw Err("WaitObjectContainer: number of wait objects exceeds limit"); CreateThreads(nThreads); DWORD error = S_OK; for (unsigned int i=0; i<m_threads.size(); i++) { WaitingThreadData &thread = *m_threads[i]; while (!thread.waitingToWait) // spin until thread is in the initial "waiting to wait" state Sleep(0); if (i<nThreads) { thread.waitHandles = &m_handles[i*WAIT_OBJECTS_PER_THREAD]; thread.count = STDMIN(WAIT_OBJECTS_PER_THREAD, m_handles.size() - i*WAIT_OBJECTS_PER_THREAD); thread.error = &error; } else thread.count = 0; } ResetEvent(m_stopWaiting); PulseEvent(m_startWaiting); DWORD result = ::WaitForSingleObject(m_stopWaiting, milliseconds); if (result == WAIT_OBJECT_0) { if (error == S_OK) return true; else throw Err("WaitObjectContainer: WaitForMultipleObjects failed with error " + IntToString(error)); } SetEvent(m_stopWaiting); if (result == WAIT_TIMEOUT) return false; else throw Err("WaitObjectContainer: WaitForSingleObject failed with error " + IntToString(::GetLastError())); } else { #if TRACE_WAIT static Timer t(Timer::MICROSECONDS); static unsigned long lastTime = 0; unsigned long timeBeforeWait = t.ElapsedTime(); #endif DWORD result = ::WaitForMultipleObjects(m_handles.size(), &m_handles[0], FALSE, milliseconds); #if TRACE_WAIT if (milliseconds > 0) { unsigned long timeAfterWait = t.ElapsedTime(); OutputDebugString(("Handles " + IntToString(m_handles.size()) + ", Woke up by " + IntToString(result-WAIT_OBJECT_0) + ", Busied for " + IntToString(timeBeforeWait-lastTime) + " us, Waited for " + IntToString(timeAfterWait-timeBeforeWait) + " us, max " + IntToString(milliseconds) + "ms\n").c_str()); lastTime = timeAfterWait; } #endif if (result >= WAIT_OBJECT_0 && result < WAIT_OBJECT_0 + m_handles.size()) { #if CRYPTOPP_DETECT_NO_WAIT if (result == m_lastResult) m_sameResultCount++; else { m_lastResult = result; m_sameResultCount = 0; } #endif return true; } else if (result == WAIT_TIMEOUT) return false; else throw Err("WaitObjectContainer: WaitForMultipleObjects failed with error " + IntToString(::GetLastError())); } } #else void WaitObjectContainer::AddReadFd(int fd) { FD_SET(fd, &m_readfds); m_maxFd = STDMAX(m_maxFd, fd); } void WaitObjectContainer::AddWriteFd(int fd) { FD_SET(fd, &m_writefds); m_maxFd = STDMAX(m_maxFd, fd); } bool WaitObjectContainer::Wait(unsigned long milliseconds) { if (m_noWait || m_maxFd == 0) return true; timeval tv, *timeout; if (milliseconds == INFINITE_TIME) timeout = NULL; else { tv.tv_sec = milliseconds / 1000; tv.tv_usec = (milliseconds % 1000) * 1000; timeout = &tv; } int result = select(m_maxFd+1, &m_readfds, &m_writefds, NULL, timeout); if (result > 0) return true; else if (result == 0) return false; else throw Err("WaitObjectContainer: select failed with error " + errno); } #endif // ******************************************************** bool Waitable::Wait(unsigned long milliseconds) { WaitObjectContainer container; GetWaitObjects(container); return container.Wait(milliseconds); } NAMESPACE_END #endif
[ [ [ 1, 330 ] ] ]
5fc7c7b287cafdf934fc66534e86d6d163b7291f
814e67bf5d1c2f2e233b3ec1ee07faaaa65a9951
/compiladormarvel/AnalSemantico.cpp
f1ccd15cb65e2f8a2d89fcd812d3f1a53987d810
[]
no_license
lsalamon/compiladormarvel
686a5814e363fee41163d8a447d6753ebe84d220
55ea7a3f3cb76ec738e792e608ab01a9f48e5f8b
refs/heads/master
2021-01-10T08:17:50.321427
2009-03-20T14:06:43
2009-03-20T14:06:43
50,113,476
0
0
null
null
null
null
ISO-8859-1
C++
false
false
1,284
cpp
#include "AnalSemantico.h" #include <stdio.h> #include "VerificadorEscopo.h" #include "ClassesArvoreAbstrata.h" #include "VerificadorTipos.h" #include "VerificadorVariaveis.h" /* Arquivo de implementação do header AnalSemantico, responsável por iniciar e finalizar a análise semântica, tendo suporte do padrão Visitor para cada um dos módulos verificadores de regras semânticas. */ void iniciarAnaliseSemantica(ProgramNode* programNode){ // Verifica se o parâmetro passado não é nulo if (programNode != NULL) { // Inicia a análise semântica chamando cada uma das classes que implementam regras semânticas // Verificação de escopo VerificadorEscopo* verificadorEscopo = new VerificadorEscopo(); (programNode->accept(verificadorEscopo)); // Verificação de tipos VerificadorTipos* verificadorTipos = new VerificadorTipos(); (programNode->accept(verificadorTipos)); // Verificação de variáveis VerificadorVariaveis* verificadorVariaveis = new VerificadorVariaveis(); (programNode->accept(verificadorVariaveis)); } } void finalizarAnaliseSemantica(){ }
[ "sergiorossini@df256a42-0e3e-0410-b2fe-0dffcef58804", "cslopes@df256a42-0e3e-0410-b2fe-0dffcef58804" ]
[ [ [ 1, 1 ], [ 3, 3 ], [ 5, 5 ], [ 7, 40 ] ], [ [ 2, 2 ], [ 4, 4 ], [ 6, 6 ] ] ]
d7757c2b589208732df7352acba8ac16daf68757
1cc5720e245ca0d8083b0f12806a5c8b13b5cf98
/archive/3146/j.cpp
9156390da87ea9758438cbe4ae4e2473417c1fb5
[]
no_license
Emerson21/uva-problems
399d82d93b563e3018921eaff12ca545415fd782
3079bdd1cd17087cf54b08c60e2d52dbd0118556
refs/heads/master
2021-01-18T09:12:23.069387
2010-12-15T00:38:34
2010-12-15T00:38:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,643
cpp
#include <iostream> using namespace std; int main() { // unfortunately it is hardcoded as the judge does not allow multiple solutions! it sucks! cout<<"10D 4D QH 10C 5H"<<endl;cout<<"6C 5C 7H 8D KS"<<endl;cout<<"QH 7H 10H 7C 9S"<<endl;cout<<"2D 10D 6D 4S 5S"<<endl;cout<<"4C AC 10S QH 3S"<<endl;cout<<"5S QS JS 10C 9H"<<endl;cout<<"AS 10S 3D KD 8D"<<endl;cout<<"AD QD JH 10D QH"<<endl;cout<<"3C KC 5C 10S AH"<<endl;cout<<"QS 7S KH 6S 8H"<<endl;cout<<"QC JC AH 6C 6H"<<endl;cout<<"JD 9D 10H 6S JC"<<endl;cout<<"2D KD 4S 4C 6S"<<endl;cout<<"4D 3D AH 8C QS"<<endl;cout<<"6D KD KS 3H AC"<<endl;cout<<"6D AD KS 8C JH"<<endl;cout<<"2S AS 3H 4S JS"<<endl;cout<<"9D 6D 5H 6S AS"<<endl;cout<<"KC QC 6H 9S 10D"<<endl;cout<<"10S 8S 3S AC KS"<<endl;cout<<"AD KD 4S 10H KC"<<endl;cout<<"6S 3S 10C 10S 2C"<<endl;cout<<"AC QC 3H AD 6S"<<endl;cout<<"2C JC 2S KH 10D"<<endl;cout<<"6D AD KD 7H 8S"<<endl;cout<<"8H 3H JS AS 10C"<<endl;cout<<"2D JD AS 4C 3C"<<endl;cout<<"2C 9C KS KD 6S"<<endl;cout<<"3H 2H 4D 5D 10H"<<endl;cout<<"8C 4C 5D JD 6S"<<endl;cout<<"5C 2C 8H JS 8D"<<endl;cout<<"JS 9S 10H 3C KD"<<endl;cout<<"4C QC 10D 5D 9H"<<endl;cout<<"4H 3H 9H 10C 10H"<<endl;cout<<"8S 4S 3C KH JD"<<endl;cout<<"10H 6H 3C QC 4D"<<endl;cout<<"7S 3S 6C 9C 7C"<<endl;cout<<"AS QS 3C 2D 5D"<<endl;cout<<"QD 7D KC 8D 9S"<<endl;cout<<"4D AD 8C JH 6S"<<endl;cout<<"KC QC 4H 7D 10H"<<endl;cout<<"3C KC 9C JH 6C"<<endl;cout<<"4H 2H 10H 7C QD"<<endl;cout<<"7D 6D AH JD JS"<<endl;cout<<"JD 6D JC 3C 7H"<<endl;cout<<"3D 2D 5D 9S JH"<<endl;cout<<"8S 3S KS 4H 10C"<<endl;cout<<"JS 5S QC 10S 9D"<<endl;cout<<"10C 6C 5H 6H 5S"<<endl;cout<<"2D KD 9S 8C KC"<<endl;return 0; }
[ [ [ 1, 7 ] ] ]
fd7c9f39e6efd123e16826670a9d45df6ec4992e
036f83e4ba5370b4ec50da6d1d1561d85dedbde0
/learning-cpp/string_methods.cpp
5a289e692e0033f735ead95a4aa5b2045e289115
[]
no_license
losvald/high-school
8ba4487889093451b519c3f582d0dce8a5a6f5b8
4bfe295ad4ef1badf8a01d19e2ab3a65d59c1ce8
refs/heads/master
2016-09-06T03:48:25.747372
2008-01-17T10:56:55
2008-01-17T10:56:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
674
cpp
#include <string.h> #include <iostream.h> #include <conio.h> #include <ctype.h> using namespace std; int main(void) { size_t ind, poc, kraj; string ime("Morin"); string prezime; prezime.append(ime); ind = prezime.find('M'); prezime[ind] = tolower(prezime[ind]); prezime.append("ok"); poc = prezime.find("ok"); prezime.replace(poc, 2, "ko"); poc = prezime.find_first_of("ko"); prezime.replace(poc, 1, "a"); prezime.append("vic"); ime.clear(); ime = prezime; kraj = ime.find("kovic"); ime.erase(kraj); cout << ime << " " << prezime; getch(); return 0; }
[ [ [ 1, 28 ] ] ]
fd2da21d024601a9a2dbb8d759d25a6e5109c4e5
522403a3807746baef6329fb27c89e127be52dcf
/libcookai-ng/libcookai-ng/pastry-like/PastryLike.h
c1e4b5bfdc22e86aba1d2c87e67c324c8ed0a81b
[ "BSD-2-Clause" ]
permissive
limura/libcookai-ng
49a716e286f54b4a421076d7968d55bf2be7df94
9b414a72f1377e5aef4d0b5c99bd6516dbb59ffc
refs/heads/master
2016-09-06T05:55:59.758305
2007-03-26T04:56:11
2007-03-26T04:56:11
32,438,420
1
0
null
null
null
null
UTF-8
C++
false
false
2,903
h
/* * Copyright (c) 2006 IIMURA Takuji. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id$ */ #ifndef PASTRY_LIKE_NG_H #define PASTRY_LIKE_NG_H #include "../config.h" #include <string> #include <stdlib.h> #include "plSendQueue.h" #include "Key.h" #include "RoutingTable.h" #include "Event.h" class PastryLike { private: int accept_socket; RoutingTable *rt; plSendQueue sendQueue; plEventManager eventManager; public: PastryLike(); ~PastryLike(); int join(char *remote, char *service); void set(plData *data); void set(char *key, unsigned char *data, size_t size); void set(plKey *key, unsigned char *data, size_t size); void del(plData *data); void del(char *key, unsigned char *data, size_t size); void del(plKey *key, unsigned char *data, size_t size); void query(plKey *key, void *userData); void query(char *key, void *userData); bool processNextEvent(); typedef void (*QueryResponceEventFunc)(plData *data, void *userData); void setQueryEventFunc(PastryLike::QueryResponceEventFunc func, void *userData); typedef void (*PeerDeadEventFunc)(Peer *peer); void setPeerDeadEventFunc(PastryLike::PeerDeadEventFunc func); typedef void (*UserEventFunc)(Peer *peer, int type, size_t length, void *value); void setUserEventFunc(PastryLike::UserEventFunc func); private: PastryLike::QueryResponceEventFunc queryResponceEventFunc; PastryLike::PeerDeadEventFunc peerDeadEventFunc; PastryLike::UserEventFunc userEventFunc; }; #endif /* PASTRY_LIKE_NG_H */
[ "uirou.j@c449407d-291a-0410-96e5-036263b31150" ]
[ [ [ 1, 76 ] ] ]
68a71163f63f6b4d37b7c66d80a9b67dc4fdb66b
0f40e36dc65b58cc3c04022cf215c77ae31965a8
/src/apps/vis/tasks/vis_create_dynamic_tree_edges.h
42276167b49343fdb9a5f9e2db6a7a99badbfbf6
[ "MIT", "BSD-3-Clause" ]
permissive
venkatarajasekhar/shawn-1
08e6cd4cf9f39a8962c1514aa17b294565e849f8
d36c90dd88f8460e89731c873bb71fb97da85e82
refs/heads/master
2020-06-26T18:19:01.247491
2010-10-26T17:40:48
2010-10-26T17:40:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,752
h
/************************************************************************ ** This file is part of the network simulator Shawn. ** ** Copyright (C) 2004,2005 by SwarmNet (www.swarmnet.de) ** ** and SWARMS (www.swarms.de) ** ** Shawn is free software; you can redistribute it and/or modify it ** ** under the terms of the GNU General Public License, version 2. ** ************************************************************************/ #ifndef __SHAWN_TUBSAPPS_VIS_CREATE_DYNAMIC_TREE_EDGES_H #define __SHAWN_TUBSAPPS_VIS_CREATE_DYNAMIC_TREE_EDGES_H #include "../buildfiles/_apps_enable_cmake.h" #ifdef ENABLE_VIS #include "apps/vis/base/vis_task.h" #include "apps/vis/elements/vis_group_element.h" #include "apps/vis/elements/vis_drawable_node.h" namespace vis { /** * This simulation task creates drawable edges, representing relationships between nodes by * connecting these nodes graphically. * * Use regex to define, which node relations should be * used to create edges, by calling "vis_create_edges source=regex target=regex", where * source is a regex about all node names that should act as an edge's source, and target is * a regex about all node names that should act as (possible) targets. * * To draw all edges, call for example "vis_create_edges source_regex=.* target_regex=.*". * * @sa DrawableEdge */ class CreateDynamicTreeEdgesTask : public VisualizationTask { public: ///@name Contructor/Destructor ///@{ CreateDynamicTreeEdgesTask(); virtual ~CreateDynamicTreeEdgesTask(); ///@} ///@name Getter ///@{ /** * The name of the task. */ virtual std::string name( void ) const throw(); /** * A short description of the task. */ virtual std::string description( void ) const throw(); ///@} /** * Runs the task. This ist the task main method. */ virtual void run( shawn::SimulationController& sc ) throw( std::runtime_error ); protected: /** * Returns the group, this task ist attached to. Throws an error, * if it is in no group. */ virtual GroupElement* group( shawn::SimulationController& sc ) throw( std::runtime_error ); /** * Helper method to get a DrawableNode object by a shawn::Node and a * prefix. */ virtual const DrawableNode* drawable_node( const shawn::Node&, const std::string& nprefix ) throw( std::runtime_error ); }; } #endif #endif
[ [ [ 1, 80 ] ] ]
9a47089da71cff277356aac1e610ab7cef82578b
57c3ef7177f9bf80874fbd357fceb8625e746060
/Personal_modle_file/Dean_Zhang/IMServer/ui_ClientInterActionView.h
7595bae068b46d152eb0b056b991ae4880fec6b9
[]
no_license
kref/mobileim
0c33cc01b312704d71e74db04c4ba9b624b4ff73
15894fa006095428727b0530e9337137262818ac
refs/heads/master
2016-08-10T08:33:27.761030
2011-08-13T13:15:37
2011-08-13T13:15:37
45,781,075
0
0
null
null
null
null
UTF-8
C++
false
false
4,790
h
/******************************************************************************** ** Form generated from reading UI file 'ClientInterActionView.ui' ** ** Created: Sat Jul 17 18:37:05 2010 ** by: Qt User Interface Compiler version 4.6.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_CLIENTINTERACTIONVIEW_H #define UI_CLIENTINTERACTIONVIEW_H #include <QtCore/QVariant> #include <QtGui/QAction> #include <QtGui/QApplication> #include <QtGui/QButtonGroup> #include <QtGui/QDialog> #include <QtGui/QGroupBox> #include <QtGui/QHeaderView> #include <QtGui/QLabel> #include <QtGui/QLineEdit> #include <QtGui/QPushButton> #include <QtGui/QRadioButton> #include <QtGui/QTextBrowser> #include <QtGui/QTextEdit> QT_BEGIN_NAMESPACE class Ui_Dialog { public: QLabel *label; QLabel *label_2; QLineEdit *lineEdit; QLineEdit *lineEdit_2; QGroupBox *groupBox; QRadioButton *radioButton; QRadioButton *radioButton_2; QTextBrowser *textBrowser; QPushButton *pushButton; QPushButton *pushButton_2; QPushButton *pushButton_3; QTextEdit *textEdit; void setupUi(QDialog *Dialog) { if (Dialog->objectName().isEmpty()) Dialog->setObjectName(QString::fromUtf8("Dialog")); Dialog->resize(400, 534); label = new QLabel(Dialog); label->setObjectName(QString::fromUtf8("label")); label->setGeometry(QRect(30, 40, 61, 20)); label_2 = new QLabel(Dialog); label_2->setObjectName(QString::fromUtf8("label_2")); label_2->setGeometry(QRect(220, 40, 71, 20)); lineEdit = new QLineEdit(Dialog); lineEdit->setObjectName(QString::fromUtf8("lineEdit")); lineEdit->setGeometry(QRect(100, 40, 113, 20)); lineEdit_2 = new QLineEdit(Dialog); lineEdit_2->setObjectName(QString::fromUtf8("lineEdit_2")); lineEdit_2->setGeometry(QRect(300, 40, 51, 20)); groupBox = new QGroupBox(Dialog); groupBox->setObjectName(QString::fromUtf8("groupBox")); groupBox->setGeometry(QRect(100, 80, 161, 51)); radioButton = new QRadioButton(groupBox); radioButton->setObjectName(QString::fromUtf8("radioButton")); radioButton->setGeometry(QRect(10, 20, 82, 17)); radioButton_2 = new QRadioButton(groupBox); radioButton_2->setObjectName(QString::fromUtf8("radioButton_2")); radioButton_2->setGeometry(QRect(100, 20, 82, 17)); textBrowser = new QTextBrowser(Dialog); textBrowser->setObjectName(QString::fromUtf8("textBrowser")); textBrowser->setGeometry(QRect(60, 160, 256, 231)); pushButton = new QPushButton(Dialog); pushButton->setObjectName(QString::fromUtf8("pushButton")); pushButton->setGeometry(QRect(320, 410, 75, 23)); pushButton_2 = new QPushButton(Dialog); pushButton_2->setObjectName(QString::fromUtf8("pushButton_2")); pushButton_2->setGeometry(QRect(320, 440, 75, 23)); pushButton_3 = new QPushButton(Dialog); pushButton_3->setObjectName(QString::fromUtf8("pushButton_3")); pushButton_3->setGeometry(QRect(70, 490, 75, 23)); textEdit = new QTextEdit(Dialog); textEdit->setObjectName(QString::fromUtf8("textEdit")); textEdit->setGeometry(QRect(60, 400, 251, 64)); retranslateUi(Dialog); QMetaObject::connectSlotsByName(Dialog); } // setupUi void retranslateUi(QDialog *Dialog) { Dialog->setWindowTitle(QApplication::translate("Dialog", "Dialog", 0, QApplication::UnicodeUTF8)); label->setText(QApplication::translate("Dialog", "Client Ip:", 0, QApplication::UnicodeUTF8)); label_2->setText(QApplication::translate("Dialog", "Client Port:", 0, QApplication::UnicodeUTF8)); groupBox->setTitle(QApplication::translate("Dialog", "choose way", 0, QApplication::UnicodeUTF8)); radioButton->setText(QApplication::translate("Dialog", "TCP", 0, QApplication::UnicodeUTF8)); radioButton_2->setText(QApplication::translate("Dialog", "UDP", 0, QApplication::UnicodeUTF8)); pushButton->setText(QApplication::translate("Dialog", "send msg", 0, QApplication::UnicodeUTF8)); pushButton_2->setText(QApplication::translate("Dialog", "disconnect", 0, QApplication::UnicodeUTF8)); pushButton_3->setText(QApplication::translate("Dialog", "Cancel", 0, QApplication::UnicodeUTF8)); } // retranslateUi }; namespace Ui { class Dialog: public Ui_Dialog {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_CLIENTINTERACTIONVIEW_H
[ [ [ 1, 113 ] ] ]
2c76158433bed1fea15f4c6903be384dab2fc155
913f43ef4d03bd5d6b42b9e31b1048ae54493f59
/CraterRacer/CraterRacer/Source_Code/Subsystem Files/MessageManager.h
8fafc1d7907a4cd1a7dd38cf5ebe345fa46ed408
[]
no_license
GreenAdept/cpsc585
bfba6ea333c2857df0822dd7d00768df6a010a73
c66745e77be4c78e435da1a59ae94ac2a61228cf
refs/heads/master
2021-01-10T16:42:03.804213
2010-04-27T00:13:52
2010-04-27T00:13:52
48,024,449
0
0
null
null
null
null
UTF-8
C++
false
false
2,795
h
#pragma once #ifndef MESSAGE_MANAGER_H #define MESSAGE_MANAGER_H //-------------------------------------------------------- // INCLUDES //-------------------------------------------------------- #include <vector> #include <string> #include "Constants.h" #include "GameObj.h" #include "Simulator.h" #include "SceneLoader.h" #include "VictoryCalculator.h" #include "CraterRacerApp.h" #include "Renderer.h" #include "Clock.h" #include "Sound.h" //event ids enum Events { EWrongWay, EWrongWayCancel, EPauseGame, EUnpauseGame, EStartClock, EGameFinished, ELapFinished, EPlayerFinished, EVibrate, EStartOrStopRace, EVehicleCollision, EVictoryScreenUpdate, ENameEntered, ESetTimeLimit, EMeteorCrashed, EBoostRamp}; using namespace std; //-------------------------------------------------------- // CLASS: MessageManager // // This class uses the Singleton design pattern. // It will be used to process event messages between // objects in the game. // // Steps to create an event and use it: // 1. Add eventID to Events enum above // 2. Add a case statement in the ProcessMessage // function below // 3. Make sure the objects you are emitting from // and updating are members of the MessageManager // (add them if not...and include the MessageManager // header in the object's .cpp file, not .h file.) // 4. Use "Emit( yourID, a_parameter )" //-------------------------------------------------------- using namespace std; class MessageManager { public: //get the instance of the manager static MessageManager* Inst( ); static void ProcessMessage ( int message, long param ); static void ProcessMessage ( int message, Vec3 param ); static void ProcessMessage ( int message, long param1, long param2 ); static void ProcessMessage ( int message, long param1, string param2 ); static void ProcessMessage ( int message, long param1, long param2, long param3 ); static void ProcessMessage ( int message, string param ); static void ProcessMessage ( int message ); static void AddEmitter ( RacerApp* app ); static void AddEmitter ( GameObj* game ); static void deleteManager ( ); ~MessageManager( ) { } protected: MessageManager( ) { } // constructor private: //Singleton instance of message manager static MessageManager* pInstance; //Event emitters and receivers static GameObj* m_Game; static Simulator* m_Simulator; static VictoryCalculator* m_VictoryCalculator; static EntityManager* m_EntityManager; static RacerApp* m_App; static Renderer* m_Renderer; static Clock* m_Clock; }; #define Emit MessageManager::Inst()->ProcessMessage #define InitEmitter MessageManager::Inst()->AddEmitter #endif //MESSAGE_MANAGER_H
[ "wshnng@b92cab1e-0213-11df-804c-772d9fe11005", "amber.wetherill@b92cab1e-0213-11df-804c-772d9fe11005", "greenadept@b92cab1e-0213-11df-804c-772d9fe11005", "[email protected]" ]
[ [ [ 1, 4 ], [ 7, 10 ], [ 20, 22 ], [ 26, 27 ], [ 44, 44 ], [ 59, 60 ], [ 72, 72 ], [ 85, 89 ] ], [ [ 5, 6 ], [ 11, 18 ], [ 28, 43 ], [ 45, 55 ], [ 57, 57 ], [ 61, 71 ], [ 73, 84 ], [ 90, 90 ] ], [ [ 19, 19 ], [ 25, 25 ] ], [ [ 23, 24 ], [ 56, 56 ], [ 58, 58 ] ] ]
9fc8c04fe997b088a13c2a27677ec3d0cdf20611
e9944cc3f8c362cd0314a2d7a01291ed21de19ee
/ xcommon/ImageEx/TestDlgDlg.cpp
2ddbd38dc5bc69ac47d60806793d9ddb5bbc3353
[]
no_license
wermanhme1990/xcommon
49d7185a28316d46992ad9311ae9cdfe220cb586
c9b1567da1f11e7a606c6ed638a9fde1f6ece577
refs/heads/master
2016-09-06T12:43:43.593776
2008-12-05T04:24:11
2008-12-05T04:24:11
39,864,906
2
0
null
null
null
null
UTF-8
C++
false
false
4,328
cpp
// TestDlgDlg.cpp : implementation file // #include "stdafx.h" #include "TestDlg.h" #include "TestDlgDlg.h" ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About class CAboutDlg : public CDialog { public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(CAboutDlg) //}}AFX_MSG DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) // No message handlers //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CTestDlgDlg dialog CTestDlgDlg::CTestDlgDlg(CWnd* pParent /*=NULL*/) : CDialog(CTestDlgDlg::IDD, pParent) { //{{AFX_DATA_INIT(CTestDlgDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); // GDI+ m_image = NULL; } void CTestDlgDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CTestDlgDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } CTestDlgDlg::~CTestDlgDlg() { // GDI+ delete m_image; } BEGIN_MESSAGE_MAP(CTestDlgDlg, CDialog) //{{AFX_MSG_MAP(CTestDlgDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CTestDlgDlg message handlers BOOL CTestDlgDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // GDI+ m_image = new ImageEx( "GIF", "HEARTS" ); CRect rc; GetClientRect(rc); int cx = (rc.Width() - m_image->GetWidth()) / 2; m_image->InitAnimation(m_hWnd, CPoint(cx,10)); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } void CTestDlgDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CTestDlgDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CTestDlgDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; }
[ [ [ 1, 189 ] ] ]
9008225c92a5cb2633a584d4541544cc86814dfc
27d5670a7739a866c3ad97a71c0fc9334f6875f2
/CPP/Targets/MapLib/Shared/include/TileMapHandlerTypes.h
ca14266c2910b6b17f14ebc9cff7dace9595dda3
[ "BSD-3-Clause" ]
permissive
ravustaja/Wayfinder-S60-Navigator
ef506c418b8c2e6498ece6dcae67e583fb8a4a95
14d1b729b2cea52f726874687e78f17492949585
refs/heads/master
2021-01-16T20:53:37.630909
2010-06-28T09:51:10
2010-06-28T09:51:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,993
h
/* Copyright (c) 1999 - 2010, Vodafone Group Services Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef TILE_MAP_HANDLER_TYPES_H #define TILE_MAP_HANDLER_TYPES_H #include "TileMapConfig.h" #include <map> #include <utility> class TileMap; /** * Some types. */ class TileMapHandlerTypes { public: /** * Class containing the current set of tilemaps and their * position in the mapVector/paramsNeeded. */ typedef std::map<MC2SimpleString, std::pair<int, TileMap*> > mapStorage_t; }; #endif
[ [ [ 1, 37 ] ] ]
ff19023a9a2c5fcd4b9f95bc026c795b5a776470
bdbd6a0ccd4ece9135b705a23fc752e880b10d2f
/GameEngine.cpp
100d78b6d813b8071da7f8da8c3ddad63a120037
[]
no_license
DarklightXIII/AI-Path
44486e8d6efa6465c4b4a9490b1e1187753cb3d0
9abe010a21f31fc8ed307bc9e935e6c1141256d5
refs/heads/master
2021-01-22T17:09:31.259362
2010-11-26T13:35:31
2010-11-26T13:35:31
1,113,325
0
0
null
null
null
null
UTF-8
C++
false
false
88,230
cpp
//----------------------------------------------------------------- // Game Engine Object // C++ Source - GameEngine.cpp - version 2010 v2_07 // Copyright Kevin Hoefman - [email protected] // Thanks to Bart Uyttenhove - [email protected] // for several changes & contributions // http://www.digitalartsandentertainment.be/ //----------------------------------------------------------------- //----------------------------------------------------------------- // Include Files //----------------------------------------------------------------- #include "GameEngine.h" #define _USE_MATH_DEFINES // necessary for including (among other values) PI - see math.h #include <math.h> // used in various draw methods #include <stdio.h> #include <tchar.h> // used for unicode strings #include <iostream> // iostream, fstream and memory.h used for targa loader #include <fstream> #include <memory.h> //----------------------------------------------------------------- // Static Variable Initialization //----------------------------------------------------------------- GameEngine* GameEngine::m_GameEnginePtr = NULL; //----------------------------------------------------------------- // Windows Functions //----------------------------------------------------------------- LRESULT CALLBACK WndProc(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam) { // Route all Windows messages to the game engine return GameEngine::GetSingleton()->HandleEvent(hWindow, msg, wParam, lParam); } DWORD WINAPI KeybThreadProc(GameEngine* gamePtr) { return gamePtr->KeybThreadProc(); } //----------------------------------------------------------------- // GameEngine Constructor(s)/Destructor //----------------------------------------------------------------- GameEngine::GameEngine() : m_hInstance(NULL), m_hWindow(NULL), m_TitlePtr(0), m_iFrameDelay(50), // 20 FPS default m_bSleep(true), m_bRunGameLoop(false), m_bKeybRunning(true), // create the keyboard monitoring thread m_KeyListPtr(0), m_KeybMonitor(0x0), // binary ; 0 = key not pressed, 1 = key pressed m_IsPainting(false), m_IsDoublebuffering(false), m_ColDraw(RGB(0,0,0)), m_FontDraw(0), m_GamePtr(0), m_PaintDoublebuffered(false), m_Fullscreen(false), m_WindowRegionPtr(0) { m_hKeybThread = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE) ::KeybThreadProc, this, NULL, &m_dKeybThreadID); } GameEngine::~GameEngine() { // Clean up the keyboard monitoring thread m_bKeybRunning = false; WaitForSingleObject( m_hKeybThread, INFINITE ); CloseHandle( m_hKeybThread ); // clean up keyboard monitor buffer after the thread that uses it is closed if (m_KeyListPtr != 0) { delete m_KeyListPtr; m_KeyListPtr = 0; } // clean up the font if (m_FontDraw != 0) { DeleteObject(m_FontDraw); m_FontDraw = 0; } // clean up title string delete m_TitlePtr; // clean up the AbstractGame object delete m_GamePtr; } //----------------------------------------------------------------- // Game Engine Static Methods //----------------------------------------------------------------- GameEngine* GameEngine::GetSingleton() { if ( m_GameEnginePtr == NULL) m_GameEnginePtr = new GameEngine(); return m_GameEnginePtr; } void GameEngine::SetGame(AbstractGame* gamePtr) { m_GamePtr = gamePtr; } DWORD GameEngine::KeybThreadProc() { while (m_bKeybRunning) { if (m_KeyListPtr != NULL) { int count = 0; int key = m_KeyListPtr[0]; while (key != '\0' && count < (8 * sizeof(unsigned int))) { if ( !(GetAsyncKeyState(key)<0) ) // key is not pressed { if (m_KeybMonitor & (0x1 << count)) { m_GamePtr->KeyPressed(key); // als de bit op 1 stond, dan firet dit een keypress } m_KeybMonitor &= ~(0x1 << count); // de bit wordt op 0 gezet: key is not pressed } else m_KeybMonitor |= (0x1 << count); // de bit wordt op 1 gezet: key is pressed key = m_KeyListPtr[++count]; // increase count and get next key } } Sleep(1000 / KEYBCHECKRATE); } return 0; } //----------------------------------------------------------------- // Game Engine General Methods //----------------------------------------------------------------- void GameEngine::SetTitle(String const& strTitleRef) { delete m_TitlePtr; // delete the title string if it already exists m_TitlePtr = new String(strTitleRef); } bool GameEngine::Run(HINSTANCE hInstance, int iCmdShow) { // create the game engine object, exit if failure if (GameEngine::GetSingleton() == NULL) return false; // set the instance member variable of the game engine GameEngine::GetSingleton()->SetInstance(hInstance); // Seed the random number generator srand(GetTickCount()); // Game Initialization m_GamePtr->GameInitialize(hInstance); // Initialize the game engine if (!GameEngine::GetSingleton()->ClassRegister(iCmdShow)) return false; // Attach the keyboard thread to the main thread. This gives the keyboard events access to the window state // In plain English: this allows a KeyPressed() event to hide the cursor of the window. AttachThreadInput(m_dKeybThreadID, GetCurrentThreadId(), true); // Enter the main message loop MSG msg; DWORD dwTimeTrigger = 0; while (true) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // Process the message if (msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } else { // Make sure the game engine isn't sleeping if (!GameEngine::GetSingleton()->GetSleep() && m_bRunGameLoop) { // Check the time to see if a game cycle has elapsed DWORD dwTimeNow = timeGetTime(); if (dwTimeNow > dwTimeTrigger) { dwTimeTrigger = dwTimeNow + GameEngine::GetSingleton()->GetFrameDelay(); // Do user defined keyboard check m_GamePtr->CheckKeyboard(); // Get window, rectangle and HDC HWND hWindow = GetWindow(); RECT WindowClientRect; HDC hDC = GetDC(hWindow); GetClientRect(hWindow, &WindowClientRect); // Double buffering code HDC hBufferDC = CreateCompatibleDC(hDC); // Create the buffer, size is iWidth and iHeight, NOT the window client rect HBITMAP hBufferBmp = CreateCompatibleBitmap(hDC, GetWidth(), GetHeight()); HBITMAP hOldBmp = (HBITMAP) SelectObject(hBufferDC, hBufferBmp); // Do user defined drawing functions on the buffer, parameters added // for ease of drawing //UPDATE BART: RECT UsedClientRect={0,0,GetWidth(),GetHeight()}; m_HdcDraw = hBufferDC; m_RectDraw = UsedClientRect; m_IsDoublebuffering = true; m_GamePtr->GameCycle(UsedClientRect); m_IsDoublebuffering = false; //BitBlt(hDC, 0, 0, iWidth, iHeight, hBufferDC, 0, 0, SRCCOPY); // As a last step copy the memdc to the hdc //use StretchBlt to scale from m_iWidth and m_iHeight to current window area StretchBlt( hDC, 0,0,WindowClientRect.right-WindowClientRect.left,WindowClientRect.bottom-WindowClientRect.top, hBufferDC, 0, 0, GetWidth(),GetHeight(),SRCCOPY ); // Reset the old bmp of the buffer, mainly for show since we kill it anyway SelectObject(hBufferDC, hOldBmp); // Kill the buffer DeleteObject(hBufferBmp); DeleteDC(hBufferDC); // Release HDC ReleaseDC(hWindow, hDC); } else Sleep(1);//Sleep for one ms te bring cpu load from 100% to 1%. if removed this loops like roadrunner } else WaitMessage(); // if the engine is sleeping or the game loop isn't supposed to run, wait for the next windows message. } } return msg.wParam?true:false; } bool GameEngine::SetGameValues(String const& TitleRef, WORD wIcon, WORD wSmallIcon, int iWidth = 640, int iHeight = 480) { SetTitle(TitleRef); SetIcon(wIcon); SetSmallIcon(wSmallIcon); SetWidth(iWidth); SetHeight(iHeight); return true; } void GameEngine::ShowMousePointer(bool value) { // set the value ShowCursor(value); // redraw the screen InvalidateRect(m_hWindow, 0, true); } bool GameEngine::SetWindowRegion(HitRegion* regionPtr) { if (m_Fullscreen) return false; if (regionPtr == 0) { /* // switch on the title bar DWORD dwStyle = GetWindowLong(m_hWindow, GWL_STYLE); dwStyle |= WS_CAPTION; SetWindowLong(m_hWindow, GWL_STYLE, dwStyle); */ // turn off window region SetWindowRgn(m_hWindow, 0, true); // delete the buffered window region (if it exists) delete m_WindowRegionPtr; m_WindowRegionPtr = 0; } else { // if there is already a window region set, release the buffered region object if (m_WindowRegionPtr != 0) { // turn off window region for safety SetWindowRgn(m_hWindow, 0, true); // delete the buffered window region delete m_WindowRegionPtr; m_WindowRegionPtr = 0; } /* // switch off the title bar DWORD dwStyle = GetWindowLong(m_hWindow, GWL_STYLE); dwStyle &= ~WS_CAPTION; SetWindowLong(m_hWindow, GWL_STYLE, dwStyle); */ // create a copy of the submitted region (windows will lock the region handle that it receives) m_WindowRegionPtr = regionPtr->Clone(); // translate region coordinates in the client field to window coordinates, taking title bar and frame into account m_WindowRegionPtr->Move(GetSystemMetrics(SM_CXFIXEDFRAME), GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION)); // set the window region SetWindowRgn(m_hWindow, m_WindowRegionPtr->GetHandle(), true); } return true; } bool GameEngine::HasWindowRegion() { return (m_WindowRegionPtr?true:false); } bool GameEngine::GoFullscreen() { // exit if already in fullscreen mode if (m_Fullscreen) return false; // turn off window region without redraw SetWindowRgn(m_hWindow, 0, false); DEVMODE newSettings; // request current screen settings EnumDisplaySettings(0, 0, &newSettings); // set desired screen size/res newSettings.dmPelsWidth = GetWidth(); newSettings.dmPelsHeight = GetHeight(); newSettings.dmBitsPerPel = 32; //specify which aspects of the screen settings we wish to change newSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; // attempt to apply the new settings long result = ChangeDisplaySettings(&newSettings, CDS_FULLSCREEN); // exit if failure, else set datamember to fullscreen and return true if ( result != DISP_CHANGE_SUCCESSFUL ) return false; else { // store the location of the window m_OldLoc = GetLocation(); // switch off the title bar DWORD dwStyle = GetWindowLong(m_hWindow, GWL_STYLE); dwStyle &= ~WS_CAPTION; SetWindowLong(m_hWindow, GWL_STYLE, dwStyle); // move the window to (0,0) SetWindowPos(m_hWindow, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER); InvalidateRect(m_hWindow, 0, true); m_Fullscreen = true; return true; } } bool GameEngine::GoWindowedMode() { // exit if already in windowed mode if (!m_Fullscreen) return false; // this resets the screen to the registry-stored values ChangeDisplaySettings(0, 0); // replace the title bar DWORD dwStyle = GetWindowLong(m_hWindow, GWL_STYLE); dwStyle = dwStyle | WS_CAPTION; SetWindowLong(m_hWindow, GWL_STYLE, dwStyle); // move the window back to its old position SetWindowPos(m_hWindow, 0, m_OldLoc.x, m_OldLoc.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER); InvalidateRect(m_hWindow, 0, true); m_Fullscreen = false; return true; } bool GameEngine::IsFullscreen() { return m_Fullscreen; } bool GameEngine::ClassRegister(int iCmdShow) { WNDCLASSEX wndclass; // Create the window class for the main window wndclass.cbSize = sizeof(wndclass); wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = m_hInstance; wndclass.hIcon = LoadIcon(m_hInstance, MAKEINTRESOURCE(GetIcon())); wndclass.hIconSm = LoadIcon(m_hInstance, MAKEINTRESOURCE(GetSmallIcon())); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = m_PaintDoublebuffered?NULL:(HBRUSH)(COLOR_WINDOW + 1); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = m_TitlePtr->ToTChar(); // Register the window class if (!RegisterClassEx(&wndclass)) return false; // Calculate the window size and position based upon the game size int iWindowWidth = m_iWidth + GetSystemMetrics(SM_CXFIXEDFRAME) * 2, iWindowHeight = m_iHeight + GetSystemMetrics(SM_CYFIXEDFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION); if (wndclass.lpszMenuName != NULL) iWindowHeight += GetSystemMetrics(SM_CYMENU); int iXWindowPos = (GetSystemMetrics(SM_CXSCREEN) - iWindowWidth) / 2, iYWindowPos = (GetSystemMetrics(SM_CYSCREEN) - iWindowHeight) / 2; // Create the window m_hWindow = CreateWindow(m_TitlePtr->ToTChar(), m_TitlePtr->ToTChar(), WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX/*uncomment this to enable scaling when programming a game| WS_MAXIMIZEBOX*/ | WS_CLIPCHILDREN, iXWindowPos, iYWindowPos, iWindowWidth, iWindowHeight, NULL, NULL, m_hInstance, NULL); if (!m_hWindow) return false; // Show and update the window ShowWindow(m_hWindow, iCmdShow); UpdateWindow(m_hWindow); return true; } bool GameEngine::IsKeyDown(int vKey) { if (GetAsyncKeyState(vKey) < 0) return true; else return false; } void GameEngine::SetKeyList(String const& keyListRef) { if (keyListRef.ToTChar() != NULL) delete m_KeyListPtr; // clear lijst als er al een lijst bestaat int iLength = 0; while (keyListRef.ToTChar()[iLength] != '\0') iLength++; // tellen hoeveel tekens er zijn m_KeyListPtr = (TCHAR*) malloc((iLength + 1) * sizeof(TCHAR)); // maak plaats voor zoveel tekens + 1 for (int count = 0; count < iLength + 1; count++) { TCHAR key = keyListRef.ToTChar()[count]; m_KeyListPtr[count] = (key > 96 && key < 123)? key-32 : key; // vul het teken in, in uppercase indien kleine letter } } void GameEngine::QuitGame() { PostMessage(GameEngine::GetWindow(), WM_DESTROY, 0, 0); } void GameEngine::MessageBox(String const& textRef) { if (sizeof(TCHAR) == 2) MessageBoxW(GetWindow(), (wchar_t*) textRef.ToTChar(), (wchar_t*) m_TitlePtr->ToTChar(), MB_ICONEXCLAMATION | MB_OK); else MessageBoxA(GetWindow(), (char*) textRef.ToTChar(), (char*) m_TitlePtr->ToTChar(), MB_ICONEXCLAMATION | MB_OK); } void GameEngine::MessageBox(int value) { MessageBox(String("") + value); } void GameEngine::MessageBox(size_t value) { MessageBox(String("") + value); } void GameEngine::MessageBox(double value) { MessageBox(String("") + value); } static bool CALLBACK EnumInsertChildrenProc(HWND hwnd, LPARAM lParam) { vector<HWND> *row = (vector<HWND> *) lParam; row->push_back(hwnd); // elk element invullen in de vector return true; } void GameEngine::TabNext(HWND ChildWindow) { vector<HWND> childWindows; EnumChildWindows(m_hWindow, (WNDENUMPROC) EnumInsertChildrenProc, (LPARAM) &childWindows); int position = 0; HWND temp = childWindows[position]; while(temp != ChildWindow) temp = childWindows[++position]; // positie van childWindow in de vector opzoeken if (position == childWindows.size() - 1) SetFocus(childWindows[0]); else SetFocus(childWindows[position + 1]); } void GameEngine::TabPrevious(HWND ChildWindow) { vector<HWND> childWindows; EnumChildWindows(m_hWindow, (WNDENUMPROC) EnumInsertChildrenProc, (LPARAM) &childWindows); int position = (int) childWindows.size() - 1; HWND temp = childWindows[position]; while(temp != ChildWindow) temp = childWindows[--position]; // positie van childWindow in de vector opzoeken if (position == 0) SetFocus(childWindows[childWindows.size() - 1]); else SetFocus(childWindows[position - 1]); } bool GameEngine::DrawLine(int x1, int y1, int x2, int y2) { HPEN hOldPen, hNewPen = CreatePen(PS_SOLID, 1, m_ColDraw); hOldPen = (HPEN) SelectObject(m_HdcDraw, hNewPen); MoveToEx(m_HdcDraw, x1, y1, NULL); LineTo(m_HdcDraw, x2, y2); MoveToEx(m_HdcDraw, 0, 0, NULL); // reset van de positie - zorgt ervoor dat bvb AngleArc vanaf 0,0 gaat tekenen ipv de laatste positie van de DrawLine SelectObject(m_HdcDraw, hOldPen); DeleteObject(hNewPen); return true; } bool GameEngine::DrawPolygon(const POINT ptsArr[], int count, bool close) { HPEN hOldPen, hNewPen = CreatePen(PS_SOLID, 1, m_ColDraw); hOldPen = (HPEN) SelectObject(m_HdcDraw, hNewPen); FormPolygon(ptsArr, count, close); SelectObject(m_HdcDraw, hOldPen); DeleteObject(hNewPen); return true; } bool GameEngine::DrawPolygon(const POINT ptsArr[], int count) { if (m_IsDoublebuffering || m_IsPainting) return DrawPolygon(ptsArr, count, false); else return false; } bool GameEngine::FillPolygon(const POINT ptsArr[], int count, bool close) { HPEN hOldPen, hNewPen = CreatePen(PS_SOLID, 1, m_ColDraw); HBRUSH hOldBrush, hNewBrush = CreateSolidBrush(m_ColDraw); hOldPen = (HPEN) SelectObject(m_HdcDraw, hNewPen); hOldBrush = (HBRUSH) SelectObject(m_HdcDraw, hNewBrush); BeginPath(m_HdcDraw); FormPolygon(ptsArr, count, close); EndPath(m_HdcDraw); StrokeAndFillPath(m_HdcDraw); SelectObject(m_HdcDraw, hOldPen); SelectObject(m_HdcDraw, hOldBrush); DeleteObject(hNewPen); DeleteObject(hNewBrush); return true; } bool GameEngine::FillPolygon(const POINT ptsArr[], int count) { if (m_IsDoublebuffering || m_IsPainting) return FillPolygon(ptsArr, count, false); else return false; } void GameEngine::FormPolygon(const POINT ptsArr[], int count, bool close) { if (!close) Polyline(m_HdcDraw, ptsArr, count); else { POINT* newpts= new POINT[count+1]; // interessant geval: deze code werkt niet met memory allocation at compile time => demo case for dynamic memory use for (int i = 0; i < count; i++) newpts[i] = ptsArr[i]; newpts[count] = ptsArr[0]; Polyline(m_HdcDraw, newpts, count+1); delete[] newpts; } } bool GameEngine::DrawRect(int x, int y, int width, int height) { HPEN hOldPen, hNewPen = CreatePen(PS_SOLID, 1, m_ColDraw); hOldPen = (HPEN) SelectObject(m_HdcDraw, hNewPen); POINT pts[4] = {x, y, x + width -1, y, x + width-1, y + height-1, x, y + height-1}; DrawPolygon(pts, 4, true); SelectObject(m_HdcDraw, hOldPen); DeleteObject(hNewPen); return true; } bool GameEngine::FillRect(int x, int y, int width, int height) { HBRUSH hOldBrush, hNewBrush = CreateSolidBrush(m_ColDraw); HPEN hOldPen, hNewPen = CreatePen(PS_SOLID, 1, m_ColDraw); hOldBrush = (HBRUSH) SelectObject(m_HdcDraw, hNewBrush); hOldPen = (HPEN) SelectObject(m_HdcDraw, hNewPen); Rectangle(m_HdcDraw, x, y, x + width, y + height); SelectObject(m_HdcDraw, hOldPen); SelectObject(m_HdcDraw, hOldBrush); DeleteObject(hNewPen); DeleteObject(hNewBrush); return true; } bool GameEngine::DrawRoundRect(int x, int y, int width, int height, int radius) { HPEN hOldPen, hNewPen = CreatePen(PS_SOLID, 1, m_ColDraw); hOldPen = (HPEN) SelectObject(m_HdcDraw, hNewPen); BeginPath(m_HdcDraw); RoundRect(m_HdcDraw, x, y, x + width, y + height, radius, radius); EndPath(m_HdcDraw); StrokePath(m_HdcDraw); SelectObject(m_HdcDraw, hOldPen); DeleteObject(hNewPen); return true; } bool GameEngine::FillRoundRect(int x, int y, int width, int height, int radius) { HBRUSH hOldBrush, hNewBrush = CreateSolidBrush(m_ColDraw); HPEN hOldPen, hNewPen = CreatePen(PS_SOLID, 1, m_ColDraw); hOldBrush = (HBRUSH) SelectObject(m_HdcDraw, hNewBrush); hOldPen = (HPEN) SelectObject(m_HdcDraw, hNewPen); RoundRect(m_HdcDraw, x, y, x + width, y + height, radius, radius); SelectObject(m_HdcDraw, hOldPen); SelectObject(m_HdcDraw, hOldBrush); DeleteObject(hNewPen); DeleteObject(hNewBrush); return true; } bool GameEngine::DrawOval(int x, int y, int width, int height) { HPEN hOldPen, hNewPen = CreatePen(PS_SOLID, 1, m_ColDraw); hOldPen = (HPEN) SelectObject(m_HdcDraw, hNewPen); Arc(m_HdcDraw, x, y, x + width, y + height, x, y + height/2, x, y + height/2); SelectObject(m_HdcDraw, hOldPen); DeleteObject(hNewPen); return true; } bool GameEngine::FillOval(int x, int y, int width, int height) { HBRUSH hOldBrush, hNewBrush = CreateSolidBrush(m_ColDraw); HPEN hOldPen, hNewPen = CreatePen(PS_SOLID, 1, m_ColDraw); hOldBrush = (HBRUSH) SelectObject(m_HdcDraw, hNewBrush); hOldPen = (HPEN) SelectObject(m_HdcDraw, hNewPen); Ellipse(m_HdcDraw, x, y, x + width, y + height); SelectObject(m_HdcDraw, hOldPen); SelectObject(m_HdcDraw, hOldBrush); DeleteObject(hNewPen); DeleteObject(hNewBrush); return true; } bool GameEngine::DrawArc(int x, int y, int width, int height, int startDegree, int angle) { if (angle == 0) return false; if (angle > 360) { DrawOval(x, y, width, height); } else { HPEN hOldPen, hNewPen = CreatePen(PS_SOLID, 1, m_ColDraw); hOldPen = (HPEN) SelectObject(m_HdcDraw, hNewPen); POINT ptStart = AngleToPoint(x, y, width, height, startDegree); POINT ptEnd = AngleToPoint(x, y, width, height, startDegree + angle); if (angle > 0) Arc(m_HdcDraw, x, y, x + width, y + height, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); else Arc(m_HdcDraw, x, y, x + width, y + height, ptEnd.x, ptEnd.y, ptStart.x, ptStart.y); SelectObject(m_HdcDraw, hOldPen); DeleteObject(hNewPen); } return true; } bool GameEngine::FillArc(int x, int y, int width, int height, int startDegree, int angle) { if (angle == 0) return false; if (angle > 360) { FillOval(x, y, width, height); } else { HBRUSH hOldBrush, hNewBrush = CreateSolidBrush(m_ColDraw); HPEN hOldPen, hNewPen = CreatePen(PS_SOLID, 1, m_ColDraw); hOldBrush = (HBRUSH) SelectObject(m_HdcDraw, hNewBrush); hOldPen = (HPEN) SelectObject(m_HdcDraw, hNewPen); POINT ptStart = AngleToPoint(x, y, width, height, startDegree); POINT ptEnd = AngleToPoint(x, y, width, height, startDegree + angle); if (angle >0) Pie(m_HdcDraw, x, y, x + width, y + height, ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); else Pie(m_HdcDraw, x, y, x + width, y + height, ptEnd.x, ptEnd.y, ptStart.x, ptStart.y); SelectObject(m_HdcDraw, hOldPen); SelectObject(m_HdcDraw, hOldBrush); DeleteObject(hNewPen); DeleteObject(hNewBrush); } return true; } POINT GameEngine::AngleToPoint(int x, int y, int width, int height, int angle) { POINT pt; // if necessary adjust angle so that it has a value between 0 and 360 degrees if (angle > 360 || angle < -360) angle = angle % 360; if (angle < 0) angle += 360; // default values for standard angles if (angle == 0) { pt.x = x + width; pt.y = y + (int) (height / 2); } else if (angle == 90) { pt.x = x + (int) (width / 2); pt.y = y; } else if (angle == 180) { pt.x = x; pt.y = y + (int) (height / 2); } else if (angle == 270) { pt.x = x + (int) (width / 2); pt.y = y + height; } // else calculate non-default values else { // point on the ellipse = "stelsel" of the cartesian equation of the ellipse combined with y = tg(alpha) * x // using the equation for ellipse with 0,0 in the center of the ellipse double aSquare = pow(width/2.0, 2); double bSquare = pow(height/2.0, 2); double tangens = tan(angle * M_PI / 180); double tanSquare = pow(tangens, 2); // calculate x pt.x = (long) sqrt( aSquare * bSquare / (bSquare + tanSquare * aSquare)); if (angle > 90 && angle < 270) pt.x *= -1; // sqrt returns the positive value of the square, take the negative value if necessary // calculate y pt.y = (long) (tangens * pt.x); pt.y *= -1; // reverse the sign because of inverted y-axis // offset the ellipse into the screen pt.x += x + (int)(width / 2); pt.y += y + (int)(height / 2); } return pt; } int GameEngine::DrawString(String const& textRef, int x, int y, int width, int height) { HFONT hOldFont; COLORREF oldColor; if (m_FontDraw != 0) hOldFont = (HFONT) SelectObject(m_HdcDraw, m_FontDraw); oldColor = SetTextColor(m_HdcDraw, m_ColDraw); SetBkMode(m_HdcDraw, TRANSPARENT); RECT rc = {x, y, x + width - 1, y + height - 1}; int result = DrawText(m_HdcDraw, textRef.ToTChar(), -1, &rc, DT_WORDBREAK); SetBkMode(m_HdcDraw, OPAQUE); SetTextColor(m_HdcDraw, oldColor); if (m_FontDraw != 0) SelectObject(m_HdcDraw, hOldFont); return result; } int GameEngine::DrawString(String const& textRef, int x, int y) { HFONT hOldFont; COLORREF oldColor; if (m_FontDraw != 0) hOldFont = (HFONT) SelectObject(m_HdcDraw, m_FontDraw); oldColor = SetTextColor(m_HdcDraw, m_ColDraw); SetBkMode(m_HdcDraw, TRANSPARENT); int count = 0; while (textRef.ToTChar()[count] != '\0') count++; int result = TextOut(m_HdcDraw, x, y, textRef.ToTChar(), count); SetBkMode(m_HdcDraw, OPAQUE); SetTextColor(m_HdcDraw, oldColor); if (m_FontDraw != 0) SelectObject(m_HdcDraw, hOldFont); return result; } bool GameEngine::DrawBitmap(Bitmap* bitmapPtr, int x, int y, RECT rect) { if (!bitmapPtr->Exists()) return false; int opacity = bitmapPtr->GetOpacity(); if (opacity == 0 && bitmapPtr->HasAlphaChannel()) return true; // don't draw if opacity == 0 and opacity is used HDC hdcMem = CreateCompatibleDC(m_HdcDraw); HBITMAP hbmOld = (HBITMAP) SelectObject(hdcMem, bitmapPtr->GetHandle()); if (bitmapPtr->HasAlphaChannel()) { BLENDFUNCTION blender={AC_SRC_OVER, 0, (int) (2.55 * opacity), AC_SRC_ALPHA}; // blend function combines opacity and pixel based transparency AlphaBlend(m_HdcDraw, x, y, rect.right - rect.left, rect.bottom - rect.top, hdcMem, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, blender); } else TransparentBlt(m_HdcDraw, x, y, rect.right - rect.left, rect.bottom - rect.top, hdcMem, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bitmapPtr->GetTransparencyColor()); SelectObject(hdcMem, hbmOld); DeleteDC(hdcMem); return true; } bool GameEngine::DrawBitmap(Bitmap* bitmapPtr, int x, int y) { if (!bitmapPtr->Exists()) return false; BITMAP bm; GetObject(bitmapPtr->GetHandle(), sizeof(bm), &bm); RECT rect = {0, 0, bm.bmWidth, bm.bmHeight}; return DrawBitmap(bitmapPtr, x, y, rect); } bool GameEngine::DrawSolidBackground(COLORREF color) { COLORREF oldColor = GetDrawColor(); SetColor(color); FillRect(0, 0, m_RectDraw.right, m_RectDraw.bottom); SetColor(oldColor); return true; } bool GameEngine::Repaint() { return InvalidateRect(m_hWindow, NULL, true)?true:false; } POINT GameEngine::GetLocation() { RECT info; POINT pos; GetWindowRect(m_hWindow, &info); pos.x = info.left; pos.y = info.top; return pos; } void GameEngine::SetLocation(int x, int y) { SetWindowPos(m_hWindow, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER); InvalidateRect(m_hWindow, 0, TRUE); } void GameEngine::SetFont(String const& fontNameRef, bool bold, bool italic, bool underline, int size) { if (m_FontDraw != 0) DeleteObject(m_FontDraw); LOGFONT ft; ZeroMemory(&ft, sizeof(ft)); _tcscpy_s(ft.lfFaceName, sizeof(ft.lfFaceName) / sizeof(TCHAR), fontNameRef.ToTChar()); ft.lfStrikeOut = 0; ft.lfUnderline = underline?1:0; ft.lfHeight = size; ft.lfEscapement = 0; ft.lfWeight = bold?FW_BOLD:0; ft.lfItalic = italic?1:0; m_FontDraw = CreateFontIndirect(&ft); } void GameEngine::RunGameLoop(bool value) { m_bRunGameLoop = value; } LRESULT GameEngine::HandleEvent(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam) { HDC hDC; PAINTSTRUCT ps; // Get window rectangle and HDC RECT WindowClientRect; GetClientRect(hWindow, &WindowClientRect); RECT UsedClientRect; UsedClientRect.left=UsedClientRect.top=0; UsedClientRect.right = GetWidth(); UsedClientRect.bottom = GetHeight(); double ScaleX=1,ScaleY=1; if(WindowClientRect.right!=0 &&WindowClientRect.bottom!=0) { ScaleX = (UsedClientRect.right-UsedClientRect.left)/(double)(WindowClientRect.right-WindowClientRect.left); ScaleY = (UsedClientRect.bottom-UsedClientRect.top)/(double)(WindowClientRect.bottom-WindowClientRect.top); } // Double buffering code HDC hBufferDC; HBITMAP hBufferBmp; HBITMAP hOldBmp; // Route Windows messages to game engine member functions switch (msg) { case WM_CREATE: // Set the game window and start the game SetWindow(hWindow); // User defined functions for start of the game m_GamePtr->GameStart(); return 0; case WM_ACTIVATE: // Activate/deactivate the game and update the Sleep status if (wParam != WA_INACTIVE) { //Lock hDC hDC = GetDC(hWindow); // Do user defined drawing functions //m_GamePtr->GameActivate(hDC, UsedClientRect); m_GamePtr->GameActivate(); // Release HDC ReleaseDC(hWindow, hDC); SetSleep(false); } else { //Lock hDC hDC = GetDC(hWindow); // Do user defined drawing functions //m_GamePtr->GameDeactivate(hDC, UsedClientRect); m_GamePtr->GameDeactivate(); // Release HDC ReleaseDC(hWindow, hDC); } return 0; case WM_PAINT: if (m_PaintDoublebuffered) { // Get window, rectangle and HDC hDC = BeginPaint(hWindow, &ps); // Double buffering code hBufferDC = CreateCompatibleDC(hDC); // Create the buffer, size is area used by client hBufferBmp = CreateCompatibleBitmap(hDC, GetWidth(), GetHeight()); hOldBmp = (HBITMAP) SelectObject(hBufferDC, hBufferBmp); // Do user defined drawing functions on the buffer, parameters added // for ease of drawing m_HdcDraw = hBufferDC; m_RectDraw = UsedClientRect; m_IsPainting = true; m_GamePtr->GamePaint(UsedClientRect); m_IsPainting = false; // As a last step copy the memdc to the hdc //BitBlt(hDC, 0, 0, iWidth, iHeight, hBufferDC, 0, 0, SRCCOPY); StretchBlt( hDC, 0,0,WindowClientRect.right-WindowClientRect.left,WindowClientRect.bottom-WindowClientRect.top, hBufferDC, 0, 0, GetWidth(),GetHeight(),SRCCOPY ); // Reset the old bmp of the buffer, mainly for show since we kill it anyway SelectObject(hBufferDC, hOldBmp); // Kill the buffer DeleteObject(hBufferBmp); DeleteDC(hBufferDC); // end paint EndPaint(hWindow, &ps); } else { m_HdcDraw = BeginPaint(hWindow, &ps); GetClientRect(hWindow, &m_RectDraw); m_IsPainting = true; m_GamePtr->GamePaint(m_RectDraw); m_IsPainting = false; EndPaint(hWindow, &ps); } return 0; case WM_CTLCOLOREDIT: return SendMessage((HWND) lParam, WM_CTLCOLOREDIT, wParam, lParam); // delegate this message to the child window case WM_CTLCOLORBTN: return SendMessage((HWND) lParam, WM_CTLCOLOREDIT, wParam, lParam); // delegate this message to the child window case WM_LBUTTONDOWN: m_GamePtr->MouseButtonAction(true, true, static_cast<int>(LOWORD(lParam)*ScaleX),static_cast<int>( HIWORD(lParam)*ScaleY), wParam); return 0; case WM_LBUTTONUP: m_GamePtr->MouseButtonAction(true, false, static_cast<int>(LOWORD(lParam)*ScaleX),static_cast<int>( HIWORD(lParam)*ScaleY), wParam); return 0; case WM_RBUTTONDOWN: m_GamePtr->MouseButtonAction(false, true, static_cast<int>(LOWORD(lParam)*ScaleX),static_cast<int>( HIWORD(lParam)*ScaleY), wParam); return 0; case WM_RBUTTONUP: m_GamePtr->MouseButtonAction(false, false, static_cast<int>(LOWORD(lParam)*ScaleX),static_cast<int>( HIWORD(lParam)*ScaleY), wParam); return 0; case WM_MOUSEMOVE: m_GamePtr->MouseMove(static_cast<int>(LOWORD(lParam)*ScaleX),static_cast<int>( HIWORD(lParam)*ScaleY), wParam); return 0; case WM_SYSCOMMAND: // trapping this message prevents a freeze after the ALT key is released if (wParam == SC_KEYMENU) return 0; // see win32 API : WM_KEYDOWN else break; case WM_DESTROY: // User defined code for exiting the game m_GamePtr->GameEnd(); // Delete the game engine delete GameEngine::GetSingleton(); // End the game and exit the application PostQuitMessage(0); return 0; case WM_SIZE: if(wParam==SIZE_MAXIMIZED) { // switch off the title bar DWORD dwStyle = GetWindowLong(m_hWindow, GWL_STYLE); dwStyle &= ~WS_CAPTION; SetWindowLong(m_hWindow, GWL_STYLE, dwStyle); //If you have changed certain window data using SetWindowLong, you must call SetWindowPos for the changes to take effect. SetWindowPos(m_hWindow, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); return 0; } return 0; //use ESC key to go from fullscreen window to smaller window case WM_KEYDOWN: switch (wParam) { case VK_ESCAPE: //alleen als fullscreen gewerkt wordt RECT WindowRect; GetWindowRect(hWindow,&WindowRect); if((WindowRect.right-WindowRect.left)>=GetSystemMetrics(SM_CXSCREEN)) { // turns title bar on/off DWORD dwStyle = GetWindowLong(m_hWindow, GWL_STYLE); if(dwStyle & WS_CAPTION)dwStyle &= ~WS_CAPTION; else dwStyle = dwStyle | WS_CAPTION; SetWindowLong(m_hWindow, GWL_STYLE, dwStyle); //dit zou moeten gecalled worden, maar na de lijn, is getclientrect verkeerd. //SetWindowPos(m_hWindow, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); } return 0; } return 0; } return DefWindowProc(hWindow, msg, wParam, lParam); } //----------------------------------------------------------------- // Caller methods //----------------------------------------------------------------- bool Caller::AddActionListener(Callable* targetPtr) { return AddListenerObject(targetPtr); } bool Caller::RemoveActionListener(Callable* targetPtr) { return RemoveListenerObject(targetPtr); } bool Caller::CallListeners() { for (vector<Callable*>::iterator it = m_TargetList.begin(); it != m_TargetList.end(); ++it) { (*it)->CallAction(this); } return (m_TargetList.size() > 0); } bool Caller::AddListenerObject(Callable* targetPtr) { for (vector<Callable*>::iterator it = m_TargetList.begin(); it != m_TargetList.end(); ++it) { if ((*it) == targetPtr) return false; } m_TargetList.push_back(targetPtr); return true; } bool Caller::RemoveListenerObject(Callable* targetPtr) { vector<Callable*>::iterator pos = find(m_TargetList.begin(), m_TargetList.end(), targetPtr); // find algorithm from STL if (pos == m_TargetList.end()) return false; else { m_TargetList.erase(pos); return true; } } //----------------------------------------------------------------- // Bitmap methods //----------------------------------------------------------------- // set static datamember to zero int Bitmap::m_nr = 0; Bitmap::Bitmap(String const& nameRef, bool createAlphaChannel): m_Handle(0), m_TransparencyKey(-1), m_Opacity(100), m_PixelsPtr(0), m_Exists(false) { // check if the file to load is a targa if (nameRef.EndsWith(".tga")) { m_IsTarga = true; m_HasAlphaChannel = true; TargaLoader* targa = new TargaLoader(); if (targa->Load(nameRef.ToTChar()) == 1) { m_Handle = CreateBitmap(targa->GetWidth(), targa->GetHeight(), 1, targa->GetBPP(), (void*)targa->GetImg()); if (m_Handle != 0) m_Exists = true; } delete targa; } // else load as bitmap else { m_IsTarga = false; m_HasAlphaChannel = createAlphaChannel; m_Handle = (HBITMAP) LoadImage(GameEngine::GetSingleton()->GetInstance(), nameRef.ToTChar(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); if (m_Handle != 0) m_Exists = true; } if (m_IsTarga || createAlphaChannel) LoadBitInfo(); } Bitmap::Bitmap(int IDBitmap, String const& sTypeRef, bool createAlphaChannel): m_TransparencyKey(-1), m_Opacity(100), m_Exists(false) { if (sTypeRef == "BITMAP") { m_IsTarga = false; m_HasAlphaChannel = createAlphaChannel; m_Handle = LoadBitmap(GameEngine::GetSingleton()->GetInstance(), MAKEINTRESOURCE(IDBitmap)); if (m_Handle != 0) m_Exists = true; if (createAlphaChannel) LoadBitInfo(); } else if (sTypeRef == "TGA") { m_IsTarga = true; m_HasAlphaChannel = true; String fileName = String("temp\\targa") + m_nr++ + ".tga"; Extract(IDBitmap, "TGA", fileName); TargaLoader* targa = new TargaLoader(); if (targa->Load(fileName.ToTChar()) == 1) { m_Handle = CreateBitmap(targa->GetWidth(), targa->GetHeight(), 1, targa->GetBPP(), (void*)targa->GetImg()); if (m_Handle != 0) m_Exists = true; } delete targa; LoadBitInfo(); } } void Bitmap::LoadBitInfo() { BITMAPINFOHEADER bminfoheader; ::ZeroMemory(&bminfoheader, sizeof(BITMAPINFOHEADER)); bminfoheader.biSize = sizeof(BITMAPINFOHEADER); bminfoheader.biWidth = GetWidth(); bminfoheader.biHeight = GetHeight(); bminfoheader.biPlanes = 1; bminfoheader.biBitCount = 32; bminfoheader.biCompression = BI_RGB; HDC windowDC = GetWindowDC(GameEngine::GetSingleton()->GetWindow()); m_PixelsPtr = new unsigned char[this->GetWidth() * this->GetHeight() * 4]; GetDIBits(windowDC, m_Handle, 0, GetHeight(), m_PixelsPtr, (BITMAPINFO*) &bminfoheader, DIB_RGB_COLORS); // load pixel info // premultiply if it's a targa if (m_IsTarga) { for (int count = 0; count < GetWidth() * GetHeight(); count++) { if (m_PixelsPtr[count * 4 + 3] < 255) { m_PixelsPtr[count * 4 + 2] = (unsigned char)((int) m_PixelsPtr[count * 4 + 2] * (int) m_PixelsPtr[count * 4 + 3] / 0xff); m_PixelsPtr[count * 4 + 1] = (unsigned char)((int) m_PixelsPtr[count * 4 + 1] * (int) m_PixelsPtr[count * 4 + 3] / 0xff); m_PixelsPtr[count * 4] = (unsigned char)((int) m_PixelsPtr[count * 4] * (int) m_PixelsPtr[count * 4 + 3] / 0xff); } } SetDIBits(windowDC, m_Handle, 0, GetHeight(), m_PixelsPtr, (BITMAPINFO*) &bminfoheader, DIB_RGB_COLORS); // save the pixel info for later manipulation } // add alpha channel values of 255 for every pixel if bmp else { for (int count = 0; count < GetWidth() * GetHeight(); count++) { m_PixelsPtr[count * 4 + 3] = 255; } } SetDIBits(windowDC, m_Handle, 0, GetHeight(), m_PixelsPtr, (BITMAPINFO*) &bminfoheader, DIB_RGB_COLORS); // save the pixel info for later manipulation } /* void Bitmap::Premultiply() // Multiply R, G and B with Alpha { //Note that the APIs use premultiplied alpha, which means that the red, //green and blue channel values in the bitmap must be premultiplied with //the alpha channel value. For example, if the alpha channel value is x, //the red, green and blue channels must be multiplied by x and divided by //0xff prior to the call. unsigned long Index,nPixels; unsigned char *bCur; short iPixelSize; // Set ptr to start of image bCur=pImage; // Calc number of pixels nPixels=iWidth*iHeight; // Get pixel size in bytes iPixelSize=iBPP/8; for(Index=0;Index!=nPixels;Index++) // For each pixel { *bCur=(unsigned char)((int)*bCur* (int)*(bCur+3)/0xff); *(bCur+1)=(unsigned char)((int)*(bCur+1)* (int)*(bCur+3)/0xff); *(bCur+2)=(unsigned char)((int)*(bCur+2)* (int)*(bCur+3)/0xff); bCur+=iPixelSize; // Jump to next pixel } } */ Bitmap::~Bitmap() { if (HasAlphaChannel()) { delete[] m_PixelsPtr; m_PixelsPtr = 0; } DeleteObject(m_Handle); } bool Bitmap::Exists() { return m_Exists; } void Bitmap::Extract(WORD id, String sType, String sFilename) { CreateDirectory(TEXT("temp\\"), NULL); HRSRC hrsrc = FindResource(NULL, MAKEINTRESOURCE(id), sType.ToTChar()); HGLOBAL hLoaded = LoadResource( NULL, hrsrc); LPVOID lpLock = LockResource(hLoaded); DWORD dwSize = SizeofResource(NULL, hrsrc); HANDLE hFile = CreateFile(sFilename.ToTChar(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); DWORD dwByteWritten; WriteFile(hFile, lpLock , dwSize , &dwByteWritten , NULL); CloseHandle(hFile); FreeResource(hLoaded); } HBITMAP Bitmap::GetHandle() { return m_Handle; } int Bitmap::GetWidth() { if (!Exists()) return 0; BITMAP bm; GetObject(m_Handle, sizeof(bm), &bm); return bm.bmWidth; } int Bitmap::GetHeight() { if (!Exists()) return 0; BITMAP bm; GetObject(m_Handle, sizeof(bm), &bm); return bm.bmHeight; } void Bitmap::SetTransparencyColor(COLORREF color) // converts transparency value to pixel-based alpha { m_TransparencyKey = color; if (HasAlphaChannel()) { BITMAPINFOHEADER bminfoheader; ::ZeroMemory(&bminfoheader, sizeof(BITMAPINFOHEADER)); bminfoheader.biSize = sizeof(BITMAPINFOHEADER); bminfoheader.biWidth = GetWidth(); bminfoheader.biHeight = GetHeight(); bminfoheader.biPlanes = 1; bminfoheader.biBitCount = 32; bminfoheader.biCompression = BI_RGB; HDC windowDC = GetWindowDC(GameEngine::GetSingleton()->GetWindow()); unsigned char* NewPixels = new unsigned char[this->GetWidth() * this->GetHeight() * 4]; // create 32 bit buffer for (int count = 0; count < this->GetWidth() * this->GetHeight(); ++count) { if (RGB(m_PixelsPtr[count * 4 + 2], m_PixelsPtr[count * 4 + 1], m_PixelsPtr[count * 4]) == color) // if the color of this pixel == transparency color { ((int*) NewPixels)[count] = 0; // set all four values to zero, this assumes sizeof(int) == 4 on this system // setting values to zero means premultiplying the RGB values to an alpha of 0 } else ((int*) NewPixels)[count] = ((int*) m_PixelsPtr)[count]; // copy all four values from m_Pixels to NewPixels } SetDIBits(windowDC, m_Handle, 0, GetHeight(), NewPixels, (BITMAPINFO*) &bminfoheader, DIB_RGB_COLORS); // insert pixels into bitmap delete[] NewPixels; //destroy buffer ReleaseDC(GameEngine::GetSingleton()->GetWindow(), windowDC); // release DC } } COLORREF Bitmap::GetTransparencyColor() { return m_TransparencyKey; } void Bitmap::SetOpacity(int opacity) { if (HasAlphaChannel()) { if (opacity > 100) m_Opacity = 100; else if (opacity < 0) m_Opacity = 0; else m_Opacity = opacity; } } int Bitmap::GetOpacity() { return m_Opacity; } bool Bitmap::IsTarga() { return m_IsTarga; } bool Bitmap::HasAlphaChannel() { return m_HasAlphaChannel; } //----------------------------------------------------------------- // Audio methods //----------------------------------------------------------------- // set static datamember to zero int Audio::m_nr = 0; #pragma warning(disable:4311) #pragma warning(disable:4312) Audio::Audio(String const& nameRef) : m_Playing(false), m_Paused(false), m_MustRepeat(false), m_hWnd(0), m_Volume(100) { if (nameRef.EndsWith(".mp3") || nameRef.EndsWith(".wav") || nameRef.EndsWith(".mid")) { m_Alias = String("audio") + m_nr++; m_FileName = nameRef; Create(nameRef); } } Audio::Audio(int IDAudio, String const& typeRef) : m_Playing(false), m_Paused(false), m_MustRepeat(false), m_hWnd(0), m_Volume(100) { if (typeRef == "MP3" || typeRef == "WAV" || typeRef == "MID") { m_Alias = String("audio") + m_nr++; m_FileName = String("temp\\") + m_Alias; if (typeRef == "MP3") m_FileName += ".mp3"; else if (typeRef == "WAV") m_FileName += ".wav"; else m_FileName += ".mid"; Extract(IDAudio, typeRef, m_FileName); Create(m_FileName); } } void Audio::Create(const String& nameRef) { TCHAR buffer[100]; String sendString; if (nameRef.EndsWith(".mp3")) sendString = String("open \"") + m_FileName + "\" type mpegvideo alias " + m_Alias; else if (nameRef.EndsWith(".wav")) sendString = String("open \"") + m_FileName + "\" type waveaudio alias " + m_Alias; else if (nameRef.EndsWith(".mid")) sendString = String("open \"") + m_FileName + "\" type sequencer alias " + m_Alias; int result = mciSendString(sendString.ToTChar(), 0, 0, 0); if (result != 0) return; sendString = String("set ") + m_Alias + " time format milliseconds"; mciSendString(sendString.ToTChar(), 0, 0, 0); sendString = String("status ") + m_Alias + " length"; mciSendString(sendString.ToTChar(), buffer, 100, 0); m_Duration = String(buffer).ToInteger(); // Create a window to catch the MM_MCINOTIFY message with m_hWnd = CreateWindow(TEXT("STATIC"), TEXT(""), 0, 0, 0, 0, 0, 0, 0, GameEngine::GetSingleton()->GetInstance(), 0); SetWindowLong(m_hWnd, GWL_WNDPROC, (LONG) AudioProcStatic); // set the custom message loop (subclassing) SetWindowLong(m_hWnd, GWL_USERDATA, (LONG) this); // set this object as the parameter for the Proc } void Audio::Extract(WORD id , String sType, String sFilename) { CreateDirectory(TEXT("temp\\"), NULL); HRSRC hrsrc = FindResource(NULL, MAKEINTRESOURCE(id), sType.ToTChar()); HGLOBAL hLoaded = LoadResource( NULL, hrsrc); LPVOID lpLock = LockResource(hLoaded); DWORD dwSize = SizeofResource(NULL, hrsrc); HANDLE hFile = CreateFile(sFilename.ToTChar(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); DWORD dwByteWritten; WriteFile(hFile, lpLock , dwSize , &dwByteWritten , NULL); CloseHandle(hFile); FreeResource(hLoaded); } #pragma warning(default:4311) #pragma warning(default:4312) Audio::~Audio() { Stop(); String sendString = String("close ") + m_Alias; mciSendString(sendString.ToTChar(), 0, 0, 0); // release the window resources if necessary if (m_hWnd) { DestroyWindow(m_hWnd); m_hWnd = 0; } } void Audio::Play(int msecStart, int msecStop) { if (!m_Playing) { m_Playing = true; m_Paused = false; if (msecStop == -1) QueuePlayCommand(msecStart); else QueuePlayCommand(msecStart, msecStop); } else if (m_Paused) { m_Paused = false; QueueResumeCommand(); } } void Audio::Pause() { if (m_Playing && !m_Paused) { m_Paused = true; QueuePauseCommand(); } } void Audio::Stop() { if (m_Playing) { m_Playing = false; m_Paused = false; QueueStopCommand(); } } void Audio::QueuePlayCommand(int msecStart) { QueueCommand(String("play ") + m_Alias + " from " + msecStart + " notify"); } void Audio::QueuePlayCommand(int msecStart, int msecStop) { QueueCommand(String("play ") + m_Alias + " from " + msecStart + " to " + msecStop + " notify"); } void Audio::QueuePauseCommand() { QueueCommand(String("pause ") + m_Alias); } void Audio::QueueResumeCommand() { QueueCommand(String("resume ") + m_Alias); } void Audio::QueueStopCommand() { QueueCommand(String("stop ") + m_Alias); } void Audio::QueueVolumeCommand(int volume) { QueueCommand(String("setaudio ") + m_Alias + " volume to " + volume * 10); } void Audio::QueueCommand(String const& commandRef) { //OutputDebugString(String("Queueing command: ") + command + "\n"); m_CommandQueue.push(commandRef); } void Audio::Tick() { if (!m_CommandQueue.empty()) { SendMCICommand(m_CommandQueue.front()); //OutputDebugString(String("Executing queued command: ") + m_CommandQueue.front() + "\n"); m_CommandQueue.pop(); } } void Audio::SendMCICommand(String const& commandRef) { int result = mciSendString(commandRef.ToTChar(), 0, 0, m_hWnd); } String& Audio::GetName() { return m_FileName; } String& Audio::GetAlias() { return m_Alias; } bool Audio::IsPlaying() { return m_Playing; } bool Audio::IsPaused() { return m_Paused; } void Audio::SwitchPlayingOff() { m_Playing = false; m_Paused = false; } void Audio::SetRepeat(bool repeat) { m_MustRepeat = repeat; } bool Audio::GetRepeat() { return m_MustRepeat; } int Audio::GetDuration() { return m_Duration; } void Audio::SetVolume(int volume) { m_Volume = min(100, max(0, volume)); // values below 0 and above 100 are trimmed to 0 and 100, respectively QueueVolumeCommand(volume); } int Audio::GetVolume() { return m_Volume; } bool Audio::Exists() { return m_hWnd?true:false; } int Audio::GetType() { return Caller::Audio; } LRESULT Audio::AudioProcStatic(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { #pragma warning(disable: 4312) Audio* audio = reinterpret_cast<Audio*>(GetWindowLong(hWnd, GWL_USERDATA)); #pragma warning(default: 4312) switch (msg) { case MM_MCINOTIFY: // message received when an audio file has finished playing - used for repeat function if (wParam == MCI_NOTIFY_SUCCESSFUL && audio->IsPlaying()) { audio->SwitchPlayingOff(); if (audio->GetRepeat()) audio->Play(); // repeat the audio else audio->CallListeners(); // notify listeners that the audio file has come to an end } } return 0; } //----------------------------------------------------------------- // TextBox methods //----------------------------------------------------------------- #pragma warning(disable:4311) #pragma warning(disable:4312) TextBox::TextBox(String const& textRef) : m_x(0), m_y(0), m_BgColor(RGB(255, 255, 255)), m_ForeColor(RGB(0, 0, 0)), m_BgColorBrush(0), m_Font(0), m_OldFont(0) { // Create the edit box m_hWndEdit = CreateWindow(TEXT("EDIT"), textRef.ToTChar(), WS_BORDER | WS_CHILD | WS_CLIPSIBLINGS | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL, 0, 0, 0, 0, GameEngine::GetSingleton()->GetWindow(), NULL, GameEngine::GetSingleton()->GetInstance(), NULL); // Set de nieuwe WNDPROC voor de edit box, en houd de oude bij m_procOldEdit = (WNDPROC) SetWindowLong(m_hWndEdit, GWL_WNDPROC, (LONG) EditProcStatic); // Stel dit object in als userdata voor de statische wndproc functie van de edit box zodat deze members kan aanroepen SetWindowLong(m_hWndEdit, GWL_USERDATA, (LONG) this); } TextBox::TextBox() : m_x(0), m_y(0), m_BgColor(RGB(255, 255, 255)), m_ForeColor(RGB(0, 0, 0)), m_BgColorBrush(0), m_Font(0), m_OldFont(0) { // Create the edit box m_hWndEdit = CreateWindow(TEXT("EDIT"), TEXT(""), WS_BORDER | WS_CHILD | WS_CLIPSIBLINGS | WS_TABSTOP | ES_LEFT | ES_AUTOHSCROLL, 0, 0, 0, 0, GameEngine::GetSingleton()->GetWindow(), NULL, GameEngine::GetSingleton()->GetInstance(), NULL); // Set de nieuwe WNDPROC voor de edit box, en houd de oude bij m_procOldEdit = (WNDPROC) SetWindowLong(m_hWndEdit, GWL_WNDPROC, (LONG) EditProcStatic); // Stel dit object in als userdata voor de statische wndproc functie van de edit box zodat deze members kan aanroepen SetWindowLong(m_hWndEdit, GWL_USERDATA, (LONG) this); } #pragma warning(default:4311) #pragma warning(default:4312) TextBox::~TextBox() { // release the background brush if necessary if (m_BgColorBrush != 0) { DeleteObject(m_BgColorBrush); m_BgColorBrush = 0; } // release the font if necessary if (m_Font != 0) { SelectObject(GetDC(m_hWndEdit), m_OldFont); DeleteObject(m_Font); m_Font = m_OldFont = 0; } // release the window resources DestroyWindow(m_hWndEdit); m_hWndEdit = NULL; } void TextBox::SetBounds(int x, int y, int width, int height) { m_x = x; m_y = y; MoveWindow(m_hWndEdit, x, y, width, height, true); } RECT TextBox::GetRect() { RECT rc; GetClientRect(m_hWndEdit, &rc); rc.left += m_x; rc.right += m_x; rc.top += m_y; rc.bottom += m_y; return rc; } void TextBox::SetEnabled(bool bEnable) { EnableWindow(m_hWndEdit, bEnable); } void TextBox::Update() { UpdateWindow(m_hWndEdit); } void TextBox::Show() { // Show and update the edit box ShowWindow(m_hWndEdit, SW_SHOW); UpdateWindow(m_hWndEdit); } void TextBox::Hide() { // Show and update the edit box ShowWindow(m_hWndEdit, SW_HIDE); UpdateWindow(m_hWndEdit); } String TextBox::GetText() { int textLength = (int) SendMessage(m_hWndEdit, (UINT) WM_GETTEXTLENGTH, 0, 0); TCHAR* bufferPtr = new TCHAR[textLength + 1]; SendMessage(m_hWndEdit, (UINT) WM_GETTEXT, (WPARAM) textLength + 1, (LPARAM) bufferPtr); String newString(bufferPtr); delete[] bufferPtr; return newString; } void TextBox::SetText(String const& textRef) { SendMessage(m_hWndEdit, WM_SETTEXT, 0, (LPARAM) textRef.ToTChar()); } void TextBox::SetFont(String const& fontNameRef, bool bold, bool italic, bool underline, int size) { LOGFONT ft; _tcscpy_s(ft.lfFaceName, sizeof(ft.lfFaceName) / sizeof(TCHAR), fontNameRef.ToTChar()); ft.lfStrikeOut = 0; ft.lfUnderline = underline?1:0; ft.lfHeight = size; ft.lfEscapement = 0; ft.lfWeight = bold?FW_BOLD:0; ft.lfItalic = italic?1:0; // clean up if another custom font was already in place if (m_Font != 0) { DeleteObject(m_Font); } // create the new font. The WM_CTLCOLOREDIT message will set the font when the textbox is about to redraw m_Font = CreateFontIndirect(&ft); // redraw the textbox InvalidateRect(m_hWndEdit, NULL, true); } void TextBox::SetForecolor( COLORREF color ) { m_ForeColor = color; // redraw the textbox InvalidateRect(m_hWndEdit, NULL, true); } void TextBox::SetBackcolor( COLORREF color ) { m_BgColor = color; if (m_BgColorBrush != 0) DeleteObject(m_BgColorBrush); m_BgColorBrush = CreateSolidBrush( color ); // redraw the textbox InvalidateRect(m_hWndEdit, NULL, true); } COLORREF TextBox::GetForecolor() { return m_ForeColor; } COLORREF TextBox::GetBackcolor() { return m_BgColor; } HBRUSH TextBox::GetBackcolorBrush() { return m_BgColorBrush; } LRESULT TextBox::EditProcStatic(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { #pragma warning(disable: 4312) return reinterpret_cast<TextBox*>(GetWindowLong(hWnd, GWL_USERDATA))->EditProc(hWnd, msg, wParam, lParam); #pragma warning(default: 4312) } LRESULT TextBox::EditProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CTLCOLOREDIT: SetBkColor((HDC) wParam, GetBackcolor() ); SetTextColor((HDC) wParam, GetForecolor() ); if (m_Font != 0) { if (m_OldFont == 0) m_OldFont = (HFONT) SelectObject((HDC) wParam, m_Font); else SelectObject((HDC) wParam, m_Font); } return (LRESULT) GetBackcolorBrush(); case WM_CHAR: if (wParam == VK_TAB) return 0; if (wParam == VK_RETURN) return 0; break; case WM_KEYDOWN : switch (wParam) { case VK_TAB: if (GameEngine::GetSingleton()->IsKeyDown(VK_SHIFT)) GameEngine::GetSingleton()->TabPrevious(hWnd); else GameEngine::GetSingleton()->TabNext(hWnd); return 0; case VK_ESCAPE: SetFocus(GetParent(hWnd)); return 0; case VK_RETURN: //if (m_Target) result = m_Target->CallAction(this); CallListeners(); break; } } return CallWindowProc(m_procOldEdit, hWnd, msg, wParam, lParam); } //----------------------------------------------------------------- // Button methods //----------------------------------------------------------------- #pragma warning(disable:4311) #pragma warning(disable:4312) Button::Button(String const& textRef) : m_x(0), m_y(0), m_Armed(false), m_Font(0), m_OldFont(0) { // Create the button object m_hWndButton = CreateWindow(TEXT("BUTTON"), textRef.ToTChar(), WS_BORDER | WS_CHILD | WS_CLIPSIBLINGS | WS_TABSTOP | BS_PUSHBUTTON, 0, 0, 0, 0, GameEngine::GetSingleton()->GetWindow(), NULL, GameEngine::GetSingleton()->GetInstance(), NULL); // Set de new WNDPROC for the button, and store the old one m_procOldButton = (WNDPROC) SetWindowLong(m_hWndButton, GWL_WNDPROC, (LONG) ButtonProcStatic); // Store 'this' as data for the Button object so that the static PROC can call the member proc SetWindowLong(m_hWndButton, GWL_USERDATA, (LONG) this); } Button::Button() : m_x(0), m_y(0), m_Armed(false), m_Font(0), m_OldFont(0) { // Create the button object m_hWndButton = CreateWindow(TEXT("BUTTON"), TEXT(""), WS_BORDER | WS_CHILD | WS_CLIPSIBLINGS | WS_TABSTOP | BS_PUSHBUTTON, 0, 0, 0, 0, GameEngine::GetSingleton()->GetWindow(), NULL, GameEngine::GetSingleton()->GetInstance(), NULL); // Set de new WNDPROC for the button, and store the old one m_procOldButton = (WNDPROC) SetWindowLong(m_hWndButton, GWL_WNDPROC, (LONG) ButtonProcStatic); // Store 'this' as data for the Button object so that the static PROC can call the member proc SetWindowLong(m_hWndButton, GWL_USERDATA, (LONG) this); } #pragma warning(default:4311) #pragma warning(default:4312) Button::~Button() { // release the font if necessary if (m_Font != 0) { SelectObject(GetDC(m_hWndButton), m_OldFont); DeleteObject(m_Font); m_Font = m_OldFont = 0; } // release the window resource DestroyWindow(m_hWndButton); m_hWndButton = NULL; } void Button::SetBounds(int x, int y, int width, int height) { m_x = x; m_y = y; MoveWindow(m_hWndButton, x, y, width, height, true); } RECT Button::GetRect() { RECT rc; GetClientRect(m_hWndButton, &rc); rc.left += m_x; rc.right += m_x; rc.top += m_y; rc.bottom += m_y; return rc; } void Button::SetEnabled(bool bEnable) { EnableWindow(m_hWndButton, bEnable); } void Button::Update() { UpdateWindow(m_hWndButton); } void Button::Show() { // Show and update the button ShowWindow(m_hWndButton, SW_SHOW); UpdateWindow(m_hWndButton); } void Button::Hide() { // Show and update the button ShowWindow(m_hWndButton, SW_HIDE); UpdateWindow(m_hWndButton); } String Button::GetText() { int textLength = (int) SendMessage(m_hWndButton, (UINT) WM_GETTEXTLENGTH, 0, 0); TCHAR* bufferPtr = new TCHAR[textLength + 1]; SendMessage(m_hWndButton, (UINT) WM_GETTEXT, (WPARAM) textLength + 1, (LPARAM) bufferPtr); String newString(bufferPtr); delete[] bufferPtr; return newString; } void Button::SetText(String const& textRef) { SendMessage(m_hWndButton, WM_SETTEXT, 0, (LPARAM) textRef.ToTChar()); } void Button::SetFont(String const& fontNameRef, bool bold, bool italic, bool underline, int size) { LOGFONT ft; _tcscpy_s(ft.lfFaceName, sizeof(ft.lfFaceName) / sizeof(TCHAR), fontNameRef.ToTChar()); ft.lfStrikeOut = 0; ft.lfUnderline = underline?1:0; ft.lfHeight = size; ft.lfEscapement = 0; ft.lfWeight = bold?FW_BOLD:0; ft.lfItalic = italic?1:0; // clean up if another custom font was already in place if (m_Font != 0) { DeleteObject(m_Font); } // create the new font. The WM_CTLCOLOREDIT message will set the font when the button is about to redraw m_Font = CreateFontIndirect(&ft); // redraw the button InvalidateRect(m_hWndButton, NULL, true); } LRESULT Button::ButtonProcStatic(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { #pragma warning(disable: 4312) return reinterpret_cast<Button*>(GetWindowLong(hWnd, GWL_USERDATA))->ButtonProc(hWnd, msg, wParam, lParam); #pragma warning(default: 4312) } LRESULT Button::ButtonProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CTLCOLOREDIT: if (m_Font != 0) { if (m_OldFont == 0) m_OldFont = (HFONT) SelectObject((HDC) wParam, m_Font); else SelectObject((HDC) wParam, m_Font); } return 0; case WM_CHAR: if (wParam == VK_TAB) return 0; if (wParam == VK_RETURN) return 0; break; case WM_KEYDOWN : switch (wParam) { case VK_TAB: if (GameEngine::GetSingleton()->IsKeyDown(VK_SHIFT)) GameEngine::GetSingleton()->TabPrevious(hWnd); else GameEngine::GetSingleton()->TabNext(hWnd); return 0; case VK_ESCAPE: SetFocus(GetParent(hWnd)); return 0; case VK_SPACE: //if (m_Target) result = m_Target->CallAction(this); CallListeners(); } break; case WM_LBUTTONDOWN : case WM_LBUTTONDBLCLK: // clicking fast will throw LBUTTONDBLCLK's as well as LBUTTONDOWN's, you need to capture both to catch all button clicks m_Armed = true; break; case WM_LBUTTONUP : if (m_Armed) { RECT rc; POINT pt; GetWindowRect(hWnd, &rc); GetCursorPos(&pt); //if (PtInRect(&rc, pt) && m_Target) result = m_Target->CallAction(this); if (PtInRect(&rc, pt)) CallListeners(); m_Armed = false; } } return CallWindowProc(m_procOldButton, hWnd, msg, wParam, lParam); } //----------------------------------------------------------------- // Timer methods //----------------------------------------------------------------- Timer::Timer(int msec, Callable* targetPtr) : m_IsRunning(false) { m_Delay = msec; AddActionListener(targetPtr); } Timer::~Timer() { if (m_IsRunning) Stop(); // stop closes the handle // no objects to delete } void Timer::Start() { if (m_IsRunning == false) { CreateTimerQueueTimer(&m_TimerHandle, NULL, TimerProcStatic, (void*) this, m_Delay, m_Delay, WT_EXECUTEINTIMERTHREAD); m_IsRunning = true; } } void Timer::Stop() { if (m_IsRunning == true) { DeleteTimerQueueTimer(NULL, m_TimerHandle, NULL); //CloseHandle (m_TimerHandle); DeleteTimerQueueTimer automatically closes the handle? MSDN Documentation seems to suggest this m_IsRunning = false; } } bool Timer::IsRunning() { return m_IsRunning; } void Timer::SetDelay(int msec) { m_Delay = max(msec, 1); // timer will not accept values less than 1 msec if (m_IsRunning) { Stop(); Start(); } } int Timer::GetDelay() { return m_Delay; } void CALLBACK Timer::TimerProcStatic(void* lpParameter, BOOLEAN TimerOrWaitFired) { Timer* timer = reinterpret_cast<Timer*>(lpParameter); //if (timer->m_IsRunning) timer->m_Target->CallAction(timer); if (timer->m_IsRunning) timer->CallListeners(); } //----------------------------------------------------------------- // String methods // CBUGFIX //----------------------------------------------------------------- String::String(wchar_t const* wideTextPtr) { m_Length = (int) wcslen(wideTextPtr) + 1; // include room for null terminator m_TextPtr = new TCHAR[m_Length]; if (sizeof(TCHAR) == 2) _tcscpy_s(m_TextPtr, m_Length, (TCHAR*) wideTextPtr); else WideCharToMultiByte(CP_ACP, 0, wideTextPtr, -1, (char*) m_TextPtr, m_Length, NULL, NULL); } String::String(char const* singleTextPtr) { m_Length = (int) strlen(singleTextPtr) + 1; // inlude room for null terminator m_TextPtr = new TCHAR[m_Length]; if (sizeof(TCHAR) == 1) strcpy_s((char*) m_TextPtr, m_Length, singleTextPtr); else MultiByteToWideChar(CP_ACP, 0, singleTextPtr, -1, (wchar_t*) m_TextPtr, m_Length * 2); } String::String(String const& sRef) { m_Length = sRef.GetLength() + 1; // include room for null terminator m_TextPtr = new TCHAR[m_Length]; _tcscpy_s(m_TextPtr, m_Length, sRef.ToTChar()); } String::String(wchar_t character) { m_Length = 2; // include room for null terminator m_TextPtr = new TCHAR[m_Length]; m_TextPtr[0] = character; m_TextPtr[1] = '\0'; } String::String(char character) { m_Length = 2; // include room for null terminator m_TextPtr = new TCHAR[m_Length]; m_TextPtr[0] = character; m_TextPtr[1] = '\0'; } String::~String() { delete m_TextPtr; m_TextPtr = 0; } String& String::operator=(String const& sRef) { if (this != &sRef) // beware of self assignment: s = s { delete m_TextPtr; m_Length = sRef.GetLength() + 1; m_TextPtr = new TCHAR[m_Length]; _tcscpy_s(m_TextPtr, m_Length, sRef.ToTChar()); } return *this; } String& String::operator+=(String const& sRef) { m_Length = this->GetLength() + sRef.GetLength() + 1; TCHAR* buffer = new TCHAR[m_Length]; _tcscpy_s(buffer, m_Length, m_TextPtr); _tcscat_s(buffer, m_Length, sRef.m_TextPtr); delete m_TextPtr; m_TextPtr = buffer; return *this; } String& String::operator+=(wchar_t* wideTextPtr) { return *this += String(wideTextPtr); } String& String::operator+=(char* singleTextPtr) { return *this += String(singleTextPtr); } String& String::operator+=(int number) { char buffer[65]; // an int will never take more than 65 characters (int64 is max 20 characters) (QUESTIONMARK: why use more then 20 then??) _itoa_s(number, buffer, sizeof(buffer), 10); return *this += String(buffer); } String& String::operator+=(size_t number) { char buffer[65]; // an int will never take more than 65 characters (int64 is max 20 characters) _ultoa_s((unsigned long) number, buffer, sizeof(buffer), 10); return *this += String(buffer); } String& String::operator+=(double number) { char buffer[_CVTBUFSIZE]; _gcvt_s(buffer, _CVTBUFSIZE, number, 40); // max 40 digits if (number == (int) number) // _gcvt_s forgets a trailing 0 when there are no significant digits behind the comma, so add it manually { size_t length = strlen(buffer); buffer[length] = '0'; buffer[length+1] = '\0'; } return *this += String(buffer); } String& String::operator+=(wchar_t character) { return *this += String(character); } String& String::operator+=(char character) { return *this += String(character); } String String::operator+(String const& sRef) { String newString = *this; newString += sRef; return newString; } String String::operator+(wchar_t* wideTextPtr) { String newString = *this; newString += wideTextPtr; return newString; } String String::operator+(char* singleTextPtr) { String newString = *this; newString += singleTextPtr; return newString; } String String::operator+(int number) { String newString = *this; newString += number; return newString; } String String::operator+(size_t number) { String newString = *this; newString += number; return newString; } String String::operator+(double number) { String newString = *this; newString += number; return newString; } String String::operator+(wchar_t character) { String newString = *this; newString += character; return newString; } String String::operator+(char character) { String newString = *this; newString += character; return newString; } bool String::operator==(String const& sRef) { return this->Equals(sRef); } bool String::operator==(String const& sRef) const { return this->Equals(sRef); } TCHAR String::CharAt(int index) const { if (index > this->GetLength() - 1) return 0; //QUESTIONMARK return m_TextPtr[index]; } String String::Replace(TCHAR oldChar, TCHAR newChar) const { String newString = *this; for (int count = 0; count < newString.GetLength(); count++) { if (newString.m_TextPtr[count] == oldChar) newString.m_TextPtr[count] = newChar; } return newString; } String String::SubString(int index) const { if (index > this->GetLength() - 1) return String(""); return String(m_TextPtr + index); } String String::SubString(int index, int length) const { if (index + length - 1 > this->GetLength() - 1) return String(""); String newString = *this; newString.m_TextPtr[index + length] = TEXT('\0'); return String(newString.m_TextPtr + index); } String String::ToLowerCase() const { String newString = *this; for (int count = 0; count < newString.GetLength(); count++) { TCHAR character = newString.m_TextPtr[count]; if (character < 91 && character > 64) newString.m_TextPtr[count] += 32; } return newString; } String String::ToUpperCase() const { String newString = *this; for (int count = 0; count < newString.GetLength(); count++) { TCHAR character = newString.m_TextPtr[count]; if (character < 123 && character > 96) newString.m_TextPtr[count] -= 32; } return newString; } String String::Trim() const { int beginIndex = 0; int endIndex = this->GetLength() - 1; while (m_TextPtr[beginIndex] == TEXT(' ') && m_TextPtr[beginIndex] != TEXT('\0')) ++beginIndex; while (m_TextPtr[endIndex] == TEXT(' ') && endIndex > 0) --endIndex; return this->SubString(beginIndex, endIndex - beginIndex + 1); } int String::IndexOf(TCHAR character) const { int index = 0; while (m_TextPtr[index] != character && m_TextPtr[index] != TEXT('\0')) ++index; if (m_TextPtr[index] == character) return index; else return -1; } int String::LastIndexOf(TCHAR character) const { int index = this->GetLength() - 1; while (m_TextPtr[index] != character && index > 0) --index; if (m_TextPtr[index] == character) return index; else return -1; } bool String::StartsWith(String const& sRef) const { // return false if 2nd string is longer than 1st string if (this->GetLength() < sRef.GetLength()) return false; // check individual characters bool result = true; int index = 0; int max = sRef.GetLength(); while (index < max && result) { if (m_TextPtr[index] != sRef.m_TextPtr[index]) result = false; else ++index; } return result; } bool String::EndsWith(String const& sRef) const { // return false if 2nd string is longer than 1st string if (this->GetLength() < sRef.GetLength()) return false; String temp = this->SubString(this->GetLength() - sRef.GetLength()); return sRef.Equals(temp); } int String::GetLength() const { return m_Length - 1; // don't include the null terminator when asked how many characters are in the string } bool String::Equals(String const& sRef) const { if (sRef.GetLength() != this->GetLength()) return false; return _tcscmp(this->ToTChar(), sRef.ToTChar())?false:true; // return true if cmp returns 0, false if not } int String::ToInteger() const { return _tstoi(this->ToTChar()); } double String::ToDouble() const { return _tcstod(this->ToTChar(), 0); } TCHAR* String::ToTChar() const { return m_TextPtr; } //----------------------------------------------------------------- // Targa loader code //----------------------------------------------------------------- #define IMG_OK 0x1 #define IMG_ERR_NO_FILE 0x2 #define IMG_ERR_MEM_FAIL 0x4 #define IMG_ERR_BAD_FORMAT 0x8 #define IMG_ERR_UNSUPPORTED 0x40 TargaLoader::TargaLoader() { pImage=pPalette=pData=NULL; iWidth=iHeight=iBPP=bEnc=0; lImageSize=0; } TargaLoader::~TargaLoader() { if(pImage) { delete [] pImage; pImage=NULL; } if(pPalette) { delete [] pPalette; pPalette=NULL; } if(pData) { delete [] pData; pData=NULL; } } int TargaLoader::Load(TCHAR* szFilename) { using namespace std; ifstream fIn; unsigned long ulSize; int iRet; // Clear out any existing image and palette if(pImage) { delete [] pImage; pImage=NULL; } if(pPalette) { delete [] pPalette; pPalette=NULL; } // Open the specified file //fIn.open(szFilename,ios::binary); fIn.open(szFilename,ios::binary); if(fIn==NULL) return IMG_ERR_NO_FILE; // Get file size fIn.seekg(0,ios_base::end); ulSize= (unsigned long) fIn.tellg(); fIn.seekg(0,ios_base::beg); // Allocate some space // Check and clear pDat, just in case if(pData) delete [] pData; pData=new unsigned char[ulSize]; if(pData==NULL) { fIn.close(); return IMG_ERR_MEM_FAIL; } // Read the file into memory fIn.read((char*)pData,ulSize); fIn.close(); // Process the header iRet=ReadHeader(); if(iRet!=IMG_OK) return iRet; switch(bEnc) { case 1: // Raw Indexed // Check filesize against header values if((lImageSize+18+pData[0]+768)>ulSize) return IMG_ERR_BAD_FORMAT; // Double check image type field if(pData[1]!=1) return IMG_ERR_BAD_FORMAT; // Load image data iRet=LoadRawData(); if(iRet!=IMG_OK) return iRet; // Load palette iRet=LoadTgaPalette(); if(iRet!=IMG_OK) return iRet; break; case 2: // Raw RGB // Check filesize against header values if((lImageSize+18+pData[0])>ulSize) return IMG_ERR_BAD_FORMAT; // Double check image type field if(pData[1]!=0) return IMG_ERR_BAD_FORMAT; // Load image data iRet=LoadRawData(); if(iRet!=IMG_OK) return iRet; //BGRtoRGB(); // Convert to RGB break; case 9: // RLE Indexed // Double check image type field if(pData[1]!=1) return IMG_ERR_BAD_FORMAT; // Load image data iRet=LoadTgaRLEData(); if(iRet!=IMG_OK) return iRet; // Load palette iRet=LoadTgaPalette(); if(iRet!=IMG_OK) return iRet; break; case 10: // RLE RGB // Double check image type field if(pData[1]!=0) return IMG_ERR_BAD_FORMAT; // Load image data iRet=LoadTgaRLEData(); if(iRet!=IMG_OK) return iRet; //BGRtoRGB(); // Convert to RGB break; default: return IMG_ERR_UNSUPPORTED; } // Check flip bit if((pData[17] & 0x20)==0) FlipImg(); // Release file memory delete [] pData; pData=NULL; return IMG_OK; } int TargaLoader::ReadHeader() // Examine the header and populate our class attributes { short ColMapStart,ColMapLen; short x1,y1,x2,y2; if(pData==NULL) return IMG_ERR_NO_FILE; if(pData[1]>1) // 0 (RGB) and 1 (Indexed) are the only types we know about return IMG_ERR_UNSUPPORTED; bEnc=pData[2]; // Encoding flag 1 = Raw indexed image // 2 = Raw RGB // 3 = Raw greyscale // 9 = RLE indexed // 10 = RLE RGB // 11 = RLE greyscale // 32 & 33 Other compression, indexed if(bEnc>11) // We don't want 32 or 33 return IMG_ERR_UNSUPPORTED; // Get palette info memcpy(&ColMapStart,&pData[3],2); memcpy(&ColMapLen,&pData[5],2); // Reject indexed images if not a VGA palette (256 entries with 24 bits per entry) if(pData[1]==1) // Indexed { if(ColMapStart!=0 || ColMapLen!=256 || pData[7]!=24) return IMG_ERR_UNSUPPORTED; } // Get image window and produce width & height values memcpy(&x1,&pData[8],2); memcpy(&y1,&pData[10],2); memcpy(&x2,&pData[12],2); memcpy(&y2,&pData[14],2); iWidth=(x2-x1); iHeight=(y2-y1); if(iWidth<1 || iHeight<1) return IMG_ERR_BAD_FORMAT; // Bits per Pixel iBPP=pData[16]; // Check flip / interleave byte if(pData[17]>32) // Interleaved data return IMG_ERR_UNSUPPORTED; // Calculate image size lImageSize=(iWidth * iHeight * (iBPP/8)); return IMG_OK; } int TargaLoader::LoadRawData() // Load uncompressed image data { short iOffset; if(pImage) // Clear old data if present delete [] pImage; pImage=new unsigned char[lImageSize]; if(pImage==NULL) return IMG_ERR_MEM_FAIL; iOffset=pData[0]+18; // Add header to ident field size if(pData[1]==1) // Indexed images iOffset+=768; // Add palette offset memcpy(pImage,&pData[iOffset],lImageSize); return IMG_OK; } int TargaLoader::LoadTgaRLEData() // Load RLE compressed image data { short iOffset,iPixelSize; unsigned char *pCur; unsigned long Index=0; unsigned char bLength,bLoop; // Calculate offset to image data iOffset=pData[0]+18; // Add palette offset for indexed images if(pData[1]==1) iOffset+=768; // Get pixel size in bytes iPixelSize=iBPP/8; // Set our pointer to the beginning of the image data pCur=&pData[iOffset]; // Allocate space for the image data if(pImage!=NULL) delete [] pImage; pImage=new unsigned char[lImageSize]; if(pImage==NULL) return IMG_ERR_MEM_FAIL; // Decode while(Index<lImageSize) { if(*pCur & 0x80) // Run length chunk (High bit = 1) { bLength=*pCur-127; // Get run length pCur++; // Move to pixel data // Repeat the next pixel bLength times for(bLoop=0;bLoop!=bLength;++bLoop,Index+=iPixelSize) memcpy(&pImage[Index],pCur,iPixelSize); pCur+=iPixelSize; // Move to the next descriptor chunk } else // Raw chunk { bLength=*pCur+1; // Get run length pCur++; // Move to pixel data // Write the next bLength pixels directly for(bLoop=0;bLoop!=bLength;++bLoop,Index+=iPixelSize,pCur+=iPixelSize) memcpy(&pImage[Index],pCur,iPixelSize); } } return IMG_OK; } int TargaLoader::LoadTgaPalette() // Load a 256 color palette { unsigned char bTemp; short iIndex,iPalPtr; // Delete old palette if present if(pPalette) { delete [] pPalette; pPalette=NULL; } // Create space for new palette pPalette=new unsigned char[768]; if(pPalette==NULL) return IMG_ERR_MEM_FAIL; // VGA palette is the 768 bytes following the header memcpy(pPalette,&pData[pData[0]+18],768); // Palette entries are BGR ordered so we have to convert to RGB for(iIndex=0,iPalPtr=0;iIndex!=256;++iIndex,iPalPtr+=3) { bTemp=pPalette[iPalPtr]; // Get Blue value pPalette[iPalPtr]=pPalette[iPalPtr+2]; // Copy Red to Blue pPalette[iPalPtr+2]=bTemp; // Replace Blue at the end } return IMG_OK; } void TargaLoader::BGRtoRGB() // Convert BGR to RGB (or back again) { unsigned long Index,nPixels; unsigned char *bCur; unsigned char bTemp; short iPixelSize; // Set ptr to start of image bCur=pImage; // Calc number of pixels nPixels=iWidth*iHeight; // Get pixel size in bytes iPixelSize=iBPP/8; for(Index=0;Index!=nPixels;Index++) // For each pixel { bTemp=*bCur; // Get Blue value *bCur=*(bCur+2); // Swap red value into first position *(bCur+2)=bTemp; // Write back blue to last position bCur+=iPixelSize; // Jump to next pixel } } void TargaLoader::FlipImg() // Flips the image vertically (Why store images upside down?) { unsigned char bTemp; unsigned char *pLine1, *pLine2; int iLineLen,iIndex; iLineLen=iWidth*(iBPP/8); pLine1=pImage; pLine2=&pImage[iLineLen * (iHeight - 1)]; for( ;pLine1<pLine2;pLine2-=(iLineLen*2)) { for(iIndex=0;iIndex!=iLineLen;pLine1++,pLine2++,iIndex++) { bTemp=*pLine1; *pLine1=*pLine2; *pLine2=bTemp; } } } int TargaLoader::GetBPP() { return iBPP; } int TargaLoader::GetWidth() { return iWidth; } int TargaLoader::GetHeight() { return iHeight; } unsigned char* TargaLoader::GetImg() { return pImage; } unsigned char* TargaLoader::GetPalette() { return pPalette; } //----------------------------------------------------------------- // OutputDebugString functions //----------------------------------------------------------------- void OutputDebugString(String const& textRef) { OutputDebugString(textRef.ToTChar()); } //--------------------------- // HitRegion methods //--------------------------- HitRegion::HitRegion() : m_HitRegion(0) { // nothing to create } HitRegion::~HitRegion() { if (m_HitRegion) DeleteObject(m_HitRegion); } bool HitRegion::Create(int type, int x, int y, int width, int height) { if (m_HitRegion) DeleteObject(m_HitRegion); if (type == HitRegion::Ellipse) m_HitRegion = CreateEllipticRgn(x, y, x + width, y + height); else m_HitRegion = CreateRectRgn(x, y, x + width, y + height); return true; } bool HitRegion::Create(int type, POINT* pointsArr, int numberOfPoints) { if (m_HitRegion) DeleteObject(m_HitRegion); m_HitRegion = CreatePolygonRgn(pointsArr, numberOfPoints, WINDING); return true; } bool HitRegion::Create(int type, Bitmap* bmpPtr, COLORREF cTransparent, COLORREF cTolerance) { if (!bmpPtr->Exists()) return false; HBITMAP hBitmap = bmpPtr->GetHandle(); if (!hBitmap) return false; if (m_HitRegion) DeleteObject(m_HitRegion); // for some reason, the BitmapToRegion function has R and B switched. Flipping the colors to get the right result. COLORREF flippedTransparent = RGB(GetBValue(cTransparent), GetGValue(cTransparent), GetRValue(cTransparent)); COLORREF flippedTolerance = RGB(GetBValue(cTolerance), GetGValue(cTolerance), GetRValue(cTolerance)); m_HitRegion = BitmapToRegion(hBitmap, flippedTransparent, flippedTolerance); return (m_HitRegion?true:false); } // BitmapToRegion : Create a region from the "non-transparent" pixels of a bitmap // Author : Jean-Edouard Lachand-Robert (http://www.geocities.com/Paris/LeftBank/1160/resume.htm), June 1998 // Some modifications: Kevin Hoefman, Febr 2007 HRGN HitRegion::BitmapToRegion(HBITMAP hBmp, COLORREF cTransparentColor, COLORREF cTolerance) { HRGN hRgn = NULL; if (hBmp) { // Create a memory DC inside which we will scan the bitmap content HDC hMemDC = CreateCompatibleDC(NULL); if (hMemDC) { // Get bitmap siz BITMAP bm; GetObject(hBmp, sizeof(bm), &bm); // Create a 32 bits depth bitmap and select it into the memory DC BITMAPINFOHEADER RGB32BITSBITMAPINFO = { sizeof(BITMAPINFOHEADER), // biSize bm.bmWidth, // biWidth; bm.bmHeight, // biHeight; 1, // biPlanes; 32, // biBitCount BI_RGB, // biCompression; 0, // biSizeImage; 0, // biXPelsPerMeter; 0, // biYPelsPerMeter; 0, // biClrUsed; 0 // biClrImportant; }; VOID * pbits32; HBITMAP hbm32 = CreateDIBSection(hMemDC, (BITMAPINFO *)&RGB32BITSBITMAPINFO, DIB_RGB_COLORS, &pbits32, NULL, 0); if (hbm32) { HBITMAP holdBmp = (HBITMAP)SelectObject(hMemDC, hbm32); // Create a DC just to copy the bitmap into the memory D HDC hDC = CreateCompatibleDC(hMemDC); if (hDC) { // Get how many bytes per row we have for the bitmap bits (rounded up to 32 bits BITMAP bm32; GetObject(hbm32, sizeof(bm32), &bm32); while (bm32.bmWidthBytes % 4) bm32.bmWidthBytes++; // Copy the bitmap into the memory D HBITMAP holdBmp = (HBITMAP)SelectObject(hDC, hBmp); BitBlt(hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, hDC, 0, 0, SRCCOPY); // For better performances, we will use the ExtCreateRegion() function to create the // region. This function take a RGNDATA structure on entry. We will add rectangles b // amount of ALLOC_UNIT number in this structure #define ALLOC_UNIT 100 DWORD maxRects = ALLOC_UNIT; HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects)); RGNDATA *pData = (RGNDATA *)GlobalLock(hData); pData->rdh.dwSize = sizeof(RGNDATAHEADER); pData->rdh.iType = RDH_RECTANGLES; pData->rdh.nCount = pData->rdh.nRgnSize = 0; SetRect(&pData->rdh.rcBound, MAXLONG, MAXLONG, 0, 0); // Keep on hand highest and lowest values for the "transparent" pixel BYTE lr = GetRValue(cTransparentColor); BYTE lg = GetGValue(cTransparentColor); BYTE lb = GetBValue(cTransparentColor); BYTE hr = min(0xff, lr + GetRValue(cTolerance)); BYTE hg = min(0xff, lg + GetGValue(cTolerance)); BYTE hb = min(0xff, lb + GetBValue(cTolerance)); // Scan each bitmap row from bottom to top (the bitmap is inverted vertically BYTE *p32 = (BYTE *)bm32.bmBits + (bm32.bmHeight - 1) * bm32.bmWidthBytes; for (int y = 0; y < bm.bmHeight; y++) { // Scan each bitmap pixel from left to righ for (int x = 0; x < bm.bmWidth; x++) { // Search for a continuous range of "non transparent pixels" int x0 = x; LONG *p = (LONG *)p32 + x; while (x < bm.bmWidth) { BYTE b = GetRValue(*p); if (b >= lr && b <= hr) { b = GetGValue(*p); if (b >= lg && b <= hg) { b = GetBValue(*p); if (b >= lb && b <= hb) // This pixel is "transparent" break; } } p++; x++; } if (x > x0) { // Add the pixels (x0, y) to (x, y+1) as a new rectangle in the regio if (pData->rdh.nCount >= maxRects) { GlobalUnlock(hData); maxRects += ALLOC_UNIT; hData = GlobalReAlloc(hData, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects), GMEM_MOVEABLE); pData = (RGNDATA *)GlobalLock(hData); } RECT *pr = (RECT *)&pData->Buffer; SetRect(&pr[pData->rdh.nCount], x0, y, x, y+1); if (x0 < pData->rdh.rcBound.left) pData->rdh.rcBound.left = x0; if (y < pData->rdh.rcBound.top) pData->rdh.rcBound.top = y; if (x > pData->rdh.rcBound.right) pData->rdh.rcBound.right = x; if (y+1 > pData->rdh.rcBound.bottom) pData->rdh.rcBound.bottom = y+1; pData->rdh.nCount++; /* // On Windows98, ExtCreateRegion() may fail if the number of rectangles is to // large (ie: > 4000). Therefore, we have to create the region by multiple steps if (pData->rdh.nCount == 2000) { HRGN h = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects), pData); // Free the data GlobalFree(hData); if (hRgn) { CombineRgn(hRgn, hRgn, h, RGN_OR); DeleteObject(h); } else hRgn = h; pData->rdh.nCount = 0; SetRect(&pData->rdh.rcBound, MAXLONG, MAXLONG, 0, 0); } */ } } // Go to next row (remember, the bitmap is inverted vertically p32 -= bm32.bmWidthBytes; } // Create or extend the region with the remaining rectangle HRGN h = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects), pData); if (hRgn) { CombineRgn(hRgn, hRgn, h, RGN_OR); DeleteObject(h); } else hRgn = h; // Clean u SelectObject(hDC, holdBmp); DeleteDC(hDC); } DeleteObject(SelectObject(hMemDC, holdBmp)); } DeleteDC(hMemDC); } } return hRgn; } HitRegion* HitRegion::Clone() { HitRegion* temp = new HitRegion(); temp->m_HitRegion = CreateRectRgn(0, 0, 10, 10); // create dummy region CombineRgn(temp->m_HitRegion, m_HitRegion, 0, RGN_COPY); return temp; } void HitRegion::Move(int x, int y) { OffsetRgn(m_HitRegion, x, y); } RECT HitRegion::GetDimension() { RECT boundingbox; GetRgnBox(m_HitRegion, &boundingbox); return boundingbox; } HRGN HitRegion::GetHandle() { return m_HitRegion; } bool HitRegion::HitTest(HitRegion* regPtr) { HRGN temp = CreateRectRgn(0, 0, 10, 10); // dummy region bool result = (CombineRgn(temp, m_HitRegion, regPtr->m_HitRegion, RGN_AND) != NULLREGION); DeleteObject(temp); return result; } bool HitRegion::HitTest(int x, int y) { return PtInRegion(m_HitRegion, x, y)?true:false; } RECT HitRegion::CollisionTest(HitRegion* regPtr) { // initalize dummy region HRGN temp = CreateRectRgn(0, 0, 10, 10); int overlap = CombineRgn(temp, m_HitRegion, regPtr->m_HitRegion, RGN_AND); RECT result; GetRgnBox(temp, &result); DeleteObject(temp); return result; }
[ [ [ 1, 3272 ] ] ]
e5d1801426964fe7be2697c6acb9744438345286
3472e587cd1dff88c7a75ae2d5e1b1a353962d78
/ytk_bak/BatDown/src/Tab.cpp
3d704d08ad65fc07ee0c001d938a406abe46d8f8
[]
no_license
yewberry/yewtic
9624d05d65e71c78ddfb7bd586845e107b9a1126
2468669485b9f049d7498470c33a096e6accc540
refs/heads/master
2021-01-01T05:40:57.757112
2011-09-14T12:32:15
2011-09-14T12:32:15
32,363,059
0
0
null
null
null
null
UTF-8
C++
false
false
2,127
cpp
#include "Tab.h" #include "WebView.h" Tab::Tab(BatDown *app, QWidget *parent) : QWidget(parent), BatDownBase(app) { m_pWebView = new WebView(m_pApp, this); QVBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); layout->addWidget(m_pWebView); setLayout(layout); connect(m_pWebView, SIGNAL(titleChanged(const QString &)), this, SLOT(updateTitle())); connect(m_pWebView, SIGNAL(iconChanged()), this, SLOT(updateIcon())); connect(m_pWebView, SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int))); } QUrl Tab::url() const { return m_pWebView->url(); } QString Tab::title() const { return m_pWebView->title(); } WebView* Tab::webView() const { return m_pWebView; } void Tab::reload() { m_pWebView->reload(); } void Tab::load(const QUrl &url, const QString &scriptFilename) { m_pWebView->openUrl(url, scriptFilename); } void Tab::updateTitle() { QTabWidget *widget = qobject_cast<QTabWidget *>(parentWidget()->parentWidget()); if(widget){ QString text = m_pWebView->title(); if(text.length() > 30){ text.truncate(27); text += "..."; } widget->setTabText(widget->indexOf(this), text); QString tooltip = QString("<table><tr><td><b>%1</b>: %2</td></tr><tr><td><b>%3</b>: %4</td></tr></table>") .arg("Title").arg(m_pWebView->title()).arg("Url").arg(url().toString()); widget->setTabToolTip(widget->indexOf(this), tooltip); } } void Tab::updateIcon() { QTabWidget *widget = qobject_cast<QTabWidget *>(parentWidget()->parentWidget()); if(widget) { QIcon icon = m_pWebView->icon(); if(icon.isNull()){ icon = QIcon(":/BatDown/defaultPageIcon.png"); } widget->setTabIcon(widget->indexOf(this), icon); } } void Tab::updateProgress(int p) { QLabel *statusBarField = this->m_pApp->getWebProgress(); if(p <= 0 || p >= 100){ statusBarField->setText("Done"); } else { statusBarField->setText(QString("%1%").arg(p)); } }
[ "yew1998@5ddc4e96-dffd-11de-b4b3-6d349e4f6f86" ]
[ [ [ 1, 81 ] ] ]
bb17e7a2760f1f71c261667ae33fdc833e413424
cd61c8405fae2fa91760ef796a5f7963fa7dbd37
/MobileRobots/ARNL/include/ArSystemError.h
f9965514c6b7645b85a89484565029d8b9a2f049
[]
no_license
rafaelhdr/tccsauron
b61ec89bc9266601140114a37d024376a0366d38
027ecc2ab3579db1214d8a404d7d5fa6b1a64439
refs/heads/master
2016-09-05T23:05:57.117805
2009-12-14T09:41:58
2009-12-14T09:41:58
32,693,544
0
0
null
null
null
null
UTF-8
C++
false
false
2,736
h
/* MobileRobots Advanced Robotics Navigation and Localization (ARNL) Version 1.7.1 Copyright (C) 2004, 2005 ActivMedia Robotics LLC Copyright (C) 2006, 2007, 2008, 2009 MobileRobots Inc. All Rights Reserved. MobileRobots Inc does not make any representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. The license for this software is distributed as LICENSE.txt in the top level directory. [email protected] MobileRobots 10 Columbia Drive Amherst, NH 03031 800-639-9481 */ /* *************************************************************************** * * File: ArSystemError.h * * Function: Header file for the systemerror.cpp file. * * Created: George V. Paul. [email protected]. December 13 2002. * *****************************************************************************/ #ifndef ARSYSTEMERROR_H #define ARSYSTEMERROR_H #include <stdio.h> #include "Aria.h" /* ArSystemError Class holds Localization error and robot motion error params. */ class ArSystemError { public: /// Base Constructor. AREXPORT ArSystemError(void); /// Base Destructor. // ~ArSystemError(void); /// Sets the 3x3 Covariance matrix. AREXPORT bool setRobotPoseErrorParams(double cm[3][3]); /// Sets the standard deviations in the pose, x, y, theta. AREXPORT bool setRobotPoseErrorParams(double stdx, double stdy, double stdt); /// Sets the motion error factors due to distance, angle and heading. AREXPORT bool setRobotMotionErrorParams(double kr, double kt, double kd); /// Sets the sensor belief factor (0-1). AREXPORT bool setSensorBelief(double b); /// Returns the standard deviation in X. AREXPORT double getRobotPoseErrorXParam(void){return myStdX;} /// Returns the standard deviation in Y. AREXPORT double getRobotPoseErrorYParam(void){return myStdY;} /// Returns the standard deviation in Theta. AREXPORT double getRobotPoseErrorTParam(void){return myStdT;} /// Returns the motion error factor for distance per distance. AREXPORT double getRobotMotionErrorKrParam(void){return myKr;} /// Returns the motion error factor for angle per angle AREXPORT double getRobotMotionErrorKtParam(void){return myKt;} /// Returns the motion error factor for angle per mm. AREXPORT double getRobotMotionErrorKdParam(void){return myKd;} /// Returns the sensor belief factor. AREXPORT double getSensorBelief(void) {return mySensorBelief;} private: double myCovarPose[3][3]; double myStdX, myStdY, myStdT; double myKr, myKt, myKd; double mySensorBelief; }; #endif // ARSYSTEMERROR.H
[ "budsbd@8373e73c-ebb0-11dd-9ba5-89a75009fd5d" ]
[ [ [ 1, 85 ] ] ]
d02afd6dc2ae1a7240e654e5969b4fc983907d56
7a0acc1c2e808c7d363043546d9581d21a129693
/jobbie/src/cpp/InternetExplorerDriver/finder.cpp
23791bda1b7538f07b01087ddca9edb3d6a7ad48
[ "Apache-2.0" ]
permissive
epall/selenium
39b9759f8719a168b021b28e500c64afc5f83582
273260522efb84116979da2a499f64510250249b
refs/heads/master
2022-06-25T22:15:25.493076
2010-03-11T00:43:02
2010-03-11T00:43:02
552,908
3
0
Apache-2.0
2022-06-10T22:44:36
2010-03-08T19:10:45
C
UTF-8
C++
false
false
23,683
cpp
/* Copyright 2007-2009 WebDriver committers Copyright 2007-2009 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "stdafx.h" #include "errorcodes.h" #include "utils.h" using namespace std; void IeThread::OnSelectElementById(WPARAM w, LPARAM lp) { SCOPETRACER ON_THREAD_COMMON(data) int &errorKind = data.error_code; CComQIPtr<IHTMLElement> inputElement(data.input_html_element_); checkValidDOM(inputElement); IHTMLElement* &pDom = data.output_html_element_; const wchar_t *elementId= data.input_string_; pDom = NULL; errorKind = SUCCESS; /// Start from root DOM by default if(!inputElement) { CComPtr<IHTMLDocument3> root_doc; getDocument3(&root_doc); if (!root_doc) { errorKind = ENOSUCHDOCUMENT; return; } root_doc->get_documentElement(&inputElement); } CComQIPtr<IHTMLDOMNode> node(inputElement); if (!node) { errorKind = ENOSUCHELEMENT; return; } CComPtr<IHTMLDocument3> doc; getDocument3(node, &doc); if (!doc) { errorKind = ENOSUCHDOCUMENT; return; } CComPtr<IHTMLElement> element; CComBSTR id(elementId); if (!SUCCEEDED(doc->getElementById(id, &element))) { errorKind = ENOSUCHELEMENT; return; } if(NULL == element) { errorKind = ENOSUCHELEMENT; return; } CComVariant value; if (!SUCCEEDED(element->getAttribute(CComBSTR(L"id"), 0, &value))) { errorKind = ENOSUCHELEMENT; return; } if (wcscmp(comvariant2cw(value), elementId)==0) { if (isOrUnder(node, element)) { element.CopyTo(&pDom); return; } } CComQIPtr<IHTMLDocument2> doc2(doc); if (!doc2) { errorKind = ENOSUCHDOCUMENT; return; } CComPtr<IHTMLElementCollection> allNodes; if (!SUCCEEDED(doc2->get_all(&allNodes))) { errorKind = ENOSUCHELEMENT; return; } long length = 0; CComPtr<IUnknown> unknown; if (!SUCCEEDED(allNodes->get__newEnum(&unknown))) { errorKind = ENOSUCHELEMENT; return; } CComQIPtr<IEnumVARIANT> enumerator(unknown); if (!enumerator) { errorKind = ENOSUCHELEMENT; return; } CComVariant var; if (!SUCCEEDED(enumerator->Next(1, &var, NULL))) { errorKind = ENOSUCHELEMENT; return; } for (CComPtr<IDispatch> disp; disp = V_DISPATCH(&var); enumerator->Next(1, &var, NULL)) { CComQIPtr<IHTMLElement> curr(disp); if (curr) { CComVariant value; if (!SUCCEEDED(curr->getAttribute(CComBSTR(L"id"), 0, &value))) { continue; } if (wcscmp( comvariant2cw(value), elementId)==0) { if (isOrUnder(node, curr)) { curr.CopyTo(&pDom); return; } } } } errorKind = ENOSUCHELEMENT; } void IeThread::OnSelectElementsById(WPARAM w, LPARAM lp) { SCOPETRACER ON_THREAD_COMMON(data) long &errorKind = data.output_long_; CComQIPtr<IHTMLElement> inputElement(data.input_html_element_); checkValidDOM(inputElement); std::vector<IHTMLElement*> &allElems = data.output_list_html_element_; const wchar_t *elementId= data.input_string_; errorKind = 0; /// Start from root DOM by default if(!inputElement) { CComPtr<IHTMLDocument3> root_doc; getDocument3(&root_doc); if (!root_doc) { errorKind = ENOSUCHDOCUMENT; return; } root_doc->get_documentElement(&inputElement); } CComQIPtr<IHTMLDOMNode> node(inputElement); if (!node) { errorKind = ENOSUCHELEMENT; return; } CComPtr<IHTMLDocument2> doc2; getDocument2(node, &doc2); if (!doc2) { errorKind = ENOSUCHDOCUMENT; return; } CComPtr<IHTMLElementCollection> allNodes; if (!SUCCEEDED(doc2->get_all(&allNodes))) { errorKind = ENOSUCHELEMENT; return; } CComPtr<IUnknown> unknown; if (!SUCCEEDED(allNodes->get__newEnum(&unknown))) { errorKind = ENOSUCHELEMENT; return; } CComQIPtr<IEnumVARIANT> enumerator(unknown); if (!enumerator) { errorKind = ENOSUCHELEMENT; return; } CComVariant var; enumerator->Next(1, &var, NULL); for (CComPtr<IDispatch> disp; disp = V_DISPATCH(&var); enumerator->Next(1, &var, NULL)) { // We are iterating through all the DOM elements CComQIPtr<IHTMLElement> curr(disp); if (!curr) continue; CComVariant value; if (!SUCCEEDED(curr->getAttribute(CComBSTR(L"id"), 0, &value))) { continue; } if (wcscmp( comvariant2cw(value), elementId)==0 && isOrUnder(node, curr)) { IHTMLElement *pDom = NULL; curr.CopyTo(&pDom); allElems.push_back(pDom); } } } void IeThread::OnSelectElementByLink(WPARAM w, LPARAM lp) { SCOPETRACER ON_THREAD_COMMON(data) int &errorKind = data.error_code; CComQIPtr<IHTMLElement> inputElement(data.input_html_element_); checkValidDOM(inputElement); IHTMLElement* &pDom = data.output_html_element_; const wchar_t *elementLink = StripTrailingWhitespace((wchar_t *)data.input_string_); pDom = NULL; errorKind = SUCCESS; CComPtr<IHTMLDocument3> root_doc; getDocument3(&root_doc); /// Start from root DOM by default if(!inputElement) { if (!root_doc) { errorKind = ENOSUCHDOCUMENT; return; } CComQIPtr<IHTMLDocument2> bodyDoc(root_doc); if (bodyDoc) { bodyDoc->get_body(&inputElement); } } CComQIPtr<IHTMLDOMNode> node(inputElement); CComQIPtr<IHTMLElement2> element2(inputElement); if (!element2 || !node) { errorKind = ENOSUCHELEMENT; return; } CComPtr<IHTMLElementCollection> elements; if (!SUCCEEDED(element2->getElementsByTagName(CComBSTR("A"), &elements))) { errorKind = ENOSUCHELEMENT; return; } long linksLength; if (!SUCCEEDED(elements->get_length(&linksLength))) { errorKind = ENOSUCHELEMENT; return; } for (int i = 0; i < linksLength; i++) { CComVariant idx; idx.vt = VT_I4; idx.lVal = i; CComVariant zero; zero.vt = VT_I4; zero.lVal = 0; CComPtr<IDispatch> dispatch; if (!SUCCEEDED(elements->item(idx, zero, &dispatch))) { // The page is probably reloading, but you never know. Continue looping continue; } CComQIPtr<IHTMLElement> element(dispatch); if (!element) { // Deeply unusual continue; } CComBSTR linkText; if (!SUCCEEDED(element->get_innerText(&linkText))) { continue; } if (wcscmp(StripTrailingWhitespace((wchar_t *)combstr2cw(linkText)),elementLink)==0 && isOrUnder(node, element)) { element.CopyTo(&pDom); return; } } errorKind = ENOSUCHELEMENT; } void IeThread::OnSelectElementsByLink(WPARAM w, LPARAM lp) { SCOPETRACER ON_THREAD_COMMON(data) long &errorKind = data.output_long_; CComQIPtr<IHTMLElement> inputElement(data.input_html_element_); checkValidDOM(inputElement); std::vector<IHTMLElement*> &allElems = data.output_list_html_element_; const wchar_t *elementLink = StripTrailingWhitespace((wchar_t *)data.input_string_); errorKind = SUCCESS; CComPtr<IHTMLDocument3> root_doc; getDocument3(&root_doc); /// Start from root DOM by default if(!inputElement) { if (!root_doc) { errorKind = ENOSUCHDOCUMENT; return; } CComQIPtr<IHTMLDocument2> bodyDoc(root_doc); if (bodyDoc) { bodyDoc->get_body(&inputElement); } } CComQIPtr<IHTMLDOMNode> node(inputElement); CComQIPtr<IHTMLElement2> element2(inputElement); if (!element2 || !node) { errorKind = ENOSUCHELEMENT; return; } CComPtr<IHTMLElementCollection> elements; if (!SUCCEEDED(element2->getElementsByTagName(CComBSTR("A"), &elements))) { errorKind = ENOSUCHELEMENT; return; } long linksLength; if (!SUCCEEDED(elements->get_length(&linksLength))) { errorKind = ENOSUCHELEMENT; return; } for (int i = 0; i < linksLength; i++) { CComVariant idx; idx.vt = VT_I4; idx.lVal = i; CComVariant zero; zero.vt = VT_I4; zero.lVal = 0; CComPtr<IDispatch> dispatch; if (!SUCCEEDED(elements->item(idx, zero, &dispatch))) { errorKind = ENOSUCHELEMENT; return; } CComQIPtr<IHTMLElement> element(dispatch); if (!element) { continue; } CComBSTR linkText; element->get_innerText(&linkText); if (wcscmp(StripTrailingWhitespace((wchar_t *)combstr2cw(linkText)),elementLink)==0 && isOrUnder(node, element)) { IHTMLElement *pDom = NULL; element.CopyTo(&pDom); allElems.push_back(pDom); } } } void IeThread::OnSelectElementByPartialLink(WPARAM w, LPARAM lp) { SCOPETRACER ON_THREAD_COMMON(data) int &errorKind = data.error_code; CComQIPtr<IHTMLElement> inputElement(data.input_html_element_); checkValidDOM(inputElement); IHTMLElement* &pDom = data.output_html_element_; const wchar_t *elementLink = data.input_string_; pDom = NULL; errorKind = SUCCESS; /// Start from root DOM by default if(!inputElement) { CComPtr<IHTMLDocument3> root_doc; getDocument3(&root_doc); if (!root_doc) { errorKind = -ENOSUCHDOCUMENT; return; } root_doc->get_documentElement(&inputElement); } CComQIPtr<IHTMLDOMNode> node(inputElement); if (!node) { errorKind = ENOSUCHELEMENT; return; } CComPtr<IHTMLDocument2> doc; getDocument2(node, &doc); if (!doc) { errorKind = ENOSUCHDOCUMENT; return; } CComPtr<IHTMLElementCollection> linkCollection; if (!SUCCEEDED(doc->get_links(&linkCollection))) { errorKind = ENOSUCHELEMENT; return; } long linksLength; if (!SUCCEEDED(linkCollection->get_length(&linksLength))) { errorKind = ENOSUCHELEMENT; return; } for (int i = 0; i < linksLength; i++) { CComVariant idx; idx.vt = VT_I4; idx.lVal = i; CComVariant zero; zero.vt = VT_I4; zero.lVal = 0; CComPtr<IDispatch> dispatch; if (!SUCCEEDED(linkCollection->item(idx, zero, &dispatch))) { continue; } CComQIPtr<IHTMLElement> element(dispatch); if (!element) { continue; } CComBSTR linkText; element->get_innerText(&linkText); if (wcsstr(combstr2cw(linkText),elementLink) && isOrUnder(node, element)) { element.CopyTo(&pDom); return; } } errorKind = ENOSUCHELEMENT; } void IeThread::OnSelectElementsByPartialLink(WPARAM w, LPARAM lp) { SCOPETRACER ON_THREAD_COMMON(data) long &errorKind = data.output_long_; CComQIPtr<IHTMLElement> inputElement(data.input_html_element_); checkValidDOM(inputElement); std::vector<IHTMLElement*> &allElems = data.output_list_html_element_; const wchar_t *elementLink= data.input_string_; errorKind = 0; /// Start from root DOM by default if(!inputElement) { CComPtr<IHTMLDocument3> root_doc; getDocument3(&root_doc); if (!root_doc) { errorKind = ENOSUCHDOCUMENT; return; } root_doc->get_documentElement(&inputElement); } CComQIPtr<IHTMLDOMNode> node(inputElement); if (!node) { errorKind = ENOSUCHELEMENT; return; } CComPtr<IHTMLDocument2> doc2; getDocument2(node, &doc2); if (!doc2) { errorKind = ENOSUCHDOCUMENT; return; } CComPtr<IHTMLElementCollection> linkCollection; if (!SUCCEEDED(doc2->get_links(&linkCollection))) { errorKind = ENOSUCHELEMENT; return; } long linksLength; if (!SUCCEEDED(linkCollection->get_length(&linksLength))) { errorKind = ENOSUCHELEMENT; return; } for (int i = 0; i < linksLength; i++) { CComVariant idx; idx.vt = VT_I4; idx.lVal = i; CComVariant zero; zero.vt = VT_I4; zero.lVal = 0; CComPtr<IDispatch> dispatch; if (!SUCCEEDED(linkCollection->item(idx, zero, &dispatch))) { continue; } CComQIPtr<IHTMLElement> element(dispatch); if (!element) { continue; } CComBSTR linkText; element->get_innerText(&linkText); if (wcsstr(combstr2cw(linkText),elementLink) && isOrUnder(node, element)) { IHTMLElement *pDom = NULL; element.CopyTo(&pDom); allElems.push_back(pDom); } } } void IeThread::OnSelectElementByName(WPARAM w, LPARAM lp) { SCOPETRACER ON_THREAD_COMMON(data) int &errorKind = data.error_code; CComQIPtr<IHTMLElement> inputElement(data.input_html_element_); checkValidDOM(inputElement); IHTMLElement* &pDom = data.output_html_element_; const wchar_t *elementName= data.input_string_; pDom = NULL; errorKind = 0; /// Start from root DOM by default if(!inputElement) { CComPtr<IHTMLDocument3> root_doc; getDocument3(&root_doc); if (!root_doc) { errorKind = ENOSUCHDOCUMENT; return; } root_doc->get_documentElement(&inputElement); } CComQIPtr<IHTMLDOMNode> node(inputElement); if (!node) { errorKind = ENOSUCHELEMENT; return; } CComPtr<IHTMLDocument2> doc; getDocument2(node, &doc); if (!doc) { errorKind = ENOSUCHDOCUMENT; return; } CComPtr<IHTMLElementCollection> elementCollection; CComBSTR name(elementName); if (!SUCCEEDED(doc->get_all(&elementCollection))) { errorKind = ENOSUCHELEMENT; return; } long elementsLength; if (!SUCCEEDED(elementCollection->get_length(&elementsLength))) { errorKind = ENOSUCHELEMENT; return; } for (int i = 0; i < elementsLength; i++) { CComVariant idx; idx.vt = VT_I4; idx.lVal = i; CComVariant zero; zero.vt = VT_I4; zero.lVal = 0; CComPtr<IDispatch> dispatch; if (!SUCCEEDED(elementCollection->item(idx, zero, &dispatch))) { continue; } CComQIPtr<IHTMLElement> element(dispatch); CComBSTR nameText; CComVariant value; if (!element) { continue; } if (!SUCCEEDED(element->getAttribute(CComBSTR(L"name"), 0, &value))) { continue; } if (wcscmp(comvariant2cw(value), elementName)==0 && isOrUnder(node, element)) { element.CopyTo(&pDom); errorKind = SUCCESS; return; } } errorKind = ENOSUCHELEMENT; } void IeThread::OnSelectElementsByName(WPARAM w, LPARAM lp) { SCOPETRACER ON_THREAD_COMMON(data) long &errorKind = data.output_long_; CComQIPtr<IHTMLElement> inputElement(data.input_html_element_); checkValidDOM(inputElement); std::vector<IHTMLElement*> &allElems = data.output_list_html_element_; const wchar_t *elementName= data.input_string_; errorKind = 0; /// Start from root DOM by default if(!inputElement) { CComPtr<IHTMLDocument3> root_doc; getDocument3(&root_doc); if (!root_doc) { errorKind = ENOSUCHDOCUMENT; return; } root_doc->get_documentElement(&inputElement); } CComQIPtr<IHTMLDOMNode> node(inputElement); if (!node) { errorKind = ENOSUCHELEMENT; return; } CComPtr<IHTMLDocument2> doc; getDocument2(node, &doc); if (!doc) { errorKind = ENOSUCHDOCUMENT; return; } CComPtr<IHTMLElementCollection> elementCollection; CComBSTR name(elementName); if (!SUCCEEDED(doc->get_all(&elementCollection))) { errorKind = ENOSUCHELEMENT; return; } long elementsLength; if (!SUCCEEDED(elementCollection->get_length(&elementsLength))) { errorKind = ENOSUCHELEMENT; return; } for (int i = 0; i < elementsLength; i++) { CComVariant idx; idx.vt = VT_I4; idx.lVal = i; CComVariant zero; zero.vt = VT_I4; zero.lVal = 0; CComPtr<IDispatch> dispatch; if (!SUCCEEDED(elementCollection->item(idx, zero, &dispatch))) { continue; } CComQIPtr<IHTMLElement> element(dispatch); if (!element) { continue; } CComBSTR nameText; CComVariant value; if (!SUCCEEDED(element->getAttribute(CComBSTR(L"name"), 0, &value))) { continue; } if (wcscmp( comvariant2cw(value), elementName)==0 && isOrUnder(node, element)) { IHTMLElement *pDom = NULL; element.CopyTo(&pDom); allElems.push_back(pDom); } } } void IeThread::OnSelectElementByTagName(WPARAM w, LPARAM lp) { SCOPETRACER ON_THREAD_COMMON(data) int &errorKind = data.error_code; CComQIPtr<IHTMLElement> inputElement(data.input_html_element_); checkValidDOM(inputElement); IHTMLElement* &pDom = data.output_html_element_; const wchar_t *tagName = data.input_string_; pDom = NULL; errorKind = SUCCESS; CComPtr<IHTMLDocument3> root_doc; getDocument3(&root_doc); if (!root_doc) { errorKind = ENOSUCHDOCUMENT; return; } CComPtr<IHTMLElementCollection> elements; if (!SUCCEEDED(root_doc->getElementsByTagName(CComBSTR(tagName), &elements))) { errorKind = ENOSUCHELEMENT; return; } if (!elements) { errorKind = ENOSUCHELEMENT; return; } long length; if (!SUCCEEDED(elements->get_length(&length))) { errorKind = ENOSUCHELEMENT; return; } CComQIPtr<IHTMLDOMNode> node(inputElement); for (int i = 0; i < length; i++) { CComVariant idx; idx.vt = VT_I4; idx.lVal = i; CComVariant zero; zero.vt = VT_I4; zero.lVal = 0; CComPtr<IDispatch> dispatch; if (!SUCCEEDED(elements->item(idx, zero, &dispatch))) { continue; } CComQIPtr<IHTMLElement> element(dispatch); if (!element) { element; } // Check to see if the element is contained return if it is if (isOrUnder(node, element)) { element.CopyTo(&pDom); return; } } errorKind = ENOSUCHELEMENT; } void IeThread::OnSelectElementsByTagName(WPARAM w, LPARAM lp) { SCOPETRACER ON_THREAD_COMMON(data) long &errorKind = data.output_long_; CComQIPtr<IHTMLElement> inputElement(data.input_html_element_); checkValidDOM(inputElement); std::vector<IHTMLElement*> &allElems = data.output_list_html_element_; const wchar_t *tagName = data.input_string_; errorKind = 0; /// Start from root DOM by default CComPtr<IHTMLDocument3> root_doc; getDocument3(&root_doc); if (!root_doc) { errorKind = ENOSUCHDOCUMENT; return; } CComPtr<IHTMLElementCollection> elements; if (!SUCCEEDED(root_doc->getElementsByTagName(CComBSTR(tagName), &elements))) { errorKind = ENOSUCHELEMENT; return; } if (!elements) { errorKind = ENOSUCHELEMENT; return; } long length; if (!SUCCEEDED(elements->get_length(&length))) { errorKind = ENOSUCHELEMENT; return; } CComQIPtr<IHTMLDOMNode> node(inputElement); for (int i = 0; i < length; i++) { CComVariant idx; idx.vt = VT_I4; idx.lVal = i; CComVariant zero; zero.vt = VT_I4; zero.lVal = 0; CComPtr<IDispatch> dispatch; if (!SUCCEEDED(elements->item(idx, zero, &dispatch))) { continue; } CComQIPtr<IHTMLElement> element(dispatch); if (!element) { continue; } if (isOrUnder(node, element)) { IHTMLElement *pDom = NULL; element.CopyTo(&pDom); allElems.push_back(pDom); } } } void IeThread::OnSelectElementByClassName(WPARAM w, LPARAM lp) { SCOPETRACER ON_THREAD_COMMON(data) int &errorKind = data.error_code; CComQIPtr<IHTMLElement> inputElement(data.input_html_element_); checkValidDOM(inputElement); IHTMLElement* &pDom = data.output_html_element_; const wchar_t *elementClassName= data.input_string_; pDom = NULL; errorKind = SUCCESS; /// Start from root DOM by default if(!inputElement) { CComPtr<IHTMLDocument3> root_doc; getDocument3(&root_doc); if (!root_doc) { errorKind = ENOSUCHDOCUMENT; return; } root_doc->get_documentElement(&inputElement); } CComQIPtr<IHTMLDOMNode> node(inputElement); if (!node) { errorKind = ENOSUCHELEMENT; return; } CComPtr<IHTMLDocument2> doc2; getDocument2(node, &doc2); if (!doc2) { errorKind = ENOSUCHDOCUMENT; return; } CComPtr<IHTMLElementCollection> allNodes; if (!SUCCEEDED(doc2->get_all(&allNodes))) { errorKind = ENOSUCHELEMENT; return; } CComPtr<IUnknown> unknown; if (!SUCCEEDED(allNodes->get__newEnum(&unknown))) { errorKind = ENOSUCHELEMENT; return; } CComQIPtr<IEnumVARIANT> enumerator(unknown); if (!enumerator) { errorKind = ENOSUCHELEMENT; return; } CComVariant var; CComBSTR nameRead; if (!SUCCEEDED(enumerator->Next(1, &var, NULL))) { errorKind = ENOSUCHELEMENT; return; } const int exactLength = (int) wcslen(elementClassName); wchar_t *next_token, seps[] = L" "; for (CComPtr<IDispatch> disp; disp = V_DISPATCH(&var); enumerator->Next(1, &var, NULL)) { // We are iterating through all the DOM elements CComQIPtr<IHTMLElement> curr(disp); if (!curr) continue; curr->get_className(&nameRead); if(!nameRead) continue; nameRead = StripTrailingWhitespace(nameRead); for ( wchar_t *token = wcstok_s(nameRead, seps, &next_token); token; token = wcstok_s( NULL, seps, &next_token) ) { __int64 lengthRead = next_token - token; if(*next_token!=NULL) lengthRead--; if(exactLength != lengthRead) continue; if(0!=wcscmp(elementClassName, token)) continue; if(!isOrUnder(node, curr)) continue; // Woohoo, we found it curr.CopyTo(&pDom); return; } } errorKind = ENOSUCHELEMENT; } void IeThread::OnSelectElementsByClassName(WPARAM w, LPARAM lp) { SCOPETRACER ON_THREAD_COMMON(data) long &errorKind = data.output_long_; CComQIPtr<IHTMLElement> inputElement(data.input_html_element_); checkValidDOM(inputElement); std::vector<IHTMLElement*> &allElems = data.output_list_html_element_; const wchar_t *elementClassName= data.input_string_; errorKind = 0; /// Start from root DOM by default if(!inputElement) { CComPtr<IHTMLDocument3> root_doc; getDocument3(&root_doc); if (!root_doc) { errorKind = ENOSUCHDOCUMENT; return; } root_doc->get_documentElement(&inputElement); } CComQIPtr<IHTMLDOMNode> node(inputElement); if (!node) { errorKind = ENOSUCHELEMENT; return; } CComPtr<IHTMLDocument2> doc2; getDocument2(node, &doc2); if (!doc2) { errorKind = ENOSUCHDOCUMENT; return; } CComPtr<IHTMLElementCollection> allNodes; if (!SUCCEEDED(doc2->get_all(&allNodes))) { errorKind = ENOSUCHELEMENT; return; } CComPtr<IUnknown> unknown; if (!SUCCEEDED(allNodes->get__newEnum(&unknown))) { errorKind = ENOSUCHELEMENT; return; } CComQIPtr<IEnumVARIANT> enumerator(unknown); if (!enumerator) { errorKind = ENOSUCHELEMENT; return; } CComVariant var; CComBSTR nameRead; if (!SUCCEEDED(enumerator->Next(1, &var, NULL))) { errorKind = ENOSUCHELEMENT; return; } const int exactLength = (int) wcslen(elementClassName); wchar_t *next_token, seps[] = L" "; for (CComPtr<IDispatch> disp; disp = V_DISPATCH(&var); enumerator->Next(1, &var, NULL)) { // We are iterating through all the DOM elements CComQIPtr<IHTMLElement> curr(disp); if (!curr) continue; curr->get_className(&nameRead); if(!nameRead) continue; nameRead = StripTrailingWhitespace(nameRead); for ( wchar_t *token = wcstok_s(nameRead, seps, &next_token); token; token = wcstok_s( NULL, seps, &next_token) ) { __int64 lengthRead = next_token - token; if(*next_token!=NULL) lengthRead--; if(exactLength != lengthRead) continue; if(0!=wcscmp(elementClassName, token)) continue; if(!isOrUnder(node, curr)) continue; // Woohoo, we found it IHTMLElement *pDom = NULL; curr.CopyTo(&pDom); allElems.push_back(pDom); } } }
[ "simon.m.stewart@07704840-8298-11de-bf8c-fd130f914ac9", "dawagner@07704840-8298-11de-bf8c-fd130f914ac9" ]
[ [ [ 1, 234 ], [ 236, 300 ], [ 302, 317 ], [ 319, 379 ], [ 381, 935 ], [ 938, 1032 ], [ 1035, 1050 ] ], [ [ 235, 235 ], [ 301, 301 ], [ 318, 318 ], [ 380, 380 ], [ 936, 937 ], [ 1033, 1034 ] ] ]
ceb63a12efeefcabfd2ed8ba0b78219022097a6e
b22c254d7670522ec2caa61c998f8741b1da9388
/dependencies/OpenSceneGraph/include/osg/Stencil
76a9cd03e7ab9f9411d49dc8ee22d0ea43d4d95d
[]
no_license
ldaehler/lbanet
341ddc4b62ef2df0a167caff46c2075fdfc85f5c
ecb54fc6fd691f1be3bae03681e355a225f92418
refs/heads/master
2021-01-23T13:17:19.963262
2011-03-22T21:49:52
2011-03-22T21:49:52
39,529,945
0
1
null
null
null
null
UTF-8
C++
false
false
6,201
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #ifndef OSG_STENCIL #define OSG_STENCIL 1 #include <osg/StateAttribute> namespace osg { #ifndef GL_INCR_WRAP #define GL_INCR_WRAP 0x8507 #define GL_DECR_WRAP 0x8508 #endif /** Encapsulate OpenGL glStencilFunc/Op/Mask functions. */ class OSG_EXPORT Stencil : public StateAttribute { public : Stencil(); /** Copy constructor using CopyOp to manage deep vs shallow copy.*/ Stencil(const Stencil& stencil,const CopyOp& copyop=CopyOp::SHALLOW_COPY): StateAttribute(stencil,copyop), _func(stencil._func), _funcRef(stencil._funcRef), _funcMask(stencil._funcMask), _sfail(stencil._sfail), _zfail(stencil._zfail), _zpass(stencil._zpass), _writeMask(stencil._writeMask) {} META_StateAttribute(osg, Stencil, STENCIL); /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/ virtual int compare(const StateAttribute& sa) const { // check the types are equal and then create the rhs variable // used by the COMPARE_StateAttribute_Parameter macro's below. COMPARE_StateAttribute_Types(Stencil,sa) // compare each parameter in turn against the rhs. COMPARE_StateAttribute_Parameter(_func) COMPARE_StateAttribute_Parameter(_funcRef) COMPARE_StateAttribute_Parameter(_funcMask) COMPARE_StateAttribute_Parameter(_sfail) COMPARE_StateAttribute_Parameter(_zfail) COMPARE_StateAttribute_Parameter(_zpass) COMPARE_StateAttribute_Parameter(_writeMask) return 0; // passed all the above comparison macro's, must be equal. } virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const { usage.usesMode(GL_STENCIL_TEST); return true; } enum Function { NEVER = GL_NEVER, LESS = GL_LESS, EQUAL = GL_EQUAL, LEQUAL = GL_LEQUAL, GREATER = GL_GREATER, NOTEQUAL = GL_NOTEQUAL, GEQUAL = GL_GEQUAL, ALWAYS = GL_ALWAYS }; inline void setFunction(Function func,int ref,unsigned int mask) { _func = func; _funcRef = ref; _funcMask = mask; } inline void setFunction(Function func) { _func = func; } inline Function getFunction() const { return _func; } inline void setFunctionRef(int ref) { _funcRef=ref; } inline int getFunctionRef() const { return _funcRef; } inline void setFunctionMask(unsigned int mask) { _funcMask=mask; } inline unsigned int getFunctionMask() const { return _funcMask; } enum Operation { KEEP = GL_KEEP, ZERO = GL_ZERO, REPLACE = GL_REPLACE, INCR = GL_INCR, DECR = GL_DECR, INVERT = GL_INVERT, INCR_WRAP = GL_INCR_WRAP, DECR_WRAP = GL_DECR_WRAP }; /** set the operations to apply when the various stencil and depth * tests fail or pass. First parameter is to control the operation * when the stencil test fails. The second parameter is to control the * operation when the stencil test passes, but depth test fails. The * third parameter controls the operation when both the stencil test * and depth pass. Ordering of parameter is the same as if using * glStencilOp(,,).*/ inline void setOperation(Operation sfail, Operation zfail, Operation zpass) { _sfail = sfail; _zfail = zfail; _zpass = zpass; } /** set the operation when the stencil test fails.*/ inline void setStencilFailOperation(Operation sfail) { _sfail = sfail; } /** get the operation when the stencil test fails.*/ inline Operation getStencilFailOperation() const { return _sfail; } /** set the operation when the stencil test passes but the depth test fails.*/ inline void setStencilPassAndDepthFailOperation(Operation zfail) { _zfail=zfail; } /** get the operation when the stencil test passes but the depth test fails.*/ inline Operation getStencilPassAndDepthFailOperation() const { return _zfail; } /** set the operation when both the stencil test and the depth test pass.*/ inline void setStencilPassAndDepthPassOperation(Operation zpass) { _zpass=zpass; } /** get the operation when both the stencil test and the depth test pass.*/ inline Operation getStencilPassAndDepthPassOperation() const { return _zpass; } inline void setWriteMask(unsigned int mask) { _writeMask = mask; } inline unsigned int getWriteMask() const { return _writeMask; } virtual void apply(State& state) const; protected: virtual ~Stencil(); Function _func; int _funcRef; unsigned int _funcMask; Operation _sfail; Operation _zfail; Operation _zpass; unsigned int _writeMask; }; } #endif
[ "vdelage@3806491c-8dad-11de-9a8c-6d5b7d1e4d13" ]
[ [ [ 1, 174 ] ] ]
d8abd64c93263f386d35b8c6ddc5bee1cbb97d21
21da454a8f032d6ad63ca9460656c1e04440310e
/src/wcpp/io/wscDataInput.h
97630da2a0e33d21f74ac578343d042a078e8c42
[]
no_license
merezhang/wcpp
d9879ffb103513a6b58560102ec565b9dc5855dd
e22eb48ea2dd9eda5cd437960dd95074774b70b0
refs/heads/master
2021-01-10T06:29:42.908096
2009-08-31T09:20:31
2009-08-31T09:20:31
46,339,619
0
0
null
null
null
null
UTF-8
C++
false
false
265
h
#ifndef __wscDataInput_h__ #define __wscDataInput_h__ #include <wcpp/lang/wscObject.h> #include "wsiDataInput.h" class wscDataInput : public wscObject , public wsiDataInput { public: static const ws_iid sIID; }; #endif // __wsIDataInput_h__
[ "xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8" ]
[ [ [ 1, 15 ] ] ]
021c367794cf9cf3b1e2e9ec2981bd777789793c
483d66ba0bc9ff989695d978e99c900d2c4c9418
/Client/ProductDlg.h
4c5b3035bb62fe87e5ba809f1244d71302add01e
[]
no_license
uwitec/storesystem
3aeeef77837bed312e6cac5bb9b18e1e96a3156d
b703e4747fa035e221eb8f2d7bf586dae83f5e6f
refs/heads/master
2021-03-12T20:17:54.942667
2011-06-06T17:46:15
2011-06-06T17:46:15
40,976,352
0
0
null
null
null
null
GB18030
C++
false
false
842
h
#ifndef PRODUCTINSERTDLG_H #define PRODUCTINSERTDLG_H #include <QDialog> #include "ui_ProductDlg.h" #include "Tables.h" class ProductDlg : public QDialog { Q_OBJECT public: ProductDlg(QWidget *parent = 0); ~ProductDlg(); const Product& getProduct(){ return m_product; } void setProduct(const Product& product); // 让产品名、类型名的ComboBox有自动完成的功能 // @param pProductModel,产品的Model void setCompleterModel(QStandardItemModel* pProductModel); // 让厂商的ComboBox具有厂商选项 // @param pFactoryModel,厂商的Model // @param pCompleter,自动完成 void setFactoryModel(QStandardItemModel* pFactoryModel, QCompleter* pCompleter); public slots: void accept(); protected: Ui::ProductDlg ui; Product m_product; }; #endif // PRODUCTINSERTDLG_H
[ [ [ 1, 32 ] ] ]
f51a9573402d0ce3943d6a361c82952a4665f8db
e8fe151e69672e33bf8cb40c2dcb65c3982baae5
/FiboHeap/main.cpp
6dfe3a3edd2e4d24c0ea05aec73d1f03a7240006
[]
no_license
juanplopes/old-uerj-projects
99fec1d4f46b6a3f292847624dc13ed1b52ba999
0aed2864520052df8cd9b2754a65d5c30ecc54eb
refs/heads/master
2020-06-04T14:16:53.191834
2010-01-12T18:05:31
2010-01-12T18:05:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,101
cpp
#include <iostream> #include <fstream> #include <string> #ifdef WIN32 #include <windows.h> #else #include <ctime> #endif #include "Dijkstra.cpp" using namespace std; double ftime() { #ifdef WIN32 double velocidade, valor; QueryPerformanceFrequency((LARGE_INTEGER *) &velocidade); QueryPerformanceCounter((LARGE_INTEGER *) &valor); return (valor/velocidade)*1000; #else return clock(); #endif } void miolo(bool semHeap, Graph* graph, int a, int b) { cout << "*** DIJKSTRA " << (semHeap?"NORMAL":"COM HEAP") << " ***" << endl; double inicio = ftime(); countHeap = 0; countDijkstra = 0; ShortestPaths* allPaths = (semHeap?graph->Dijkstra(a):graph->DijkstraHeap(a)); ShortestPath* onePath = allPaths->GetPath(b); cout << "Custo: " << onePath->cost << endl; cout << "Caminho: "; onePath->Print(cout, 0); cout << endl; delete(allPaths); delete(onePath); double fim = ftime(); cout << "Tempo gasto para execucao: " << (fim - inicio) << " milisegundos" << endl; cout << "Numero de operacoes elementares (D+H) = " << countDijkstra << " + " << countHeap << " = " << countDijkstra + countHeap << endl; cout << endl; } int main() { int n, m, a, b, c; n = m = a = b = c = 0; double inicio , fim; string arquivo; cout << "Digite o nome do arquivo com os dados do grafo." << endl; cin >> arquivo; ifstream fin(arquivo.c_str() , ios::binary); fin >> n >> m; Graph* graph = new Graph(n); for(int i=0; i<m; i++) { fin >> a >> b >> c; graph->AddEdge(a, b, c); } cout << "Todos os vertices foram adicionados" << endl; cout << " n=" << n << ", m=" << m << endl << endl; while(true) { cout << "Digite s (saida) e t (destino). 0 0 para sair" << endl; cin >> a >> b; if (!a && !b) break; miolo(false, graph, a, b); miolo(true, graph, a, b); } delete(graph); }
[ [ [ 1, 82 ] ] ]
2f409cca4edcf5017ee550f9adad786eb73bdaa6
563e71cceb33a518f53326838a595c0f23d9b8f3
/v2/POC/POC/Square.h
41a3e5c9d3df54c243f43d941f1423554ddf7b79
[]
no_license
fabio-miranda/procedural
3d937037d63dd16cd6d9e68fe17efde0688b5a0a
e2f4b9d34baa1315e258613fb0ea66d1235a63f0
refs/heads/master
2021-05-28T18:13:57.833985
2009-10-07T21:09:13
2009-10-07T21:09:13
39,636,279
1
1
null
null
null
null
UTF-8
C++
false
false
786
h
#ifndef SQUARE_H #define SQUARE_H #include "Vertex.h" #include "Vector3.h" #include "VBO.h" #include <list> class Square{ ///////////// // 3------2 // | | // | | // 0------1 //////////// private: void Init(); Vertex* m_vertices[4]; GLuint* m_indices[4]; Vector3<float> m_position; VBO* m_vboMesh; float m_size; bool m_isSplit; std::list<GLuint>::iterator m_listIndexEndPosition; std::list<Vertex>::iterator m_listVertexEndPosition; public: Square(); Square(float size); Square(Vector3<float> position, float size); ~ Square(); //void FillArray(VBO*); void SplitSquareIn4(); void Render(); Square* m_squares[4]; //The subdivisions of the big square Square* m_parent; }; #endif
[ "fabiom@01b71de8-32d4-11de-96ab-f16d9912eac9" ]
[ [ [ 1, 54 ] ] ]
8cac6aef5bc4921fd68995e413c13008579410cf
65f587a75567b51375bde5793b4ec44e4b79bc7d
/midiDevice.h
96f0f738798b54ec2de4dccc1715e7956552f665
[]
no_license
discordance/sklepseq
ce4082074afbdb7e4f7185f042ce9e34d42087ef
8d4fa5a2710ba947e51f5572238eececba4fef74
refs/heads/master
2021-01-13T00:15:23.218795
2008-07-20T20:48:44
2008-07-20T20:48:44
49,079,555
0
0
null
null
null
null
UTF-8
C++
false
false
627
h
// midiDevice.h: interface for the midiDevice class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_MIDIDEVICE_H__FB529C4A_C29B_4DF3_9006_E29AE9591D05__INCLUDED_) #define AFX_MIDIDEVICE_H__FB529C4A_C29B_4DF3_9006_E29AE9591D05__INCLUDED_ #include <juce.h> class midiDevice { public: midiDevice (int _deviceIndex); ~midiDevice(); bool openDevice (); void sendMessage (const MidiMessage *m); void sendMessageBuffer (const MidiBuffer *mb); void process(); bool isOpen(); private: int deviceIndex; MidiOutput *d; bool open; }; #endif
[ "kubiak.roman@0c9c7eae-764f-0410-aff0-6774c5161e44" ]
[ [ [ 1, 28 ] ] ]
bd48f78e13a4b8870fc3bbeaa3fe51fbaa916886
54cacc105d6bacdcfc37b10d57016bdd67067383
/trunk/source/level/objects/components/ICmpYoke.h
61159883b64fe7a68d42023c38ae85149a375628
[]
no_license
galek/hesperus
4eb10e05945c6134901cc677c991b74ce6c8ac1e
dabe7ce1bb65ac5aaad144933d0b395556c1adc4
refs/heads/master
2020-12-31T05:40:04.121180
2009-12-06T17:38:49
2009-12-06T17:38:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,322
h
/*** * hesperus: ICmpYoke.h * Copyright Stuart Golodetz, 2009. All rights reserved. ***/ #ifndef H_HESP_ICMPYOKE #define H_HESP_ICMPYOKE #include <source/level/objects/base/ObjectComponent.h> #include <source/util/PolygonTypes.h> namespace hesp { //#################### FORWARD DECLARATIONS #################### class InputState; typedef shared_ptr<const class NavManager> NavManager_CPtr; typedef shared_ptr<class ObjectCommand> ObjectCommand_Ptr; typedef shared_ptr<const class OnionTree> OnionTree_CPtr; class ICmpYoke : public ObjectComponent { //#################### PUBLIC ABSTRACT METHODS #################### public: virtual std::vector<ObjectCommand_Ptr> generate_commands(InputState& input, const std::vector<CollisionPolygon_Ptr>& polygons, const OnionTree_CPtr& tree, const NavManager_CPtr& navManager) = 0; //#################### PUBLIC METHODS #################### public: std::string group_type() const { return "Yoke"; } static std::string static_group_type() { return "Yoke"; } std::string own_type() const { return "Yoke"; } static std::string static_own_type() { return "Yoke"; } }; //#################### TYPEDEFS #################### typedef shared_ptr<ICmpYoke> ICmpYoke_Ptr; typedef shared_ptr<const ICmpYoke> ICmpYoke_CPtr; } #endif
[ [ [ 1, 41 ] ] ]
af1ad88f631ba253db48d5dc8e4d46d21c07349d
709cd826da3ae55945fd7036ecf872ee7cdbd82a
/Term/WildMagic2/Source/Containment/WmlContCylinder3.cpp
840359c53b8de0c8eb60ba1b23832c8233c8c888
[]
no_license
argapratama/kucgbowling
20dbaefe1596358156691e81ccceb9151b15efb0
65e40b6f33c5511bddf0fa350c1eefc647ace48a
refs/heads/master
2018-01-08T15:27:44.784437
2011-06-19T15:23:39
2011-06-19T15:23:39
36,738,655
0
0
null
null
null
null
UTF-8
C++
false
false
2,287
cpp
// Magic Software, Inc. // http://www.magic-software.com // http://www.wild-magic.com // Copyright (c) 2003. All Rights Reserved // // The Wild Magic Library (WML) source code is supplied under the terms of // the license agreement http://www.magic-software.com/License/WildMagic.pdf // and may not be copied or disclosed except in accordance with the terms of // that agreement. #include "WmlContCylinder3.h" #include "WmlApprLineFit3.h" #include "WmlDistVec3Lin3.h" using namespace Wml; //---------------------------------------------------------------------------- template <class Real> Cylinder3<Real> Wml::ContCylinder (int iQuantity, const Vector3<Real>* akPoint) { Cylinder3<Real> kCylinder; Line3<Real> kLine; OrthogonalLineFit(iQuantity,akPoint,kLine.Origin(),kLine.Direction()); Real fMaxRadiusSqr = (Real)0.0; int i; for (i = 0; i < iQuantity; i++) { Real fRadiusSqr = SqrDistance(akPoint[i],kLine); if ( fRadiusSqr > fMaxRadiusSqr ) fMaxRadiusSqr = fRadiusSqr; } Vector3<Real> kDiff = akPoint[0] - kLine.Origin(); Real fWMin = kLine.Direction().Dot(kDiff), fWMax = fWMin; for (i = 1; i < iQuantity; i++) { kDiff = akPoint[i] - kLine.Origin(); Real fW = kLine.Direction().Dot(kDiff); if ( fW < fWMin ) fWMin = fW; else if ( fW > fWMax ) fWMax = fW; } kCylinder.Center() = kLine.Origin() + (((Real)0.5)*(fWMax+fWMin))*kLine.Direction(); kCylinder.Direction() = kLine.Direction(); kCylinder.Radius() = Math<Real>::Sqrt(fMaxRadiusSqr); kCylinder.Height() = fWMax - fWMin; return kCylinder; } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- // explicit instantiation //---------------------------------------------------------------------------- namespace Wml { template WML_ITEM Cylinder3<float> ContCylinder<float> (int, const Vector3<float>*); template WML_ITEM Cylinder3<double> ContCylinder<double> (int, const Vector3<double>*); } //----------------------------------------------------------------------------
[ [ [ 1, 68 ] ] ]
b76f0c3760306f2debe4beb557c541811764e89e
f9ed86de48cedc886178f9e8c7ee4fae816ed42d
/src/geometry/box.h
f0c42e387e9532e3e570223d03ca74dc3916180d
[ "MIT" ]
permissive
rehno-lindeque/Flower-of-Persia
bf78d144c8e60a6f30955f099fe76e4a694ec51a
b68af415a09b9048f8b8f4a4cdc0c65b46bcf6d2
refs/heads/master
2021-01-25T04:53:04.951376
2011-01-29T11:41:38
2011-01-29T11:41:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,542
h
#ifndef __BOX_H__ #define __BOX_H__ class Box : public Geometry { public: Box(float radius) { float box[8][3] = { //front {-radius, -radius, -radius}, { radius, -radius, -radius}, { radius, radius, -radius}, {-radius, radius, -radius}, //back {-radius, -radius, radius}, { radius, -radius, radius}, { radius, radius, radius}, {-radius, radius, radius}}; *this << Quad(box[0], box[3], box[2], box[1]) //front << Quad(box[1], box[2], box[6], box[5]) //right << Quad(box[4], box[5], box[6], box[7]) //back << Quad(box[3], box[0], box[4], box[7]); //left } Box(float* position, float radius) { float box[8][3] = { //front {-radius, -radius, -radius}, { radius, -radius, -radius}, { radius, radius, -radius}, {-radius, radius, -radius}, //back {-radius, -radius, radius}, { radius, -radius, radius}, { radius, radius, radius}, {-radius, radius, radius}}; Vector3 p = position; *this << Quad(p+box[0], p+box[3], p+box[2], p+box[1]) //front << Quad(p+box[1], p+box[2], p+box[6], p+box[5]) //right << Quad(p+box[4], p+box[5], p+box[6], p+box[7]) //back << Quad(p+box[3], p+box[0], p+box[4], p+box[7]) //left << Quad(p+box[2], p+box[3], p+box[7], p+box[6]) //top << Quad(p+box[1], p+box[0], p+box[4], p+box[5]); //bottom } }; #endif
[ [ [ 1, 53 ] ] ]
cca462d4df58b54a60c64fef59792a9726602eeb
f9acc77870f5a372ee1955e5ac225399d6f841e7
/lenguajes de Programacion/Archivos cpp Lenguajes/ReGrillaWXApp.h
6328a0ca56bc78de8beb79d3fe1ef99cbad16611
[]
no_license
sergiobuj/campari_royal
3a713cff0fc86837bda4cd69c59f0d8146ffe0e5
e653b170e5e3ab52e6148242a883b570f216d664
refs/heads/master
2016-09-05T21:32:21.092149
2011-10-18T22:09:30
2011-10-18T22:09:30
976,668
0
0
null
null
null
null
UTF-8
C++
false
false
584
h
//--------------------------------------------------------------------------- // // Name: ReGrillaWXApp.h // Author: Sergio // Created: 11/09/2007 09:05:45 p.m. // Description: // //--------------------------------------------------------------------------- #ifndef __REGRILLAWXFRMApp_h__ #define __REGRILLAWXFRMApp_h__ #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include <wx/wx.h> #else #include <wx/wxprec.h> #endif class ReGrillaWXFrmApp : public wxApp { public: bool OnInit(); int OnExit(); }; #endif
[ [ [ 1, 30 ] ] ]
86eed6d34f797a968e269a2ef45ba997f1b8e292
41efaed82e413e06f31b65633ed12adce4b7abc2
/projects/shaders/src/MyApp.cpp
076dd90020cd8363ae3d262b71b4f673cb5e3b66
[]
no_license
ivandro/AVT---project
e0494f2e505f76494feb0272d1f41f5d8f117ac5
ef6fe6ebfe4d01e4eef704fb9f6a919c9cddd97f
refs/heads/master
2016-09-06T03:45:35.997569
2011-10-27T15:00:14
2011-10-27T15:00:14
2,642,435
0
2
null
2016-04-08T14:24:40
2011-10-25T09:47:13
C
UTF-8
C++
false
false
795
cpp
#include <GL/glew.h> #include "MyApp.h" namespace shaders { MyApp::MyApp() { _windowInfo.caption = "Shaders"; _windowInfo.width = 800; _windowInfo.height = 600; } MyApp::~MyApp() { } void MyApp::createEntities() { addEntity(new MyCamera("Camera")); addEntity(new MyTeapot("Teapot")); addEntity(new MyObject("Object")); addEntity(new MyWorld("World")); } void MyApp::createViews() { cg::View* v1 = createView("View1"); v1->setViewport(0.0f,0.0f,0.5f,1.0f); v1->linkEntityAtEnd("Camera"); v1->linkEntityAtEnd("Teapot"); v1->linkEntityAtEnd("World"); cg::View* v2 = createView("View2"); v2->setViewport(0.5f,0.0f,0.5f,1.0f); v2->linkEntityAtEnd("Camera"); v2->linkEntityAtEnd("Object"); v2->linkEntityAtEnd("World"); } }
[ "Moreira@Moreira-PC.(none)" ]
[ [ [ 1, 33 ] ] ]
53279e533314e61324a368b5daacc75d5512d98a
cd07acbe92f87b59260478f62a6f8d7d1e218ba9
/src/MophyListCtrl.cpp
24b8557a37ead4f2b9c33919c0acd7996c1f3f92
[]
no_license
niepp/sperm-x
3a071783e573d0c4bae67c2a7f0fe9959516060d
e8f578c640347ca186248527acf82262adb5d327
refs/heads/master
2021-01-10T06:27:15.004646
2011-09-24T03:33:21
2011-09-24T03:33:21
46,690,957
1
1
null
null
null
null
GB18030
C++
false
false
2,670
cpp
// MophyListCtrl.cpp : implementation file // #include "stdafx.h" #include "sperm.h" #include "MophyListCtrl.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMophyListCtrl TCHAR* MophyColOrder[][2] = { // 活力常规检测 TEXT("pName"), TEXT("姓名"), TEXT("pCaseNO"), TEXT("样本号"), TEXT("pDetectDateTime"), TEXT("取精日期"), TEXT("pTotalNormalRatio"), TEXT("形态正常率"), NULL, NULL }; CMophyListCtrl::CMophyListCtrl() { } CMophyListCtrl::~CMophyListCtrl() { } BEGIN_MESSAGE_MAP(CMophyListCtrl, CListCtrl) //{{AFX_MSG_MAP(CMophyListCtrl) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMophyListCtrl message handlers int CMophyListCtrl::SetListCtrlData(const _RecordsetPtr &rs) { int i , colN; DeleteAllItems(); int nColumnCount = GetHeaderCtrl()->GetItemCount(); for (i=0;i < nColumnCount; i++) { DeleteColumn(0); } LONG lStyle = SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE); lStyle |= LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP | LVS_EX_FLATSB ; SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, (LPARAM)lStyle); long n; rs->GetFields()->get_Count(&n); LV_COLUMN lc; lc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH /*| LVCF_FMT*/; lc.cx = 100; i = 0; while (MophyColOrder[i][0]) { lc.iSubItem = i; lc.pszText = MophyColOrder[i][1]; InsertColumn(i, &lc); ++i; } colN = i; i = 0; while (!rs->EndOfFile) { for(int j=0;j<colN;++j) { LV_ITEM lvitem; lvitem.mask = LVIF_TEXT; lvitem.state = 0; lvitem.stateMask = 0; lvitem.iItem = i; lvitem.iSubItem = j ; _variant_t vt = rs->GetCollect((LPCSTR)CString(MophyColOrder[j][0])); _bstr_t ss = (_bstr_t)vt; lvitem.pszText = (char*)ss; if( j == 0) InsertItem(&lvitem); else if(j==2) { CString cs(lvitem.pszText); // *** int len=10; if(isdigit(cs[6])) { if(isdigit(cs[9])) len = 10; else len = 9; } else { if(isdigit(cs[8])) len = 9; else len = 8; } SetItemText(i,j,cs.Left(len)); } else if(j==3) { CString cs; double vr = atof(lvitem.pszText); cs.Format("%.1lf%%", vr); SetItemText(i,j,cs.Left(10)); } else SetItemText(i,j,lvitem.pszText); } ++i; rs->MoveNext(); } return i; }
[ "harithchen@e030fd90-5f31-5877-223c-63bd88aa7192" ]
[ [ [ 1, 122 ] ] ]
72b3856b94de66748f02d568a9142777885fbffb
b9115b524856b1595a21004603ce52bc25440515
/Conversation/header_files/Conversation/CChoice.hpp
8015ab29c2be397db85ed606cc355b82cd209420
[]
no_license
martu/simple-VN
74a3146b3f03d1684fa4533ba58b88c7bb61057c
ed175b8228433d942a62eb8229150326c831bbd7
refs/heads/master
2021-01-10T18:46:04.218361
2010-10-11T23:09:53
2010-10-11T23:09:53
962,351
4
0
null
null
null
null
UTF-8
C++
false
false
604
hpp
/* * CChoice.hpp * * Created on: 30.08.2010 * Author: Martu */ #ifndef CCHOICE_HPP_ #define CCHOICE_HPP_ #include "CButton.hpp" #include "CFontManager.hpp" // defines a choice Button class CChoice : public CButton { private: string m_sFlag; sf::String m_sName; // Text displayed on the Button void ComputeNamePos (); public: void Render (sf::RenderWindow *pWindow); void SetFont (string sFont); void SetChoice (string sName, string sFlag); void SetMouseOver (bool MouseOver); string GetFlag () {return m_sFlag;}; }; #endif /* CCHOICE_HPP_ */
[ [ [ 1, 33 ] ] ]
a65319bce2395cf260387a615461dd1bb9a9cc89
ef25bd96604141839b178a2db2c008c7da20c535
/src/src/Engine/Renderer/D3DApp/d3dapp.h
4ac7432ccdc6e7e8d43cbcf2a70f48addc98df68
[]
no_license
OtterOrder/crock-rising
fddd471971477c397e783dc6dd1a81efb5dc852c
543dc542bb313e1f5e34866bd58985775acf375a
refs/heads/master
2020-12-24T14:57:06.743092
2009-07-15T17:15:24
2009-07-15T17:15:24
32,115,272
0
0
null
null
null
null
ISO-8859-1
C++
false
false
8,514
h
#pragma once //===========================================================================// // Include // //===========================================================================// #include <string> #include "D3DUtil.h" #include "D3DEnumeration.h" #include "D3DSettings.h" #include "d3dfont.h" //===========================================================================// // Codes d'erreurs // //===========================================================================// enum APPMSGTYPE { MSG_NONE, MSGERR_APPMUSTEXIT, MSGWARN_SWITCHEDTOREF }; #define D3DAPPERR_NODIRECT3D 0x82000001 #define D3DAPPERR_NOWINDOW 0x82000002 #define D3DAPPERR_NOCOMPATIBLEDEVICES 0x82000003 #define D3DAPPERR_NOWINDOWABLEDEVICES 0x82000004 #define D3DAPPERR_NOHARDWAREDEVICE 0x82000005 #define D3DAPPERR_HALNOTCOMPATIBLE 0x82000006 #define D3DAPPERR_NOWINDOWEDHAL 0x82000007 #define D3DAPPERR_NODESKTOPHAL 0x82000008 #define D3DAPPERR_NOHALTHISMODE 0x82000009 #define D3DAPPERR_NONZEROREFCOUNT 0x8200000a #define D3DAPPERR_MEDIANOTFOUND 0x8200000b #define D3DAPPERR_RESETFAILED 0x8200000c #define D3DAPPERR_NULLREFDEVICE 0x8200000d //===========================================================================// // Classe bas-niveau D3D Application // //===========================================================================// class CD3DApplication { protected: CD3DEnumeration m_d3dEnumeration; CD3DSettings m_d3dSettings; //===========================================================================// // Variables internes pour les différents états // //===========================================================================// bool m_bWindowed; bool m_bActive; bool m_bDeviceLost; bool m_bMinimized; bool m_bMaximized; bool m_bIgnoreSizeChange; bool m_bDeviceObjectsInited; bool m_bDeviceObjectsRestored; bool m_bShowFPS; int m_FullScreenWidth; int m_FullScreenHeight; int m_FullScreenRefreshRate; //===========================================================================// // Variables internes pour le timing // //===========================================================================// bool m_bFrameMoving; bool m_bSingleStep; //===========================================================================// // Objets principaux pour créer et rendre la scène 3D // //===========================================================================// D3DPRESENT_PARAMETERS m_d3dpp; // Paramètres pour la création/reset du device HWND m_hWnd; // Main app Windows HWND m_hWndFocus; // Focus Windows HMENU m_hMenu; // Menu Windows LPDIRECT3D9 m_pD3D; // Object principal D3D protected: DWORD m_dwCreateFlags; // Indique si software ou hardware vertex processing DWORD m_dwWindowStyle; // Sauvegarde du style de la fenêtre RECT m_rcWindowBounds; // Sauvegarde de la zone de la fenêtre RECT m_rcWindowClient; // Sauvegarde de la taille de la fenêtre public: LPDIRECT3DDEVICE9 m_pd3dDevice; // Pointeur vers le device de rendu D3DCAPS9 m_d3dCaps; // Capabilities du device D3DSURFACE_DESC m_d3dsdBackBuffer; // Description de la surface du backbuffer CFirstPersonCamera m_DevCamera; //===========================================================================// // Variables temporelles (public car utile partout) // //===========================================================================// FLOAT m_fTime; // Le temps en seconde FLOAT m_fElapsedTime; // Temps écoulé depuis la frame précédente FLOAT m_fFPS; // Frame rate instantané TCHAR m_strDeviceStats[90]; // String pour stocker les stats du device TCHAR m_strFrameStats[90]; // String pour stocker les stats des frames CD3DFont* m_pStatsFont; // Font pour les framestats protected: //===========================================================================// // Variables propre à l'application // //===========================================================================// std::string m_WindowTitle; // Titre de l'application Windows DWORD m_dwCreationWidth; // Hauteur pour créer la fenêtre DWORD m_dwCreationHeight; // Largeur pour créer la fenêtre bool m_bShowCursorWhenFullscreen; // Pour savoir si l'on montre le curseur en fullscreen bool m_bClipCursorWhenFullscreen; // Pour savoir si l'on limite la position du curseur en fullscreen bool m_bStartFullscreen; // Pour savoir si on commence l'application en fullscreen //===========================================================================// // Callback à dériver // //===========================================================================// virtual HRESULT ConfirmDevice(D3DCAPS9*,DWORD,D3DFORMAT) { return S_OK; } virtual HRESULT BeforeCreateDevice() { return S_OK; } virtual HRESULT OnCreateDevice() { return S_OK; } virtual HRESULT OnResetDevice() { return S_OK; } virtual HRESULT FrameMove(float fElapsedTime) { return S_OK; } virtual HRESULT Render() { return S_OK; } virtual HRESULT OnLostDevice() { return S_OK; } virtual HRESULT OnDestroyDevice() { return S_OK; } virtual HRESULT AfterDestroyDevice() { return S_OK; } //===========================================================================// // Fonction de gestion d'erreur // //===========================================================================// HRESULT DisplayErrorMsg( HRESULT hr, DWORD dwType ); //===========================================================================// // Fonctions internes pour gérer et rendre la scene 3D // //===========================================================================// static bool ConfirmDeviceHelper (D3DCAPS9* pCaps, VertexProcessingType vertexProcessingType, D3DFORMAT backBufferFormat); void BuildPresentParamsFromSettings (); bool FindBestWindowedMode (bool bRequireHAL, bool bRequireREF); bool FindBestFullscreenMode ( bool bRequireHAL, bool bRequireREF); HRESULT ChooseInitialD3DSettings (); HRESULT Initialize3DEnvironment (); HRESULT HandlePossibleSizeChange (); HRESULT Reset3DEnvironment (); HRESULT ToggleFullscreen (); HRESULT ForceWindowed (); HRESULT UserSelectNewDevice (); void Cleanup3DEnvironment (); HRESULT Render3DEnvironment (); virtual HRESULT AdjustWindowForChange (); virtual void UpdateStats (); public: //===========================================================================// // Fonctions pour créer, lancer, et mettre en pause l'application //===========================================================================// virtual HRESULT Create( HINSTANCE hInstance, WNDCLASS wndClass ); virtual void Run(); virtual void Close(); virtual LRESULT EventsCallback( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); virtual void SetFullScreenResolution(int width, int height, int RefreshRate=60); virtual void Pause( bool bPause ); virtual ~CD3DApplication() { } CD3DApplication(); // Constructeur par défaut };
[ "mathieu.chabanon@7c6770cc-a6a4-11dd-91bf-632da8b6e10b", "germain.mazac@7c6770cc-a6a4-11dd-91bf-632da8b6e10b" ]
[ [ [ 1, 50 ], [ 55, 149 ], [ 151, 159 ] ], [ [ 51, 54 ], [ 150, 150 ] ] ]
450b8e8d8d0cac4a38a672f36c9428236c148555
ec4c161b2baf919424d8d21cd0780cf8065e3f69
/Velo/Source/Embedded Controller/arduino/cBrake.h
3915835a6299d479a61e014dcb93dff0b73dc14b
[]
no_license
jhays200/EV-Tracking
b215d2a915987fe7113a05599bda53f254248cfa
06674e6f0f04fc2d0be1b1d37124a9a8e0144467
refs/heads/master
2016-09-05T18:41:21.650852
2011-06-04T01:50:25
2011-06-04T01:50:25
1,673,213
2
0
null
null
null
null
UTF-8
C++
false
false
669
h
/////////////////////////////////////////////////////////// // cBrake.h // Implementation of the Class cBrake // Created on: 05-May-2010 3:27:43 AM // Original author: shawn.mcginnis /////////////////////////////////////////////////////////// #if !defined(EA_AA8289DD_E420_478d_B6DB_9517904FC703__INCLUDED_) #define EA_AA8289DD_E420_478d_B6DB_9517904FC703__INCLUDED_ #include "cDigital.h" /** * The Brake class will be the interface between internal software and the * hardware brake. */ class cBrake : public cDigital { public: virtual bool Update(); }; #endif // !defined(EA_AA8289DD_E420_478d_B6DB_9517904FC703__INCLUDED_)
[ [ [ 1, 24 ] ] ]