RSzacki

Sprite Test w języku C

Mar 27th, 2015
375
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. /* "Sprite Test" w jezyku C */
  3.  
  4. #include <stdio.h>
  5. #include <graphics/sprite.h>
  6. #include <hardware/intbits.h>
  7. #include <exec/interrupts.h>
  8. #include <dos/dos.h>
  9.  
  10. #include <clib/graphics_protos.h>
  11. #include <clib/exec_protos.h>
  12. #include <clib/dos_protos.h>
  13.  
  14. /* Grafika duszka */
  15.  
  16. __chip UWORD sprite_data[] =
  17. {
  18.     0, 0,
  19.     0x0000, 0x07E0,
  20.     0x07E0, 0x1FF8,
  21.     0x1FF8, 0x3FFC,
  22.     0x1FF8, 0x3FFC,
  23.     0x399C, 0x7FFE,
  24.     0x37EC, 0x799E,
  25.     0x37EC, 0x799E,
  26.     0x399C, 0x7FFE,
  27.     0x3FFC, 0x7FFE,
  28.     0x0FF0, 0x3FFC,
  29.     0x07E0, 0x0FF0,
  30.     0x05A0, 0x0FF0,
  31.     0x0000, 0x07E0,
  32.     0x0000, 0x0000,
  33.     0x0000, 0x73CE,
  34.     0x63C6, 0xF7EF,
  35.     0x700E, 0xFBDF,
  36.     0x381C, 0xFC3F,
  37.     0x1C38, 0x3E7C,
  38.     0x0E70, 0x1FF8,
  39.     0x07E0, 0x0FF0,
  40.     0x07E0, 0x0FF0,
  41.     0x0E70, 0x1FF8,
  42.     0x1C38, 0x3E7C,
  43.     0x381C, 0xFC3F,
  44.     0x700E, 0xF81F,
  45.     0x6006, 0xF00F,
  46.     0x0000, 0x700E,
  47.     0, 0
  48. };
  49.  
  50. __regargs __asm __saveds ULONG mycode( register __a1 struct SimpleSprite *s )
  51. {
  52.     MoveSprite( NULL, s, s->x + 1, s->y + 1 );
  53.  
  54.     return( 0 );
  55. }
  56.  
  57. int main()
  58. {
  59.     struct SimpleSprite sprite = { 0 };
  60.     WORD number;
  61.  
  62.     struct Interrupt myvblank = { 0 };
  63.  
  64.     /* Probujemy zaalokowac duszka */
  65.  
  66.     if( ( number = GetSprite( &sprite, -1 ) ) == -1 )
  67.     {
  68.         printf( "Nie mozna zaalokowac duszka.\n" );
  69.         return( RETURN_WARN );
  70.     }
  71.  
  72.     sprite.x      = 0; /* Ustawiamy pozycje poczatkowa */
  73.     sprite.y      = 0;
  74.     sprite.height = 28; /* Ustawiamy wysokosc duszka */
  75.  
  76.     ChangeSprite( NULL, &sprite, sprite_data ); /* Ustawiamy wyglad */
  77.  
  78.     myvblank.is_Data = &sprite;
  79.     myvblank.is_Code = ( VOID (*) ) mycode;
  80.     myvblank.is_Node.ln_Name = "Sprite Test";
  81.     myvblank.is_Node.ln_Pri  = 20; /* Priorytet */
  82.  
  83.     AddIntServer( INTB_VERTB, &myvblank ); /* Instalujemy obsluge przerwania */
  84.  
  85.     Delay( 200 );
  86.  
  87.     RemIntServer( INTB_VERTB, &myvblank ); /* Usuwamy obsluge przerwania */
  88.  
  89.     FreeSprite( number ); /* Zwalniamy duszka */
  90.  
  91.     return( 0 ); /* Wychodzimy */
  92. }
RAW Paste Data