home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / Screens / DoubleBuffer.s < prev    next >
Encoding:
Text File  |  1997-01-24  |  2.8 KB  |  122 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Double Buffering
  3. ;----------------
  4. ;This just shows how to double buffer the screen.  You can also try out
  5. ;triple buffering just by changing the DBLBUFFER flag to TPLBUFFER in the
  6. ;GameScreen.
  7.  
  8.     INCDIR    "INCLUDES:"
  9.     INCLUDE    "exec/exec_lib.i"
  10.     INCLUDE    "games/games_lib.i"
  11.     INCLUDE    "games/games.i"
  12.  
  13. CALL    MACRO
  14.     jsr    _LVO\1(a6)
  15.     ENDM
  16.  
  17.     SECTION    "DoubleBuffer",CODE
  18.  
  19. ;===========================================================================;
  20. ;                             INITIALISE DEMO
  21. ;===========================================================================;
  22.  
  23. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  24.     move.l    ($4).w,a6
  25.     lea    GMS_Name(pc),a1
  26.     moveq    #$00,d0
  27.     CALL    OpenLibrary
  28.     move.l    d0,GMS_Base
  29.     beq.s    .Error_GMS
  30.  
  31.     move.l    GMS_Base(pc),a6
  32.     sub.l    a0,a0
  33.     CALL    SetUserPrefs
  34.  
  35.     lea    Screen(pc),a0    ;Add screen for use.
  36.     CALL    AddScreen
  37.     tst.l    d0
  38.     bne.s    .Error_Screen
  39.  
  40.     lea    Picture(pc),a1    ;Load background picture.
  41.     move.l    GS_MemPtr1(a0),PIC_Data(a1)
  42.     CALL    LoadPic
  43.     tst.w    d0
  44.     bne.s    .Error_Picture
  45.  
  46.     move.l    PIC_Palette(a1),GS_Palette(a0)
  47.     CALL    UpdatePalette
  48.  
  49.     CALL    ShowScreen
  50.  
  51.     bsr.s    Main
  52.  
  53. .ReturnToDOS
  54.     move.l    GMS_Base(pc),a6
  55.     lea    Picture(pc),a1
  56.     CALL    FreePic
  57. .Error_Picture
  58.     lea    Screen(pc),a0
  59.     CALL    DeleteScreen    ;Give back screen memory etc.
  60. .Error_Screen
  61.     move.l    GMS_Base(pc),a1
  62.     move.l    ($4).w,a6
  63.     CALL    CloseLibrary
  64. .Error_GMS
  65.     MOVEM.L    (SP)+,A0-A6/D1-D7
  66.     moveq    #$00,d0
  67.     rts
  68.  
  69. ;===========================================================================;
  70. ;                                MAIN LOOP
  71. ;===========================================================================;
  72.  
  73. Main:    CALL    WaitSVBL    ;Nice VBL wait for multi-tasking.
  74.     CALL    SwapBuffers
  75.     moveq    #JPORT1,d0
  76.     moveq    #JT_ZBXY,d1
  77.     CALL    ReadJoyPort
  78.     btst    #MB_LMB,d0
  79.     beq.s    Main
  80.     rts
  81.  
  82. ;===========================================================================;
  83. ;                                  DATA
  84. ;===========================================================================;
  85.  
  86. GMS_Name:
  87.     dc.b    "games.library",0
  88.     even
  89. GMS_Base:
  90.     dc.l    0
  91.  
  92. AMT_PLANES =    5
  93.  
  94. Screen:    dc.l    GSV1,0    ;Structure Version.
  95.     dc.l    0,0,0    ;Screen Memory 1/2/3.
  96.     dc.l    0    ;Screen link.
  97.     dc.l    0    ;Address of screen palette
  98.     dc.l    0    ;Address of rasterlist.
  99.     dc.l    0    ;Amt of colours in palette.
  100.     dc.w    320,256    ;Screen Width and Height.
  101.     dc.w    0,0,0    ;Picture Width, ByteWidth, Height.
  102.     dc.w    AMT_PLANES    ;Amt of planes
  103.     dc.w    0,0    ;X/Y screen offset
  104.     dc.w    0,0    ;X/Y picture offset
  105.     dc.l    DBLBUFFER    ;Special attributes.
  106.     dc.w    LORES|COL12BIT    ;Screen mode.
  107.     dc.w    PLANAR    ;Screen type
  108.     even
  109.  
  110. Picture    dc.l    PCV1,0    ;Version header.
  111.     dc.l    0    ;Source data.
  112.     dc.w    320,320/8,256    ;Width, Height.
  113.     dc.w    AMT_PLANES    ;Amount of Planes.
  114.     dc.l    32    ;Amount of colours.
  115.     dc.l    0    ;Source palette (remap).
  116.     dc.w    LORES|COL12BIT    ;Screen mode.
  117.     dc.w    PLANAR    ;Screen type.
  118.     dc.l    GETPALETTE    ;Parameters.
  119.     dc.l    .File
  120. .File    dc.b    "GAMESLIB:data/IFF.Pic320",0
  121.     even
  122.