Exemplo n.º 1
0
/***
*__TrapFromGestalt - Contains functions for test existence of Gestalt call
*
*
*Purpose:
*       Test if certain trap is avaiable through Gestalt
*
*
*Entry:
*       selector and bit const for Gestalt
*
*Exit:
*       1 if avaiable
*       0 if not
*******************************************************************************/
int __TrapFromGestalt(OSType selector, long bitNum)
	{
   
	OSErr osErr;
	long gestaltRespond;
	
	if (__GestaltAvailable())
		{
		osErr = Gestalt(selector, &gestaltRespond);
		if (!osErr)
			{
			if (BitTst(&gestaltRespond, 31-bitNum))
				{
				return 1;  //trap avaliable
				}
			else
				{
				return 0;  //trap not avaliable
				}
			}
		else
			{
			return 0;     
			}
		}
	return 0;
	}
Exemplo n.º 2
0
void SW_timer_handler()
{
    char buffer[20];
    uint8_t timnum;
    for(timnum=0;timnum<SWTIMERNUM;timnum++)
    {
        if(BitTst(SWtimerFlags,BitMsk(timnum)))
        {
            switch (timnum)
            {
                case 0 :
                    LED_action(LED1,TOGGLE);
                    break;
                case 1 :
                    therm_read_temperature(buffer);
                    debug_send(buffer);
                    break;
                case 2 :
                    LED_action(LED2,TOGGLE);
                    break;
                case 3 :
                   LED_action(LED3,TOGGLE);
                    break;
            }

            BitClr(SWtimerFlags,BitMsk(timnum));
        }
    }
    go_to_sleep();
}
Exemplo n.º 3
0
static int key_mac_init(void)
{

#if (TRACE_MAC_KBRD)
   fprintf(stdout, "key_mac_init()\n");
   fflush(stdout);
#endif
   GetKeys(KeyNow);
   _key_shifts=0;
   if(BitTst(KeyNow,k_apple_shift) || BitTst(KeyNow,k_apple_rshift))_key_shifts |= KB_SHIFT_FLAG;
   if(BitTst(KeyNow,k_apple_alt) || BitTst(KeyNow,k_apple_altgr))_key_shifts |= KB_ALT_FLAG;
   if(BitTst(KeyNow,k_apple_control) || BitTst(KeyNow,k_apple_rcontrol))_key_shifts |= KB_CTRL_FLAG;
   _mouse2nd=BitTst(KeyNow,k_2nd);
   LOCK_VARIABLE(KeyNow);
   LOCK_VARIABLE(KeyOld);
   LOCK_VARIABLE(key_apple_to_allegro);
   LOCK_VARIABLE(modifier_table);
   LOCK_VARIABLE(standard_key_ascii_table);
   LOCK_VARIABLE(standard_key_capslock_table);
   LOCK_VARIABLE(standard_key_shift_table);
   LOCK_VARIABLE(standard_key_control_table);
   LOCK_FUNCTION(_key_mac_interrupt);
   LOCK_FUNCTION(_handle_mac_key_press);
   LOCK_FUNCTION(_handle_mac_key_release);
   
   BlockMove(KeyNow, KeyOld, sizeof(KeyMap));
   if (!tm_running)
      _tm_sys_init();
   _mac_keyboard_installed=1;
   return 0;
}
Exemplo n.º 4
0
unsigned char RecebeSerial(void) 
{ 
	char resp = 0;
	if (BitTst(PIR1,5))	//Verifica se existe algum valor disponivel
	{	
		resp = RCREG;	//retorna o valor
	}
	return resp;		//retorna zero
}
Exemplo n.º 5
0
static boolean meallocmenuid (short *id) {
	
	/*
	12/27/96 dmb: windows port
	*/

	register short i;
	register hdlmenubarlist hlist = menubarlist;
	register byte *pbitmap;
	boolean	flFound = false;
	#ifdef MACVERSION
		//9/1/00 Timothy Paustian
		//got rid of nasty use of direct memory access.
		//not allowed in carbon
		#if TARGET_API_MAC_CARBON == 1
		MenuBarHandle MenuList = nil;
		MenuList = GetMenuBar();
		#else
		#define MenuList (*(Handle *)0xA1C)
		#endif		
	#endif

	if (hlist == nil)
		return (false);
	
	pbitmap = (**hlist).menubitmap;
	
	for (i = 0; i < maxmenus; i++) {
		
		if (!BitTst (pbitmap, i)) { /*found one not in use*/
			
			BitSet (pbitmap, i);
			
			*id = (**hlist).basemenuid + i;
			
			#ifdef MACVERSION
				if ((MenuList != nil) && (GetMenuHandle (*id) != nil)) /*2.1a6 dmb: in use by someone!*/
					continue;
			#endif
			
			#ifdef WIN95VERSION
				*id *= 100; // 4.18.97 dmb: leave room for 99 items with their own, sequenced ids
			#endif
			
			flFound = true;
			break;
			}
		} /*for*/
	#if MACVERSION && TARGET_API_MAC_CARBON
		//Code change by Timothy Paustian Tuesday, September 5, 2000 9:27:35 PM
		//Only dispose of in carbon
		if(MenuList != nil)
			DisposeMenuBar(MenuList);
	#endif
	return (flFound); /*all menu ids are in use*/
	} /*meallocmenuid*/
