int KXML::GetAttributeText(IXMLDOMNode* pNode, LPSTR strAttrName, LPSTR strRet){ wchar_t wstrAttr[128]; IXMLDOMNode* pAttrNode = NULL; IXMLDOMNamedNodeMap* pMap = NULL; VARIANT varValue; try{ //int n = mbstowcs(wstrAttr, strAttrName, 128); //int n = mbstowcs_s(wstrAttr, strAttrName, 128); // TODO : error test size_t convertedSize; int n = mbstowcs_s(&convertedSize, wstrAttr, strlen(strAttrName) + 1, strAttrName, 128); pNode->get_attributes(&pMap); pMap->getNamedItem(wstrAttr, &pAttrNode); pAttrNode->get_nodeValue(&varValue); strcpy_s(strRet, 128, (const char*)_bstr_t(varValue.bstrVal, FALSE)); // wcstombs(strRet, varValue.bstrVal, 128) REL(pAttrNode); REL(pMap); return TRUE; } catch (...){ REL(pAttrNode); REL(pMap); return FALSE; } }
void sqrt(int p2) { static int af = 0; int nps; /* point size for radical */ double radscale = 0.95; if (ttype == DEVPOST) radscale = 1.05; nps = ps * radscale * eht[p2] / EM(1.0,ps) + 0.99; /* kludgy */ nps = max(EFFPS(nps), ps); yyval = p2; if (ttype == DEVCAT || ttype == DEVAPS) eht[yyval] = EM(1.2, nps); else if (ttype == DEVPOST) eht[yyval] = EM(1.15, nps); else /* DEV202, DEVPOST */ eht[yyval] = EM(1.15, nps); dprintf(".\tS%d <- sqrt S%d;b=%g, h=%g, nps=%d\n", yyval, p2, ebase[yyval], eht[yyval], nps); printf(".as %d \\|\n", yyval); nrwid(p2, ps, p2); if (af++ == 0) printf(".af 10 01\n"); /* make it two digits when it prints */ printf(".nr 10 %.3fu*\\n(.su/10\n", 9.2*eht[p2]); /* this nonsense */ /* guesses point size corresponding to height of stuff */ printf(".ds %d \\v'%gm'\\s(\\n(10", yyval, REL(ebase[p2],ps)); if (ttype == DEVCAT || ttype == DEVAPS) printf("\\v'-.2m'\\(sr\\l'\\n(%du\\(rn'\\v'.2m'", p2); else /* DEV202, DEVPOST so far */ printf("\\(sr\\l'\\n(%du\\(rn'", p2); printf("\\s0\\v'%gm'\\h'-\\n(%du'\\^\\*(%d\n", REL(-ebase[p2],ps), p2, p2); lfont[yyval] = rfont[yyval] = ROM; }
bool CSystemObjectWrapper::Attach(std::string sSystemName,std::string sName,bool bTraceIfFailed) { bool bOk=false; ISystemManager *piSystemManager=GetSystemManager(); ISystem *piSystem=piSystemManager->GetSystem(sSystemName); if(piSystem){bOk=Attach(piSystem,sName,bTraceIfFailed);} REL(piSystem); REL(piSystemManager); return bOk; }
/// 지형객체를 메모리에서 소거한다. HRESULT ZTerrain::_Destroy() { DEL( m_pQuadTree ); DELS( m_pvHeightMap ); REL( m_pVB ); REL( m_pIB ); for( int i = 0 ; i < 4 ; i++ ) REL( m_pTex[i] ); return S_OK; }
void CSystemObjectWrapper::ReleaseInterfaces() { if(m_piObject && m_bObjectMustBeDestroyed) { m_piObject->Destroy(); } REL(m_piObject); REL(m_piSerializable); m_bObjectMustBeDestroyed=false; m_bAttached=false; }
void fromto(int p1, int p2, int p3) { double b, h1, b1, t; int subps; yyval = salloc(); lfont[yyval] = rfont[yyval] = 0; h1 = eht[yyval] = eht[p1]; b1 = ebase[p1]; b = 0; subps = ps; ps += deltaps; nrwid(p1, ps, p1); printf(".nr %d \\n(%d\n", yyval, p1); if (p2 > 0) { nrwid(p2, subps, p2); printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, yyval, yyval, p2); eht[yyval] += eht[p2]; b = eht[p2]; } if (p3 > 0) { nrwid(p3, subps, p3); printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p3, yyval, yyval, p3); eht[yyval] += eht[p3]; } printf(".ds %d ", yyval); /* bottom of middle box */ if (p2 > 0) { t = eht[p2]-ebase[p2]+b1; printf("\\v'%gm'\\h'\\n(%du-\\n(%du/2u'%s\\*(%d%s", REL(t,ps), yyval, p2, DPS(ps,subps), p2, DPS(subps,ps)); printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gm'\\\n", yyval, p2, REL(-t,ps)); } printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du/2u'\\\n", yyval, p1, p1, yyval, p1); if (p3 >0) { t = h1-b1+ebase[p3]; printf("\\v'%gm'\\h'-\\n(%du-\\n(%du/2u'%s\\*(%d%s\\h'\\n(%du-\\n(%du/2u'\\v'%gm'\\\n", REL(-t,ps), yyval, p3, DPS(ps,subps), p3, DPS(subps,ps), yyval, p3, REL(t,ps)); } printf("\n"); ebase[yyval] = b + b1; dprintf(".\tS%d <- %d from %d to %d; h=%g b=%g\n", yyval, p1, p2, p3, eht[yyval], ebase[yyval]); sfree(p1); if (p2 > 0) sfree(p2); if (p3 > 0) sfree(p3); }
void CEntityEditorSoundPropertyPanel::OnButtonClicked(IGameGUIButton *piControl) { if(m_Object.m_piDesign==NULL){return;} bool bUpdateConfig=false; SSoundAnimationObjectTypeConfig sConfig; m_Object.m_piDesign->GetConfig(&sConfig); unsigned int nIncrement=10; if(m_piGUIManager->IsKeyDown(GK_LCONTROL)){nIncrement=100;} if(m_piGUIManager->IsKeyDown(GK_LSHIFT)){nIncrement=500;} if(m_piBTLoop==piControl){bUpdateConfig=true;sConfig.bLoop=!sConfig.bLoop;} if(m_piBTIncreaseVolume==piControl){bUpdateConfig=true;sConfig.nVolume+=5;if(sConfig.nVolume>100){sConfig.nVolume=100;}} if(m_piBTDecreaseVolume==piControl){bUpdateConfig=true;sConfig.nVolume-=5;if(sConfig.nVolume<0){sConfig.nVolume=0;}} if(m_piBTIncreaseStartTime==piControl){bUpdateConfig=true;sConfig.nStartTime+=nIncrement;} if(m_piBTDecreaseStartTime==piControl){bUpdateConfig=true;sConfig.nStartTime=(sConfig.nStartTime<nIncrement)?0:sConfig.nStartTime-nIncrement;} if(m_piBTIncreaseEndTime==piControl){bUpdateConfig=true;sConfig.nEndTime+=nIncrement;} if(m_piBTDecreaseEndTime==piControl){bUpdateConfig=true;sConfig.nEndTime=(sConfig.nEndTime<nIncrement)?0:sConfig.nEndTime-nIncrement;} if(bUpdateConfig) { m_Object.m_piDesign->SetConfig(&sConfig); UpdateData(); NOTIFY_EVENT(IEntityEditorPropertyPanelEvents,OnObjectChanged(this,m_Object.m_piObject)); } if(piControl==m_piBTRemove) { if(!ConfirmDialog("Remove sound '"+m_Object.m_piDesign->GetAnimationObjectDescription()+"' ?","Entity Editor",eMessageDialogType_Warning)){return;} ISystemObject *piObject=ADD(m_Object.m_piObject); m_Object.Detach(); NOTIFY_EVENT(IEntityEditorPropertyPanelEvents,OnObjectRemoved(this,piObject)); REL(piObject); } }
IEntity *CLiveBonusType::CreateInstance(IEntity *piParent,unsigned int dwCurrentTime) { CLiveBonus *piEntity=new CLiveBonus(this); SPhysicInfo *pPhysicInfo=piEntity->GetPhysicInfo(); InitializeEntity(piEntity,dwCurrentTime); // Se posiciona el bonus en el plano aereo, en el juego no hay bonus de armas entregados por unidades // de tierra, pero just in case CVector vPosition=pPhysicInfo->vPosition=piParent?piParent->GetPhysicInfo()->vPosition:Origin; CVector vStart,vEnd; CVector vCameraPos; if(m_PlayAreaManager.m_piPlayAreaManager) { m_PlayAreaManager.m_piPlayAreaManager->GetCameraRoute(&vStart,&vEnd); IGenericCamera *piCamera=m_PlayAreaManager.m_piPlayAreaManager->GetCamera(); if(piCamera){vCameraPos=piCamera->GetPosition();} REL(piCamera); } CPlane playAreaPlane=CPlane(AxisPosY,vStart); CVector vCut; if(playAreaPlane.Cut(vPosition,vCameraPos,&vCut)) { pPhysicInfo->vPosition=vCut; } piEntity->SetState(eLiveBonusState_Normal,ANIMATION_RANDOM); piEntity->SetInitialVelocity(); return piEntity; }
cDxSound::~cDxSound(void) { REL(_pSegment); REL(_pPerformance); REL(_pLoader); POSITION pos = _sounds.GetStartPosition(); long key; CSound* value; while(pos) { _sounds.GetNextAssoc(pos, key, value); delete value; } _sounds.RemoveAll(); DEL(_pSoundManager); }
BOOL cDxSound::stopCurrentSong() { if(!_pPerformance) return FALSE; _pPerformance->Stop(_pSegment, NULL, 0, 0); REL(_pSegment); return TRUE; }
//--------------------------------------------------------------------------- HSplatting::~HSplatting(){ REL(m_pBaseTexture); for( int i = 0 ; i < TexNumber ; i++ ){ m_Texture[i].pTexture->Release(); m_Texture[i].pAlphamap->Release(); } }
void CEntityEditorEventPropertyPanel::OnButtonClicked(IGameGUIButton *piControl) { if(m_Object.m_piDesign==NULL){return;} bool bUpdateConfig=false; SEventAnimationObjectTypeConfig sConfig; m_Object.m_piDesign->GetConfig(&sConfig); if(m_piBTIncreaseTime==piControl){bUpdateConfig=true;sConfig.nTime+=100;} if(m_piBTDecreaseTime==piControl){bUpdateConfig=true;sConfig.nTime=(sConfig.nTime<100)?0:sConfig.nTime-100;} if(bUpdateConfig) { m_Object.m_piDesign->SetConfig(&sConfig); UpdateData(); NOTIFY_EVENT(IEntityEditorPropertyPanelEvents,OnObjectChanged(this,m_Object.m_piObject)); } if(piControl==m_piBTRemove) { if(!ConfirmDialog("Remove event '"+m_Object.m_piDesign->GetAnimationObjectDescription()+"' ?","Entity Editor",eMessageDialogType_Warning)){return;} ISystemObject *piObject=ADD(m_Object.m_piObject); m_Object.Detach(); NOTIFY_EVENT(IEntityEditorPropertyPanelEvents,OnObjectRemoved(this,piObject)); REL(piObject); } }
bool CSystemObjectWrapper::Attach(ISystem *piSystem,std::string sName,bool bTraceIfFailed) { bool bOk=false; ISystemObject *piObject=NULL; if(piSystem->GetObject(sName,&piObject)){bOk=Attach(piObject);} if(!bOk && bTraceIfFailed) { RTTRACE("CSystemObjectWrapper::Attach -> Failed to attach to System: %s, Object:%s",piSystem->GetName().c_str(),sName.c_str()); } REL(piObject); return bOk; }
bool CSystemObjectWrapper::Create(std::string sSystem,std::string sClass,std::string sName) { ReleaseInterfaces(); bool bOk=false; ISystemObject *piObject=NULL; ISystem *piSystem=NULL; ISystemManager *piManager=GetSystemManager(); if(piManager){piSystem=piManager->GetSystem(sSystem);} if(piSystem){bOk=Create(piSystem,sClass,sName);} if(piObject){bOk=GetInterfaces(piObject);} if(!bOk) { RTTRACE("CSystemObjectWrapper::Create -> Failed to create System: %s, Class: %s, Object:%s",sSystem.c_str(),sClass.c_str(),sName.c_str()); } REL(piManager); REL(piSystem); REL(piObject); return bOk; }
void boverb(int p1, int p2) { int treg; double h, b, d, d1, d2; extern double Overgap, Overwid, Overline; treg = salloc(); yyval = p1; d = EM(Overgap, ps); h = eht[p1] + eht[p2] + d; b = eht[p2] - d; dprintf(".\tS%d <- %d over %d; b=%g, h=%g\n", yyval, p1, p2, b, h); nrwid(p1, ps, p1); nrwid(p2, ps, p2); printf(".nr %d \\n(%d\n", treg, p1); printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2); printf(".nr %d \\n(%d+%gm\n", treg, treg, Overwid); d2 = eht[p2]-ebase[p2]-d; /* denom */ printf(".ds %d \\v'%gm'\\h'\\n(%du-\\n(%du/2u'\\*(%d\\v'%gm'\\\n", yyval, REL(d2,ps), treg, p2, p2, REL(-d2,ps)); d1 = 2 * d + ebase[p1]; /* num */ printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gm'\\*(%d\\v'%gm'\\\n", p2, p1, REL(-d1,ps), p1, REL(d1,ps)); printf("\\h'-\\n(%du-\\n(%du/2u+%gm'\\v'%gm'\\l'\\n(%du-%gm'\\h'%gm'\\v'%gm'\n", treg, p1, Overline, REL(-d,ps), treg, 2*Overline, Overline, REL(d,ps)); ebase[yyval] = b; eht[yyval] = h; lfont[yyval] = rfont[yyval] = 0; sfree(p2); sfree(treg); }
void CBombProjectile::ProcessFrame(unsigned int dwCurrentTime,double dTimeFraction) { CEntityBase::ProcessFrame(dwCurrentTime,dTimeFraction); m_nCurrentTime=dwCurrentTime; if(GetState()==eBombState_Normal) { if(dwCurrentTime>(m_dwCreationTime+m_pType->m_nTimeToExplode)) { if(m_pTypeBase->GetStateAnimations(eBombState_Hit)) { m_PhysicInfo.vVelocity=Origin; m_PhysicInfo.dwMoveType=PHYSIC_MOVE_TYPE_NONE; SetState(eBombState_Hit); } else { Remove(); } } } else if(GetState()==eBombState_Hit) { if(dwCurrentTime>(m_dwCreationTime+m_pType->m_nTimeToExplode+m_pType->m_nDamageEndTime)) { Remove(); } else if(dwCurrentTime>(m_dwCreationTime+m_pType->m_nTimeToExplode+m_pType->m_nDamageStartTime)) { IGenericCamera *piCamera=g_PlayAreaManagerWrapper.m_piInterface->GetCamera(); CVector vCameraPos=piCamera?piCamera->GetPosition():Origin; REL(piCamera); double dElapsedTime=((double)(dwCurrentTime-(m_dwCreationTime+m_pType->m_nTimeToExplode+m_pType->m_nDamageStartTime))); double dTotalDuration=((double)(m_pType->m_nDamageEndTime-m_pType->m_nDamageStartTime)); double dElapsedFraction=dElapsedTime/dTotalDuration; SBombDamageData data; data.dTimeFraction=dTimeFraction; data.dDamage=m_pType->m_dDamagePerSecond*dTimeFraction; data.dRadius=(m_pType->m_dDamageEndRadius-m_pType->m_dDamageStartRadius)*dElapsedFraction+m_pType->m_dDamageStartRadius; data.vCameraPos=vCameraPos; data.playAreaPlane=CPlane(AxisPosY,m_PhysicInfo.vPosition); if(dwCurrentTime>m_nNextDamageEffect) { data.bDamageEffect=true; m_nNextDamageEffect=dwCurrentTime+m_pType->m_nDamageEffectInterval; } GetEntityManager()->PerformUnaryOperation(ApplyDamageOperation,this,&data); } } }
CVector CRoute::GetEstimatedAbsolutePoint(unsigned int nIndex,double dTime) { CVector vPoint=GetAbsolutePoint(nIndex); IPlayAreaDesign *piDesign=QI(IPlayAreaDesign,g_PlayAreaManagerWrapper.m_piInterface); if(piDesign) { SPlayAreaConfig sConfig; piDesign->GetPlayAreaConfig(&sConfig); vPoint.c[0]+=sConfig.dCameraSpeed*dTime; } REL(piDesign); return vPoint; }
void CEntityEditorClassSelector::OnInitDialog() { CGameDialogBase::OnInitDialog(); if(m_piSTTitle){m_piSTTitle->SetText(m_sTitle);} if(m_piLSClasses) { m_piGUIManager->SetFocus(m_piLSClasses); ISystemManager *piSystemManager=GetSystemManager(); ISystem *piSystem=piSystemManager?piSystemManager->GetSystem(m_sTargetSystem):NULL; if(piSystem) { std::vector<ISystemClass *> vClasses; piSystem->GetClasses(&vClasses); for(unsigned int x=0;x<vClasses.size();x++) { ISystemClass *piClass=vClasses[x]; m_piLSClasses->AddElement(piClass->GetName()); REL(piClass); } } REL(piSystem); REL(piSystemManager); } }
bool CSystemObjectWrapper::Create(ISystem *piSystem,std::string sClass,std::string sName) { ReleaseInterfaces(); bool bOk=false; ISystemObject *piObject=NULL; if(!piSystem->GetObject(sName,&piObject)) { if(piSystem->CreateObject(sClass,sName,&piObject)) { //m_bObjectMustBeDestroyed=true; } } if(piObject){bOk=GetInterfaces(piObject);} REL(piObject); return bOk; }
bool CPlayAreaEntity::ProcessFrame(CVector vPlayPosition,SPlayAreaInfo *pAreaInfo,unsigned int dwCurrentTime,double dInterval) { CVector vActivationPosition=m_vPosition; vActivationPosition.c[0]+=(m_nDelay && g_PlayAreaManagerWrapper.m_piInterface)?g_PlayAreaManagerWrapper.m_piInterface->GetCameraSpeed()*((double)m_nDelay)/1000.0:0; if(m_bFirstFrame) { m_bFirstFrame=false; if(!m_bDynamic && Util_IsInPlayArea(vActivationPosition+CVector(0,m_vRTMins.c[1],0),m_dRTActivationMin+m_dRTShadowPreactivation,m_dRTActivationMax,pAreaInfo)) { SEntityTypeConfig sConfig; IEntityTypeDesign *piDesign=QI(IEntityTypeDesign,m_EntityType.m_piEntityType); if(piDesign){piDesign->GetEntityTypeConfig(&sConfig);} REL(piDesign); m_bDoNotActivate=(sConfig.nAlignment==ENTITY_ALIGNMENT_ENEMIES && m_Route.GetPointCount()>0); } } if(!m_bActive && !m_bDoNotActivate) { bool bCurrentlyInPlayArea=Util_IsInPlayArea(vActivationPosition+CVector(0,m_vRTMins.c[1],0),m_dRTActivationMin+m_dRTShadowPreactivation,m_dRTActivationMax,pAreaInfo); if(bCurrentlyInPlayArea) { Activate(dwCurrentTime); } } // Comprobar si la entidad esta activa otra vez para procesar el frame en caso de que se acabe de activar, if(m_bActive) { if(m_EntityType.m_piEntityType!=NULL && ((m_nCreatedEntities==0) || (m_nCreatedEntities>0 && m_nCreatedEntities<m_nEntityCount && dwCurrentTime>=(m_nLastEntityTime+m_nInterval)))) { IEntity *piEntity=m_EntityType.m_piEntityType->CreateInstance(NULL,dwCurrentTime); piEntity->GetPhysicInfo()->vPosition=m_vPosition; piEntity->GetPhysicInfo()->vAngles=m_vAngles; if(m_Route.GetPointCount()) { piEntity->SetRoute(&m_Route); piEntity->SetRouteDelay(m_nRouteDelay); piEntity->GetPhysicInfo()->vAngles=AnglesFromVector(m_Route.GetAbsolutePoint(0)-m_vPosition); } SUBSCRIBE_TO(piEntity,IEntityEvents); m_mEntities.insert(std::pair<IEntity*,bool>(piEntity,false)); m_nCreatedEntities++; m_nLastEntityTime=dwCurrentTime; } map<IEntity*,bool>::iterator i; for(i=m_mEntities.begin();i!=m_mEntities.end();) { IEntity *piEntity=i->first; bool bHasBeenVisible=i->second; bool bEntityCurrentlyInPlayArea=Util_IsInPlayArea(piEntity->GetPhysicInfo()->vPosition+CVector(0,m_vRTMins.c[1],0),m_dRTActivationMin+m_dRTShadowPreactivation,m_dRTActivationMax,pAreaInfo); if(!bEntityCurrentlyInPlayArea && bHasBeenVisible && piEntity->HasFinishedRoute() ) { m_mEntities.erase(i++); UNSUBSCRIBE_FROM_CAST(piEntity,IEntityEvents); piEntity->Remove(); piEntity=NULL; } else { if(bEntityCurrentlyInPlayArea){i->second=true;} i++; } } if(m_nCreatedEntities==m_nEntityCount && m_mEntities.size()==0) { bool bCurrentlyInPlayArea=Util_IsInPlayArea(vActivationPosition+CVector(0,m_vRTMins.c[1],0),m_dRTActivationMin+m_dRTShadowPreactivation,m_dRTActivationMax,pAreaInfo); if(!bCurrentlyInPlayArea){Deactivate();} } } return m_bActive; }
/* * Read and process the relocations for one link object, we assume all * relocation sections for loadable segments are stored contiguously in * the file. */ int elf_reloc(Rt_map *lmp, uint_t plt, int *in_nfavl, APlist **textrel) { ulong_t relbgn, relend, relsiz, basebgn, pltbgn, pltend; ulong_t _pltbgn, _pltend; ulong_t dsymndx, roffset, rsymndx, psymndx = 0; uchar_t rtype; long value, pvalue; Sym *symref, *psymref, *symdef, *psymdef; Syminfo *sip; char *name, *pname; Rt_map *_lmp, *plmp; int ret = 1, noplt = 0; int relacount = RELACOUNT(lmp), plthint = 0; Rel *rel; uint_t binfo, pbinfo; APlist *bound = NULL; /* * Although only necessary for lazy binding, initialize the first * global offset entry to go to elf_rtbndr(). dbx(1) seems * to find this useful. */ if ((plt == 0) && PLTGOT(lmp)) { mmapobj_result_t *mpp; /* * Make sure the segment is writable. */ if ((((mpp = find_segment((caddr_t)PLTGOT(lmp), lmp)) != NULL) && ((mpp->mr_prot & PROT_WRITE) == 0)) && ((set_prot(lmp, mpp, 1) == 0) || (aplist_append(textrel, mpp, AL_CNT_TEXTREL) == NULL))) return (0); elf_plt_init(PLTGOT(lmp), (caddr_t)lmp); } /* * Initialize the plt start and end addresses. */ if ((pltbgn = (ulong_t)JMPREL(lmp)) != 0) pltend = pltbgn + (ulong_t)(PLTRELSZ(lmp)); relsiz = (ulong_t)(RELENT(lmp)); basebgn = ADDR(lmp); if (PLTRELSZ(lmp)) plthint = PLTRELSZ(lmp) / relsiz; /* * If we've been called upon to promote an RTLD_LAZY object to an * RTLD_NOW then we're only interested in scaning the .plt table. * An uninitialized .plt is the case where the associated got entry * points back to the plt itself. Determine the range of the real .plt * entries using the _PROCEDURE_LINKAGE_TABLE_ symbol. */ if (plt) { Slookup sl; Sresult sr; relbgn = pltbgn; relend = pltend; if (!relbgn || (relbgn == relend)) return (1); /* * Initialize the symbol lookup, and symbol result, data * structures. */ SLOOKUP_INIT(sl, MSG_ORIG(MSG_SYM_PLT), lmp, lmp, ld_entry_cnt, elf_hash(MSG_ORIG(MSG_SYM_PLT)), 0, 0, 0, LKUP_DEFT); SRESULT_INIT(sr, MSG_ORIG(MSG_SYM_PLT)); if (elf_find_sym(&sl, &sr, &binfo, NULL) == 0) return (1); symdef = sr.sr_sym; _pltbgn = symdef->st_value; if (!(FLAGS(lmp) & FLG_RT_FIXED) && (symdef->st_shndx != SHN_ABS)) _pltbgn += basebgn; _pltend = _pltbgn + (((PLTRELSZ(lmp) / relsiz)) * M_PLT_ENTSIZE) + M_PLT_RESERVSZ; } else { /* * The relocation sections appear to the run-time linker as a * single table. Determine the address of the beginning and end * of this table. There are two different interpretations of * the ABI at this point: * * o The REL table and its associated RELSZ indicate the * concatenation of *all* relocation sections (this is the * model our link-editor constructs). * * o The REL table and its associated RELSZ indicate the * concatenation of all *but* the .plt relocations. These * relocations are specified individually by the JMPREL and * PLTRELSZ entries. * * Determine from our knowledege of the relocation range and * .plt range, the range of the total relocation table. Note * that one other ABI assumption seems to be that the .plt * relocations always follow any other relocations, the * following range checking drops that assumption. */ relbgn = (ulong_t)(REL(lmp)); relend = relbgn + (ulong_t)(RELSZ(lmp)); if (pltbgn) { if (!relbgn || (relbgn > pltbgn)) relbgn = pltbgn; if (!relbgn || (relend < pltend)) relend = pltend; } } if (!relbgn || (relbgn == relend)) { DBG_CALL(Dbg_reloc_run(lmp, 0, plt, DBG_REL_NONE)); return (1); } DBG_CALL(Dbg_reloc_run(lmp, M_REL_SHT_TYPE, plt, DBG_REL_START)); /* * If we're processing a dynamic executable in lazy mode there is no * need to scan the .rel.plt table, however if we're processing a shared * object in lazy mode the .got addresses associated to each .plt must * be relocated to reflect the location of the shared object. */ if (pltbgn && ((MODE(lmp) & RTLD_NOW) == 0) && (FLAGS(lmp) & FLG_RT_FIXED)) noplt = 1; sip = SYMINFO(lmp); /* * Loop through relocations. */ while (relbgn < relend) { mmapobj_result_t *mpp; uint_t sb_flags = 0; rtype = ELF_R_TYPE(((Rel *)relbgn)->r_info, M_MACH); /* * If this is a RELATIVE relocation in a shared object (the * common case), and if we are not debugging, then jump into a * tighter relocation loop (elf_reloc_relative). */ if ((rtype == R_386_RELATIVE) && ((FLAGS(lmp) & FLG_RT_FIXED) == 0) && (DBG_ENABLED == 0)) { if (relacount) { relbgn = elf_reloc_relative_count(relbgn, relacount, relsiz, basebgn, lmp, textrel, 0); relacount = 0; } else { relbgn = elf_reloc_relative(relbgn, relend, relsiz, basebgn, lmp, textrel, 0); } if (relbgn >= relend) break; rtype = ELF_R_TYPE(((Rel *)relbgn)->r_info, M_MACH); } roffset = ((Rel *)relbgn)->r_offset; /* * If this is a shared object, add the base address to offset. */ if (!(FLAGS(lmp) & FLG_RT_FIXED)) { /* * If we're processing lazy bindings, we have to step * through the plt entries and add the base address * to the corresponding got entry. */ if (plthint && (plt == 0) && (rtype == R_386_JMP_SLOT) && ((MODE(lmp) & RTLD_NOW) == 0)) { relbgn = elf_reloc_relative_count(relbgn, plthint, relsiz, basebgn, lmp, textrel, 0); plthint = 0; continue; } roffset += basebgn; } rsymndx = ELF_R_SYM(((Rel *)relbgn)->r_info); rel = (Rel *)relbgn; relbgn += relsiz; /* * Optimizations. */ if (rtype == R_386_NONE) continue; if (noplt && ((ulong_t)rel >= pltbgn) && ((ulong_t)rel < pltend)) { relbgn = pltend; continue; } /* * If we're promoting plts, determine if this one has already * been written. */ if (plt && ((*(ulong_t *)roffset < _pltbgn) || (*(ulong_t *)roffset > _pltend))) continue; /* * If this relocation is not against part of the image * mapped into memory we skip it. */ if ((mpp = find_segment((caddr_t)roffset, lmp)) == NULL) { elf_reloc_bad(lmp, (void *)rel, rtype, roffset, rsymndx); continue; } binfo = 0; /* * If a symbol index is specified then get the symbol table * entry, locate the symbol definition, and determine its * address. */ if (rsymndx) { /* * If a Syminfo section is provided, determine if this * symbol is deferred, and if so, skip this relocation. */ if (sip && is_sym_deferred((ulong_t)rel, basebgn, lmp, textrel, sip, rsymndx)) continue; /* * Get the local symbol table entry. */ symref = (Sym *)((ulong_t)SYMTAB(lmp) + (rsymndx * SYMENT(lmp))); /* * If this is a local symbol, just use the base address. * (we should have no local relocations in the * executable). */ if (ELF_ST_BIND(symref->st_info) == STB_LOCAL) { value = basebgn; name = NULL; /* * Special case TLS relocations. */ if (rtype == R_386_TLS_DTPMOD32) { /* * Use the TLS modid. */ value = TLSMODID(lmp); } else if (rtype == R_386_TLS_TPOFF) { if ((value = elf_static_tls(lmp, symref, rel, rtype, 0, roffset, 0)) == 0) { ret = 0; break; } } } else { /* * If the symbol index is equal to the previous * symbol index relocation we processed then * reuse the previous values. (Note that there * have been cases where a relocation exists * against a copy relocation symbol, our ld(1) * should optimize this away, but make sure we * don't use the same symbol information should * this case exist). */ if ((rsymndx == psymndx) && (rtype != R_386_COPY)) { /* LINTED */ if (psymdef == 0) { DBG_CALL(Dbg_bind_weak(lmp, (Addr)roffset, (Addr) (roffset - basebgn), name)); continue; } /* LINTED */ value = pvalue; /* LINTED */ name = pname; /* LINTED */ symdef = psymdef; /* LINTED */ symref = psymref; /* LINTED */ _lmp = plmp; /* LINTED */ binfo = pbinfo; if ((LIST(_lmp)->lm_tflags | AFLAGS(_lmp)) & LML_TFLG_AUD_SYMBIND) { value = audit_symbind(lmp, _lmp, /* LINTED */ symdef, dsymndx, value, &sb_flags); } } else { Slookup sl; Sresult sr; /* * Lookup the symbol definition. * Initialize the symbol lookup, and * symbol result, data structures. */ name = (char *)(STRTAB(lmp) + symref->st_name); SLOOKUP_INIT(sl, name, lmp, 0, ld_entry_cnt, 0, rsymndx, symref, rtype, LKUP_STDRELOC); SRESULT_INIT(sr, name); symdef = NULL; if (lookup_sym(&sl, &sr, &binfo, in_nfavl)) { name = (char *)sr.sr_name; _lmp = sr.sr_dmap; symdef = sr.sr_sym; } /* * If the symbol is not found and the * reference was not to a weak symbol, * report an error. Weak references * may be unresolved. */ /* BEGIN CSTYLED */ if (symdef == 0) { if (sl.sl_bind != STB_WEAK) { if (elf_reloc_error(lmp, name, rel, binfo)) continue; ret = 0; break; } else { psymndx = rsymndx; psymdef = 0; DBG_CALL(Dbg_bind_weak(lmp, (Addr)roffset, (Addr) (roffset - basebgn), name)); continue; } } /* END CSTYLED */ /* * If symbol was found in an object * other than the referencing object * then record the binding. */ if ((lmp != _lmp) && ((FLAGS1(_lmp) & FL1_RT_NOINIFIN) == 0)) { if (aplist_test(&bound, _lmp, AL_CNT_RELBIND) == 0) { ret = 0; break; } } /* * Calculate the location of definition; * symbol value plus base address of * containing shared object. */ if (IS_SIZE(rtype)) value = symdef->st_size; else value = symdef->st_value; if (!(FLAGS(_lmp) & FLG_RT_FIXED) && !(IS_SIZE(rtype)) && (symdef->st_shndx != SHN_ABS) && (ELF_ST_TYPE(symdef->st_info) != STT_TLS)) value += ADDR(_lmp); /* * Retain this symbol index and the * value in case it can be used for the * subsequent relocations. */ if (rtype != R_386_COPY) { psymndx = rsymndx; pvalue = value; pname = name; psymdef = symdef; psymref = symref; plmp = _lmp; pbinfo = binfo; } if ((LIST(_lmp)->lm_tflags | AFLAGS(_lmp)) & LML_TFLG_AUD_SYMBIND) { dsymndx = (((uintptr_t)symdef - (uintptr_t)SYMTAB(_lmp)) / SYMENT(_lmp)); value = audit_symbind(lmp, _lmp, symdef, dsymndx, value, &sb_flags); } } /* * If relocation is PC-relative, subtract * offset address. */ if (IS_PC_RELATIVE(rtype)) value -= roffset; /* * Special case TLS relocations. */ if (rtype == R_386_TLS_DTPMOD32) { /* * Relocation value is the TLS modid. */ value = TLSMODID(_lmp); } else if (rtype == R_386_TLS_TPOFF) { if ((value = elf_static_tls(_lmp, symdef, rel, rtype, name, roffset, value)) == 0) { ret = 0; break; } } } } else { /* * Special cases. */ if (rtype == R_386_TLS_DTPMOD32) { /* * TLS relocation value is the TLS modid. */ value = TLSMODID(lmp); } else value = basebgn; name = NULL; } DBG_CALL(Dbg_reloc_in(LIST(lmp), ELF_DBG_RTLD, M_MACH, M_REL_SHT_TYPE, rel, NULL, 0, name)); /* * Make sure the segment is writable. */ if (((mpp->mr_prot & PROT_WRITE) == 0) && ((set_prot(lmp, mpp, 1) == 0) || (aplist_append(textrel, mpp, AL_CNT_TEXTREL) == NULL))) { ret = 0; break; } /* * Call relocation routine to perform required relocation. */ switch (rtype) { case R_386_COPY: if (elf_copy_reloc(name, symref, lmp, (void *)roffset, symdef, _lmp, (const void *)value) == 0) ret = 0; break; case R_386_JMP_SLOT: if (((LIST(lmp)->lm_tflags | AFLAGS(lmp)) & (LML_TFLG_AUD_PLTENTER | LML_TFLG_AUD_PLTEXIT)) && AUDINFO(lmp)->ai_dynplts) { int fail = 0; int pltndx = (((ulong_t)rel - (uintptr_t)JMPREL(lmp)) / relsiz); int symndx = (((uintptr_t)symdef - (uintptr_t)SYMTAB(_lmp)) / SYMENT(_lmp)); (void) elf_plt_trace_write(roffset, lmp, _lmp, symdef, symndx, pltndx, (caddr_t)value, sb_flags, &fail); if (fail) ret = 0; } else { /* * Write standard PLT entry to jump directly * to newly bound function. */ DBG_CALL(Dbg_reloc_apply_val(LIST(lmp), ELF_DBG_RTLD, (Xword)roffset, (Xword)value)); *(ulong_t *)roffset = value; } break; default: /* * Write the relocation out. */ if (do_reloc_rtld(rtype, (uchar_t *)roffset, (Word *)&value, name, NAME(lmp), LIST(lmp)) == 0) ret = 0; DBG_CALL(Dbg_reloc_apply_val(LIST(lmp), ELF_DBG_RTLD, (Xword)roffset, (Xword)value)); } if ((ret == 0) && ((LIST(lmp)->lm_flags & LML_FLG_TRC_WARN) == 0)) break; if (binfo) { DBG_CALL(Dbg_bind_global(lmp, (Addr)roffset, (Off)(roffset - basebgn), (Xword)(-1), PLT_T_FULL, _lmp, (Addr)value, symdef->st_value, name, binfo)); } } return (relocate_finish(lmp, bound, ret)); }
void diacrit(int p1, int type) { int c, t; c = salloc(); t = salloc(); nrwid(p1, ps, p1); printf(".nr 10 %gm\n", max(REL(eht[p1]-ebase[p1]-1,ps), 0)); /* vert shift if high */ if (type == HIGHBAR) printf(".nr 10 \\n(10+%gm\n", Dvshift); else if (type == LOWBAR) printf(".nr 10 0\n"); else printf(".if \\n(ct>1 .nr 10 \\n(10+%gm\n", Dvshift); printf(".nr %d %gm\n", t, Dhshift); /* horiz shift if high */ printf(".if \\n(ct>1 .nr %d %gm\n", t, Dh2shift); /* was .1 and .15 */ switch (type) { case VEC: printf(".ds %d %s\n", c, lookup(deftbl, "vec_def")->cval); break; case DYAD: printf(".ds %d %s\n", c, lookup(deftbl, "dyad_def")->cval); break; case HAT: printf(".ds %d %s\n", c, lookup(deftbl, "hat_def")->cval); break; case TILDE: printf(".ds %d %s\n", c, lookup(deftbl, "tilde_def")->cval); break; case DOT: printf(".ds %d %s\n", c, lookup(deftbl, "dot_def")->cval); break; case DOTDOT: printf(".ds %d %s\n", c, lookup(deftbl, "dotdot_def")->cval); break; case BAR: case LOWBAR: case HIGHBAR: printf(".ds %d \\v'%gm'\\h'%gm'\\l'\\n(%du-%gm'\\h'%gm'\\v'%gm'\n", c, -Barv, Barh, p1, 2*Barh, Barh, Barv); break; case UNDER: printf(".ds %d \\v'%gm'\\l'\\n(%du-%gm\\(ul'\\h'%gm'\\v'%gm'\n", c, -Ubarv, p1, Ubarh, Ubarh, Ubarv); /* printf(".ds %d \\v'-%gm'\\l'\\n(%du\\(ul'\\v'%gm'\n", c, Ubarv, p1, Ubarv); */ printf(".nr %d 0\n", t); printf(".nr 10 0-.1m-%gm\n", REL(ebase[p1],ps)); printf(".if \\n(ct%%2=1 .nr 10 0\\n(10-.1m\n"); break; case UTILDE: printf(".ds %d %s\n", c, lookup(deftbl, "utilde_def")->cval); printf(".nr %d 0\n", t); printf(".nr 10 0-%gm\n", REL(ebase[p1],ps)); printf(".if \\n(ct%%2=1 .nr 10 0\\n(10-%gm\n", 0.1); break; } nrwid(c, ps, c); if (lfont[p1] != ITAL) printf(".nr %d 0\n", t); printf(".as %d \\h'-\\n(%du-\\n(%du/2u+\\n(%du'\\v'0-\\n(10u'\\*(%d", p1, p1, c, t, c); printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u-\\n(%du'\n", c, p1, t); if (type != UNDER && type != UTILDE) eht[p1] += EM(Dheight, ps); /* was .15 */ dprintf(".\tdiacrit: %c over S%d, lf=%c, rf=%c, h=%g, b=%g\n", type, p1, lfont[p1], rfont[p1], eht[p1], ebase[p1]); sfree(c); sfree(t); }
void paren(int leftc, int p1, int rightc) { int n, m, j; double h1, b1; double v, bv; /* v = shift of inside, bv = shift of brackets */ extern double Parenbase, Parenshift, Parenheight; bv = ttype == DEVPOST ? Parenshift : 0; /* move brackets down this much */ h1 = eht[p1]; b1 = ebase[p1]; yyval.token = p1; lfont[yyval.token] = rfont[yyval.token] = 0; n = REL(h1,ps) + 0.99; /* ceiling */ if (n < 2) n = 1; m = n - 2; if (leftc == '{' || rightc == '}') { n = n%2 ? n : ++n; if (n < 3) n = 3; m = n-3; } eht[yyval.token] = EM((double) n + Parenheight, ps); ebase[yyval.token] = eht[yyval.token]/2 - EM(Parenbase, ps); /* try to cope with things that are badly centered */ /* (top heavy or bottom heavy) */ if (abs(h1/2 - b1) >= EM(0.5, ps)) v = REL(-ebase[yyval.token] + (eht[yyval.token]-h1)/2 + b1, ps); else v = 0; /* don't shift it at all */ printf(".ds %d \\^", yyval.token); /* was \| */ if (bv) printf("\\v'%gm'", bv); switch (leftc) { case 'n': /* nothing */ case '\0': break; case 'f': /* floor */ if (n <= 1) printf("\\(lf"); else brack(m, "\\(bv", "\\(bv", "\\(lf"); break; case 'c': /* ceiling */ if (n <= 1) printf("\\(lc"); else brack(m, "\\(lc", "\\(bv", "\\(bv"); break; case '{': printf("\\b'\\(lt"); for(j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(lk"); for(j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(lb'"); break; case '(': brack(m, "\\(lt", "\\(bv", "\\(lb"); break; case '[': brack(m, "\\(lc", "\\(bv", "\\(lf"); break; case '|': brack(m, "|", "|", "|"); break; default: brack(m, (char *) &leftc, (char *) &leftc, (char *) &leftc); break; } if (bv) printf("\\v'%gm'", -bv); if (v) printf("\\v'%gm'\\*(%d\\v'%gm'", -v, p1, v); else printf("\\*(%d", p1); if (rightc) { if (bv) printf("\\v'%gm'", bv); switch (rightc) { case 'f': /* floor */ if (n <= 1) printf("\\(rf"); else brack(m, "\\(bv", "\\(bv", "\\(rf"); break; case 'c': /* ceiling */ if (n <= 1) printf("\\(rc"); else brack(m, "\\(rc", "\\(bv", "\\(bv"); break; case '}': printf("\\b'\\(rt"); for(j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(rk"); for(j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(rb'"); break; case ']': brack(m, "\\(rc", "\\(bv", "\\(rf"); break; case ')': brack(m, "\\(rt", "\\(bv", "\\(rb"); break; case '|': brack(m, "|", "|", "|"); break; default: brack(m, (char *) &rightc, (char *) &rightc, (char *) &rightc); break; } if (bv) printf("\\v'%gm'", -bv); } printf("\n"); dprintf(".\tcurly: h=%g b=%g n=%d v=%g l=%c, r=%c\n", eht[yyval.token], ebase[yyval.token], n, v, leftc, rightc); }
void RCharCloth::OnInvalidate() { REL(gpClothVertexBuffer); }
////////////////////////////////////////////////////////////////////////// // render ////////////////////////////////////////////////////////////////////////// void RCharCloth::render() { // bHarewareBuffer = true; int i; LPDIRECT3DDEVICE9 dev = RGetDevice(); // Get Device Pointer UpdateNormal(); RMtrlMgr* pMtrlMgr = &mpMeshNode->m_pParentMesh->m_mtrl_list_ex; RMtrl* pMtrl = pMtrlMgr->Get_s(mpMeshNode->m_mtrl_id,-1); int num_mtrl = pMtrl->m_sub_mtrl_num; int point_index; // 현재 버텍스의 인덱스 for( i = 0 ; i < mpMeshNode->m_face_num ; ++i ) { for( int j = 0 ; j < 3; ++j ) { point_index = mpMeshNode->m_face_list[i].m_point_index[j]; gVertices[3*i+j].p = m_pX[point_index]; gVertices[3*i+j].tu = mpMeshNode->m_face_list[i].m_point_tex[j].x; gVertices[3*i+j].tv = mpMeshNode->m_face_list[i].m_point_tex[j].y; gVertices[3*i+j].n = m_pNormal[point_index]; } } if( bHarewareBuffer && gpClothVertexBuffer) { //// Copy Begin void *Buffer; if( FAILED( gpClothVertexBuffer->Lock( 0, sizeof(RVertex) * mpMeshNode->m_face_num * 3, (VOID**)&Buffer, D3DLOCK_DISCARD ))) { bHarewareBuffer = false; REL( gpClothVertexBuffer ); mlog("Fail to lock of Vertex Buffer\n"); goto e2SoftRender; } //memcpy( Buffer, gVertices, sizeof(RVertex) * m_nCntP ); memcpy( Buffer, gVertices, sizeof(RVertex) * mpMeshNode->m_face_num * 3 ); gpClothVertexBuffer->Unlock(); // Copy End } e2SoftRender: prerender(); if(mpMesh->m_pVisualMesh) mpMesh->m_pVisualMesh->UpdateLight(); rmatrix rtemp; dev->GetTransform( D3DTS_WORLD, &rtemp ); dev->SetTransform( D3DTS_WORLD , &( mLocalMat * mWorldMat ) ); mpMesh->SetCharacterMtrl_ON( pMtrl,mpMeshNode,1 ,mpMeshNode->GetTColor()); #ifdef USE_TOON_RENDER mpMeshNode->ToonRenderSettingOn(pMtrl); #endif if( bHarewareBuffer ) { dev->DrawPrimitive( D3DPT_TRIANGLELIST, 0, mpMeshNode->m_face_num ); } else { dev->DrawPrimitiveUP( D3DPT_TRIANGLELIST, mpMeshNode->m_face_num, gVertices, sizeof(RVertex)); } #ifdef USE_TOON_RENDER // if(Silhouette) { mpMeshNode->ToonRenderSilhouetteSettingOn(); if( bHarewareBuffer ) dev->DrawPrimitive( D3DPT_TRIANGLELIST, 0, mpMeshNode->m_face_num ); else dev->DrawPrimitiveUP( D3DPT_TRIANGLELIST, mpMeshNode->m_face_num, gVertices, sizeof(RVertex)); mpMeshNode->ToonRenderSilhouetteSettingOff(); } mpMeshNode->ToonRenderSettingOff(); #endif mpMesh->SetCharacterMtrl_OFF( pMtrl, 1 ); dev->SetTransform( D3DTS_WORLD, &rtemp ); postrender(); }
static int _compilecode(const char **re_loc, ByteProg *prog, int sizecode) { const char *re = *re_loc; char *code = sizecode ? NULL : prog->insts; int start = PC; int term = PC; int alt_label = 0; for (; *re && *re != ')'; re++) { switch (*re) { case '\\': { re++; if (!*re) goto syntax_error; // Trailing backslash char c = *re | 0x20; if (c == 'd' || c == 's' || c == 'w') { term = PC; EMIT(PC++, NamedClass); EMIT(PC++, *re); prog->len++; break; } if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')) { goto unsupported_escape; } } default: term = PC; EMIT(PC++, Char); EMIT(PC++, *re); prog->len++; break; case '.': term = PC; EMIT(PC++, Any); prog->len++; break; case '[': { int cnt; term = PC; re++; if (*re == '^') { EMIT(PC++, ClassNot); re++; } else { EMIT(PC++, Class); } PC++; // Skip "# of pairs" byte prog->len++; for (cnt = 0; *re != ']'; re++, cnt++) { if (!*re) goto syntax_error; if (*re == '\\') { re++; if (!*re) goto syntax_error; if (*re != '\\' && *re != ']') goto unsupported_escape; } EMIT(PC++, *re); if (re[1] == '-' && re[2] != ']') { re += 2; } EMIT(PC++, *re); } EMIT(term + 1, cnt); break; } case '(': { term = PC; int sub; int capture = 1; re++; if (*re == '?') { re++; if (*re == ':') { capture = 0; re++; } else { *re_loc = re; return RE1_5_UNSUPPORTED_SYNTAX; } } if (capture) { sub = ++prog->sub; EMIT(PC++, Save); EMIT(PC++, 2 * sub); prog->len++; } int res = _compilecode(&re, prog, sizecode); *re_loc = re; if (res < 0) return res; if (*re != ')') return RE1_5_SYNTAX_ERROR; if (capture) { EMIT(PC++, Save); EMIT(PC++, 2 * sub + 1); prog->len++; } break; } case '{': *re_loc = re; return RE1_5_UNSUPPORTED_SYNTAX; case '?': if (PC == term) goto syntax_error; // nothing to repeat INSERT_CODE(term, 2, PC); if (re[1] == '?') { EMIT(term, RSplit); re++; } else { EMIT(term, Split); } EMIT(term + 1, REL(term, PC)); prog->len++; term = PC; break; case '*': if (PC == term) goto syntax_error; // nothing to repeat INSERT_CODE(term, 2, PC); EMIT(PC, Jmp); EMIT(PC + 1, REL(PC, term)); PC += 2; if (re[1] == '?') { EMIT(term, RSplit); re++; } else { EMIT(term, Split); } EMIT(term + 1, REL(term, PC)); prog->len += 2; term = PC; break; case '+': if (PC == term) goto syntax_error; // nothing to repeat if (re[1] == '?') { EMIT(PC, Split); re++; } else { EMIT(PC, RSplit); } EMIT(PC + 1, REL(PC, term)); PC += 2; prog->len++; term = PC; break; case '|': if (alt_label) { EMIT(alt_label, REL(alt_label, PC) + 1); } INSERT_CODE(start, 2, PC); EMIT(PC++, Jmp); alt_label = PC++; EMIT(start, Split); EMIT(start + 1, REL(start, PC)); prog->len += 2; term = PC; break; case '^': EMIT(PC++, Bol); prog->len++; term = PC; break; case '$': EMIT(PC++, Eol); prog->len++; term = PC; break; } } if (alt_label) { EMIT(alt_label, REL(alt_label, PC) + 1); } *re_loc = re; return RE1_5_SUCCESS; syntax_error: *re_loc = re; return RE1_5_SYNTAX_ERROR; unsupported_escape: *re_loc = re; return RE1_5_UNSUPPORTED_ESCAPE; }
CBombBonus::~CBombBonus() { REL(m_piCamera); }
{ "CPY", 1, { IMD(0xc0), ZP(0xc4), ABS(0xcc), -1 } }, { "EOR", 1, { IMD(0x49), ZP(0x45), ZPX(0x55), ABS(0x4D), ABX(0x5d), ABY(0x59), INX(0x41), INY(0x51), -1 } }, { "LDA", 1, { IMD(0xa9), ZP(0xa5), ZPX(0xb5), ABS(0xaD), ABX(0xbd), ABY(0xb9), INX(0xa1), INY(0xb1), -1 } }, { "LDX", 1, { IMD(0xa2), ZP(0xa6), ZPY(0xB6), ABS(0xae), ABY(0xbe), -1 } }, { "LDY", 1, { IMD(0xa0), ZP(0xa4), ZPX(0xB4), ABS(0xac), ABX(0xbc), -1 } }, { "ORA", 1, { IMD(0x09), ZP(0x05), ZPX(0x15), ABS(0x0D), ABX(0x1d), ABY(0x19), INX(0x01), INY(0x11), -1 } }, { "SBC", 1, { IMD(0xEB), IMD(0xe9), ZP(0xe5), ZPX(0xf5), ABS(0xeD), ABX(0xfd), ABY(0xf9), INX(0xe1), INY(0xf1), -1 } }, { "STA", 2, { ZP(0x85), ZPX(0x95), ABS(0x8D), ABX(0x9d), ABY(0x99), INX(0x81), INY(0x91), -1 } }, { "STX", 2, { ZP(0x86), ZPY(0x96), ABS(0x8E), -1 } }, { "STY", 2, { ZP(0x84), ZPX(0x94), ABS(0x8C), -1 } }, { "BCC", 1, { REL(0x90), -1 } }, { "BCS", 1, { REL(0xb0), -1 } }, { "BEQ", 1, { REL(0xf0), -1 } }, { "BNE", 1, { REL(0xd0), -1 } }, { "BMI", 1, { REL(0x30), -1 } }, { "BPL", 1, { REL(0x10), -1 } }, { "BVC", 1, { REL(0x50), -1 } }, { "BVS", 1, { REL(0x70), -1 } }, }; uint16 FCEUI_Disassemble(void *XA, uint16 a, char *stringo) { X6502 *X = XA; uint8 buf; uint32 arg; int32 info; int x;
void CGameGUIList::OnDraw(IGenericRender *piRender) { CGameWindowBase::OnDraw(piRender); double dFontSize=0,dFontPixelWidth=0; IGenericFont *piFont=NULL; GetFont(&piFont,&dFontSize); if(!piFont){return;} piFont->CalcTextSize(dFontSize,"A",&dFontPixelWidth,&m_dFontPixelHeight); double y=m_rRealRect.h; m_nVisibleCount=(int)(m_dFontPixelHeight?m_rRealRect.h/m_dFontPixelHeight:0); double dElementWidth=m_rRealRect.w; if(m_nVisibleCount<(int)m_vElements.size()) { dElementWidth=m_rRealRect.w-m_dScrollBarWidth; piRender->PushState(); piRender->ActivateBlending(); m_dThumbPixelsPerLine=m_vElements.size()?((m_rRealRect.h-m_dScrollBarWidth*2-2*2)/((double)m_vElements.size())):m_rRealRect.h-m_dScrollBarWidth*2-2*2; double dThumbSize=((double)m_nVisibleCount)*m_dThumbPixelsPerLine; m_rScrollUp.x=dElementWidth; m_rScrollUp.y=m_rRealRect.h-m_dScrollBarWidth; m_rScrollUp.w=m_dScrollBarWidth; m_rScrollUp.h=m_dScrollBarWidth; m_rScrollDown.x=dElementWidth; m_rScrollDown.y=0; m_rScrollDown.w=m_dScrollBarWidth; m_rScrollDown.h=m_dScrollBarWidth; m_rScroll.x=dElementWidth; m_rScroll.y=m_dScrollBarWidth; m_rScroll.w=m_dScrollBarWidth; m_rScroll.h=m_rRealRect.h-m_dScrollBarWidth*2.0; m_rScrollThumb.x=dElementWidth+2; m_rScrollThumb.y=(m_rRealRect.h-m_dScrollBarWidth)-dThumbSize-((double)m_nFirstVisible)*m_dThumbPixelsPerLine-2; m_rScrollThumb.w=m_dScrollBarWidth-2*2; m_rScrollThumb.h=dThumbSize; // Boton superior piRender->SetColor(m_vScrollButtonColor,1); piRender->RenderRect(m_rScrollUp.x,m_rScrollUp.y,m_rScrollUp.w,m_rScrollUp.h); // ScrollBar piRender->SetColor(m_vScrollBkColor,m_dBackgroundAlpha); piRender->RenderRect(m_rScroll.x,m_rScroll.y,m_rScroll.w,m_rScroll.h); // Thumb piRender->SetColor(m_vScrollButtonColor,1); piRender->RenderRect(m_rScrollThumb.x,m_rScrollThumb.y,m_rScrollThumb.w,m_rScrollThumb.h); // Boton inferior piRender->SetColor(m_vScrollButtonColor,1); piRender->RenderRect(m_rScrollDown.x,m_rScrollDown.y,m_rScrollDown.w,m_rScrollDown.h); piRender->PopState(); } for(int x=m_nFirstVisible;x<(m_nFirstVisible+m_nVisibleCount+1) && x<(int)m_vElements.size();x++) { y-=m_dFontPixelHeight; if(m_nSelectedElement==(int)x) { piRender->SetColor(m_vSelectedBackgroundColor,m_dTextAlpha); piRender->RenderRect(0,y,dElementWidth,m_dFontPixelHeight); piRender->SetColor(m_vSelectedTextColor,m_dTextAlpha); } else { piRender->SetColor(m_vTextColor,m_dTextAlpha); } piFont->RenderTextEx(piRender,dFontSize,1,y,dElementWidth,m_dFontPixelHeight,m_vElements[x].c_str(),eTextAlignment_Left,eTextAlignment_Center); } REL(piFont); }
const char *_compilecode(const char *re, ByteProg *prog) { char *code = prog->insts; int pc = prog->bytelen; int start = pc; int term = pc; int alt_label = 0; for (; *re && *re != ')'; re++) { switch (*re) { case '\\': re++; default: term = pc; EMIT(pc++, Char); EMIT(pc++, *re); prog->len++; break; case '.': term = pc; EMIT(pc++, Any); prog->len++; break; case '[': { int cnt; term = pc; EMIT(pc++, Class); pc++; // Skip # of pair byte prog->len++; re++; for (cnt = 0; *re != ']'; re++, cnt++) { if (!*re) return NULL; EMIT(pc++, *re); if (re[1] == '-') { re += 2; } EMIT(pc++, *re); } EMIT(term + 1, cnt); break; } case '(': term = pc; EMIT(pc++, Save); EMIT(pc++, 2 * ++prog->sub); prog->len++; prog->bytelen = pc; re = _compilecode(re + 1, prog); pc = prog->bytelen; EMIT(pc++, Save); EMIT(pc++, 2 * prog->sub + 1); prog->len++; break; case '?': insert_code(code, term, 2, &pc); EMIT(term, Split); EMIT(term + 1, REL(term, pc)); prog->len++; break; case '*': insert_code(code, term, 2, &pc); EMIT(pc, Jmp); EMIT(pc + 1, REL(pc, term)); pc += 2; if (re[1] == '?') { EMIT(term, RSplit); re++; } else { EMIT(term, Split); } EMIT(term + 1, REL(term, pc)); prog->len += 2; break; case '+': if (re[1] == '?') { EMIT(pc, Split); re++; } else { EMIT(pc, RSplit); } EMIT(pc + 1, REL(pc, term)); pc += 2; prog->len++; break; case '|': if (alt_label) { EMIT(alt_label, REL(alt_label, pc) + 1); } insert_code(code, start, 2, &pc); EMIT(pc++, Jmp); alt_label = pc++; EMIT(start, Split); EMIT(start + 1, REL(start, pc)); prog->len += 2; break; case '^': EMIT(pc++, Bol); prog->len++; break; case '$': EMIT(pc++, Eol); prog->len++; break; } } if (alt_label) { EMIT(alt_label, REL(alt_label, pc) + 1); } prog->bytelen = pc; return re; }