home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 563.lha / BlackBorder_v1.0 / BlackBorder.s < prev    next >
Text File  |  1991-10-28  |  7KB  |  261 lines

  1.     opt o-,x-
  2.  
  3.     Incdir    "Include:" 
  4.     Include "Misc/DevPacMacros.i"
  5.     Include "Exec/Exec.i"
  6.     Include "Intuition/Intuition.i"
  7.     Include "Libraries/DOS.i"
  8.     Include "Graphics/Text.i"
  9.     Include "Graphics/GfxBase.i"
  10.     Include    "Graphics/VideoControl.i"
  11.  
  12. ******************************************************************************
  13. *                                         *
  14. *    Written by Peter Kunath and Frank Riffel $Release 1.00/26.08.1991/$     *
  15. *                                         *
  16. ******************************************************************************
  17. *                                         *
  18. *    THIS TOOL REQUIRES KICKSTART 2.0 AND A SUPER DENISE !!!             *
  19. *                                         *
  20. *       BlackBorder patches the  OpenScreen() function under V2.0 and above  *
  21. *       to change the bordercolor of any opend Screen from 0 to black.       *
  22. *       Requires 2.x and a Superdenise.    You should run this Tool imediately  *
  23. *    after IPrefs in your StartUp-Sequence.                     *
  24. *                                         *
  25. *     If you have an A3000 or a A2320 you probably noticed that the first  *
  26. *    line on a de-interlaced screen flickers. This tool makes this ugly   *
  27. *    effect non visible by turning the bordercolor to black.                 *
  28. *                                         *
  29. *    DISCLAIMER                                 *
  30. *                                         *
  31. *    This program is FREELY DISTRIBUTABLE, but COPYRIGHTED. This means    *
  32. *    that you can copy it freely as long as you don't ask for any more    *
  33. *    money than a nominal fee for copying. This program may be put on PD  *
  34. *       disks, especially on Fred Fish's AmigaLibDisks. If you want to       *
  35. *       distribute this program you MUST keep the source code with it.       *
  36. *       Program, document and source code must be distributed in their       *
  37. *       original UNMODIFIED form. Of course you can use an archiver like     *
  38. *       LHarc to make it available on mailboxes and FTP sites. This program  *
  39. *    cannot be used for commercial purposes without written permission    *
  40. *    from the authors. The authors can not be made responsible for any    *
  41. *       damage which is caused by using this program.                 *
  42. *                                         *
  43. ******************************************************************************
  44.  
  45. Begin
  46.     lea dosname(pc),a1            ; Open DOS
  47.     CALLEXEC OldOpenLibrary
  48.     move.l    d0,_DOSBase
  49.     beq    Exit
  50.  
  51.     CALLDOS Output                ; Get Outputhandle
  52.     move.l    d0,_Outhandle
  53.     beq    CloseDOS            ; We give up 
  54.  
  55.     move.l    d0,d1                ; Write Info
  56.     move.l    #Info,d2
  57.     move.l    #InfoEnd-Info,d3
  58.     CALLDOS Write
  59.  
  60.     lea gfxname(pc),a1            ; Open Gfx    
  61.     moveq    #36,d0
  62.     CALLEXEC OpenLibrary
  63.     move.l    d0,_GfxBase
  64.     bne.s    Is_V36                ; We are running under 2.x !
  65.  
  66.     move.l    d0,d1                ; False Kickstart !
  67.     move.l    #FalseKick,d2
  68.     move.l    #FalseKickEnd-FalseKick,d3
  69.     CALLDOS Write
  70.     bra    CloseDOS
  71.  
  72. Is_V36    move.l     d0,a0                ; Is the Superhires denise here?
  73.     btst    #GFXB_HR_DENISE,gb_ChipRevBits0(a0)
  74.     bne.s    OpenInt                ; yes !
  75.  
  76.     move.l    d0,d1                ; No Superdenise !
  77.     move.l    #NoSupDen,d2
  78.     move.l    #NoSupDenEnd-NoSupDen,d3
  79.     CALLDOS Write
  80.  
  81.     move.l    _GfxBase(pc),a1
  82.     CALLEXEC CloseLibrary
  83.     bra CloseDOS
  84.     
  85. OpenInt    lea intname(pc),a1            ; Open Intuition
  86.     CALLEXEC OldOpenLibrary
  87.     move.l d0,_IntuitionBase
  88.     beq    CloseDOS            ; Should *NEVER* occour !!!
  89.  
  90.     move.l    #PatchEnd-Patchcode,d0        ; Alloc Mem 
  91.     move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  92.     CALLEXEC AllocMem
  93.     move.l    d0,d2
  94.     beq    CloseDOS
  95.  
  96.     CALLEXEC Forbid                ; Install patch
  97.  
  98.     move.l    _IntuitionBase(pc),a1        ; OpenWorkbench()
  99.     move.w    #_LVOOpenWorkBench,a0        
  100.     move.l    d2,d0
  101.     CALLEXEC SetFunction
  102.     move.l    d0,_OldFunc
  103.  
  104.     move.l    _IntuitionBase(pc),a1        ; OpenScreen()
  105.     move.w    #_LVOOpenScreen,a0
  106.     move.l    d2,d0
  107.     add.l    #Patchcode1-Patchcode,d0    ; add offset
  108.     CALLEXEC SetFunction
  109.     move.l    d0,_OldFunc1
  110.  
  111.     move.l    _IntuitionBase(pc),a1        ; OpenScreenTagList()
  112.     move.w    #_LVOOpenScreenTagList,a0
  113.     move.l    d2,d0
  114.     add.l    #Patchcode2-Patchcode,d0    ; add offset
  115.     CALLEXEC SetFunction
  116.     move.l    d0,_OldFunc2
  117.  
  118.     move.l    d2,a0                ; Copy the Patchcode
  119.     lea    Patchcode(pc),a1
  120.     move.w    #PatchEnd-Patchcode-1,d0
  121. Copy    move.b    (a1)+,(a0)+
  122.     dbra    d0,Copy
  123.  
  124.     CALLEXEC Permit
  125.     
  126.     CALLINT OpenWorkBench            ; apply patch to wb *NOW*
  127.  
  128.     move.l    _Outhandle(pc),d1        ; Success !
  129.     move.l    #Success,d2
  130.     move.l    #SuccessEnd-Success,d3
  131.     CALLDOS Write
  132.  
  133. CloseDOS
  134.     move.l    _DOSBase(pc),a1
  135.     CALLEXEC CloseLibrary
  136. Exit
  137.     moveq    #0,d0
  138.     rts
  139.  
  140. *-----------------------------------------------------------------------*
  141.  
  142. Patchcode                    ; OpenWorkbench()
  143.     move.l    a2,-(sp)            ; save scratch
  144.     move.l    _OldFunc(pc),a2            ; get old callvector
  145.     jsr    (a2)                ; do the old OpenWorkbench()
  146.  
  147.     movem.l    d1/a0/a1,-(sp)            ; lock WB Screen
  148.     lea    wbname(pc),a0            ; workbench name
  149.     jsr    _LVOLockPubScreen(a6)        ; screen => d0
  150.     movem.l    (sp)+,d1/a0/a1        
  151.  
  152.     bsr.s    Patch                ; apply the patch
  153.  
  154.     movem.l    d0/d1/a0/a1,-(sp)        ; save reg's
  155.     sub.l    a0,a0                ; NULL
  156.     move.l    d0,a1                ; screen
  157.     jsr    _LVOUnlockPubScreen(a6)        ; unlock WB Screen
  158.     movem.l    (sp)+,d0/d1/a0/a1        ; restore reg's
  159.     
  160.     move.l    (sp)+,a2            ; restore scratch
  161.     rts                    ; bye
  162.  
  163.  
  164. Patchcode1                    ; OpenScreen()
  165.     move.l    a2,-(sp)            ; save scratch register
  166.     move.l    _OldFunc1(pc),a2        ; get old routineaddress
  167.     jsr    (a2)                ; jump to old libraryroutine
  168.     bsr.s    Patch                ; do the patch 
  169.     move.l    (sp)+,a2            ; restore reg
  170.     rts                    ; ciao
  171.  
  172. Patchcode2                    ; OpenScreenTagList()
  173.     move.l    a2,-(sp)            ; same as above 
  174.     move.l    _OldFunc2(pc),a2        ; but other Vector
  175.     jsr    (a2)                ; jump to old libraryroutine
  176.     bsr.s    Patch                ; do the patch
  177.     move.l    (sp)+,a2            ; same as above
  178.     rts                    ; bye
  179.  
  180.  
  181. ;
  182. ; this is the actual patch (the routine that does the magic)
  183. ;
  184.  
  185. Patch    move.l    a2,-(sp)            ; this is the actual patch
  186.     move.l    d0,-(sp)            ; in: d0 = screen
  187.     beq.s    PatchExit            ; screen not open !
  188.  
  189.     movem.l d1/a0/a1,-(sp)            ; there should be no need BUT for
  190.                         ; compatibility with shitty Stuff ...
  191.  
  192.     move.l    d0,a2                ; Screen
  193.     lea    sc_ViewPort(a2),a0        ; Viewport
  194.     move.l    vp_ColorMap(a0),a0        ; Colormap
  195.     lea    PatchTags(pc),a1        ; Tag array    
  196.  
  197.     move.l    _GfxBase(pc),a6            ;
  198.     jsr    _LVOVideoControl(a6)        ; set the tags
  199.  
  200.     move.l    a2,a0                ; screen
  201.     move.l    _IntuitionBase(pc),a6        ;
  202.     jsr    _LVOMakeScreen(a6)        ; Re-Make the screen
  203.     jsr    _LVORethinkDisplay(a6)        ; Note: a6 is intlib again
  204.  
  205.     movem.l (sp)+,d1/a0/a1            ; restore registers
  206. PatchExit
  207.     move.l    (sp)+,d0            ; restore register
  208.     move.l    (sp)+,a2            ; restore register
  209.     rts
  210.  
  211. ;
  212. ;    Some data structures
  213. ;
  214.  
  215. _OldFunc    dc.l 0                ; OpenWorkbench()
  216. _OldFunc1    dc.l 0                ; OpenScreen()
  217. _OldFunc2    dc.l 0                ; OpenScreenTagList()
  218. _GfxBase    dc.l 0                ; LibBase
  219. _IntuitionBase    dc.l 0                ; LibBase
  220.  
  221. PatchTags          dc.l VTAG_BORDERBLANK_SET    ; That makes the Magic
  222.         dc.l 1                ; TRUE
  223.         dc.l TAG_DONE            ; End of TAG ARRAY
  224.         dc.l 0                ; ti_Data unused
  225.  
  226. wbname        dc.b 'Workbench',0        ; name of workbench screen    
  227.  
  228. PatchEnd
  229.  
  230. *-----------------------------------------------------------------------*
  231.  
  232. ;
  233. ;    Other datastructures (used only at installtime)
  234. ;
  235.     even
  236.  
  237. _DOSBase    dc.l 0                ; LibBase
  238. _Outhandle    dc.l 0                ; filehandle
  239.  
  240. dosname     DOSNAME                ; Libname's
  241. gfxname     GFXNAME
  242. intname     INTNAME                            
  243.  
  244. ;     some messages for the user
  245.                         
  246. FalseKick
  247.     dc.b    'Requires AmigaOS Release 2.0 or higher',10,0
  248. FalseKickEnd
  249.  
  250. NoSupDen
  251.     dc.b    'Requires a Superdenise',10,0
  252. NoSupDenEnd
  253.  
  254. Success
  255.     dc.b    'Patch installed!',10,0
  256. SuccessEnd
  257.  
  258. Info
  259.     dc.b    27,"[33mBlackBorder V1.0",27,"[31m © 1991 by Frank Riffel & Peter Kunath",10,0
  260. InfoEnd
  261.