コード例 #1
0
ファイル: cpurec.cpp プロジェクト: V10lator/emumaster
/*!
	Initializes translator.
 */
bool NesCpuTranslator::init()
{
	m_labels = recLabels;
	memMapping = new AnonymousMemMapping(BufferSize);
	if (!memMapping->address())
		return false;
	m_codeBuffer = (u8 *)memMapping->address();
	m_masm = new MacroAssembler(m_codeBuffer, BufferSize);

	m_checkAlertAfterInstruction = false;

	// compile some needed stubs
	mEntryPoint();
	mTranslateCaller();
	mSync();
	mAlertHandler();
#if defined(ENABLE_DEBUGGING)
	mDebugStep();
#endif

	// mark pages "used before" here to force page clearing
	m_pageUsedMask = (1<<NesNumOfCpuPages)-1;
	for (int i = 0; i < NesNumOfCpuPages; i++)
		clearPage(i);

	m_lastRecompilationInRam = 0;
	return true;
}
コード例 #2
0
ファイル: MUIFloatInt.c プロジェクト: AlphaPixel/3DNature
SAVEDS ULONG mSet(struct IClass *cl,Object *obj,struct opSet *msg)
{
struct FloatIntData *data = INST_DATA(cl,obj);
struct TagItem *tags,*tag;
ULONG Temp;
signed long int Limit;
double *D;

for (tags=msg->ops_AttrList;tag=NextTagItem(&tags);)
	{
	switch (tag->ti_Tag)
		{
		case MUIA_FloatInt_IncDecInt:
			{
			Temp = tag->ti_Data;
			Limit = *(signed long int *)(&Temp);
			data->IncDecAmount = Limit;
			/* No reason to Sync */
			break;
			} /* IncDecInt */
		case MUIA_FloatInt_IncDecDouble:
			{
			D = (double *)tag->ti_Data;
			if(D) /* prevent enforcer hits from stupidity */
				{
				data->IncDecAmount = *D;
				data->FIFlags &= ~FIOFlag_Frac;
				} /* if */
			/* No reason to Sync */
			break;
			} /* IncDecDouble */
		case MUIA_FloatInt_IDFracDouble:
			{
			D = (double *)tag->ti_Data;
			if(D) /* prevent enforcer hits from stupidity */
				{
				data->IncDecAmount = *D;
				data->FIFlags |= FIOFlag_Frac;
				} /* if */
			/* No reason to Sync */
			break;
			} /* IDFracDouble */

		case MUIA_FloatInt_MaxValDouble:
			{
			D = (double *)tag->ti_Data;
			if(D) /* prevent enforcer hits from stupidity */
				{
				data->MaxAmount = *D;
				if(!GetTagData(MUIV_FloatInt_InhibitAutoSync, NULL, msg->ops_AttrList))
					{
					mSync(cl, obj, msg);
					} /* if */
				} /* if */
			break;
			} /* MaxValDouble */
		case MUIA_FloatInt_MinValDouble:
			{
			D = (double *)tag->ti_Data;
			if(D) /* prevent enforcer hits from stupidity */
				{
				data->MinAmount = *D;
				if(!GetTagData(MUIV_FloatInt_InhibitAutoSync, NULL, msg->ops_AttrList))
					{
					mSync(cl, obj, msg);
					} /* if */
				} /* if */
			break;
			} /* MinValDouble */

		case MUIA_FloatInt_MaxValInt:
			{
			Temp = tag->ti_Data;
			Limit = *(signed long int *)(&Temp);
			data->MaxAmount = Limit;
			if(!GetTagData(MUIV_FloatInt_InhibitAutoSync, NULL, msg->ops_AttrList))
				{
				mSync(cl, obj, msg);
				} /* if */
			break;
			} /* MaxValInt */
		case MUIA_FloatInt_MinValInt:
			{
			Temp = tag->ti_Data;
			Limit = *(signed long int *)(&Temp);
			data->MinAmount = Limit;
			if(!GetTagData(MUIV_FloatInt_InhibitAutoSync, NULL, msg->ops_AttrList))
				{
				mSync(cl, obj, msg);
				} /* if */
			break;
			} /* MinValInt */


		case MUIA_FloatInt_VarPtr:
			{
			data->MasterVariable = (void *)tag->ti_Data;
			if(!GetTagData(MUIV_FloatInt_InhibitAutoSync, NULL, msg->ops_AttrList))
				{
				mSync(cl, obj, msg);
				} /* if */
			break;
			} /* VarPtr */
		case MUIA_FloatInt_VarType:
			{
			Temp = tag->ti_Data;
			if(Temp & FI_TypeMask)
				{
				data->FIFlags &= ~FI_TypeMask;
				data->FIFlags |= Temp;
				if(!GetTagData(MUIV_FloatInt_InhibitAutoSync, NULL, msg->ops_AttrList))
					{
					mSync(cl, obj, msg);
					} /* if */
				} /* if */
			break;
			} /* VarType */
		case MUIA_FloatInt_Contents:
			{
			if(data->MasterVariable)
				{
				*((long *)(data->MasterVariable)) = (long)tag->ti_Data;
				if(!GetTagData(MUIV_FloatInt_InhibitAutoSync, NULL, msg->ops_AttrList))
					{
					mSync(cl, obj, msg);
					} /* if */
				} /* if */
			break;
			} /* VarPtr */
		}
	}

return(DoSuperMethodA(cl,obj,(Msg)msg));
}
コード例 #3
0
ファイル: MUIFloatInt.c プロジェクト: AlphaPixel/3DNature
SAVEDS ULONG mStr(struct IClass *cl,Object *obj,Msg msg)
{
struct FloatIntData *data;
char ReSync = 0;

double *D;
float *F;
char *C, *Str;
unsigned char *UC;
short *S;
unsigned short *US;
long *L;
unsigned long *UL;

data = INST_DATA(cl,obj);

get(data->string, MUIA_String_Contents, &Str);

if(data->FIFlags & FIOFlag_Float)
	{
	F = (float *)data->MasterVariable;
	*F = atof(Str);
	} /* if */
else if(data->FIFlags & FIOFlag_Double)
	{
	D = (double *)data->MasterVariable;
	*D = atof(Str);
	} /* if */
else if(data->FIFlags & FIOFlag_Char)
	{
	if(data->FIFlags && FIOFlag_Unsigned)
		{
		C = (char *)data->MasterVariable;
		*C = (char)atoi(Str);
		if(*C > data->MaxAmount) {*C = (char)data->MaxAmount; ReSync = 1;}
		if(*C < data->MinAmount) {*C = (char)data->MinAmount; ReSync = 1;}
		} /* if */
	else
		{
		UC = (unsigned char *)data->MasterVariable;
		*UC = (unsigned char)atoi(Str);
		if(*UC > data->MaxAmount) {*UC = (unsigned char)data->MaxAmount; ReSync = 1;}
		if(*UC < data->MinAmount) {*UC = (unsigned char)data->MinAmount; ReSync = 1;}
		} /* else */
	} /* if */
else if(data->FIFlags & FIOFlag_Short)
	{
	if(data->FIFlags && FIOFlag_Unsigned)
		{
		S = (short *)data->MasterVariable;
		*S = (short)atoi(Str);
		if(*S > data->MaxAmount) {*S = (short)data->MaxAmount; ReSync = 1;}
		if(*S < data->MinAmount) {*S = (short)data->MinAmount; ReSync = 1;}
		} /* if */
	else
		{
		US = (unsigned short *)data->MasterVariable;
		*US = (unsigned short)atoi(Str);
		if(*US > data->MaxAmount) {*US = (unsigned short)data->MaxAmount; ReSync = 1;}
		if(*US < data->MinAmount) {*US = (unsigned short)data->MinAmount; ReSync = 1;}
		} /* else */
	} /* if */
else if(data->FIFlags & FIOFlag_Long)
	{
	if(data->FIFlags && FIOFlag_Unsigned)
		{
		L = (long *)data->MasterVariable;
		*L = (long)atol(Str);
		if(*L > data->MaxAmount) {*L = (long)data->MaxAmount; ReSync = 1;}
		if(*L < data->MinAmount) {*L = (long)data->MinAmount; ReSync = 1;}
		} /* if */
	else
		{
		UL = (unsigned long *)data->MasterVariable;
		*UL = (unsigned long)atol(Str);
		if(*UL > data->MaxAmount) {*UL = (unsigned long)data->MaxAmount; ReSync = 1;}
		if(*UL < data->MinAmount) {*UL = (unsigned long)data->MinAmount; ReSync = 1;}
		} /* else */
	} /* if */

if(ReSync)
	{
	/* Update string gadget to reflect max/min limiting */
	/* This will trigger notifies */
	mSync(cl, obj, msg);
	} /* if */
else
	{
	/* No-op to invoke triggers, if any */
	UL = (unsigned long *)data->MasterVariable;
	/* set(obj, MUIA_FloatInt_Contents, *(UL)); */
	SetAttrs(obj,MUIV_FloatInt_InhibitAutoSync,TRUE,MUIA_FloatInt_Contents, *(UL),TAG_DONE);
	} /* else */

return(0);
}
コード例 #4
0
ファイル: MUIFloatInt.c プロジェクト: AlphaPixel/3DNature
SAVEDS ULONG mNew(struct IClass *cl,Object *obj,struct opSet *msg)
{
	struct FloatIntData *data;
	double *D;
	ULONG Store;
	signed long int Limit;
	char *AllowChars, Width;
	APTR MyWin;

	/* This looks like cookbook code. */
	if (!(obj = (Object *)DoSuperMethodA(cl,obj,(Msg)msg)))
		return(0);
	data = INST_DATA(cl,obj);

	data->FIFlags = NULL;
	data->MasterVariable = NULL;
	data->IncDecAmount = 1.0;
	data->MinAmount = 0;
	data->MaxAmount = FLT_MAX;
	
	if(Store = GetTagData(MUIA_FloatInt_IncDecInt, NULL, msg->ops_AttrList))
		{
		Limit = *(signed long int *)(&Store);
		data->IncDecAmount = Limit;
		data->FIFlags &= ~FIOFlag_Frac;
		} /* if */

	if(Store = GetTagData(MUIA_FloatInt_IncDecDouble, NULL, msg->ops_AttrList))
		{
		D = (double *)Store;
		data->IncDecAmount = *D;
		data->FIFlags &= ~FIOFlag_Frac;
		} /* if */

	if(Store = GetTagData(MUIA_FloatInt_IDFracDouble, NULL, msg->ops_AttrList))
		{
		D = (double *)Store;
		data->IncDecAmount = *D;
		data->FIFlags |= FIOFlag_Frac;
		} /* if */

	if(Store = GetTagData(MUIA_FloatInt_MaxValDouble, NULL, msg->ops_AttrList))
		{
		D = (double *)Store;
		data->MaxAmount = *D;
		} /* if */

	if(Store = GetTagData(MUIA_FloatInt_MinValDouble, NULL, msg->ops_AttrList))
		{
		D = (double *)Store;
		data->MinAmount = *D;
		} /* if */

	if(Store = GetTagData(MUIA_FloatInt_MaxValInt, NULL, msg->ops_AttrList))
		{
		Limit = *(signed long int *)(&Store);
		data->MaxAmount = Limit;
		} /* if */

	if(Store = GetTagData(MUIA_FloatInt_MinValInt, NULL, msg->ops_AttrList))
		{
		Limit = *(signed long int *)(&Store);
		data->MinAmount = Limit;
		} /* if */

	Width = GetTagData(MUIA_FloatInt_FieldWidth, 5, msg->ops_AttrList);
	if(Width > 10) Width = 10;
	if(Width < 1)  Width = 1;

	data->FIFlags        |= GetTagData(MUIA_FloatInt_VarType, NULL, msg->ops_AttrList);
	data->MasterVariable  = (void *)GetTagData(MUIA_FloatInt_VarPtr, NULL, msg->ops_AttrList);
	data->LabelText       = (char *)GetTagData(MUIA_FloatInt_LabelText, NULL, msg->ops_AttrList);

	/* make sure we have required args */
	if(data->LabelText && data->MasterVariable && (data->FIFlags & FI_TypeMask))
		{
		if(data->FIFlags & (FIOFlag_Float | FIOFlag_Double)) /* is it floating-point? */
			{
			AllowChars = ".+-0123456789";
			} /* if */
		else
			{
			AllowChars = "+-0123456789";
			} /* else */
		data->group = 	HGroup, MUIA_Group_HorizSpacing, 0,
								Child, Label2(data->LabelText),
								Child, data->string = StringObject, StringFrame,
									MUIA_String_Accept, AllowChars,
									MUIA_FixWidthTxt, FWT[Width], End,
								Child, data->decbutton = ImageButton(MUII_ArrowLeft),
								Child, data->incbutton = ImageButton(MUII_ArrowRight),
								End;
		} /* if */

	if (!data->group)
	{
		CoerceMethod(cl,obj,OM_DISPOSE);
		return(0);
	}


	get(data->string, MUIA_WindowObject, &MyWin);

   /* Set up notification for change of ActiveObject */
   
   DoMethod(MyWin, MUIM_Notify, MUIA_Window_ActiveObject, MUIV_EveryTime,
    obj, 3, MUIM_FloatInt_ChangeFocus, MUIA_FloatInt_Focus, MUIV_TriggerValue);

	/* Set up notification for increment/decrement buttons */
	DoMethod(data->decbutton, MUIM_Notify, MUIA_Pressed, FALSE, obj,
	 1, MUIM_FloatInt_Dec);
	DoMethod(data->incbutton, MUIM_Notify, MUIA_Pressed, FALSE, obj,
	 1, MUIM_FloatInt_Inc);
	
	/* Set up notification for string gadget */
	DoMethod(data->string, MUIM_Notify, MUIA_Selected, FALSE, obj,
	 1, MUIM_FloatInt_Str);


	DoMethod(obj,OM_ADDMEMBER,data->group);
	
	mSync(cl, obj, msg);
	
	return((ULONG)obj);
}