home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff257.lzh / ColorReq / ColorTest.asm < prev    next >
Assembly Source File  |  1989-10-19  |  5KB  |  220 lines

  1. ;==========================================================================
  2. ; An assembly application to demo the use of the dissidents ColorTool.
  3. ; This example code was written by Jeff Glatt and is in the public domain.
  4. ; The actual "color.library" is copyrighted by dissidents software. The
  5. ; color.library may be used by and distributed with any commercial software
  6. ; as long as the library is not modified in any way.
  7.  
  8.     OPTIMON                    ;CAPE directives
  9.     OBJFILE    "rad:ColorTest.o"
  10.     ADDSYM
  11.     SMALLOBJ
  12.  
  13. _LVODoColor equ    -30
  14.  
  15.     XREF    _SysBase
  16.  
  17.     XREF    _LVOOpenLibrary,_LVOCloseLibrary,_LVOOpenWindow,_LVOCloseWindow
  18.     XREF    _LVOWait,_LVOGetMsg,_LVOReplyMsg
  19.     XREF    _LVOOpenScreen,_LVOCloseScreen,_LVODisplayBeep
  20.  
  21.     XDEF    _main
  22. _main:
  23. ;-----Open Graphics. Since this is in ROM, let's assume it will open.
  24. ;      If the user doesn't have at least 1.2, screw him.
  25.         moveq        #33,d0
  26.         lea        GfxName,a1
  27.         movea.l    _SysBase,a6
  28.         jsr        _LVOOpenLibrary(a6)
  29.         move.l    d0,_GfxBase
  30. ;---------Open Intuition---------
  31.         moveq        #33,d0
  32.         lea        IntuiName,a1
  33.         jsr        _LVOOpenLibrary(a6)
  34.         move.l    d0,_IntuitionBase
  35. ;---------Open Color Lib---------
  36.         moveq        #0,d0
  37.         lea        ColorName,a1
  38.         jsr        _LVOOpenLibrary(a6)
  39.         move.l    d0,_ColorBase
  40.         beq        clselibs
  41. ;---------Open screen----------
  42.         lea        newWindowHi,a3
  43.         lea      newScreenHi,a0
  44.         moveq        #4,d2                ;hires depth limit
  45.     ;---If passed an arg from CLI, get the screen resolution
  46.         move.l    4(sp),d0
  47.         subq.l    #1,d0
  48.         beq.s        Hires    ;no arg
  49.         subq.l    #1,d0
  50.         bcs.s        Hires
  51.         movea.l  8(sp),a2
  52.         addq.l    #4,a2
  53.         movea.l    (a2)+,a1
  54.         cmpi.b    #'h',(a1)
  55.         beq.s        nlow
  56.         lea        newWindowLo,a3
  57.         lea        newScreenLo,a0
  58.         moveq        #5,d2
  59.     ;---If another arg, use it as the default depth
  60. nlow    subq.l    #1,d0
  61.         bcs.s        Hires
  62.         movea.l    (a2),a1
  63.         moveq        #0,d0
  64.         move.b    (a1),d0
  65.         subi.b    #'0',d0
  66.         bls.s        Hires
  67.         cmp.b        d2,d0
  68.         bhi.s        Hires
  69.         move.w    d0,8(a0)
  70. Hires    movea.l    _IntuitionBase,a6
  71.         jsr        _LVOOpenScreen(a6)
  72.         move.l    d0,30(a3)
  73.         beq        clsecolor
  74. ;--------Open window on our screen-------
  75.         movea.l    a3,a0
  76.         jsr        _LVOOpenWindow(a6)
  77.         move.l    d0,WindowPtr
  78.         beq        clsescr
  79. ;-------------------set up and do IDCMP loop--------------
  80.         movea.l    d0,a0
  81.         movea.l    86(a0),a2
  82.         moveq        #0,d7
  83.         move.b    15(a2),d1
  84.         bset.l    d1,d7
  85.    ;---Get IntuiMsg
  86. idcmp:
  87.         movea.l    a2,a0
  88.         movea.l    _SysBase,a6
  89.         jsr        _LVOGetMsg(a6)
  90.         move.l    d0,d1
  91.         bne.s        chkmsg
  92.    ;---wait for an IntuiMsg
  93.         move.l    d7,d0
  94.         jsr        _LVOWait(a6)
  95.         bra.s        idcmp
  96.    ;---Get needed fields and reply to msg
  97. chkmsg:
  98.         moveq        #20,d1
  99.         movea.l    d0,a1
  100.         adda.l    d1,a1      ;CLASS field
  101.         move.l    (a1)+,d2
  102.         move.w    (a1)+,d3
  103.         movea.l    d0,a1
  104.         jsr        _LVOReplyMsg(a6)
  105.         bclr.l    #9,d2
  106.         bne.s        close_up
  107.         cmpi.w    #$68,d3
  108.         bne.s        idcmp
  109.         movea.l    30(a3),a1        ;get Screen address
  110.         suba.l    a0,a0                ;use original color table for default gadget
  111.         movea.l    _ColorBase,a6
  112.         jsr        _LVODoColor(a6)
  113.         bpl.s        idcmp                ;must be SAVE (0) or CANCEL (1)
  114.     ;---If negative return value, then an error
  115.         movea.l    30(a3),a0
  116.         movea.l    _IntuitionBase,a6
  117.         jsr        _LVODisplayBeep(a6)
  118.         bra.s        idcmp
  119. close_up:
  120. ;=============== drain the window IDCMP and close it ================
  121.         movea.l    _SysBase,a6
  122.         move.l    WindowPtr,d0
  123.         beq.s        clsescr
  124. empit    movea.l    WindowPtr,a0
  125.         movea.l    86(a0),a0
  126.         jsr        _LVOGetMsg(a6)
  127.         move.l    d0,d1
  128.         beq.s        empty
  129.         movea.l    d0,a1
  130.         jsr        _LVOReplyMsg(a6)
  131.         bra.s        empit
  132. empty    movea.l    WindowPtr,a0
  133.         movea.l    _IntuitionBase,a6
  134.         jsr        _LVOCloseWindow(a6)
  135. ;-------Close the screen--------
  136. clsescr:
  137.         move.l    30(a3),d0
  138.         beq.s        clsecolor
  139.         movea.l    d0,a0
  140.         jsr        _LVOCloseScreen(a6)
  141. ;----------Close libs----------
  142. clsecolor:
  143.         movea.l    _SysBase,a6
  144.         movea.l    _ColorBase,a1
  145.         jsr        _LVOCloseLibrary(a6)
  146. clselibs:
  147.         movea.l    _GfxBase,a1
  148.         jsr        _LVOCloseLibrary(a6)
  149.         movea.l    _IntuitionBase,a1
  150.         jsr        _LVOCloseLibrary(a6)
  151.         moveq        #0,d0
  152.         rts
  153.  
  154. DEPTH        equ 4
  155. HIRES        equ $8000
  156.  
  157. DEPTH2    equ 5
  158. LORES        equ 0
  159.  
  160.     XDEF    _GfxBase,_IntuitionBase,_ColorBase
  161. _GfxBase            dc.l    0
  162. _IntuitionBase    dc.l    0
  163. _ColorBase        dc.l    0
  164.  
  165.     XDEF   newScreenHi
  166. newScreenHi:
  167.     dc.w    0,0,640,200
  168.     dc.w    DEPTH
  169.     dc.b    0,1
  170.     dc.w    HIRES
  171.     dc.w    15                ;CUSTOMSCREEN
  172.     dc.l    TextAttr
  173.     dc.l    ScreenTitle,0,0
  174.  
  175.    XDEF   newWindowHi
  176. newWindowHi:
  177.     dc.w    0,12,640,188
  178.     dc.b    -1,-1
  179.     dc.l    $208
  180.     dc.l    $110F
  181.     dc.l    0,0,WindowTitle
  182.     dc.l    0,0
  183.     dc.w    640,188,640,188
  184.     dc.w    15
  185.  
  186.     XDEF   newScreenLo
  187. newScreenLo:
  188.     dc.w    0,0,320,200
  189.     dc.w    DEPTH2
  190.     dc.b    0,1
  191.     dc.w    LORES
  192.     dc.w    15                ;CUSTOMSCREEN
  193.     dc.l    TextAttr
  194.     dc.l    ScreenTitle,0,0
  195.  
  196.    XDEF   newWindowLo
  197. newWindowLo:
  198.     dc.w    0,12,320,188
  199.     dc.b    -1,-1
  200.     dc.l    $208
  201.     dc.l    $110F
  202.     dc.l    0,0,WindowTitle
  203.     dc.l    0,0
  204.     dc.w    320,188,320,188
  205.     dc.w    15
  206.  
  207.     XDEF    WindowPtr
  208. WindowPtr    dc.l    0
  209.  
  210. TextAttr:
  211.     dc.l    FontName
  212.     dc.w    8,0
  213.  
  214. WindowTitle    dc.b    'Click Close Gadget to Exit',0
  215. ScreenTitle    dc.b    'Color Requester Demo',0
  216. GfxName        dc.b    'graphics.library',0
  217. IntuiName    dc.b    'intuition.library',0
  218. FontName        dc.b    'topaz.font',0
  219. ColorName    dc.b    'color.library',0
  220.