Exemplo n.º 6
0
Boolean IsObjectUndone (ObjectRecHdl ObjectHdl)
{
	Boolean bUndoFlag;
	short	objectFlags;

	objectFlags = (**ObjectHdl).objectFlags;
	bUndoFlag = BitTst (&objectFlags, kUndoMask);	

	return (bUndoFlag);
}
Exemplo n.º 7
0
Boolean IsObjectMarked (ObjectRecHdl ObjectHdl)
{
	Boolean	MarkedFlag;
	short	objectFlags;
	
	objectFlags = (**ObjectHdl).objectFlags;
	MarkedFlag = BitTst (&objectFlags, kMarkedMask);
	
	return (MarkedFlag);
}
Exemplo n.º 8
0
Boolean IsObjectSelected (ObjectRecHdl ObjectHdl)
{
	Boolean	SelectedFlag;
	short	objectFlags;
	
	objectFlags = (**ObjectHdl).objectFlags;
	SelectedFlag = BitTst (&objectFlags, kSelectedMask);	
	
	return (SelectedFlag);
}
Exemplo n.º 9
0
Boolean IsObjectVisible (ObjectRecHdl ObjectHdl)
{
	Boolean VisibleFlag;
	short	objectFlags;

	objectFlags = (**ObjectHdl).objectFlags;
	VisibleFlag = BitTst (&objectFlags, kVisibleMask);	

	return (VisibleFlag);
}
Exemplo n.º 10
0
Boolean IsObjectFGrouped (ObjectRecHdl thisObjectHdl)
{
	Boolean	GroupedFlag;
	short	objectFlags;
	
	objectFlags = (**thisObjectHdl).objectFlags;
	GroupedFlag = BitTst (&objectFlags, kGroupedMask);	
	
	return (GroupedFlag);
}
Exemplo n.º 11
0
void SetUpQD(void)
{
    ProcessSerialNumber PSN;
    FSSpec              myFSSpec;
    Str63               name;
    ProcessInfoRec      infoRec;
    OSErr               result = noErr;
    CFragConnectionID   connID;
    Str255              errName;

    // Memorize the plugin¹s resource file refnum for later use.
    gResFile = CurResFile();

#if !TARGET_API_MAC_CARBON
    // Ask the system if CFM is available.
    long response;
    OSErr err = Gestalt(gestaltCFMAttr, &response);
    Boolean hasCFM = BitTst(&response, 31-gestaltCFMPresent);

    if (hasCFM) {
        // GetProcessInformation takes a process serial number and
        // will give us back the name and FSSpec of the application.
        // See the Process Manager in IM.
        infoRec.processInfoLength = sizeof(ProcessInfoRec);
        infoRec.processName = name;
        infoRec.processAppSpec = &myFSSpec;

        PSN.highLongOfPSN = 0;
        PSN.lowLongOfPSN = kCurrentProcess;

        result = GetProcessInformation(&PSN, &infoRec);
    } else {
        // If no CFM installed, assume it must be a 68K app.
        result = -1;
    }

    if (result == noErr) {
        // Now that we know the app name and FSSpec, we can call
        // GetDiskFragmentto get a connID to use in a subsequent call
        // to FindSymbol (it will also return the address of ³main² in
        // app, which we ignore). If GetDiskFragment returns an
        // error, we assume the app must be 68K.
        Ptr mainAddr;
        result =  GetDiskFragment(infoRec.processAppSpec, 0L, 0L,
                                  infoRec.processName, kReferenceCFrag,
                                  &connID, (Ptr*)&mainAddr, errName);
    }

    if (result == noErr) {
        // The app is a PPC code fragment, so call FindSymbol
        // to get the exported ³qd² symbol so we can access its
        // QuickDraw globals.
        CFragSymbolClass symClass;
        result = FindSymbol(connID, "\pqd", (Ptr*)&gQDPtr, &symClass);
    } else {
Exemplo n.º 12
0
static int key_adb_init(void)
{
   OSErr e;
   short adb_command;
   short adb_devices;
   char adb_key_registers[8];
   ADBAddress adb_address;
   ADBSetInfoBlock mySet;

   adb_key_cpt_upp = NewADBCompletionUPP(adb_command_callback);
   adb_key_upp = NewADBServiceRoutineUPP (key_adb_interrupt);

   adb_devices = CountADBs();
   for(adb_keyboard_id = 1 ; adb_keyboard_id <= adb_devices ; adb_keyboard_id++){
      adb_address = GetIndADB(&adb_key_save, adb_keyboard_id);
      e = GetADBInfo(&adb_key_save, adb_address);
      if(adb_key_save.origADBAddr == ADB_KEYBOARD){
         switch (adb_key_save.devType){
            case 2:case 3:case 5:
	       LOCK_VARIABLE(KeyNow);
 	       LOCK_VARIABLE(KeyOld);
 	       LOCK_VARIABLE(_mouse2nd);
 	       LOCK_VARIABLE(adb_to_allegro);
 	       LOCK_VARIABLE(modifier_table);
	       LOCK_VARIABLE(standard_key_ascii_table);
	       LOCK_VARIABLE(standard_key_capslock_table);
	       LOCK_VARIABLE(standard_key_shift_table);
 	       LOCK_VARIABLE(standard_key_control_table);
/*	       LOCK_FUNCTION(key_adb_interrupt);*/
/*	       LOCK_FUNCTION(adb_command_callback);*/

               mySet.siService = adb_key_upp;
	       mySet.siDataAreaAddr = NULL;
	       SetADBInfo (&mySet,adb_address);
               adb_key_registers[0] = 2;
               adb_command = (adb_address * 16) + ADB_TALKMASK + ADB_TYPEREGISTER;
	       if (send_adb_command_sync(adb_key_registers, adb_command) == noErr){
		  adb_key_registers[2] = 3;
                  adb_command = (adb_address * 16) + ADB_LISTENMASK + ADB_TYPEREGISTER;
                  send_adb_command_sync(adb_key_registers, adb_command);
               }
               GetKeys(KeyNow);
               _key_shifts=0;

               if(BitTst(KeyNow,k_apple_shift) || BitTst(KeyNow,k_apple_rshift))_key_shifts |= KB_SHIFT_FLAG;
               if(BitTst(KeyNow,k_apple_alt) || BitTst(KeyNow,k_apple_altgr))_key_shifts |= KB_ALT_FLAG;
               if(BitTst(KeyNow,k_apple_control) || BitTst(KeyNow,k_apple_rcontrol))_key_shifts |= KB_CTRL_FLAG;
               _mouse2nd = BitTst(KeyNow,k_2nd);
               return 0;
            default:
               break;
      	 }
      }
   }
   adb_keyboard_id=0;
   return -1;
}
Exemplo n.º 13
0
Boolean MenuItemEnabled(MenuHandle menu, short item)
{
#if TARGET_API_MAC_CARBON
	// first check the entire  menu
	if(!IsMenuItemEnabled(menu,0)) return false;
	return IsMenuItemEnabled(menu,item);
	
#else
	return ((**menu).enableFlags & 1) && // low bit means menu itself is enabled
		   (BitTst((Ptr)&((**menu).enableFlags),
						 31 - (item <= 31 ? item : 0)));
#endif
}
Exemplo n.º 14
0
void _key_mac_interrupt()
{
   UInt32 xKeys;
   int a, row, base, keycode;
   KeyNow[0]=(*(UInt32*)0x174);
   KeyNow[1]=(*(UInt32*)0x178);
   KeyNow[2]=(*(UInt32*)0x17C);
   KeyNow[3]=(*(UInt32*)0x180);
   for(row=0, base=0;row<4;row++, base+=32) {
      xKeys=KeyOld[row]^KeyNow[row];
      if (xKeys) {
         for(a=0;a<32;a++) {
            if (BitTst(&xKeys, a)) {
               keycode=key_apple_to_allegro[a+base];
               if (keycode) {
                  if (BitTst( &KeyNow[row], a)) {
		     _handle_mac_key_press(keycode);
                  }
                  else{
                     _handle_mac_key_release(keycode);
                  }
	       }
	       else{
	          switch(a+base){
                     case k_2nd:
		        _mouse2nd = BitTst( &KeyNow[row], a);
		        break;
		     default:
		        break;
                  }	       
	       }
            }
         }
      }
      KeyOld[row]=KeyNow[row];
   }
}
Exemplo n.º 15
0
BOOL _stdcall DllMain (HANDLE hModule, DWORD reason, void * unused) {
	if (reason != DLL_PROCESS_ATTACH) return true;

	MGEFlags = NULL;
	bool iniLoaded = LoadSettings ();
	if (!IsMorrowind ()) return true;

	if (FindWindow (0, GUI_VERSION)) {
		ERRORMSG ("Error: MGEgui is running. Please shut it down before launching morrowind.");
	}

	if (!iniLoaded) {
		ERRORMSG ("Error: MGE is not configured. Please run MGEgui to configure it before launching Morrowind.");
	}
	Initialized = !BitTst (&MGEFlags, MGE_DISABLED_BIT);

	HANDLE MWSEpipe;
	HANDLE MGEpipe;

	if (Initialized) {
		MWSEpipe = CreateNamedPipeA ("\\\\.\\pipe\\MWSEMGEpipe", PIPE_ACCESS_DUPLEX, 
			PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT,
			PIPE_UNLIMITED_INSTANCES, 4096, 4096, 20000, NULL
		);
		MWSEpipe2 = CreateNamedPipeA ("\\\\.\\pipe\\MWSEMGEpipe2", PIPE_ACCESS_DUPLEX, 
			PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT,
			PIPE_UNLIMITED_INSTANCES, 4096, 4096, 20000, NULL
		);
		if (MWSEpipe == INVALID_HANDLE_VALUE || MWSEpipe2 == INVALID_HANDLE_VALUE) {
			LOG::log ("Failed to create mge-mwse pipe\r\n");
			return false;
		}
		MGEpipe = CreateFile ("\\\\.\\pipe\\MWSEMGEpipe", GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
		MGEpipe2 = CreateFile ("\\\\.\\pipe\\MWSEMGEpipe2", GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
		if (MGEpipe == INVALID_HANDLE_VALUE || MGEpipe2 == INVALID_HANDLE_VALUE) {
			LOG::log ("Failed to open mge-mwse pipe\r\n");
			return false;
		}
	} else MWSEpipe = INVALID_HANDLE_VALUE;

	if (MGEFlags & MWSE_DISABLED) LOG::log ("MWSE: Disabled\r\n");
	else MWSEOnProcessStart (MWSEpipe);
	if (Initialized) {
		MGEOnProcessStart (MGEpipe);
		DInputOnProcessStart ();
	} else LOG::log ("MGE: Disabled\r\n");

	return true;
}
Exemplo n.º 16
0
void DebounceTeclas(void)
{
    unsigned char i,j;
    static unsigned char tempo;
    static unsigned int valorNovo = 0x0000;
    static unsigned int valorAntigo = 0x0000;

    for(i = 0; i < 4; i++)
    {
        //o bug ta aki
        //PORTB = (1<<i);

        //PORTB = 0x0f;
        //BitClr(PORTB,(i));    //liga a coluna correspondente
        //gasta tempo atoa, necess�rio para garantir que o pino atingiu o nivel alto
        for(j=0; j<100; j++);

        //realiza o teste para cada bit e atualiza a vari�vel
        for(j = 0; j < 4; j++)
        {
            if (!BitTst(PORTB,j+4))
            {
                BitSet(valorNovo,(i*4)+j);
            }
            else
            {
                BitClr(valorNovo,(i*4)+j);
            }
        }
    }
    if (valorAntigo == valorNovo)
    {
        tempo --;
    }
    else
    {
        tempo = 10;
        valorAntigo = valorNovo;
    }
    if (tempo == 0)
    {
        valor = valorAntigo;
    }
}
Exemplo n.º 17
0
void MGEOnProcessStart(HANDLE pipe) {
	// Set variables dependent on configuration
	switch (FogMode) {
		case 2:
			FogPixelMode = 0;
			FogVertexMode = 3;
			RangedFog = 1;
			break;
		case 1:
			FogPixelMode = 0;
			FogVertexMode = 3;
			RangedFog = 0;
			break;
		default:
			FogPixelMode = 3;
			FogVertexMode = 0;
			RangedFog = 0;
			break;
	}
	if (!(MGEFlags & REFLECTIVE_WATER)) {
		BitReset(&MGEFlags, REFLECT_NEAR_BIT);
		BitReset(&MGEFlags, REFLECT_FAR_BIT);
	}
	if (!(MGEFlags & REFLECT_NEAR)) {
		BitReset(&MGEFlags, REFLECT_FAR_BIT);
	}
	DL_WaterReflect = (BYTE)BitTst(&MGEFlags, REFLECTIVE_WATER_BIT) + (BYTE)BitTst(&MGEFlags, REFLECT_NEAR_BIT) + (BYTE)BitTst(&MGEFlags, REFLECT_FAR_BIT);
	Rotation *= PI / 180;
	ReactionSpeed = 1.0f / ReactionSpeed;
	DL_DrawDist *= 8192.0f;
	DL_NearStaticEnd *= 8192.0f;
	DL_FarStaticEnd *= 8192.0f;
	DL_VeryFarStaticEnd *= 8192.0f;
	DL_AboveWaterFogStart *= 8192.0f;
	DL_AboveWaterFogEnd *= 8192.0f;
	DL_BelowWaterFogStart *= 8192.0f;
	DL_BelowWaterFogEnd *= 8192.0f;
	DL_InteriorFogStart *= 8192.0f;
	DL_InteriorFogEnd *= 8192.0f;
	for (int fog = 0; fog <= 9; ++fog) DL_FgOD[fog] /= 100.0f;
	//zero all the structs
	//ZeroStruct(Cam3Offset);
	ZeroStruct(JointInfo);
	//ZeroStruct(Options);
	ZeroStruct(fpsString);
	ZeroStruct(ShaderStruct);
	ZeroStruct(RcpRes);
	ZeroStruct(SinVar);
	ZeroStruct(LinVar);
	ZeroStruct(EyeVec);
	ZeroStruct(EyePos);
	ZeroStruct(SunVec);
	ZeroStruct(SunCol);
	ZeroStruct(AmbCol);
	EyeVec.w=1;
	//Set some values for some structs
	fpsRect.bottom=35;
	fpsRect.right=600;
	fpsRect.left=5;
	fpsRect.top=20;
	StatusRect.bottom=50;
	StatusRect.right=635;
	StatusRect.left=5;
	StatusRect.top=5;
	fpsColor.a=255;
	fpsColor.r=255;
	fpsColor.b=255;
	fpsColor.g=255;
	fps=0;
	//Setup any global variables
	UsingDistantLand=false;
	UseDistantStatics=true;
	UseGrass=true;
	RealDevice=NULL;
	BackBuffer=NULL;
	DepthTexture=NULL;
	DepthBuffer=NULL;
	StateBlock=0;
	Font=NULL;
	StatusStringTime=0;
	//Scenecount
	SceneCount=0;
	HUDScene=-1;
	AlphaScene=2;
	SolarScene=-1;
	Indoors=false;
	UpdateScene=false;
	LastSceneCount=0;
	PixelShading=false;
	StencilEnabled=false;
	AlphaBlendEnabled=false;
	AlphaTestEnabled=false;
	SunEnabled=false;
	LightsSet=false;
	ShadowsDrawn=0;
	NumDrawCalls=0;
	WaterDrawn=false;
	FogAlreadySet=false;
	DlDoneHooking=false;
	//fps variables (Could make an fps structure I suppose)
	fpsLastTime=0;
	fpsFrames=0;
	fpsAdjusting=false;
	//These are variables used for graphics features which cant be set by MGEgui
	Zoom=false;
	//FOV=4.0f;
	FogRange=1.0f;
	FogStart=0;
	FogEnd=0;
	//Rotation=(PI*Options.Rotation)/2;
	D3DXMatrixRotationZ(&RotateMatrix,Rotation);
	//MaxViewRange=STDMAXVIEWDISTANCE;
	//MinViewRange=STDMINVIEWDISTANCE;
	//MWSE stuff
	//Lighting
	ZeroStruct(LightIDs);
	ActiveLights=0;
	//STANDARD stuff
	ZeroStruct(Objects);
	UsedMWSEobjects=0;
	ZeroStruct(HUDbits);
	UsedHUDbits=0;
	HUDsprite=NULL;
	ZeroStruct(LoadedTextures);
	LastTimer=0;
	UsedMWSEShaders=0;
	HookNextTexture=false;
	NextTexIsWater=false;
	NextHookIndex=0;
	ZeroStruct(HookedTextures);
	HookedShaderActive=0;
	ActiveHookedShader=0;
	for(int i=0;i<8;i++) SetHookedTextures[i]=255;
	//Camera shake
	CameraShake=false;
	CameraShakeAmp=0;
	CameraShakeChange=false;
	CameraShakeChangeRate=0;
	D3DXMatrixTranslation(&CameraShakeMatrix,0,0,0);
	//fps independent stuff
	FOVZooming=false;
	FOVZoomRate=0;
	FogZooming=false;
	FogZoomRate=0;
	RotSpinning=false;
	RotSpinRate=0;
	//Exterior lighting control
	SunManual=false;
	SunManColour=false;
	SunManDir=false;
	AmbientManual=false;
	FogManual=false;
	ClsManual=false;
	SkyManual=false;
	HUDManual=false;
	ZeroStruct(SunDirection);
	SunColour=D3DXCOLOR(0,0,0,0);
	AmbientColour=0;
	FogColour=0;
	ClsColour=0;
	SkyColour=0;
	HUDColour=0xFFFFFFFF;
	SunTexture=NULL;
	//Texture spamming
	TexRenderTarget=NULL;
	TexCopyTo=NULL;
	SufRenderTarget=NULL;
	SufCopyTo=NULL;
	ZeroStruct(TexDrawOrigin);
	ZeroStruct(TexDrawScale);
	//video stuff
	LoadedVideoCount=0;
	DistantLandActive=false; //phal
        //Now init some stuff
	//MWSE timer
	TimerFrequency=0;
	if(!QueryPerformanceFrequency((LARGE_INTEGER*)&TimerFrequency)) {
		TimerFrequency=0;
		DEBUGSTRING("Your computer has no high resolution performance counter available.\n"
			"Some MGE features or plugins will not function correctly.\n");
	}
	MWSEpipe=pipe;
}
Exemplo n.º 18
0
void EnviaSerial(unsigned char c) 
{ 
	while(!BitTst(PIR1,4));	//aguarda o registro ficar disponível
	TXREG=c; 		//coloca o valor para ser enviado
}