97Fermer99
vinceLe 18/02/2017 à 14:52
#include <lynx.h> #include <lynxlib.h> /* LYNX-specific #defines: */ #define JOY_RIGHT 0x10 #define JOY_LEFT 0x20 #define JOY_DOWN 0x40 #define JOY_UP 0x80 #define BUTTON_OPTION1 0x08 #define BUTTON_OPTION2 0x04 #define BUTTON_INNER 0x02 #define BUTTON_OUTER 0x01 #define BUTTON_PAUSE 0x01 struct _timer timerV at 0xfd10; char SCREEN[8160] at (MEMTOP-16320); char RENDER[8160] at (MEMTOP-8160); char drawPending; char pal[] = { 0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,0x08,0x0F,0x08,0x00,0x0F,0x00,0x08,0x0F, //0G 0x00,0x0F,0x4F,0x0F,0x00,0xF0,0xF8,0x00,0x88,0x8F,0xFF,0xFF,0xFF,0x80,0x8F,0xFF //BR }; unsigned char x; unsigned char y; VBL() interrupt { if (drawPending) { SwapBuffers(); drawPending = 0; } } SER() interrupt { DisableIRQ(4); POKE(0x10,0xFD80); x=serdat; EnableIRQ(4); } void Vsync() { #asm vretrace: lda $fd0a bne vretrace #endasm } char WaitButton() { char key; while ( (key = joystick) == 0); while ( joystick ); return key; } void ComLynx_Init() { //timer4.reload = 12; /* 9600 bps */ //timer4.control = 0x18; /* Horloge 1 MHz, rechargement auto activé, timer activé */ POKE(0xFD10,12); POKE(0xFD11,0x18); serctl = 0x5D; /* Parité paire, mode collecteur ouvert, interruptions désactivées, reset des erreurs, break désactivé */ /* Effacement du buffer de réception */ while (serctl & 0x40) { unsigned char c; c = serdat; } InstallIRQ(4,SER); EnableIRQ(4); } /* Réception d'un octet */ unsigned char ComLynx_ReceptionOctet() { while (!(serctl & 0x40)); /* Attend qu'un octet ait été reçu */ return serdat; /* Retourne l'octet reçu */ } /* Envoi d'un octet */ void ComLynx_EnvoiOctet(octet) unsigned char octet; { while (!(serctl & 0x80)); /* Attend que l'émetteur soit prêt */ serdat = octet; /* Envoie l'octet */ ComLynx_ReceptionOctet(); /* Comme Tx et Rx sont communs, chaque octet envoyé est reçu, on l'efface donc du buffer de réception */ } /* Envoi d'une chaîne de caractères */ void ComLynx_EnvoiChaine(chaine) unsigned char *chaine; { unsigned char c; while ((c = *(chaine)++) != '0') ComLynx_EnvoiOctet(c); } char main(){ InitIRQ(); CLI; SetBuffers(SCREEN, RENDER ,0); InstallIRQ(2,VBL); EnableIRQ(2); SetRGB(pal); drawPending=1; Vsync(); x=0; y=0; ComLynx_Init(); for(;;){ DrawFBox(0,0,160,102,0); DrawFBox(x,y,5,5,5); Vsync(); drawPending = 1; y++; if(y>100) y=0; } }