1

Salut,

Je restructure un peu mon code, et j'ai fais les choses suivantes:

la structure:
typedef struct _ENVIRONMENTDESC
{
	INT_HANDLER					ai1;
	INT_HANDLER					ai5;
	LCD_BUFFER					screen;
	LPVOID						frame;
	BOOL						initialized;
} ENVIRONMENTDESC, *PENVIRONMENTDESC;


l'initialisation:
PENVIRONMENTDESC InitializeEnvironment()
{
	PENVIRONMENTDESC				pEnvironment=NULL;
	int					nBytes=GRAY_BIG_VSCREEN_SIZE*2+LCD_SIZE*2;
	
	// initializes the ENVIRONMENTDESC structure
	pEnvironment=(PENVIRONMENTDESC) malloc(sizeof(ENVIRONMENTDESC));
	
	if (pEnvironment)
	{
		// reset the ENVIRONMENTDESC structure
		memset(pEnvironment, 0, sizeof(ENVIRONMENTDESC));
		
		// initializes the off screen image
		pEnvironment->frame=malloc(nBytes);
		
		if (pEnvironment->frame)
		{
			// reset the frame's content
			memset(pEnvironment->frame, 0, nBytes);

			// saves the screen
			LCD_save(pEnvironment->screen);
			
			// saves the interruptions
			pEnvironment->ai1=GetIntVec(AUTO_INT_1);
			pEnvironment->ai5=GetIntVec(AUTO_INT_5);
	
			// sets the interruptions
			SetIntVec(AUTO_INT_1, DUMMY_HANDLER);
			SetIntVec(AUTO_INT_5, DUMMY_HANDLER);

			// activates grays
			if (GrayOn())
			{
			  GrayClearScreen();
			  pEnvironment->initialized=TRUE;
			}
		}
	}
	
	return pEnvironment;
}


la libération:
void UninitializeEnvironment(PENVIRONMENTDESC* pEnvironment)
{
	if (*pEnvironment)
	{
		if ((*pEnvironment)->initialized)
			GrayOff();
		
		SAFE_FREE((*pEnvironment)->frame);
		
		if ((*pEnvironment)->ai1)
			SetIntVec(AUTO_INT_1, (*pEnvironment)->ai1);
			
		if ((*pEnvironment)->ai5)
			SetIntVec(AUTO_INT_1, (*pEnvironment)->ai5);
		
		GKeyFlush();
		LCD_restore((*pEnvironment)->screen);
		
		SAFE_FREE(*pEnvironment);
		pEnvironment=NULL;
	}
	
}


Et lorsque j'exécute:
int main()
{
	PENVIRONMENTDESC			pEnvironment=NULL;

	pEnvironment=InitializeEnvironment();
	
	if (pEnvironment && pEnvironment->initialized)
	{
		// start the game
		while (!KeyPressed(ESC_KEY))
		{
		}
	}
	
	UninitializeEnvironment(&pEnvironment);

	return 0;
}


ça crash à la sortie. Il semble qu'il y ait un problème avec les interruptions ai1 et ai5 car lorsque je mets en commentaire les lignes gérant les interruptions, ça marche. Je ne vois pas pourquoi...

J'ai peut-être loupé quelque chose...

Si quelqu'un a une explication ça serait la bienvenue smile

Fred.
There is no spoon.

2

quel balochard je fais....
un copier/coller trop rapide tongue
SetIntVec(AUTO_INT_1, (*pEnvironment)->ai5); 

ça, ça ne marchera jamais wink

comme ça, c'est beaucoup mieux:
SetIntVec(AUTO_INT_5, (*pEnvironment)->ai5); 

There is no spoon.

3

Tu es du Nord boulifb ?
[URL=http://www.ti-bank.fr]TI-BANK[/url]
Téléchargez tous vos cours BAC & prépas pour TI sur TI-BANK
[URL=http://tibank.forumactif.com]Forum TI-BANK[/url]
Aide en ligne massive pour tos vos pb TI

4

.2/ ben ouais, pourquoi ça?
There is no spoon.

5

"balochard"

6

Ben ouais.... :P

"carabistouille" pronnoncé "carabistoule"
There is no spoon.