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

  1. *******************************************************************************
  2. * triple buffering & zoom example
  3. *******************************************************************************
  4. * INFO    loads a 320x256x8 ILBM and then zooms it in onto a triple
  5. *    buffered FullRes screen
  6. * NOTE    - optionally you can pass as CLI argument the name of another
  7. *      320x256x8 ILBM to load (yours must have the same size and
  8. *      must respect all the restrictions of TCS_LdILBM(), otherwise
  9. *      the program won't execute or the graphics will look bad -
  10. *      not dangerous, anyway!)
  11. *    - LMB to exit anytime
  12. *******************************************************************************
  13.  
  14.     machine    68020
  15.  
  16.     include    INCLUDES:libraries/tcs.i
  17.     include    INCLUDES:libraries/tcs_lib.i
  18.     include    /inc/macros.i
  19.  
  20.  
  21.  
  22. *******************************************************************************
  23. * custom display & other definitions
  24. *******************************************************************************
  25.  
  26. DSPLWD    =    320    ;our TCS display width and
  27. DSPLHT    =    256    ;height (LORES pixels)
  28. SCRWD    =    320    ;TCS screen width and
  29. SCRHT    =    256    ;height (FullRes pixels)
  30. DSPLX0    =    $81*4    ;display start
  31. DSPLY0    =    $2c    ;position (SHRES pixels)
  32. DSPLX1    =    DSPLX0+DSPLWD*4    ;display end
  33. DSPLY1    =    DSPLY0+DSPLHT    ;position (SHRES pixels)
  34. DSPLBRTNS    =    256    ;max brightness
  35. GFXCTXT    =    0    ;graphic context
  36. CWBTM    =    0    ;clipping
  37. CWTOP    =    0    ;window
  38. CWRT    =    0    ;borders
  39. CWLF    =    0    ;coordinates
  40. VDOMODE    =    TCS_VMf_FullRes | TCS_VMf_TriBuf ;display video mode
  41.  
  42. ARGSNO    =    1    ;command line arguments No.
  43.  
  44. STP    =    2    ;zoom step (multiple of 2)
  45. BRSHWD    =    DSPLWD    ;source brush has the
  46. BRSHHT    =    DSPLHT    ;same dimensions of display
  47.     ifgt    SCRWD-SCRHT
  48. DF    =    SCRHT/2
  49.     else
  50. DF    =    SCRWD/2
  51.     endif
  52. LPS    =    DF/STP    ;numbers of loops to perform
  53.  
  54.  
  55.  
  56. *******************************************************************************
  57. * code start
  58. *******************************************************************************
  59.  
  60.     include    /inc/shl_strtup.i
  61.  
  62.  
  63.  
  64. *******************************************************************************
  65. * init
  66. *******************************************************************************
  67.  
  68. _PrgInit    movea.l    CmdLnArgs,a0    ;picture filename address
  69.     tst.l    a0
  70.     bne.s    .ld    ;if filename specified...
  71.     lea.l    PicFlNm,a0    ;default picture
  72. .ld    suba.l    a1,a1    ;to separate buffer
  73.     CALLTCS    LdILBM    ;load it
  74.     cmpi.l    #TCS_PE_OK,d0    ;success?
  75.     blo.s    .fail    ;if not...
  76.     move.l    d0,PicIIAdr    ;else store its ILBMInfo structure address
  77.  
  78.     movea.l    DIAdr,a0    ;our display
  79.     move.b    (TCS_II_RGBxMode.w,d0.l),d0 ;picture RGBx mode
  80.     move.w    #256,d1    ;max brightness
  81.     CALLTCS    SetRGBxMode    ;set appropriate palette
  82.  
  83.     move.w    #0,ccr    ;OK!
  84.     rts
  85.  
  86. .fail    move.w    #4,ccr    ;signal error
  87.     rts
  88.  
  89.  
  90.  
  91. *******************************************************************************
  92. * main
  93. *******************************************************************************
  94.  
  95. _PrgMain    move.l    #TriBufHndlr,([_VBR.l],$6c.w) ;set level3 autovector
  96.     move.w    #$c020,$dff09a    ;set INTENA.INTEN/VERTB
  97.  
  98.     movea.l    ([PicIIAdr.l],TCS_II_GfxAdr.w),a3 ;brush address
  99.     lea.l    ZmStrc,a2    ;info about the zoom areas
  100.     move.w    #LPS-1,d6    ;loops counter
  101.  
  102. .lp    subq.w    #STP,(8,a2)    ;enlarge
  103.     subq.w    #STP,(10,a2)    ;the destination
  104.     addq.w    #STP,(12,a2)    ;area
  105.     addq.w    #STP,(14,a2)    ;on the screen
  106.  
  107.     movea.l    DIAdr,a0    ;our display
  108.     movea.l    a3,a1    ;brush address
  109.     move.w    #BRSHWD,d0    ;brush width
  110.     CALLTCS    FastFitBrshZn0    ;zoom in!
  111.  
  112.     movea.l    DIAdr,a0    ;render FullRes
  113.     move.w    (8,a2),d0    ;screen to make
  114.     move.w    (10,a2),d1    ;changes visible
  115.     move.w    (12,a2),d2    ;(for speed-up,
  116.     move.w    (14,a2),d3    ;only the area
  117.     move.w    d0,d4    ;written by
  118.     move.w    d1,d5    ;FastFitBrshZn0()
  119.     CALLTCS    CPUFRPass2    ;is updated)
  120.  
  121.     movea.l    DIAdr,a0    ;acknowledge screen
  122.     CALLTCS    TriUpd    ;rendering completion
  123.  
  124.     btst.b    #6,$bfe001
  125.     dbeq.s    d6,.lp    ;if not LMB...
  126.  
  127.     WTLMB
  128.     rts
  129.  
  130.  
  131.  
  132. *******************************************************************************
  133. * cleanup
  134. *******************************************************************************
  135.  
  136. _PrgClnUp    movea.l    PicIIAdr,a0    ;free all the memory
  137.     CALLTCS    UnLdILBM    ;allocated for the picture
  138.     rts
  139.  
  140.  
  141.  
  142. *******************************************************************************
  143. * triple buffer handler (level 3 interrupt handler)
  144. *******************************************************************************
  145.  
  146. TriBufHndlr    btst.b    #5,$dff01f
  147.     beq.s    .exit    ;if not INTREQR.VERTB...
  148.     movem.l    d0-d1/a0-a1/a6,-(sp)
  149.  
  150.     movea.l    DIAdr,a0
  151.     CALLTCS    TriSwp    ;swap screen buffers
  152.  
  153.     movem.l    (sp)+,d0-d1/a0-a1/a6
  154. .exit    move.w    #$70,$dff09c    ;clr INTREQ.BLIT/VERTB/COPER
  155.     rte
  156.  
  157.  
  158.  
  159. *******************************************************************************
  160. * data
  161. *******************************************************************************
  162.  
  163.     include    /inc/dat.i
  164.  
  165.     cnop    0,4
  166. ZmStrc    dc.w    0,0    ;source
  167.     dc.w    BRSHWD-1,BRSHHT-1    ;area
  168.     dc.w    DF,DF    ;destination
  169.     dc.w    SCRWD-DF-1,SCRHT-DF-1    ;area
  170.  
  171. PicIIAdr    dc.l    0    ;picture ILBMInfo structure address
  172. tmplt    dc.b    "PICTURE=P",0    ;template for ReadArgs()
  173. PicFlNm    dc.b    "/pix/TigerMask.rgb332.iff",0 ;default picture
  174.