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

  1. *******************************************************************************
  2. * triple buffering & rotzoom example
  3. *******************************************************************************
  4. * INFO    loads a 512x512x8 ILBM (and another ILBM of the same size as
  5. *    mask, if required) and then rotzooms it in onto a triple
  6. *    buffered FullRes screen
  7. * NOTE    - optionally you can pass as CLI argument the name of another
  8. *      512x512x8 ILBM to load (yours must have the same size and
  9. *      must respect all the restrictions of TCS_LdILBM(), otherwise
  10. *      the program won't execute or the graphics will look bad -
  11. *      not dangerous, anyway!)
  12. *    - LMB to exit anytime
  13. *******************************************************************************
  14.  
  15.     machine    68020
  16.  
  17.     include    INCLUDES:libraries/tcs.i
  18.     include    INCLUDES:libraries/tcs_lib.i
  19.     include    /inc/macros.i
  20.  
  21.  
  22.  
  23. *******************************************************************************
  24. * custom display & other definitions
  25. *******************************************************************************
  26.  
  27. DSPLWD    =    192    ;our TCS display width and
  28. DSPLHT    =    192    ;height (LORES pixels)
  29. SCRWD    =    192    ;TCS screen width and
  30. SCRHT    =    192    ;height (FullRes pixels)
  31. DSPLX0    =    $c1*4    ;display start
  32. DSPLY0    =    $49    ;position (SHRES pixels)
  33. DSPLX1    =    DSPLX0+DSPLWD*4    ;display end
  34. DSPLY1    =    DSPLY0+DSPLHT    ;position (SHRES pixels)
  35. DSPLBRTNS    =    256    ;max brightness
  36. GFXCTXT    =    0    ;graphic context
  37. CWBTM    =    0    ;clipping
  38. CWTOP    =    0    ;window
  39. CWRT    =    0    ;borders
  40. CWLF    =    0    ;coordinates
  41. VDOMODE    =    TCS_VMf_FullRes | TCS_VMf_TriBuf ;display video mode
  42.  
  43. ARGSNO    =    3    ;command line arguments No.
  44.  
  45. ROTSPD    =    1    ;rotation speed
  46. SCLSTP    =    1    ;scale step
  47. ACCDLY    =    5    ;acceleration delay
  48. BRSHWDLOG    =    9    ;brush width = 512
  49. BRSHWD    =    1<<BRSHWDLOG    ;source brush
  50. BRSHHT    =    BRSHWD    ;dimensions
  51. WHEELWD    =    256    ;calculate loops needed
  52. STRTCTR    =    256*WHEELWD/(SCLSTP*DSPLWD) ;to fit wheel on screen
  53. *STRTCTR    =    256    ;counter to stop at scale 1:1
  54.  
  55.  
  56.  
  57. *******************************************************************************
  58. * code start
  59. *******************************************************************************
  60.  
  61.     include    /inc/shl_strtup.i
  62.  
  63.  
  64.  
  65. *******************************************************************************
  66. * init
  67. *******************************************************************************
  68.  
  69. _PrgInit    tst.l    CmdLnArgs+8
  70.     beq.s    .pic    ;if mask not required...
  71.     movea.l    CmdLnArgs+4,a0    ;mask filename address
  72.     tst.l    a0
  73.     bne.s    .LdMsk    ;if filename specified...
  74.     lea.l    MskFlNm,a0    ;default mask
  75. .LdMsk    suba.l    a1,a1    ;to separate buffer
  76.     CALLTCS    LdILBM    ;load it
  77.     cmpi.l    #TCS_PE_OK,d0    ;success?
  78.     blo.s    .fail    ;if not...
  79.     move.l    d0,MskIIAdr    ;else store its ILBMInfo structure address
  80.  
  81.     movea.l    DIAdr,a0    ;our display
  82.     lea.l    DsplDef+TCS_DD_GfxCtxt,a1 ;add masking
  83.     ori.w    #TCS_GCf_msk,(a1)    ;to its
  84.     CALLTCS    SetGfxCtxt    ;Graphic Context
  85.  
  86. .pic    movea.l    CmdLnArgs,a0    ;picture filename address
  87.     tst.l    a0
  88.     bne.s    .LdPic    ;if filename specified...
  89.     lea.l    PicFlNm,a0    ;default picture
  90. .LdPic    suba.l    a1,a1    ;to separate buffer
  91.     CALLTCS    LdILBM    ;load it
  92.     cmpi.l    #TCS_PE_OK,d0    ;success?
  93.     blo.s    .fail    ;if not...
  94.     move.l    d0,PicIIAdr    ;else store its ILBMInfo structure address
  95.  
  96.     movea.l    DIAdr,a0    ;our display
  97.     move.b    (TCS_II_RGBxMode.w,d0.l),d0 ;picture RGBx mode
  98.     move.w    #256,d1    ;max brightness
  99.     CALLTCS    SetRGBxMode    ;set appropriate palette
  100.  
  101.     move.w    #0,ccr    ;OK!
  102.     rts
  103.  
  104. .fail    move.w    #4,ccr    ;signal error
  105.     rts
  106.  
  107.  
  108.  
  109. *******************************************************************************
  110. * main
  111. *******************************************************************************
  112.  
  113. _PrgMain    move.l    #TriBufHndlr,([_VBR.l],$6c.w) ;set level3 autovector
  114.     move.w    #$c020,$dff09a    ;set INTENA.INTEN/VERTB
  115.  
  116.     movea.w    #ROTSPD,a3    ;rotation step
  117.     move.w    #SCLSTP,a5    ;scaling step
  118.  
  119.     movea.l    ([PicIIAdr.l],TCS_II_GfxAdr.w),a2 ;calculate brsh
  120.     adda.l    #((BRSHHT/2)*BRSHWD)+BRSHWD/2,a2 ;centre address
  121.     movea.l    ([MskIIAdr.l],TCS_II_GfxAdr.w),a4 ;calculate mask
  122.     adda.l    #((BRSHHT/2)*BRSHWD)+BRSHWD/2,a4 ;centre address
  123.     move.w    #SCRWD-1,d2    ;bottom-right corner
  124.     move.w    #SCRHT-1,d3    ;of destination area
  125.     move.w    #0,d4    ;start rotation angle
  126.     move.w    #0,d5    ;start scaling factor
  127.     move.w    #BRSHWDLOG,d6    ;brush width logarythm
  128.     move.w    #STRTCTR-1,d7    ;initialize counter
  129.  
  130. .lp    movea.l    DIAdr,a0    ;our display
  131.     movea.l    a2,a1    ;brush centre address
  132.     moveq.l    #0,d0    ;top-left corner
  133.     moveq.l    #0,d1    ;of destination area
  134.     CALLTCS    FastRotZmBrsh    ;rotzoom!
  135.  
  136.     movea.l    DIAdr,a0    ;render FullRes screen
  137.     CALLTCS    CPUFRPass0    ;to make changes visible
  138.  
  139.     movea.l    DIAdr,a0    ;acknowledge screen
  140.     CALLTCS    TriUpd    ;rendering completion
  141.  
  142.     btst.b    #6,$bfe001
  143.     beq.s    .exit    ;if LMB...
  144.  
  145.     add.w    a3,d4    ;new rotation angle
  146.     add.w    a5,d5    ;new scale factor
  147.     dbra    d7,.lp    ;repeat till next change of speed
  148.  
  149.     addq.l    #1,a3    ;increase rotation speed
  150.     suba.l    a5,a5    ;stop zooming
  151.     moveq.l    #ACCDLY-1,d7    ;re-initialize counter
  152.     bra.s    .lp    ;repeat all
  153.  
  154. .exit    rts
  155.  
  156.  
  157.  
  158. *******************************************************************************
  159. * cleanup
  160. *******************************************************************************
  161.  
  162. _PrgClnUp    movea.l    MskIIAdr,a0    ;free all the memory
  163.     CALLTCS    UnLdILBM    ;allocated for mask
  164.     movea.l    PicIIAdr,a0    ;free all the memory
  165.     CALLTCS    UnLdILBM    ;allocated for picture
  166.     rts
  167.  
  168.  
  169.  
  170. *******************************************************************************
  171. * triple buffer handler (level 3 interrupt handler)
  172. *******************************************************************************
  173.  
  174. TriBufHndlr    btst.b    #5,$dff01f
  175.     beq.s    .exit    ;if not INTREQR.VERTB...
  176.     movem.l    d0-d1/a0-a1/a6,-(sp)
  177.  
  178.     movea.l    DIAdr,a0
  179.     CALLTCS    TriSwp    ;swap screen buffers
  180.  
  181.     movem.l    (sp)+,d0-d1/a0-a1/a6
  182. .exit    move.w    #$70,$dff09c    ;clr INTREQ.BLIT/VERTB/COPER
  183.     rte
  184.  
  185.  
  186.  
  187. *******************************************************************************
  188. * data
  189. *******************************************************************************
  190.  
  191.     include    /inc/dat.i
  192.  
  193. PicIIAdr    dc.l    0    ;picture ILBMInfo structure address
  194. MskIIAdr    dc.l    0    ;mask ILBMInfo structure address
  195. tmplt    dc.b    "PICTURE=P,"
  196.     dc.b    "MASK=M,USEMASK=U/S",0    ;template for ReadArgs()
  197. PicFlNm    dc.b    "/pix/wheel.rgbw.iff",0    ;default picture
  198. MskFlNm    dc.b    "/pix/Suppa.rgbs.iff",0    ;default mask
  199.