void SetArilouPilot(pPlayer pl) { //setup pilot int off=(pl->plr==1)?0:6; sprites[43+off].attribute0 = COLOR_256 | TALL | 160; sprites[43+off].attribute1 =SIZE_32 | 240; sprites[43+off].attribute2 = pl->SpriteStart+pl->pilot_sprite+64 | PRIORITY(2); sprites[44+off].attribute0 = COLOR_256 | TALL | 160; sprites[44+off].attribute1 =SIZE_32 | 240; sprites[44+off].attribute2 = pl->SpriteStart+pl->pilot_sprite+80 | PRIORITY(2); sprites[45+off].attribute0 = COLOR_256 | SQUARE | 160; sprites[45+off].attribute1 =SIZE_16 | 240; sprites[45+off].attribute2 = pl->SpriteStart+pl->pilot_sprite+96 | PRIORITY(1); sprites[46+off].attribute0 = COLOR_256 |TALL | 160; sprites[46+off].attribute1 =SIZE_32 | 240; sprites[46+off].attribute2 = pl->SpriteStart+pl->pilot_sprite+104 | PRIORITY(1); sprites[47+off].attribute0 = COLOR_256 | TALL | 160; sprites[47+off].attribute1 =SIZE_32 | 240; sprites[47+off].attribute2 = pl->SpriteStart+pl->pilot_sprite+120 | PRIORITY(2); }
void bakery_lock_get(unsigned int id, unsigned int offset) { unsigned int they, me, is_cached; unsigned int my_ticket, my_prio, their_ticket; bakery_info_t *their_bakery_info; unsigned int their_bakery_data; me = plat_my_core_pos(); is_cached = read_sctlr_el3() & SCTLR_C_BIT; /* Get a ticket */ my_ticket = bakery_get_ticket(id, offset, me, is_cached); /* * Now that we got our ticket, compute our priority value, then compare * with that of others, and proceed to acquire the lock */ my_prio = PRIORITY(my_ticket, me); for (they = 0; they < BAKERY_LOCK_MAX_CPUS; they++) { if (me == they) continue; /* * Get a reference to the other contender's bakery info and * ensure that a stale copy is not read. */ their_bakery_info = get_bakery_info_by_index(offset, id, they); assert(their_bakery_info); /* Wait for the contender to get their ticket */ do { read_cache_op(their_bakery_info, is_cached); their_bakery_data = their_bakery_info->lock_data; } while (bakery_is_choosing(their_bakery_data)); /* * If the other party is a contender, they'll have non-zero * (valid) ticket value. If they do, compare priorities */ their_ticket = bakery_ticket_number(their_bakery_data); if (their_ticket && (PRIORITY(their_ticket, they) < my_prio)) { /* * They have higher priority (lower value). Wait for * their ticket value to change (either release the lock * to have it dropped to 0; or drop and probably content * again for the same lock to have an even higher value) */ do { wfe(); read_cache_op(their_bakery_info, is_cached); } while (their_ticket == bakery_ticket_number(their_bakery_info->lock_data)); } } /* Lock acquired */ }
/* * Acquire bakery lock * * Contending CPUs need first obtain a non-zero ticket and then calculate * priority value. A contending CPU iterate over all other CPUs in the platform, * which may be contending for the same lock, in the order of their ordinal * position (CPU0, CPU1 and so on). A non-contending CPU will have its ticket * (and priority) value as 0. The contending CPU compares its priority with that * of others'. The CPU with the highest priority (lowest numerical value) * acquires the lock */ void bakery_lock_get(unsigned long mpidr, bakery_lock_t *bakery) { unsigned int they, me; unsigned int my_ticket, my_prio, their_ticket; me = platform_get_core_pos(mpidr); assert_bakery_entry_valid(me, bakery); /* Prevent recursive acquisition */ assert(bakery->owner != me); /* Get a ticket */ my_ticket = bakery_get_ticket(bakery, me); /* * Now that we got our ticket, compute our priority value, then compare * with that of others, and proceed to acquire the lock */ my_prio = PRIORITY(my_ticket, me); for (they = 0; they < BAKERY_LOCK_MAX_CPUS; they++) { if (me == they) continue; /* Wait for the contender to get their ticket */ while (bakery->entering[they]) wfe(); /* * If the other party is a contender, they'll have non-zero * (valid) ticket value. If they do, compare priorities */ their_ticket = bakery->number[they]; if (their_ticket && (PRIORITY(their_ticket, they) < my_prio)) { /* * They have higher priority (lower value). Wait for * their ticket value to change (either release the lock * to have it dropped to 0; or drop and probably content * again for the same lock to have an even higher value) */ do { wfe(); } while (their_ticket == bakery->number[they]); } } /* Lock acquired */ bakery->owner = me; }
short PEXPORT Kpp__SetupRule(LPRULE lpRule, LISTID idVarList, LISTID idClassList, EXPID idIfPart, EXPID idThenPart) { #ifdef INFERENCE PRIORITY(lpRule) = 0; MATCHES(lpRule) = NULLID; NUMVARS(lpRule) = KppListLen(idVarList); BODY(lpRule) = JoinIfThen(idIfPart, idThenPart); if (idIfPart) KppDeleteExp(idIfPart); if (idThenPart) KppDeleteExp(idThenPart); if (NUMVARS(lpRule) == 0) VARS(lpRule) = KppMakeList(0); else { VARS(lpRule) = MakeRuleArgList(idVarList, idClassList); if (idVarList) KppDeleteList(idVarList); if (idClassList) KppDeleteList(idClassList); idVarList = VARS(lpRule); KppClearVarList(idVarList); KppBindVars(idVarList, BODY(lpRule)); } #endif return TRUE; }
static HRESULT WINAPI HttpProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv) { HttpProtocol *This = PROTOCOL_THIS(iface); *ppv = NULL; if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); *ppv = PROTOCOL(This); }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) { TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv); *ppv = PROTOCOL(This); }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) { TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv); *ppv = PROTOCOL(This); }else if(IsEqualGUID(&IID_IInternetPriority, riid)) { TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv); *ppv = PRIORITY(This); }else if(IsEqualGUID(&IID_IWinInetInfo, riid)) { TRACE("(%p)->(IID_IWinInetInfo %p)\n", This, ppv); *ppv = INETHTTPINFO(This); }else if(IsEqualGUID(&IID_IWinInetHttpInfo, riid)) { TRACE("(%p)->(IID_IWinInetHttpInfo %p)\n", This, ppv); *ppv = INETHTTPINFO(This); } if(*ppv) { IInternetProtocol_AddRef(iface); return S_OK; } WARN("not supported interface %s\n", debugstr_guid(riid)); return E_NOINTERFACE; }
static int ism_interface_up (struct ospf_interface *oi) { int next_state = 0; /* if network type is point-to-point, Point-to-MultiPoint or virtual link, the state transitions to Point-to-Point. */ if (oi->type == OSPF_IFTYPE_POINTOPOINT || oi->type == OSPF_IFTYPE_POINTOMULTIPOINT || oi->type == OSPF_IFTYPE_VIRTUALLINK) next_state = ISM_PointToPoint; /* Else if the router is not eligible to DR, the state transitions to DROther. */ else if (PRIORITY (oi) == 0) /* router is eligible? */ next_state = ISM_DROther; else /* Otherwise, the state transitions to Waiting. */ next_state = ISM_Waiting; if (oi->type == OSPF_IFTYPE_NBMA) ospf_nbr_nbma_if_update (oi->ospf, oi); /* ospf_ism_event (t); */ return next_state; }
RULEID __CopyRule(LPRULE lpOldRule, ITEMID idName) { #ifdef INFERENCE RULEID idRule; LPRULE lpRule; LPEXP lpBody; EXPID idBody; if (GetRule(idName) != NULLID) return NULLID; idRule = KppAddItemAndName (RULE, (LPLPSTR)&lpRule, idName); if (!idRule) return NULLID; NAME(lpRule) = idName; FLAGS(lpRule) = NULL; PRIORITY(lpRule) = 0; MATCHES(lpRule) = NULLID; NUMVARS(lpRule) = NUMVARS(lpOldRule); if (! (FLAGS(lpRule) & CBODY)) { VARS(lpRule) = KppDeepListCopy(VARS(lpOldRule), Kpp__CopyVar,idRule); idBody = BODY(lpRule) = KppCopyExp( BODY(lpOldRule), (LPLPSTR)&lpBody, kPERMMODE); KppReleaseExp(idBody); } KppReleaseItem(RULE, idRule); /* Add to KnowledgeTools */ KppAddItemCB (RULE, 1); return idRule; #endif }
/**************************************************************** ** C GOAL function *****************************************************************/ BOOL PEXPORT KppMakeCGoal(ATOMID idName, LOGICALID (PEXPORT *pGoal)(void)) { BOOL bExists = FALSE; GOALID idGoal = NULLID; LPGOAL lpGoal; #ifdef INFERENCE if (!KppIsGoodAtom(idName)) return FALSE; idGoal = KppGetItemFromName(GOAL, idName, (LPLPSTR) &lpGoal); if (idGoal) bExists = TRUE; else if (!(idGoal = KppAddItemAndName(GOAL, (LPLPSTR) &lpGoal, idName))) return FALSE; NAME(lpGoal) = idName; FLAGS(lpGoal) = CBODY; PRIORITY(lpGoal) = 0; CBODYPTR(lpGoal) = pGoal; KppReleaseItem(GOAL, idGoal); /* Add to KnowledgeTools */ if (!bExists) KppAddItemCB(GOAL, 1); #endif return idGoal; }
BOOL PEXPORT KppMakeCRule(ATOMID idName, ATOMID (PEXPORT *pIfPart)(), void (PEXPORT *pThenPart)(), short sPrio) { #ifdef INFERENCE BOOL bExists = FALSE; RULEID idRule; LPRULE lpRule; if (!KppIsGoodAtom(idName)) return FALSE; idRule = KppGetItemFromName(RULE, idName, (LPLPSTR) &lpRule); if (idRule) bExists = TRUE; else if (!(idRule = KppAddItemAndName(RULE, (LPLPSTR) &lpRule, idName))) return FALSE; NAME(lpRule) = idName; FLAGS(lpRule) = CBODY; PRIORITY(lpRule) = sPrio; CIFPTR(lpRule) = pIfPart; CTHENPTR(lpRule) = (ATOMID (PEXPORT *)()) pThenPart; CIFPAIRS(lpRule) = NULLID; CTHENPAIRS(lpRule) = NULLID; KppReleaseItem(RULE, idRule); /* Add to KnowledgeTools */ if (!bExists) KppAddItemCB(RULE, 1); KppChangeRuleCB(); return TRUE; #endif }
int SpecialSyreen(pPlayer pl) { s16 b; s16 angle; pPlayer opp=(pPlayer)pl->opp; int ret=0; s32 dist=distanceBetweenPoints(pl->object.xpos,pl->object.ypos,opp->object.xpos, opp->object.ypos); if (dist<208&&(!(opp->ship_flags & CREW_IMMUNE))) { s8 crew_loss; crew_loss = ((8 * (208 - dist)/ 209)); if (crew_loss >= opp->crew) crew_loss = opp->crew - 1; for (int i=0;i<crew_loss&&opp->crew-ret>1;i++) { b=nextWeapon(pl,4,12); if (b>0) { pl->weapon[b].type=CREW; pl->weapon[b].object.life=1; pl->weapon[b].status=200;//GUESS pl->weapon[b].damage=0; pl->weapon[b].target=pl->opp; pl->weapon[b].parent=pl; pl->weapon[b].damageparent=1; pl->weapon[b].movefunc=&MoveCrew; pl->weapon[b].hitfunc=&HitCrew; pl->weapon[b].object.ignorecollision=0; pl->weapon[b].object.size=8; pl->weapon[b].object.angle = 0; pl->weapon[b].object.xspeed=0; pl->weapon[b].object.yspeed=0; pl->weapon[b].turn_wait=CREW_WAIT; angle=FindAngle(opp->object.xpos,opp->object.ypos,pl->object.xpos,pl->object.ypos); angle=ModifyAngle(angle,((i*2)-crew_loss)*20); pl->weapon[b].object.xpos = opp->object.xpos+((s32)(opp->offset*3 * SIN[angle])>>8); pl->weapon[b].object.ypos = opp->object.ypos-((s32)(opp->offset*3 * COS[angle])>>8); drawOnScreen(&pl->weapon[b].object.xscreen,&pl->weapon[b].object.yscreen, pl->weapon[b].object.xpos,pl->weapon[b].object.ypos,screenx,screeny,pl->weapon[b].object.size); sprites[pl->weapon[b].sprite].attribute0 = COLOR_256 | SQUARE | ROTATION_FLAG |SIZE_DOUBLE | MODE_TRANSPARENT | pl->weapon[b].object.yscreen; //setup sprite info, 256 colour, shape and y-coord sprites[pl->weapon[b].sprite].attribute1 =SIZE_8 | ROTDATA(pl->weapon[b].sprite) | pl->weapon[b].object.xscreen; sprites[pl->weapon[b].sprite].attribute2 = pl->SpriteStart+66 | PRIORITY(1); ret++; } } //loop
GOALID PEXPORT Kpp_MakeGoal(ITEMID idName, EXPID idBody) { #ifdef INFERENCE GOALID idGoal; LPGOAL lpGoal; if (!KppIsGoodAtom(idName)) return NULLID; idGoal = Kpp_GetItem(GOAL, idName); if (idGoal) { int over = KppAllowOverrideCB(GOAL, idName, idGoal, NULLID); if (!over) return KppRegisterKappaMessage(hResThisDll, IDE_ITEMALREADYEXISTS, idName, NULLID, NULLID); else if (over == -1) { bItemSkipped = TRUE; return idGoal; } } CHECK_MAX_LIMITED_VER(GOAL, idName); idGoal = KppAddItemAndName (GOAL, (LPLPSTR)&lpGoal, idName); if (!idGoal) return NULLID; NAME(lpGoal) = idName; FLAGS(lpGoal) = NULL; PRIORITY(lpGoal) = 0; if (!idBody) idBody = KppBuildNullExp(); else KppResetBoundFlag(idBody); BODY(lpGoal) = idBody; KppReleaseItem(GOAL, idGoal); /* Add to KnowledgeTools */ KppAddItemCB (GOAL, 1); return idGoal; #endif }
BOOL PEXPORT Kpp_SetRulePriority(RULEID idRule, short sPrio) { #ifdef INFERENCE LPRULE lpRule; if ((lpRule = (LPRULE) KppGetItem(RULE, idRule)) == NULL) return FALSE; if (FLAGS (lpRule) & ITEMOPEN) { KppReleaseItem(RULE, idRule); return KppRegisterKappaMessage (hResThisDll, IDE_BEINGEDITED, lpIDs->idError, NAME(lpRule), NULLID); } PRIORITY(lpRule) = sPrio; KppReleaseItem(RULE, idRule); #endif return TRUE; }
int FireArilou(pPlayer pl) { pPlayer opp=(pPlayer)pl->opp; play_sfx(&arilou_fire,pl->plr-1); for (int b=0;b<4;b++) { pl->weapon[b].type=LASER; pl->weapon[b].object.life=2; pl->weapon[b].damage=-1; pl->weapon[b].target=pl->opp; pl->weapon[b].parent=pl; pl->weapon[b].damageparent=0; pl->weapon[b].movefunc=0; pl->weapon[b].hitfunc=0; pl->weapon[b].object.ignorecollision=0; pl->weapon[b].object.size=32;//(b==3?8:32); pl->weapon[b].object.angle = FindAngle(pl->object.xpos,pl->object.ypos,opp->object.xpos,opp->object.ypos); s32 off=(b==0?13:13+(b*32)); pl->weapon[b].object.xspeed=0; pl->weapon[b].object.yspeed=0; pl->weapon[b].object.xpos = pl->object.xpos+((off * (s32)SIN[pl->weapon[b].object.angle])>>8); pl->weapon[b].object.ypos = pl->object.ypos-((off * (s32)COS[pl->weapon[b].object.angle])>>8); drawOnScreen(&pl->weapon[b].object.xscreen,&pl->weapon[b].object.yscreen, pl->weapon[b].object.xpos,pl->weapon[b].object.ypos,screenx,screeny,pl->weapon[b].object.size); sprites[pl->weapon[b].sprite].attribute0 = COLOR_256 | SQUARE | ROTATION_FLAG |SIZE_DOUBLE | MODE_TRANSPARENT | pl->weapon[b].object.yscreen; //setup sprite info, 256 colour, shape and y-coord sprites[pl->weapon[b].sprite].attribute1 =SIZE_32 | ROTDATA(pl->weapon[b].sprite) | pl->weapon[b].object.xscreen; sprites[pl->weapon[b].sprite].attribute2 = pl->SpriteStart+64 | PRIORITY(1); } return 1; }
static HRESULT WINAPI BindProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv) { BindProtocol *This = PROTOCOL_THIS(iface); *ppv = NULL; if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); *ppv = PROTOCOL(This); }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) { TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv); *ppv = PROTOCOL(This); }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) { TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv); *ppv = PROTOCOL(This); }else if(IsEqualGUID(&IID_IInternetBindInfo, riid)) { TRACE("(%p)->(IID_IInternetBindInfo %p)\n", This, ppv); *ppv = BINDINFO(This); }else if(IsEqualGUID(&IID_IInternetPriority, riid)) { TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv); *ppv = PRIORITY(This); }else if(IsEqualGUID(&IID_IAuthenticate, riid)) { FIXME("(%p)->(IID_IAuthenticate %p)\n", This, ppv); }else if(IsEqualGUID(&IID_IServiceProvider, riid)) { TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv); *ppv = SERVPROV(This); }else if(IsEqualGUID(&IID_IInternetProtocolSink, riid)) { TRACE("(%p)->(IID_IInternetProtocolSink %p)\n", This, ppv); *ppv = PROTSINK(This); } if(*ppv) { IInternetProtocol_AddRef(iface); return S_OK; } WARN("not supported interface %s\n", debugstr_guid(riid)); return E_NOINTERFACE; }
GOALID __CopyGoal(LPGOAL lpOldGoal, ITEMID idName) { #ifdef INFERENCE GOALID idGoal; LPGOAL lpGoal; LPEXP lpBody; EXPID idBody; if (GetGoal(idName) != NULLID) return NULLID; idGoal = KppAddItemAndName(GOAL, (LPLPSTR)&lpGoal, idName); if (!idGoal) return NULLID; NAME(lpGoal) = idName; FLAGS(lpGoal) = NULL; PRIORITY(lpGoal) = 0; if (! (FLAGS(lpGoal) & CBODY)) { if (BODY(lpGoal) == NULLID) idBody = NULLID; else { idBody = BODY(lpGoal) = KppCopyExp(BODY(lpOldGoal), (LPLPSTR)&lpBody, kPERMMODE); KppReleaseExp(idBody); } } KppReleaseItem(GOAL, idGoal); /* Add to KnowledgeTools */ KppAddItemCB(GOAL, 1); return idGoal; #endif }
static HRESULT WINAPI BindProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv) { BindProtocol *This = PROTOCOL_THIS(iface); *ppv = NULL; if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); *ppv = PROTOCOL(This); }else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) { TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv); *ppv = PROTOCOL(This); }else if(IsEqualGUID(&IID_IInternetProtocol, riid)) { TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv); *ppv = PROTOCOL(This); }else if(IsEqualGUID(&IID_IInternetBindInfo, riid)) { TRACE("(%p)->(IID_IInternetBindInfo %p)\n", This, ppv); *ppv = BINDINFO(This); }else if(IsEqualGUID(&IID_IInternetPriority, riid)) { TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv); *ppv = PRIORITY(This); }else if(IsEqualGUID(&IID_IAuthenticate, riid)) { FIXME("(%p)->(IID_IAuthenticate %p)\n", This, ppv); }else if(IsEqualGUID(&IID_IServiceProvider, riid)) { TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv); *ppv = SERVPROV(This); }else if(IsEqualGUID(&IID_IInternetProtocolSink, riid)) { TRACE("(%p)->(IID_IInternetProtocolSink %p)\n", This, ppv); *ppv = PROTSINK(This); }else if(IsEqualGUID(&IID_IWinInetInfo, riid)) { TRACE("(%p)->(IID_IWinInetInfo %p)\n", This, ppv); if(This->protocol) { IWinInetInfo *inet_info; HRESULT hres; hres = IInternetProtocol_QueryInterface(This->protocol, &IID_IWinInetInfo, (void**)&inet_info); if(SUCCEEDED(hres)) { *ppv = HTTPINFO(This); IWinInetInfo_Release(inet_info); } } }else if(IsEqualGUID(&IID_IWinInetHttpInfo, riid)) { TRACE("(%p)->(IID_IWinInetHttpInfo %p)\n", This, ppv); if(This->protocol) { IWinInetHttpInfo *http_info; HRESULT hres; hres = IInternetProtocol_QueryInterface(This->protocol, &IID_IWinInetHttpInfo, (void**)&http_info); if(SUCCEEDED(hres)) { *ppv = HTTPINFO(This); IWinInetHttpInfo_Release(http_info); } } }else { WARN("not supported interface %s\n", debugstr_guid(riid)); } if(!*ppv) return E_NOINTERFACE; IUnknown_AddRef((IUnknown*)*ppv); return S_OK; }
int FireUtwig(pPlayer pl) { s16 b; int ret=0; for (int i=0;i<6;i++) { b= nextWeapon(pl); if (b>=0) { pl->weapon[b].type=SIMPLE; pl->weapon[b].object.life=MISSILE_LIFE;//range pl->weapon[b].damage=-1*MISSILE_DAMAGE;//6 suspect 6 was for both guns; pl->weapon[b].target=pl->opp; pl->weapon[b].parent=pl; pl->weapon[b].damageparent=0; pl->weapon[b].movefunc=0; pl->weapon[b].hitfunc=0; pl->weapon[b].object.ignorecollision=0; pl->weapon[b].object.size=8; pl->weapon[b].object.angle = pl->object.angle; s32 speed=20; pl->weapon[b].object.xspeed = ((MISSILE_SPEED * (s32)SIN[pl->object.angle])>>8);///SPEED_REDUCT; pl->weapon[b].object.yspeed = ((MISSILE_SPEED * (s32)COS[pl->object.angle])>>8);///SPEED_REDUCT; //pl->weapon[b].object.xpos = pl->object.xpos+((52 * (s32)SIN[pl->object.angle+(i==0?-30:+30)])>>8)/3; //pl->weapon[b].object.ypos = pl->object.ypos-((52 * (s32)COS[pl->object.angle+(i==0?-30:+30)])>>8)/3; s16 angle; if (i==0) angle=ModifyAngle(pl->object.angle,-55); else if (i==1) angle=ModifyAngle(pl->object.angle,-35); else if (i==2) angle=ModifyAngle(pl->object.angle,-10); else if (i==3) angle=ModifyAngle(pl->object.angle,15); else if (i==4) angle=ModifyAngle(pl->object.angle,45); else if (i==5) angle=ModifyAngle(pl->object.angle,65); pl->weapon[b].object.xpos = pl->object.xpos+((52 * (s32)SIN[angle])>>8)/3; pl->weapon[b].object.ypos = pl->object.ypos-((52 * (s32)COS[angle])>>8)/3; #ifdef MISSILE_START pl->weapon[b].object.xpos-=pl->weapon[b].object.xspeed; pl->weapon[b].object.ypos+=pl->weapon[b].object.yspeed; #endif drawOnScreen(&pl->weapon[b].object.xscreen,&pl->weapon[b].object.yscreen, pl->weapon[b].object.xpos,pl->weapon[b].object.ypos,screenx,screeny,pl->weapon[b].object.size); sprites[pl->weapon[b].sprite].attribute0 = COLOR_256 | SQUARE | ROTATION_FLAG |SIZE_DOUBLE | MODE_TRANSPARENT | pl->weapon[b].object.yscreen; //setup sprite info, 256 colour, shape and y-coord sprites[pl->weapon[b].sprite].attribute1 =SIZE_8| ROTDATA(pl->weapon[b].sprite) | pl->weapon[b].object.xscreen; sprites[pl->weapon[b].sprite].attribute2 = pl->SpriteStart+64 | PRIORITY(1); ret++; } }
int main(){ struct Handler *handler_p, *next_handler; unsigned hid; unsigned oep; // This is NOT THE PROPER WAY!!! unsigned siginfo[512]; unsigned baseaddr, memsize; enum __ptrace_request pr, pr2; //struct user_regs_struct regs; //char inst_str[128]; // Test const char *prog = "./try"; //char indirect = 0; //char manual = 0; //char plt = 1; //int pop = 0; //ban = 0x0804841b; int wait_status; struct user_regs_struct regs; init(); pid_t pid = fork(); if (pid == 0){ Ptrace(PTRACE_TRACEME, 0, NULL, NULL); execl(prog, prog, NULL); }else if (pid > 0){ oep = get_entry_point(prog); // On loaded wait(&wait_status); if (WIFSTOPPED(wait_status)){ // Test, wrong memsize = get_memsize(prog); baseaddr = get_baseaddr(prog); add_module(&whitelist, baseaddr, memsize); get_handler(pid, oep, get_trace_option(fopen("/tmp/trace","w"), whitelist)); get_handler(pid, 0x8048380, get_disable_option(API_TYPE_PLT)); Ptrace(PTRACE_CONT, pid, NULL, NULL); } wait(&wait_status); // Withdraw control from plugins while (WIFSTOPPED(wait_status)){ Ptrace(PTRACE_GETSIGINFO, pid, NULL, &siginfo); // Caused by breakpoint if (siginfo[2] == 0x80){ // Discard the 0xcc int 3 instruction // So move the eip upper by 1 Ptrace(PTRACE_GETREGS, pid, NULL, ®s); regs.eip --; Ptrace(PTRACE_SETREGS, pid ,NULL, ®s); } // PTRACE_CONT by default because it has the lowest priority pr = PTRACE_CONT; hid = GETID(regs.eip); for (handler_p=global_handler;handler_p;handler_p=next_handler){ next_handler = handler_p->next_handler; pr2 = dispatch(pid, handler_p); pr = PRIORITY(pr, pr2); pr2 = global_expire(pid, handler_p, &next_handler); pr = PRIORITY(pr, pr2); } for (handler_p=handlers[hid];handler_p;handler_p=next_handler){ next_handler = handler_p->next_handler; pr2 = dispatch(pid, handler_p); pr = PRIORITY(pr, pr2); pr2 = expire(pid, handler_p, hid, &next_handler); pr = PRIORITY(pr, pr2); } Ptrace(pr, pid, NULL, NULL); wait(&wait_status); } }else{ perror("Folk failed: "); exit(-1); } finalize(); return 0; }