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

  1. *******************************************************************************
  2. * double buffering and FullRes scrolling example
  3. *******************************************************************************
  4. * INFO    shows how to scroll a double buffered FullRes 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    ;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    =    TCS_VMf_FullRes | TCS_VMf_DubBuf ;display video mode
  39.  
  40. ARGSNO    =    1    ;command line arguments No.
  41.  
  42.  
  43.  
  44. *******************************************************************************
  45. * code start
  46. *******************************************************************************
  47.  
  48.     include    /inc/shl_strtup.i
  49.  
  50.  
  51.  
  52. *******************************************************************************
  53. * init
  54. *******************************************************************************
  55.  
  56. _PrgInit    movea.l    CmdLnArgs,a0    ;picture filename address
  57.     tst.l    a0
  58.     bne.s    .ld    ;if filename specified...
  59.     lea.l    PicFlNm,a0    ;default picture
  60. .ld    suba.l    a1,a1    ;allocate new buffer for data
  61.     CALLTCS    LdILBM    ;load it
  62.     cmpi.l    #TCS_PE_OK,d0    ;success?
  63.     blo.s    .fail    ;if not...
  64.     move.l    d0,PicIIAdr    ;else store its ILBMInfo structure address
  65.     rts        ;& clr ccr.Z to signal success
  66. .fail    move.w    #4,ccr    ;signal error
  67.     rts
  68.  
  69.  
  70.  
  71. *******************************************************************************
  72. * main
  73. *******************************************************************************
  74.  
  75. _PrgMain    movea.l    DIAdr,a4    ;our display
  76.     movea.l    PicIIAdr,a3    ;picture ILBMInfo structure address
  77.  
  78.     movea.l    a4,a0
  79.     move.b    (TCS_II_RGBxMode,a3),d0    ;picture RGBx mode
  80.     move.w    #DSPLBRTNS,d1
  81.     CALLTCS    SetRGBxMode    ;set display palette
  82.  
  83.     movea.l    a4,a0    ;display
  84.     movea.l    (TCS_II_GfxAdr,a3),a1    ;picture graphics address
  85.     lea.l    VtxsAdr,a2
  86.     move.w    (TCS_II_wd,a3),d0    ;picture width
  87.     move.w    d0,d1
  88.     subq.w    #1,d1
  89.     move.w    d1,(4,a2)
  90.     move.w    (TCS_II_ht,a3),d1    ;resize the picture
  91.     subq.w    #1,d1    ;to fit perfectly
  92.     move.w    d1,(6,a2)    ;the chunky screen
  93.     CALLTCS    FitBrshZn0    ;of the display
  94.  
  95.     movea.l    a4,a0
  96.     moveq.l    #0,d0    ;render the
  97.     moveq.l    #0,d1    ;logical
  98.     CALLTCS    CPUFRPass1    ;video buffer
  99.     movea.l    a4,a0    ;update both the
  100.     CALLTCS    EquVdoBufs    ;video buffers
  101.  
  102.     moveq.l    #0,d2    ;x position
  103.     moveq.l    #0,d3    ;y position
  104.     moveq.l    #0,d4    ;direction
  105.     lea.l    shfs,a2    ;shifts address
  106.     lea.l    lmts,a3    ;limits address
  107.     
  108. .scrl    add.w    (a2,d4*4),d2    ;update x position
  109.     add.w    (2,a2,d4*4),d3    ;update y position
  110.     move.w    d2,d0    ;x position
  111.     move.w    d3,d1    ;y position
  112.     movea.l    a4,a0    ;display
  113.     CALLTCS    CPUFRPass1    ;scroll screen
  114.  
  115.     WTRSTLN    DSPLY1-1    ;wait end of frame
  116.     movea.l    a4,a0    ;swap display
  117.     CALLTCS    DubSwp    ;video buffers
  118.  
  119.     btst.b    #6,$bfe001
  120.     beq.s    .exit    ;exit if LMB
  121.  
  122.     cmp.w    (a3,d4*4),d2    ;check x position
  123.     beq.s    .ChgDrctn    ;if limit reached...
  124.     cmp.w    (2,a3,d4*4),d3    ;check y position
  125.     bne.s    .scrl    ;if limit not reached...
  126. .ChgDrctn    addq.w    #1,d4    ;change direction
  127.     andi.w    #3,d4
  128.     bra.s    .scrl
  129.  
  130. .exit    rts
  131.  
  132.  
  133.  
  134. *******************************************************************************
  135. * cleanup
  136. *******************************************************************************
  137.  
  138. _PrgClnUp    movea.l    PicIIAdr,a0    ;free all the memory
  139.     CALLTCS    UnLdILBM    ;allocated for the picture
  140.     rts
  141.  
  142.  
  143.  
  144. *******************************************************************************
  145. * data
  146. *******************************************************************************
  147.  
  148.     include    /inc/dat.i
  149.  
  150.     cnop    0,4
  151. PicIIAdr    dc.l    0    ;picture ILBMInfo structure address
  152. tmplt    dc.b    "PICTURE=P",0    ;template for ReadArgs()
  153. PicFlNm    dc.b    "/pix/MyWB.rgbm.iff",0    ;default picture
  154.  
  155.     even
  156. VtxsAdr    dc.w    0,0,655,413    ;coordinates for
  157.     dc.w    0,0,SCRWD-1,SCRHT-1    ;picture fitting
  158.  
  159. shfs    dc.w    1,0    ;scrolling
  160.     dc.w    0,1    ;shift values
  161.     dc.w    -1,0
  162.     dc.w    0,-1
  163.  
  164. lmts    dc.w    (SCRWD-DSPLWD),-1    ;scrolling
  165.     dc.w    -1,SCRHT-DSPLHT    ;limits
  166.     dc.w    0,-1
  167.     dc.w    -1,0
  168.