home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / new / amigalibdisks / d991 / prtsc / prtsc.s < prev   
Text File  |  1994-04-04  |  24KB  |  1,146 lines

  1. ;
  2. ; PrintScreen V1.75   Saturday, 12-Mar-1994
  3. ;
  4. ; (c) 1993-1994 by Jan Hagqvist
  5. ;
  6.  
  7. ; Utilizies the PrtSc-key and makes it to
  8. ; create a graphics dump to the printer
  9. ; or save the screen into a file
  10.  
  11.  
  12.   XREF _LVOOpenLibrary
  13.   XREF _LVOCloseLibrary
  14.   XREF _LVOOpenDevice
  15.   XREF _LVOCloseDevice
  16.   XREF _LVODisplayAlert
  17.   XREF _LVOCreateMsgPort
  18.   XREF _LVODeleteMsgPort
  19.   XREF _LVOCreateIORequest
  20.   XREF _LVODeleteIORequest
  21.   XREF _LVOGetVPModeID
  22.   XREF _LVODoIO
  23.   XREF _LVODelay
  24.   XREF _LVOOpenWindow
  25.   XREF _LVOCloseWindow
  26.   XREF _LVOWaitPort
  27.   XREF _LVOGetMsg
  28.   XREF _LVOReplyMsg
  29.   XREF _LVOOpen
  30.   XREF _LVOClose
  31.   XREF _LVOWrite
  32.   XREF _LVORead
  33.   XREF _LVOWait
  34.   XREF _LVOAllocSignal
  35.   XREF _LVOFreeSignal
  36.   XREF _LVOFindTask
  37.   XREF _LVOSignal
  38.   XREF _LVOAddGList
  39.   XREF _LVOCreateContext
  40.   XREF _LVOGetVisualInfoA
  41.   XREF _LVOFreeGadgets
  42.   XREF _LVOFreeVisualInfo
  43.   XREF _LVOCreateGadgetA
  44.   XREF _LVORefreshGList
  45.   XREF _LVOGT_SetGadgetAttrsA
  46.   XREF _LVOScreenToFront
  47.   XREF _LVOSeek
  48.  
  49.  
  50. JAM1                equ 0
  51. WBENCHSCREEN            equ 1
  52. PRD_PRTCOMMAND            equ $a
  53. io_Device            equ 20
  54. io_Unit                equ 24
  55. io_Command            equ 28
  56. io_PrtCommand            equ 32
  57. io_Parm0            equ 34
  58. io_Data                equ 40
  59. is_Pri                equ 9
  60. is_Name                equ 10
  61. is_Data                equ 14
  62. is_Code                equ 18
  63. ie_Class            equ 4
  64. ie_Code                equ 6
  65. ie_Qualifier            equ 8
  66. IND_ADDHANDLER            equ 9
  67. IND_REMHANDLER            equ 10
  68. IECLASS_NULL            equ 0
  69. IECLASS_RAWKEY            equ 1
  70. IEQUALIFIER_LSHIFT        equ 0
  71. IEQUALIFIER_RSHIFT        equ 1
  72. IEQUALIFIER_LALT        equ 4
  73. IEQUALIFIER_RALT        equ 5
  74. pr_MsgPort            equ 92
  75. pr_CLI                equ 172
  76. BUTTON_KIND            equ 1
  77. CHECKBOX_KIND            equ 2
  78. CYCLE_KIND            equ 7
  79. STRING_KIND            equ 12
  80. PLACETEXT_RIGHT            equ $0002
  81. PLACETEXT_IN            equ $0010
  82. IDCMP_GADGETUP            equ $00000040
  83. IDCMP_CLOSEWINDOW        equ $00000200
  84. WFLG_DRAGBAR            equ $00000002
  85. WFLG_DEPTHGADGET        equ $00000004
  86. WFLG_CLOSEGADGET        equ $00000008
  87. WFLG_SIMPLE_REFRESH        equ $00000040
  88. WFLG_ACTIVATE            equ $00001000
  89. WFLG_RMBTRAP            equ $00010000
  90. WFLG_NOCAREREFRESH        equ $00020000
  91. GTCB_Checked            equ $80080004
  92. GTCY_Labels            equ $8008000e
  93. GTCY_Active            equ $8008000f
  94. GTST_String            equ $8008002d
  95. GTST_MaxChars            equ $8008002e
  96. TAG_DONE            equ 0
  97.  
  98.  
  99. PrtSc
  100.   move.l  4,a6
  101.   sub.l   a1,a1
  102.   jsr     _LVOFindTask(a6)
  103.   move.l  d0,MyTask
  104.   move.l  d0,a4
  105.   tst.l   pr_CLI(a4)
  106.   bne.s   NoWorkbench
  107.   lea     pr_MsgPort(a4),a0
  108.   jsr     _LVOWaitPort(a6)            ; Wait for message
  109.   lea     pr_MsgPort(a4),a0
  110.   jsr     _LVOGetMsg(a6)            ; Get it
  111.   move.l  d0,WorkbenchMsg            ; Store it
  112. NoWorkbench
  113.  
  114.   moveq.l #0,d0
  115.   lea     IntuitionName(pc),a1
  116.   jsr     _LVOOpenLibrary(a6)
  117.   move.l  d0,IntuitionBase
  118.   tst.l   d0
  119.   beq     Quit
  120.   moveq.l #36,d0
  121.   lea     GfxName(pc),a1
  122.   jsr     _LVOOpenLibrary(a6)
  123.   move.l  d0,GfxBase
  124.   tst.l   d0
  125.   beq     NoGfx36
  126.   moveq.l #0,d0
  127.   lea     DosName(pc),a1
  128.   jsr     _LVOOpenLibrary(a6)
  129.   move.l  d0,DosBase
  130.   tst.l   d0
  131.   beq     NoDos
  132.   moveq.l #0,d0
  133.   lea     GadToolsName(pc),a1
  134.   jsr     _LVOOpenLibrary(a6)
  135.   move.l  d0,GadToolsBase
  136.   tst.l   d0
  137.   beq     NoGadTools
  138.  
  139.   jsr     _LVOCreateMsgPort(a6)
  140.   move.l  d0,MsgPort
  141.   tst.l   d0
  142.   beq     NoMsgPort
  143.   move.l  d0,a0
  144.   moveq.l #62,d0
  145.   jsr     _LVOCreateIORequest(a6)        ; IODRPReq
  146.   move.l  d0,Request
  147.   tst.l   d0
  148.   beq     NoRequest
  149.   move.l  MsgPort(pc),a0
  150.   moveq.l #38,d0
  151.   jsr     _LVOCreateIORequest(a6)        ; IOPrtCmdReq
  152.   move.l  d0,Request3
  153.   tst.l   d0
  154.   beq     NoRequest
  155.  
  156.   jsr     _LVOCreateMsgPort(a6)
  157.   move.l  d0,MsgPort2
  158.   tst.l   d0
  159.   beq     NoMsgPort
  160.   move.l  d0,a0
  161.   moveq.l #48,d0
  162.   jsr     _LVOCreateIORequest(a6)        ; IOStdReq
  163.   move.l  d0,Request2
  164.   tst.l   d0
  165.   beq     NoRequest
  166.  
  167.   lea     InputName(pc),a0
  168.   move.l  Request2(pc),a1
  169.   moveq.l #0,d0                    ; unit 0
  170.   moveq.l #0,d1
  171.   jsr     _LVOOpenDevice(a6)
  172.   tst.l   d0
  173.   bne     Quit
  174.  
  175.   move.l  4,a6
  176.   moveq.l #-1,d0
  177.   jsr     _LVOAllocSignal(a6)
  178.   move.l  d0,PrintSignal
  179.   cmp.b   #-1,d0
  180.   beq     NoSignal
  181.   moveq.l #-1,d0
  182.   jsr     _LVOAllocSignal(a6)
  183.   move.l  d0,WindowSignal
  184.   cmp.b   #-1,d0
  185.   beq     NoSignal
  186.  
  187.   bsr     LoadConfig                ; Load the configuration!
  188.  
  189.   lea     Interrupt,a0
  190.   move.l  #MyHandler,is_Code(a0)
  191.   move.l  #0,is_Data(a0)
  192.   move.b  #100,is_Pri(a0)
  193.   move.l  #MyHandlerName,is_Name(a0)
  194.  
  195.   move.l  4,a6
  196.   move.l  Request2(pc),a1
  197.   move.l  #Interrupt,io_Data(a1)
  198.   move.w  #IND_ADDHANDLER,io_Command(a1)
  199.   jsr     _LVODoIO(a6)
  200.  
  201.   moveq.l #0,d0
  202.   move.l  PrintSignal(pc),d1
  203.   bset    d1,d0
  204.   move.l  WindowSignal(pc),d1
  205.   bset    d1,d0
  206.   move.l  d0,SignalMask
  207.  
  208.   clr.b   QuitFlag
  209. GetKey
  210.   tst.b   QuitFlag
  211.   bne.s   GetKey4
  212.   move.l  4,a6
  213.   move.l  SignalMask(pc),d0
  214.   jsr     _LVOWait(a6)
  215.   move.l  d0,d7
  216.   move.l  PrintSignal(pc),d1
  217.   btst    d1,d7
  218.   bne.s   GetKey2
  219.   move.l  WindowSignal(pc),d1
  220.   btst    d1,d7
  221.   bne.s   GetKey3
  222.   bra.s   GetKey
  223. GetKey2
  224.   bsr     DoTheDump            ; Shift+PrtSc pressed
  225.   bra.s   GetKey
  226. GetKey3
  227.   bsr     GetFlags            ; Alt+PrtSc pressed
  228.   bra.s   GetKey
  229. GetKey4
  230.  
  231. RemoveHandler
  232.   move.l  4,a6
  233.   move.l  Request2(pc),a1
  234.   move.l  #Interrupt,io_Data(a1)
  235.   move.w  #IND_REMHANDLER,io_Command(a1)
  236.   jsr     _LVODoIO(a6)
  237.  
  238. Quit
  239.   move.l  4,a6
  240.   tst.l   GadToolsBase
  241.   beq.s   Quit12
  242.   move.l  GadToolsBase(pc),a1
  243.   jsr     _LVOCloseLibrary(a6)
  244. Quit12
  245.   cmp.l   #-1,PrintSignal
  246.   beq.s   Quit11
  247.   move.l  PrintSignal(pc),d0
  248.   jsr     _LVOFreeSignal(a6)
  249. Quit11
  250.   cmp.l   #-1,WindowSignal
  251.   beq.s   Quit10
  252.   move.l  WindowSignal(pc),d0
  253.   jsr     _LVOFreeSignal(a6)
  254. Quit10
  255.   tst.l   DosBase
  256.   beq.s   Quit9
  257.   move.l  DosBase(pc),a1
  258.   jsr     _LVOCloseLibrary(a6)
  259. Quit9
  260.   tst.l   Request2
  261.   beq.s   Quit8
  262.   move.l  Request2(pc),a1
  263.   jsr     _LVOCloseDevice(a6)
  264.   move.l  Request2(pc),a0
  265.   jsr     _LVODeleteIORequest(a6)
  266. Quit8
  267.   tst.l   Request3
  268.   beq.s   Quit7
  269.   move.l  Request3(pc),a0
  270.   jsr     _LVODeleteIORequest(a6)
  271. Quit7
  272.   tst.l   MsgPort2
  273.   beq.s   Quit6
  274.   move.l  MsgPort2(pc),a0
  275.   jsr     _LVODeleteMsgPort(a6)
  276. Quit6
  277.   tst.l   Request
  278.   beq.s   Quit5
  279.   move.l  Request(pc),a0
  280.   jsr     _LVODeleteIORequest(a6)
  281. Quit5
  282.   tst.l   MsgPort
  283.   beq.s   Quit4
  284.   move.l  MsgPort(pc),a0
  285.   jsr     _LVODeleteMsgPort(a6)
  286. Quit4
  287.   tst.l   GfxBase
  288.   beq.s   Quit3
  289.   move.l  GfxBase(pc),a1
  290.   jsr     _LVOCloseLibrary(a6)
  291. Quit3
  292.   tst.l   IntuitionBase
  293.   beq.s   Quit2
  294.   move.l  IntuitionBase(pc),a1
  295.   jsr     _LVOCloseLibrary(a6)
  296. Quit2
  297.   tst.l   WorkbenchMsg
  298.   bne.s   WBQuit            ; We were started from WB
  299.   moveq.l #0,d0
  300.   rts                    ; Exit to CLI
  301. WBQuit
  302.   move.l  4,a6
  303.   move.l  WorkbenchMsg(pc),a1
  304.   jsr     _LVOReplyMsg(a6)
  305.   moveq.l #0,d0
  306.   rts                    ; Exit to WB
  307.  
  308.  
  309.  
  310. DoTheDump
  311.   tst.b   SaveFileFlag
  312.   bne     SaveFile
  313.   move.l  4,a6
  314.   lea     PrinterName(pc),a0
  315.   move.l  Request(pc),a1
  316.   moveq.l #0,d0                ; unit 0
  317.   moveq.l #0,d1
  318.   jsr     _LVOOpenDevice(a6)
  319.   tst.l   d0
  320.   bne     DoTheDump3
  321.  
  322.   move.l  Request(pc),a0
  323.   move.l  Request3(pc),a1
  324.   move.l  io_Device(a0),io_Device(a1)        ; Copy device to Request3
  325.   move.l  io_Unit(a0),io_Unit(a1)        ; Copy unit to Request3
  326.  
  327.   tst.b   ResetBeforeFlag
  328.   beq.s   DoTheDump1.1
  329.   bsr     ResetIt
  330. DoTheDump1.1
  331.  
  332.   move.l  IntuitionBase(pc),a5
  333.   move.l  56(a5),a4            ; ActiveScreen
  334.   tst.b   ActiveScreenFlag
  335.   beq.s   DoTheDump1.15
  336.   move.l  60(a5),a4            ; FirstScreen
  337. DoTheDump1.15
  338.   move.l  a4,ActiveScreen
  339.   add.l   #44,a4
  340.   move.l  a4,ActiveVPort
  341.   add.l   #40,a4
  342.   move.l  a4,ActiveRPort
  343.   move.l  GfxBase(pc),a6
  344.   move.l  ActiveVPort(pc),a0
  345.   jsr     _LVOGetVPModeID(a6)
  346.  
  347.   move.l  Request(pc),a5
  348.   move.l  d0,40(a5)            ; io_Modes
  349.   move.l  ActiveRPort(pc),32(a5)    ; io_RastPort
  350.   move.l  ActiveScreen(pc),a4
  351.   move.w  8(a4),44(a5)            ; io_ScrX
  352.   move.w  10(a4),46(a5)            ; io_ScrY
  353.   move.w  12(a4),48(a5)            ; io_ScrWidth
  354.   move.w  12(a4),d0
  355.   swap    d0
  356.   move.l  d0,52(a5)            ; io_DestCols
  357.   move.w  14(a4),50(a5)            ; io_ScrHeight
  358.   move.w  14(a4),d0
  359.   swap    d0
  360.   move.l  d0,56(a5)            ; io_DestRows
  361.   move.l  ActiveVPort(pc),a4
  362.   move.l  4(a4),36(a5)            ; io_ColorMap
  363.   move.w  SpecialFlags,60(a5)        ; io_Special = ASPECT+NOFORMFEED
  364.   move.w  #$b,io_Command(a5)        ; io_Command = PRD_DUMPRPORT
  365.  
  366.   move.l  4,a6
  367.   move.l  a5,a1
  368.   jsr     _LVODoIO(a6)            ; Dump it!
  369.  
  370.   tst.b   ResetAfterFlag
  371.   beq.s   DoTheDump1.2
  372.   bsr     ResetIt
  373. DoTheDump1.2
  374.  
  375.   move.l  Request(pc),a1
  376.   jsr     _LVOCloseDevice(a6)
  377. DoTheDump2
  378.   rts
  379. DoTheDump3
  380.   lea     NoPrinterText(pc),a0
  381.   bsr.s   ShowAlert
  382.   bra.s   DoTheDump2
  383.  
  384.  
  385. NoDos
  386.   lea