home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff396.lha / colorcatch / ColorCatchExe.asm < prev    next >
Assembly Source File  |  1990-10-29  |  2KB  |  96 lines

  1. ;    This is the code created by ColorCatch V1.0
  2. ;    by Preben Nielsen.
  3. ;    Assemble it as case-sensitive.
  4. ;    OPT O+
  5. ;    OPT O1+        ;Tells when a branch could be optimised to short
  6. ;    OPT i+        ;Tells when '#' is probably missing
  7.  
  8.     incdir    "INCLUDE:"
  9.     include "exec/exec_lib.i"
  10.     include "graphics/view.i"
  11.     include "graphics/graphics_lib.i"
  12.     include "intuition/intuition.i"
  13.     include "intuition/intuition_lib.i"
  14.     include "libraries/dos.i"
  15.     include "libraries/dosextens.i"
  16.     include "libraries/dos_lib.i"
  17.  
  18. LoadBase    MACRO
  19.         IFNC        '\1','ExecBase'
  20.         movea.l        \1(PC),A6
  21.         ENDC
  22.         IFC        '\1','ExecBase'
  23.         movea.l        4.W,A6
  24.         ENDC
  25.         ENDM
  26. CallLib        MACRO
  27.         jsr        _LVO\1(A6)
  28.         ENDM
  29. Call        MACRO
  30.         bsr        \1
  31.         ENDM
  32. Push        MACRO
  33.         movem.l        \1,-(SP)
  34.         ENDM
  35. Pop        MACRO
  36.         movem.l        (SP)+,\1
  37.         ENDM
  38.  
  39. ColorExe    Push        D0-D7/A0-A6
  40.         LoadBase    ExecBase
  41.         suba.l        A1,A1
  42.         CallLib        FindTask        ;Find us
  43.         movea.l        D0,A2
  44.         tst.l        pr_CLI(A2)
  45.         bne.S        WBAndCLIStartUp
  46.         lea        pr_MsgPort(A2),A0
  47.         CallLib        WaitPort        ;wait for a message
  48.         lea        pr_MsgPort(A2),A0
  49.         CallLib        GetMsg            ;then get it
  50.         move.l        D0,WBenchMsg        ;save it for later reply
  51. WBAndCLIStartUp    lea        GfxName(PC),A1
  52.         CallLib        OldOpenLibrary
  53.         move.l        D0,GfxBase
  54.         beq.S        Exit
  55.         lea        IntName(PC),A1
  56.         CallLib        OldOpenLibrary
  57.         move.l        D0,IntBase
  58.         beq.S        Exit
  59.  
  60.         move.l        D0,A0
  61.         move.l        ib_FirstScreen(A0),A0    ;IntuitionBase->FirstScreen
  62.         lea        sc_ViewPort(A0),A0    ;Screen.ViewPort
  63.         move.w        Count(PC),D0
  64.         lea        ColorTab(PC),A1
  65.         LoadBase    GfxBase
  66.         CallLib        LoadRGB4        ;Set new colors
  67.  
  68. Exit        LoadBase    ExecBase
  69. FreeInt        move.l        IntBase(PC),D0
  70.         beq.S        FreeGfx
  71.         movea.l        D0,A1
  72.         CallLib        CloseLibrary
  73. FreeGfx        move.l        GfxBase(PC),D0
  74.         beq.S        ReplyWB
  75.         movea.l        D0,A1
  76.         CallLib        CloseLibrary
  77. ReplyWB        move.l        WBenchMsg(PC),D0
  78.         beq.S        AllDone
  79.         CallLib        Forbid
  80.         movea.l        D0,A1
  81.         CallLib        ReplyMsg        ;Reply WBenchMessage if we are started from WB
  82. AllDone        Pop        D0-D7/A0-A6
  83.         moveq        #0,D0
  84.         rts
  85. GfxName        dc.b        'graphics.library',0
  86. IntName        dc.b        'intuition.library',0
  87.         EVEN
  88. Count        dc.w        0
  89. ;This is where ColorCatch stores the colors
  90. ColorTab    dcb.w        32,0
  91. GfxBase        dc.l        0
  92. IntBase        dc.l        0
  93. WBenchMsg    dc.l        0
  94.         END
  95.  
  96.