home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / Sprites / AGASprites.s next >
Encoding:
Text File  |  1997-01-10  |  5.2 KB  |  221 lines

  1. ;Sprite Example (AGA only)
  2. ;-------------------------
  3. ;This example contains four 64 pixel wide sprites, in high resolution.
  4. ;You can move sprite number 2 around with the mouse, notice how it
  5. ;appears behind number 1 and in front of 3 and 4.
  6. ;
  7. ;This demo also uses the LIST feature to initialise the four sprites.
  8. ;
  9. ;The LMB exits the demo.
  10.  
  11.     INCDIR    "INCLUDES:"
  12.     INCLUDE    "exec/exec_lib.i"
  13.     INCLUDE    "games/games_lib.i"
  14.     INCLUDE    "games/games.i"
  15.  
  16. CALL    MACRO
  17.     jsr    _LVO\1(a6)
  18.     ENDM
  19.  
  20.     SECTION    "Sprites",CODE
  21.  
  22. ;===========================================================================;
  23. ;                             INITIALISE DEMO
  24. ;===========================================================================;
  25.  
  26. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  27.     move.l    ($4).w,a6
  28.     lea    GMS_Name(pc),a1
  29.     moveq    #$00,d0
  30.     CALL    OpenLibrary
  31.     move.l    d0,GMS_Base
  32.     beq.s    .Error_GMS
  33.  
  34.     move.l    GMS_Base(pc),a6
  35.     sub.l    a0,a0
  36.     CALL    SetUserPrefs
  37.  
  38.     lea    Screen(pc),a0    ;Initialise our screen for use.
  39.     CALL    AddScreen
  40.     tst.l    d0
  41.     bne.s    .Error_Screen
  42.  
  43.     CALL    ShowScreen    ;Show our screen.
  44.  
  45.     lea    SpriteList(pc),a1
  46.     CALL    InitSprite
  47.     tst.l    d0
  48.     bne.s    .Error_Sprites
  49.  
  50.     lea    Circle1(pc),a1
  51.     CALL    UpdateSprite
  52.     lea    Circle3(pc),a1
  53.     CALL    UpdateSprite
  54.     lea    Circle4(pc),a1
  55.     CALL    UpdateSprite
  56.  
  57.     CALL    InitJoyPorts
  58.  
  59.     bsr.s    Main
  60.  
  61.  
  62. .ReturnToDOS
  63.     move.l    GMS_Base(pc),a6
  64.     lea    SpriteList(pc),a1
  65.     CALL    FreeSprite
  66. .Error_Sprites
  67.     lea    Screen(pc),a0
  68.     CALL    DeleteScreen
  69. .Error_Screen
  70.     move.l    GMS_Base(pc),a1
  71.     move.l    ($4).w,a6
  72.     CALL    CloseLibrary
  73. .Error_GMS
  74.     MOVEM.L    (SP)+,A0-A6/D1-D7
  75.     moveq    #$00,d0
  76.     rts
  77.  
  78. ;===========================================================================;
  79. ;                                MAIN LOOP
  80. ;===========================================================================;
  81.  
  82. Main:    lea    Circle2(pc),a1
  83. .loop    moveq    #JPORT1,d0    ;Read from port 1
  84.     CALL    ReadMouse    ;Go get mouse position.
  85.     move.w    d0,d1
  86.     asr.w    #8,d0
  87.     add.w    d0,SPR_XPos(a1)
  88.     ext.w    d1
  89.     add.w    d1,SPR_YPos(a1)
  90.  
  91.     CALL    WaitSVBL    ;Allow screen-switching.
  92.     CALL    UpdateSprite    ;Put Sparkie on the screen.
  93.  
  94.     btst    #MB_LMB,d0
  95.     beq.s    .loop
  96.     rts
  97.  
  98. ;===========================================================================;
  99. ;                                  DATA
  100. ;===========================================================================;
  101.  
  102. GMS_Name:
  103.     dc.b    "games.library",0
  104.     even
  105. GMS_Base:
  106.     dc.l    0
  107.  
  108. SpriteList:
  109.     dc.l    "LIST"
  110.     dc.l    Circle1
  111.     dc.l    Circle2
  112.     dc.l    Circle3
  113.     dc.l    Circle4
  114.     dc.l    LISTEND
  115.  
  116. Circle1    dc.l    SPV1,0    ;Structure version.
  117.     dc.w    0    ;Bank Number 0.
  118.     dc.l    Gfx_Circle1    ;Ptr to graphic.
  119.     dc.w    20,20    ;Beginning X/Y position
  120.     dc.w    0    ;Current frame.
  121.     dc.w    64    ;Width (16/32/64)
  122.     dc.w    64    ;Height
  123.     dc.w    16    ;Amt of colours.
  124.     dc.w    16    ;Colour start in palette.
  125.     dc.w    2    ;Amt of planes.
  126.     dc.w    LORES    ;Resolution.
  127.     dc.w    0    ;PlayField position.
  128.     dc.w    0    ;Special attributes.
  129.  
  130. Circle2    dc.l    SPV1,0    ;Structure version.
  131.     dc.w    2    ;Bank Number 2.
  132.     dc.l    Gfx_Circle2    ;Ptr to graphic.
  133.     dc.w    70,70    ;Beginning X/Y position
  134.     dc.w    0    ;Current frame.
  135.     dc.w    64    ;Width (16/32/64)
  136.     dc.w    64    ;Height
  137.     dc.w    16    ;Amt of colours.
  138.     dc.w    16    ;Colour start in palette.
  139.     dc.w    2    ;Amt of planes.
  140.     dc.w    LORES    ;Resolution
  141.     dc.w    0    ;PlayField position.
  142.     dc.w    0    ;Special attributes.
  143.  
  144. Circle3    dc.l    SPV1,0    ;Structure version.
  145.     dc.w    4    ;Bank Number 4.
  146.     dc.l    Gfx_Circle3    ;Ptr to graphic.
  147.     dc.w    120,120    ;Beginning X/Y position
  148.     dc.w    0    ;Current frame.
  149.     dc.w    64    ;Width (16/32/64)
  150.     dc.w    64    ;Height
  151.     dc.w    16    ;Amt of colours.
  152.     dc.w    16    ;Colour start in palette.
  153.     dc.w    2    ;Amt of planes.
  154.     dc.w    LORES    ;Resolution.
  155.     dc.w    0    ;PlayField position.
  156.     dc.w    0    ;Special attributes.
  157.  
  158. Circle4    dc.l    SPV1,0    ;Structure version.
  159.     dc.w    6    ;Bank Number 4.
  160.     dc.l    Gfx_Circle4    ;Ptr to graphic.
  161.     dc.w    170,170    ;Beginning X/Y position
  162.     dc.w    0    ;Current frame.
  163.     dc.w    64    ;Width (16/32/64)
  164.     dc.w    64    ;Height
  165.     dc.w    16    ;Amt of colours.
  166.     dc.w    16    ;Colour start in palette.
  167.     dc.w    2    ;Amt of planes.
  168.     dc.w    HIRES    ;Screen mode.
  169.     dc.w    0    ;PlayField position.
  170.     dc.w    0    ;Special attributes.
  171.  
  172. AMT_PLANES =    1
  173.  
  174. Screen:    dc.l    GSV1,0
  175.     dc.l    0,0,0    ;Screen Memory 1/2/3.
  176.     dc.l    0    ;Screen link.
  177.     dc.l    .Palette    ;Address of the screen palette.
  178.     dc.l    0    ;Address of a ColourList.
  179.     dc.l    32    ;Amt of colours in the palette.
  180.     dc.w    320,256    ;Screen Width and Height.
  181.     dc.w    0,0,0    ;Picture Widths and Height.
  182.     dc.w    AMT_PLANES    ;Amt_Planes
  183.     dc.w    0,0    ;X/Y screen offset.
  184.     dc.w    0,0    ;X/Y picture offset.
  185.     dc.l    SPRITES|NOSCRBDR    ;Special attributes.
  186.     dc.w    LORES|COL24BIT    ;Screen mode.
  187.     dc.w    INTERLEAVED    ;Screen type
  188.     even
  189.  
  190. .Palette
  191.     dc.l    $000000,$0F0000,$1F0000,$2F0000,$3F0000,$4F0000
  192.     dc.l    $5F0000,$6F0000,$7F0000,$8F0000,$9F0000,$AF0000
  193.     dc.l    $BF0000,$CF0000,$DF0000,$EF0000,$FF0000,$001111
  194.     dc.l    $002222,$003333,$004444,$005555,$006666,$007777
  195.     dc.l    $008888,$009999,$00AAAA,$00BBBB,$00CCCC,$00DDDD
  196.     dc.l    $00EEEE,$00FFFF
  197.  
  198. ;===========================================================================;
  199. ;                         ALL CHIP RAM DATA HERE
  200. ;===========================================================================;
  201.  
  202.     SECTION    "Graphics",DATA_C
  203.  
  204.     CNOP    0,4            ;Sprite must be 64bit aligned.
  205. Gfx_Circle1:
  206.     INCBIN    "GAMESLIB:data/CircleSpr1.raw"
  207.  
  208.     CNOP    0,4            ;Sprite must be 64bit aligned.
  209. Gfx_Circle2:
  210.     INCBIN    "GAMESLIB:data/CircleSpr2.raw"
  211.  
  212.     CNOP    0,4            ;Sprite must be 64bit aligned.
  213. Gfx_Circle3:
  214.     INCBIN    "GAMESLIB:data/CircleSpr3.raw"
  215.  
  216.     CNOP    0,4            ;Sprite must be 64bit aligned.
  217. Gfx_Circle4:
  218.     INCBIN    "GAMESLIB:data/CircleSpr3.raw"
  219.  
  220.  
  221.