static word LookUp( word sdtseg, word seg, word global ) { dword sdtoff; dword sdtlim; dword linear; word otherseg; sdtlim = SegLimit( sdtseg ); linear = GetLinear( seg, 0 ); for( sdtoff = 0; sdtoff < sdtlim; sdtoff += 8 ) { if( sdtoff == ( seg & 0xfff8 ) ) continue; otherseg = sdtoff + ( global ? 0 : 4 ); if( !WriteOk( otherseg ) ) continue; if( GetLinear( otherseg, 0 ) != linear ) continue; _DBG3(("lookup %4.4x", otherseg)); return( otherseg ); } return( 0 ); }
int CValueCurveDef::GetChancePercent( int iSkillPercent ) const { ADDTOCALLSTACK("CValueCurveDef::GetChancePercent"); // ARGS: // iSkillPercent = 0 - 1000 = 0 to 100.0 percent // // m_Rate[3] = the 3 advance rate control numbers, 0,50,100 skill levels // (How many uses for a gain of .1 (div by 100)) // RETURN: // percent chance of success * 10 = 0 - 1000. // How many uses for a gain of .1 (div by 100) int iChance = GetLinear( iSkillPercent ); if ( iChance <= 0 ) return 0; // less than no chance ? // Express uses as a percentage * 10. return( 100000 / iChance ); }
trap_retval ReqSet_watch( void ) { watch *curr; set_watch_req *acc; set_watch_ret *ret; int i,needed; _DBG0(( "AccSetWatch" )); acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); ret->multiplier = 20000; ret->err = 1; if( WatchCount < MAX_WP ) { ret->err = 0; curr = WatchPoints + WatchCount; curr->addr = acc->watch_addr; ReadMemory( &acc->watch_addr, (byte *)&curr->value, 4 ); ++WatchCount; curr->linear = GetLinear( curr->addr.segment, curr->addr.offset ); curr->len = acc->size; curr->dregs = ( curr->linear & (curr->len-1) ) ? 2 : 1; curr->linear &= ~(curr->len-1); needed = 0; for( i = 0; i < WatchCount; ++i ) { needed += WatchPoints[ i ].dregs; } if( needed <= 4 ) ret->multiplier |= USING_DEBUG_REG; _DBG0(( "addr %4.4x:%8.8lx " "linear %8.8x " "len %d " "needed %d " ,curr->addr.segment,curr->addr.offset ,curr->linear ,curr->len ,needed )); } return( sizeof( *ret ) ); }
int CValueRangeDef::GetRandomLinear( int iPercent ) const { ADDTOCALLSTACK("CValueRangeDef::GetRandomLinear"); return( ( GetRandom() + GetLinear(iPercent) ) / 2 ); }
int CValueCurveDef::GetRandomLinear( int iSkillPercent ) const { ADDTOCALLSTACK("CValueCurveDef::GetRandomLinear"); return ( GetLinear( iSkillPercent ) + GetRandom() ) / 2; }
int CValueCurveDef::GetRandom( ) const { ADDTOCALLSTACK("CValueCurveDef::GetRandom"); return GetLinear( Calc_GetRandVal( 1000 ) ); }