Advertisement
RSzacki

Efekt CopperScreen - Test.c

Aug 28th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.19 KB | None | 0 0
  1.  
  2. #include <intuition/screens.h>
  3. #include <graphics/copper.h>
  4. #include <hardware/intbits.h>
  5. #include <hardware/dmabits.h>
  6. #include <graphics/gfxmacros.h>
  7. #include <hardware/custom.h>
  8. #include <exec/interrupts.h>
  9. #include <exec/memory.h>
  10. #include <graphics/gfxbase.h>
  11.  
  12. #include <clib/exec_protos.h>
  13. #include <clib/graphics_protos.h>
  14. #include <clib/intuition_protos.h>
  15.  
  16. __far extern struct Custom custom;
  17.  
  18. extern void initCopperlist(); /* Inicjuje Copperlistę */
  19. extern void myCopperInt();    /* Obsługa przerwania Coppera */
  20.  
  21. extern struct GfxBase *GfxBase;
  22.  
  23. int main()
  24. {
  25.     struct Screen *s;
  26.     struct UCopList *ucl;
  27.     struct Interrupt irq;
  28.     struct myData
  29.         {
  30.         struct Task *thisTask;
  31.         ULONG sigmask;
  32.         } mydata;
  33.     ULONG signal;
  34.     struct View *oldview;
  35.  
  36.     /* Inicjujemy Copperlistę (ustawiamy wskaźniki do bitplanów) */
  37.     initCopperlist();
  38.  
  39.  
  40.     /* Otwieramy ekran */
  41.     if (s = OpenScreenTags(NULL,
  42.         SA_Left,        0,
  43.         SA_Top,         0,
  44.         SA_Width,       320,
  45.         SA_Height,      256,
  46.         SA_Depth,       1,
  47.         SA_Quiet,       TRUE,
  48.         SA_Exclusive,   TRUE,
  49.         TAG_DONE))
  50.         {
  51.  
  52.         /* Szukamy zadania */
  53.         mydata.thisTask = FindTask(NULL);
  54.  
  55.         /* Rezerwujemy sygnał */
  56.         if ((signal = AllocSignal(-1)) != -1)
  57.             {
  58.             mydata.sigmask = 1L << signal;
  59.  
  60.             /* Inicjujemy strukturę przerwania */
  61.             irq.is_Node.ln_Pri = 0;
  62.             irq.is_Code = myCopperInt;
  63.             irq.is_Data = &mydata;
  64.  
  65.             /* Dodajemy obsługę przerwania Coppera */
  66.             AddIntServer(INTB_COPER, &irq);
  67.  
  68.             /* Tworzymy Copperlistę użytkownika */
  69.             if (ucl = AllocMem(sizeof(struct UCopList), MEMF_PUBLIC|MEMF_CLEAR))
  70.                 {
  71.                 CINIT(ucl, 2);
  72.                 CWAIT(ucl, 0, 0);
  73.  
  74.                 /* Wywołujemy przerwanie w linii 0, gdy nasz ekran (Copperlista) staje się aktywny */
  75.                 CMOVE(ucl, custom.intreq, INTF_SETCLR|INTF_COPER);
  76.                 CEND(ucl);
  77.  
  78.                 /* Ustawiamy Copperlistę użytkownika */
  79.                 Forbid();
  80.                 s->ViewPort.UCopIns = ucl;
  81.                 Permit();
  82.                 RethinkDisplay();
  83.  
  84.                 oldview = GfxBase->ActiView;
  85.                 WORD i;
  86.                 for (i = 0; i < 5; i++)
  87.                     {
  88.  
  89.                     /* Czekamy na sygnał */
  90.                     SetSignal(0L, mydata.sigmask);
  91.                     Wait(mydata.sigmask);
  92.  
  93.                     /* Załadowujemy copperlistę */
  94.                     if (i < 4)
  95.                         loadCopperlist();
  96.                     }
  97.  
  98.                 /* Odtwarzamy oryginalna copperlistę */
  99.                 WaitTOF();
  100.                 WaitTOF();
  101.                 LoadView(oldview);
  102.                 custom.cop1lc = (ULONG)GfxBase->copinit;
  103.                 }
  104.  
  105.             /* Usuwamy obsługę przerwania */
  106.             RemIntServer(INTB_COPER, &irq);
  107.  
  108.             /* Zwalniamy sygnał */
  109.             FreeSignal(signal);
  110.             }
  111.  
  112.         /* Zamykamy ekran */
  113.         CloseScreen(s);
  114.         }
  115.     return(0);
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement