home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / Blitter / Transparent.s < prev   
Encoding:
Text File  |  1997-02-11  |  6.5 KB  |  274 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Circle Example
  3. ;--------------
  4. ;This an example of 2 circles blitted onto a planar screen at different
  5. ;levels.  Move the green circle over the red circle to get an idea of the
  6. ;effect you can achieve with a planar screen.
  7. ;
  8. ;The screen is double buffered and in hi-res, just to be a bit different
  9. ;from the other demos.  The circles are removed from the screen using the
  10. ;CLEAR mode and a RestoreList.
  11.  
  12.     INCDIR    "INCLUDES:"
  13.     INCLUDE    "exec/exec_lib.i"
  14.     INCLUDE    "games/games_lib.i"
  15.     INCLUDE    "games/games.i"
  16.  
  17. CALL    MACRO
  18.     jsr    _LVO\1(a6)
  19.     ENDM
  20.  
  21.     SECTION    "Circles",CODE
  22.  
  23. ;===========================================================================;
  24. ;                             INITIALISE DEMO
  25. ;===========================================================================;
  26.  
  27. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  28.     move.l    ($4).w,a6
  29.     lea    GMS_Name(pc),a1
  30.     moveq    #$00,d0
  31.     CALL    OpenLibrary
  32.     move.l    d0,GMS_Base
  33.     beq.s    .Error_GMS
  34.  
  35.     move.l    GMS_Base(pc),a6
  36.     sub.l    a0,a0
  37.     CALL    SetUserPrefs
  38.  
  39.     CALL    AllocBlitter
  40.     bne.s    .Error_Blitter
  41.  
  42.     lea    Screen(pc),a0
  43.     CALL    AddScreen
  44.     tst.w    d0
  45.     bne.s    .Error_Screen
  46.  
  47.     lea    BOB_List(pc),a1
  48.     CALL    InitBOB    ;Initialise the BOB.
  49.     tst.w    d0
  50.     bne.s    .Error_BOB
  51.  
  52.     moveq    #2,d0    ;d0 = 2 buffers.
  53.     moveq    #3,d1    ;d1 = 3 BOB Entries.
  54.     CALL    InitRestore
  55.     move.l    d0,RestoreList
  56.     beq.s    .Error_RestoreList
  57.  
  58.     CALL    ShowScreen
  59.  
  60.     CALL    InitJoyPorts
  61.  
  62.     bsr.s    Main
  63.  
  64. .ReturnToDOS
  65.     move.l    GMS_Base(pc),a6
  66.     move.l    RestoreList(pc),d0
  67.     CALL    FreeRestore
  68. .Error_RestoreList
  69.     lea    BOB_List(pc),a1
  70.     CALL    FreeBOB
  71. .Error_BOB
  72.     move.l    GMS_Base(pc),a6
  73.     lea    Screen(pc),a0
  74.     CALL    DeleteScreen
  75. .Error_Screen
  76.     CALL    FreeBlitter
  77. .Error_Blitter
  78.     move.l    GMS_Base(pc),a1
  79.     move.l    ($4).w,a6
  80.     CALL    CloseLibrary
  81. .Error_GMS
  82.     MOVEM.L    (SP)+,A0-A6/D1-D7
  83.     moveq    #$00,d0
  84.     rts
  85.  
  86. ;===========================================================================;
  87. ;                                MAIN LOOP
  88. ;===========================================================================;
  89.  
  90. Main:    moveq    #$00,d7
  91. .loop    lea    BOB_Circle1(pc),a1
  92.     moveq    #JPORT1,d0
  93.     moveq    #JT_ZBXY,d1
  94.     CALL    ReadJoyPort    ;Go get port status.
  95.     move.w    d0,d1
  96.     ext.w    d0
  97.     add.w    d0,BOB_YPos(a1)
  98.     asr.w    #8,d1
  99.     add.w    d1,BOB_XPos(a1)
  100.     btst    #MB_LMB,d0
  101.     bne.s    .done
  102.  
  103.     lea    Screen(pc),a0
  104.     lea    BOB_Circle2(pc),a1
  105.     movem.w    Circle2XV(pc),d0/d1
  106.     bsr.s    MoveBOB
  107.     movem.w    d0/d1,Circle2XV
  108.  
  109.     lea    BOB_Circle3(pc),a1
  110.     movem.w    Circle3XV(pc),d0/d1
  111.     bsr.s    MoveBOB
  112.     movem.w    d0/d1,Circle3XV
  113.  
  114. .draw    lea    Screen(pc),a0
  115.     move.l    RestoreList(pc),a1
  116.     CALL    Restore    ;Clear all buffered BOB's.
  117.  
  118.     lea    BOB_List(pc),a1
  119.     move.l    RestoreList(pc),a2
  120.     move.w    #BUFFER2,d0
  121.     CALL    DrawBOBList    ;Go and draw all circles.
  122.     CALL    WaitSVBL
  123.     CALL    SwapBuffers
  124.     bra.s    .loop
  125. .done    rts
  126.  
  127. ;===========================================================================;
  128. ;                              MOVE A BOB
  129. ;===========================================================================;
  130. ;Function: Moves a BOB, bouncing it across the screen.
  131. ;Requires: a0 = GameScreen
  132. ;       a1 = BOB to move.
  133. ;       d0 = X Velocity
  134. ;       d1 = Y Velocity
  135. ;Returns:  d0 = New X Velocity.
  136. ;       d1 = New Y Velocity.
  137.  
  138. MoveBOB:
  139.     add.w    d0,BOB_XCoord(a1)
  140.     add.w    d1,BOB_YCoord(a1)
  141.  
  142. .ChkLX    tst.w    BOB_XCoord(a1)
  143.     bgt.s    .ChkTY
  144.     neg.w    BOB_XCoord(a1)
  145.     neg.w    d0
  146.  
  147. .ChkTY    tst.w    BOB_YCoord(a1)
  148.     bgt.s    .ChkRX
  149.     neg.w    BOB_YCoord(a1)
  150.     neg.w    d1
  151.  
  152. .ChkRX    move.w    GS_PicWidth(a0),d2
  153.     sub.w    BOB_Width(a1),d2
  154.     cmp.w    BOB_XCoord(a1),d2
  155.     bgt.s    .ChkBY
  156.     move.w    d2,BOB_XCoord(a1)
  157.     neg.w    d0
  158.  
  159. .ChkBY    move.w    GS_PicHeight(a0),d2
  160.     sub.w    BOB_Height(a1),d2
  161.     cmp.w    BOB_YCoord(a1),d2
  162.     bgt.s    .done
  163.     move.w    d2,BOB_YCoord(a1)
  164.     neg.w    d1
  165. .done    rts
  166.  
  167. ;===========================================================================;
  168. ;                                  DATA
  169. ;===========================================================================;
  170.  
  171. Circle2XV: dc.w 3
  172. Circle2YV: dc.w 2
  173. Circle3XV: dc.w -2
  174. Circle3YV: dc.w -4
  175.  
  176. RestoreList:
  177.     dc.l    0
  178.  
  179. GMS_Name:
  180.     dc.b    "games.library",0
  181.     even
  182. GMS_Base:
  183.     dc.l    0
  184.  
  185. AMT_PLANES =    4
  186.  
  187. Screen:    dc.l    "GSV1",0    ;Structure version.
  188.     dc.l    0,0,0    ;Screen memory 1/2/3
  189.     dc.l    0    ;Screen link.
  190.     dc.l    Palette    ;Address of screen palette.
  191.     dc.l    0    ;Address of rasterlist.
  192.     dc.l    8    ;Amount of colours in palette.
  193.     dc.w    640,256    ;Screen Width and Height.
  194.     dc.w    640,640/8,256    ;Picture Width and Height.
  195.     dc.w    AMT_PLANES    ;Amount of planes.
  196.     dc.w    0,0    ;X/Y screen offset.
  197.     dc.w    0,0    ;X/Y picture offset.
  198.     dc.l    DBLBUFFER    ;Special attributes.
  199.     dc.w    HIRES|COL12BIT|LACED    ;Screen Mode.
  200.     dc.w    PLANAR    ;Screen Type
  201.     even
  202.  
  203. Palette    dc.w    $000,$f00,$0f0,$ff0,$00f,$f0f,$0ff,$fff
  204.  
  205. ;---------------------------------------------------------------------------;
  206.  
  207. BOB_List:
  208.     dc.l    "LIST"
  209.     dc.l    BOB_Circle1
  210.     dc.l    BOB_Circle2
  211.     dc.l    BOB_Circle3
  212.     dc.l    LISTEND
  213.  
  214. BOB_Circle1:
  215.     dc.l    BBV1,0    ;Structure version.
  216.     dc.l    CircleGfx,CircleGfx    ;Graphics and Mask data.
  217.     dc.w    0    ;Current frame.
  218.     dc.l    .Frame    ;Pointer to frame list.
  219.     dc.w    96/8    ;Modulo (skip in source) in bytes.
  220.     dc.w    96,96/8,83    ;Width, Width in bytes, Height.
  221.     dc.w    100,40    ;X/Y destination.
  222.     dc.w    0,0    ;Border restriction LeftX,TopY.
  223.     dc.w    0,0    ;Border restrictions RightX,EndY.
  224.     dc.w    1,1    ;1st Plane, Amount of planes.
  225.     dc.l    0    ;Plane Size.
  226.     dc.l    CLIP|MASK|CLEAR|CLRNOMASK    ;Attributes.
  227.     dc.l    0    ;Picture Struct (Bob Origin)
  228. .Frame    dc.w    0,0,0,0
  229.     dc.l    -1
  230.  
  231. BOB_Circle2:
  232.     dc.l    BBV1,0    ;Structure version.
  233.     dc.l    CircleGfx,CircleGfx    ;Graphics and Mask data.
  234.     dc.w    0    ;Current frame.
  235.     dc.l    .Frame    ;Pointer to frame list.
  236.     dc.w    96/8    ;Modulo (skip in source) in bytes.
  237.     dc.w    96,96/8,83    ;Width, Width in bytes, Height.
  238.     dc.w    278,86    ;X/Y destination.
  239.     dc.w    0,0    ;Border restriction LeftX,TopY.
  240.     dc.w    0,0    ;Border restrictions RightX,EndY.
  241.     dc.w    0,1    ;1st Plane, Amount of planes.
  242.     dc.l    0    ;Plane Size, not required.
  243.     dc.l    CLEAR|CLRNOMASK    ;Attributes.
  244.     dc.l    0    ;Picture Struct (Bob Origin)
  245. .Frame    dc.w    0,0,0,0
  246.     dc.l    -1
  247.  
  248. BOB_Circle3:
  249.     dc.l    BBV1,0    ;Structure version.
  250.     dc.l    CircleGfx,CircleGfx    ;Graphics and Mask data.
  251.     dc.w    0    ;Current frame.
  252.     dc.l    .Frame    ;Pointer to frame list.
  253.     dc.w    96/8    ;Modulo (skip in source) in bytes.
  254.     dc.w    96,96/8,83    ;Width, Width in bytes, Height.
  255.     dc.w    450,150    ;X/Y destination.
  256.     dc.w    0,0    ;Border restriction LeftX,TopY.
  257.     dc.w    0,0    ;Border restrictions RightX,EndY.
  258.     dc.w    2,1    ;1st Plane, Amount of planes.
  259.     dc.l    0    ;Plane Size, not required.
  260.     dc.l    CLEAR|CLRNOMASK    ;Attributes.
  261.     dc.l    0    ;Picture Struct (Bob Origin)
  262. .Frame    dc.w    0,0,0,0
  263.     dc.l    -1
  264.  
  265. ;===========================================================================;
  266. ;                         ALL CHIP RAM DATA HERE
  267. ;===========================================================================;
  268.  
  269.     SECTION    "Graphics",DATA_C
  270.  
  271. CircleGfx:
  272.     INCBIN    "GAMESLIB:Data/BOB_Circle.raw"
  273.  
  274.