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

  1. *******************************************************************************
  2. * ILBM handling and fade in/out example
  3. *******************************************************************************
  4. * INFO    loads a 320x256x8 ILBM to a FullRes screen and then fades it
  5. *    in and out
  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. * 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    =    0    ;min 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    ;display video mode
  41.  
  42. ARGSNO    =    1    ;command line arguments No.
  43.  
  44.  
  45.  
  46. *******************************************************************************
  47. * code start
  48. *******************************************************************************
  49.  
  50.     include    /inc/shl_strtup.i
  51.  
  52.  
  53.  
  54. *******************************************************************************
  55. * init
  56. *******************************************************************************
  57.  
  58. _PrgInit    movea.l    CmdLnArgs,a0    ;picture filename address
  59.     tst.l    a0
  60.     bne.s    .ld    ;if filename specified...
  61.     lea.l    PicFlNm,a0    ;default picture
  62. .ld    movea.l    ([DIAdr.l],TCS_DI_CSAdr.w),a1 ;directly to
  63.     move.l    #SCRWD*SCRHT,d0    ;screen buffer
  64.     CALLTCS    LdILBM    ;load it
  65.     cmpi.l    #TCS_PE_OK,d0    ;success?
  66.     blo.s    .fail    ;if not...
  67.     move.l    d0,PicIIAdr    ;else store its ILBMInfo structure address
  68.     rts        ;& clr ccr.Z to signal success
  69. .fail    move.w    #4,ccr    ;signal error
  70.     rts
  71.  
  72.  
  73.  
  74. *******************************************************************************
  75. * main
  76. *******************************************************************************
  77.  
  78. _PrgMain    movea.l    DIAdr,a2    ;our display
  79.     movea.l    PicIIAdr,a0    ;picture ILBMInfo structure address
  80.     movea.l    (TCS_II_GfxAdr,a0),a1    ;address of picture graphics
  81.     move.b    (TCS_II_RGBxMode,a0),d3    ;picture RGBx mode
  82.  
  83.     movea.l    a2,a0    ;render FullRes screen
  84.     CALLTCS    CPUFRPass0    ;to make pixels visible
  85.  
  86.     moveq.l    #0,d2    ;brightness at beginning (min)
  87. .FadeIn    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  88.     movea.l    a2,a0    ;our display
  89.     move.b    d3,d0    ;RGBx mode
  90.     move.w    d2,d1    ;brightness
  91.     CALLTCS    SetRGBxMode    ;change palette
  92.     addq.w    #1,d2    ;increase brightness
  93.     btst.b    #6,$bfe001
  94.     beq.s    .exit    ;if LMB...
  95.     cmpi.w    #256,d2
  96.     bls.s    .FadeIn    ;repeat other 256 times
  97.  
  98.     move.w    #256,d2    ;brightness at beginning (max)
  99. .FadeOut    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  100.     movea.l    a2,a0    ;our display
  101.     move.b    d3,d0    ;RGBx mode
  102.     move.w    d2,d1    ;brightness
  103.     CALLTCS    SetRGBxMode    ;change palette
  104.     btst.b    #6,$bfe001    ;exit if LMB
  105.     dbeq    d2,.FadeOut    ;decrease brightness and repeat other 256 times
  106. .exit    rts
  107.  
  108.  
  109.  
  110. *******************************************************************************
  111. * cleanup
  112. *******************************************************************************
  113.  
  114. _PrgClnUp    movea.l    PicIIAdr,a0    ;free all the memory
  115.     CALLTCS    UnLdILBM    ;allocated for the picture
  116.     rts
  117.  
  118.  
  119.  
  120. *******************************************************************************
  121. * data
  122. *******************************************************************************
  123.  
  124.     include    /inc/dat.i
  125.  
  126.     cnop    0,4
  127. PicIIAdr    dc.l    0    ;picture ILBMInfo structure address
  128. tmplt    dc.b    "PICTURE=P",0    ;template for ReadArgs()
  129. PicFlNm    dc.b    "/pix/TigerMask.rgbw.iff",0 ;default picture
  130.