home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / TCS / demos / cod / DubBuf&HRScrl.s < prev    next >
Encoding:
Text File  |  2000-09-26  |  4.6 KB  |  165 lines

  1. *******************************************************************************
  2. * double buffering and HalfRes scrolling example
  3. *******************************************************************************
  4. * INFO    shows how to scroll a double buffered HalfRes screen
  5. * NOTE    - optionally you can pass as CLI argument the name of the ILBM
  6. *      to load (its palette must be one of those in TCS/pal/ and
  7. *      must respect all the restrictions of TCS_LdILBM(), otherwise
  8. *      the program won't execute; no restriction on size)
  9. *    - LMB to exit anytime
  10. *******************************************************************************
  11.  
  12.     machine    68020
  13.  
  14.     include    INCLUDES:libraries/tcs.i
  15.     include    INCLUDES:libraries/tcs_lib.i
  16.     include    /inc/macros.i
  17.  
  18.  
  19.  
  20. *******************************************************************************
  21. * custom display definitions
  22. *******************************************************************************
  23.  
  24. DSPLWD    =    320    ;our TCS display width and
  25. DSPLHT    =    256    ;height (LORES pixels)
  26. SCRWD    =    656/2    ;TCS screen width and
  27. SCRHT    =    414    ;height (HalfRes pixels)
  28. DSPLX0    =    $81*4    ;display start
  29. DSPLY0    =    $2c    ;position (SHRES pixels)
  30. DSPLX1    =    DSPLX0+DSPLWD*4    ;display end
  31. DSPLY1    =    DSPLY0+DSPLHT    ;position (SHRES pixels)
  32. DSPLBRTNS    =    256    ;max brightness
  33. GFXCTXT    =    0    ;graphic context
  34. CWBTM    =    0    ;clipping
  35. CWTOP    =    0    ;window
  36. CWRT    =    0    ;borders
  37. CWLF    =    0    ;coordinates
  38. VDOMODE    set    TCS_VMf_chqr | TCS_VMf_MskPln
  39. VDOMODE    set    VDOMODE | TCS_VMf_DubBuf | TCS_VMf_HScrl ;display video mode
  40.  
  41. ARGSNO    =    1    ;command line arguments No.
  42.  
  43.  
  44.  
  45. *******************************************************************************
  46. * code start
  47. *******************************************************************************
  48.  
  49.     include    /inc/shl_strtup.i
  50.  
  51.  
  52.  
  53. *******************************************************************************
  54. * init
  55. *******************************************************************************
  56.  
  57. _PrgInit    movea.l    CmdLnArgs,a0    ;picture filename address
  58.     tst.l    a0
  59.     bne.s    .ld    ;if filename specified...
  60.     lea.l    PicFlNm,a0    ;default picture
  61. .ld    suba.l    a1,a1    ;allocate new buffer for data
  62.     CALLTCS    LdILBM    ;load it
  63.     cmpi.l    #TCS_PE_OK,d0    ;success?
  64.     blo.s    .fail    ;if not...
  65.     move.l    d0,PicIIAdr    ;else store its ILBMInfo structure address
  66.     rts        ;& clr ccr.Z to signal success
  67. .fail    move.w    #4,ccr    ;signal error
  68.     rts
  69.  
  70.  
  71.  
  72. *******************************************************************************
  73. * main
  74. *******************************************************************************
  75.  
  76. _PrgMain    movea.l    DIAdr,a4    ;our display
  77.     movea.l    PicIIAdr,a3    ;picture ILBMInfo structure address
  78.  
  79.     movea.l    a4,a0
  80.     move.b    (TCS_II_RGBxMode,a3),d0    ;picture RGBx mode
  81.     move.w    #DSPLBRTNS,d1
  82.     CALLTCS    SetRGBxMode    ;set display palette
  83.  
  84.     movea.l    a4,a0    ;display
  85.     movea.l    (TCS_II_GfxAdr,a3),a1    ;picture graphics address
  86.     lea.l    VtxsAdr,a2
  87.     move.w    (TCS_II_wd,a3),d0    ;picture width
  88.     move.w    d0,d1
  89.     subq.w    #1,d1
  90.     move.w    d1,(4,a2)
  91.     move.w    (TCS_II_ht,a3),d1    ;resize the picture
  92.     subq.w    #1,d1    ;to fit perfectly
  93.     move.w    d1,(6,a2)    ;the chunky screen
  94.     CALLTCS    FitBrshZn0    ;of the display
  95.  
  96.     movea.l    a4,a0    ;update both the
  97.     CALLTCS    EquVdoBufs    ;video buffers
  98.  
  99.     moveq.l    #0,d2    ;x position
  100.     moveq.l    #0,d3    ;y position
  101.     moveq.l    #0,d4    ;direction
  102.     lea.l    shfs,a2    ;shifts address
  103.     lea.l    lmts,a3    ;limits address
  104.     
  105. .scrl    add.w    (a2,d4*4),d2    ;update x position
  106.     add.w    (2,a2,d4*4),d3    ;update y position
  107.     move.w    d2,d0    ;x position
  108.     move.w    d3,d1    ;y position
  109.     movea.l    a4,a0    ;display
  110.     WTRSTLN    DSPLY0+1    ;wait end of VBL
  111.     CALLTCS    SetPlnsPos    ;scroll screen
  112.  
  113.     movea.l    a4,a0    ;swap display
  114.     CALLTCS    DubSwp    ;video buffers
  115.  
  116.     btst.b    #6,$bfe001
  117.     beq.s    .exit    ;exit if LMB
  118.  
  119.     cmp.w    (a3,d4*4),d2    ;check x position
  120.     beq.s    .ChgDrctn    ;if limit reached...
  121.     cmp.w    (2,a3,d4*4),d3    ;check y position
  122.     bne.s    .scrl    ;if limit not reached...
  123. .ChgDrctn    addq.w    #1,d4    ;change direction
  124.     andi.w    #3,d4
  125.     bra.s    .scrl
  126.  
  127. .exit    rts
  128.  
  129.  
  130.  
  131. *******************************************************************************
  132. * cleanup
  133. *******************************************************************************
  134.  
  135. _PrgClnUp    movea.l    PicIIAdr,a0    ;free all the memory
  136.     CALLTCS    UnLdILBM    ;allocated for the picture
  137.     rts
  138.  
  139.  
  140.  
  141. *******************************************************************************
  142. * data
  143. *******************************************************************************
  144.  
  145.     include    /inc/dat.i
  146.  
  147.     cnop    0,4
  148. PicIIAdr    dc.l    0    ;picture ILBMInfo structure address
  149. tmplt    dc.b    "PICTURE=P",0    ;template for ReadArgs()
  150. PicFlNm    dc.b    "/pix/MyWB.rgbm.iff",0    ;default picture
  151.  
  152.     even
  153. VtxsAdr    dc.w    0,0,655,413    ;coordinates for
  154.     dc.w    0,0,SCRWD-1,SCRHT-1    ;picture fitting
  155.  
  156. shfs    dc.w    1,0    ;scrolling
  157.     dc.w    0,1    ;shift values
  158.     dc.w    -1,0
  159.     dc.w    0,-1
  160.  
  161. lmts    dc.w    (SCRWD*2-DSPLWD)*4,-1    ;scrolling
  162.     dc.w    -1,SCRHT-DSPLHT    ;limits
  163.     dc.w    0,-1
  164.     dc.w    -1,0
  165.