home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d991 / prtsc.lha / PrtSc / PrtSc.s < prev   
Text File  |  1994-04-05  |  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     NoDosText(pc),a0
  387.   bra.s   OpenAlert
  388.  
  389. NoRequest
  390.   lea     NoRequestText(pc),a0
  391.   bra.s   OpenAlert
  392.  
  393. NoMsgPort
  394.   lea     NoMsgPortText(pc),a0
  395.   bra.s   OpenAlert
  396.  
  397. NoGfx36
  398.   lea     NoGfx36Text(pc),a0
  399.   bra.s   OpenAlert
  400.  
  401. NoSignal
  402.   lea     NoSignalText(pc),a0
  403.   bra.s   OpenAlert
  404.  
  405. NoGadTools
  406.   lea     NoGadToolsText(pc),a0
  407. ;  bra.s   OpenAlert
  408.  
  409. OpenAlert
  410.   move.l  IntuitionBase(pc),a6
  411.   moveq.l #0,d0
  412.   moveq.l #24,d1
  413.   jsr     _LVODisplayAlert(a6)
  414.   bra     Quit
  415.  
  416. ShowAlert
  417.   move.l  IntuitionBase(pc),a6
  418.   moveq.l #0,d0
  419.   moveq.l #24,d1
  420.   jsr     _LVODisplayAlert(a6)
  421.   rts
  422.  
  423. NoWindow
  424.   lea     NoWindowText(pc),a0
  425.   bsr.s   ShowAlert
  426.   move.b  #1,QuitFlag
  427.   rts
  428.  
  429.  
  430. GetFlags
  431.   move.l  IntuitionBase(pc),a6
  432.   lea     NewWindow(pc),a0
  433.   move.l  PreviousPlace(pc),(a0)
  434.   jsr     _LVOOpenWindow(a6)
  435.   move.l  d0,MyWindow
  436.   tst.l   d0
  437.   beq.s   NoWindow
  438.  
  439.   move.l  60(a6),-(sp)                ; Store FirstScreen
  440.  
  441.   move.l  d0,a0
  442.   move.l  86(a0),MyUserPort
  443.   move.l  GadToolsBase(pc),a6
  444.   move.l  46(a0),a5
  445.   move.l  a5,a0
  446.   sub.l   a1,a1
  447.   jsr     _LVOGetVisualInfoA(a6)
  448.   move.l  d0,VisualInfo
  449.  
  450.   bsr     CreateGadgets
  451.  
  452.   move.l  IntuitionBase(pc),a6
  453.   move.l  a5,a0
  454.   jsr     _LVOScreenToFront(a6)
  455.  
  456. WaitForMessage
  457.   tst.b   QuitFlag
  458.   bne     GetFlags2
  459.  
  460.   move.l  4,a6
  461.   move.l  MyUserPort(pc),a0
  462.   jsr     _LVOWaitPort(a6)
  463. WaitForMessage2
  464.   move.l  4,a6
  465.   move.l  MyUserPort(pc),a0
  466.   jsr     _LVOGetMsg(a6)
  467.   tst.l   d0
  468.   beq.s   WaitForMessage
  469.   move.l  d0,a1
  470.   move.l  20(a1),Class
  471.   move.w  24(a1),Code
  472.   move.w  26(a1),Qualifier
  473.   move.l  28(a1),IAddress
  474.   jsr     _LVOReplyMsg(a6)
  475.   cmp.l   #IDCMP_CLOSEWINDOW,Class
  476.   bne.s   WaitForMessage3
  477.   bra.s   GetFlags2
  478. WaitForMessage3
  479.   cmp.l   #IDCMP_GADGETUP,Class
  480.   bne.s   WaitForMessage4
  481.   move.l  IAddress(pc),a1
  482.   move.l  a1,a0
  483.   tst.l   40(a0)
  484.   beq.s   WaitForMessage4
  485.   move.l  IntuitionBase(pc),a6
  486.   move.l  40(a0),a0
  487.   jsr     (a0)
  488. WaitForMessage4
  489.   bra     WaitForMessage2
  490. GetFlags2
  491.   move.l  IntuitionBase(pc),a6
  492.   move.l  MyWindow(pc),a0
  493.   move.l  4(a0),PreviousPlace
  494.   jsr     _LVOCloseWindow(a6)
  495.   move.l  (sp)+,a0
  496.   jsr     _LVOScreenToFront(a6)
  497.  
  498.   move.l  GadToolsBase(pc),a6
  499.   move.l  GList(pc),a0
  500.   jsr     _LVOFreeGadgets(a6)
  501.   move.l  VisualInfo(pc),a0
  502.   jsr     _LVOFreeVisualInfo(a6)
  503.   rts
  504.  
  505.  
  506. SetQuitFlag
  507.   move.b  #1,QuitFlag
  508.   rts
  509.  
  510. SaveConfig
  511.   move.l  DosBase(pc),a6
  512.   move.l  #ConfigFile,d1
  513.   move.l  #1006,d2
  514.   jsr     _LVOOpen(a6)
  515.   move.l  d0,d7
  516.   tst.l   d0
  517.   beq.s   SaveConfig2
  518.  
  519.   move.l  d7,d1
  520.   move.l  #SpecialFlags,d2
  521. ;  moveq.l #6,d3
  522.   moveq.l #5,d3
  523.   jsr     _LVOWrite(a6)
  524.  
  525.   move.l  d7,d1
  526.   jsr     _LVOClose(a6)
  527. SaveConfig2
  528.   rts
  529.  
  530. LoadConfig
  531.   move.l  DosBase(pc),a6
  532.   move.l  #ConfigFile,d1
  533.   move.l  #1005,d2
  534.   jsr     _LVOOpen(a6)
  535.   move.l  d0,d7
  536.   tst.l   d0
  537.   beq.s   LoadConfig2
  538.  
  539.   move.l  d7,d1
  540.   move.l  #SpecialFlags,d2
  541. ;  moveq.l #6,d3
  542.   moveq.l #5,d3
  543.   jsr     _LVORead(a6)
  544.  
  545.   move.l  d7,d1
  546.   jsr     _LVOClose(a6)
  547. LoadConfig2
  548.   rts
  549.  
  550.  
  551. CreateGadgets
  552.   move.l  GadToolsBase(pc),a6
  553.   lea     GList(pc),a0
  554.   move.l  #0,(a0)
  555.   jsr     _LVOCreateContext(a6)
  556.   move.l  d0,LastGadget
  557.  
  558.   lea     SelectedTags(pc),a4
  559.   sub.l   a2,a2
  560.   tst.b   ResetBeforeFlag
  561.   beq.s   CreateGadgets1.2
  562.   move.l  a4,a2
  563. CreateGadgets1.2
  564.   lea     ResetBeforeGadget(pc),a1
  565.   bsr     CreateGadgets2
  566.   sub.l   a2,a2
  567.   tst.b   ResetAfterFlag
  568.   beq.s   CreateGadgets1.3
  569.   move.l  a4,a2
  570. CreateGadgets1.3
  571.   lea     ResetAfterGadget(pc),a1
  572.   bsr     CreateGadgets2
  573.   move.w  SpecialFlags(pc),d4
  574.   sub.l   a2,a2
  575.   move.w  d4,d0
  576.   and.w   #$0080,d0
  577.   beq.s   CreateGadgets1.4
  578.   move.l  a4,a2
  579. CreateGadgets1.4
  580.   lea     AspectGadget(pc),a1
  581.   bsr     CreateGadgets2
  582.   sub.l   a2,a2
  583.   move.w  d4,d0
  584.   and.w   #$0040,d0
  585.   beq.s   CreateGadgets1.5
  586.   move.l  a4,a2
  587. CreateGadgets1.5
  588.   lea     CenterGadget(pc),a1
  589.   bsr     CreateGadgets2
  590.   sub.l   a2,a2
  591.   move.w  d4,d0
  592.   and.w   #$0800,d0
  593.   beq.s   CreateGadgets1.6
  594.   move.l  a4,a2
  595. CreateGadgets1.6
  596.   lea     NoFormFeedGadget(pc),a1
  597.   bsr     CreateGadgets2
  598.   sub.l   a2,a2
  599.   move.w  d4,d0
  600.   and.w   #$0004,d0
  601.   beq.s   CreateGadgets1.7
  602.   move.l  a4,a2
  603. CreateGadgets1.7
  604.   lea     FullColumnsGadget(pc),a1
  605.   bsr     CreateGadgets2
  606.   sub.l   a2,a2
  607.   move.w  d4,d0
  608.   and.w   #$0008,d0
  609.   beq.s   CreateGadgets1.8
  610.   move.l  a4,a2
  611. CreateGadgets1.8
  612.   lea     FullRowsGadget(pc),a1
  613.   bsr     CreateGadgets2
  614.  
  615.   lea     ActiveScreenTags(pc),a2
  616.   move.b  ActiveScreenFlag(pc),7(a2)
  617.   moveq.l #CYCLE_KIND,d0
  618.   lea     ActiveScreenGadget(pc),a1
  619.   bsr     CreateGadgets2.2
  620.   lea     SaveFileTags(pc),a2
  621.   move.b  SaveFileFlag(pc),7(a2)
  622.   moveq.l #CYCLE_KIND,d0
  623.   lea     SaveFileGadget(pc),a1
  624.   bsr     CreateGadgets2.2
  625.   moveq.l #BUTTON_KIND,d0
  626.   lea     SaveGadget(pc),a1
  627.   sub.l   a2,a2
  628.   bsr     CreateGadgets2.2
  629.   moveq.l #BUTTON_KIND,d0
  630.   lea     QuitGadget(pc),a1
  631.   sub.l   a2,a2
  632.   bsr     CreateGadgets2.2
  633.   moveq.l #STRING_KIND,d0
  634.   lea     FileNameGadget(pc),a1
  635.   lea     FileNameTags(pc),a2
  636.   bsr     CreateGadgets2.2
  637.   move.l  d0,FileNameGadgetBase
  638.  
  639.   move.l  IntuitionBase(pc),a6
  640.   move.l  MyWindow(pc),a0
  641.   move.l  GList(pc),a1
  642.   moveq.l #-1,d0
  643.   moveq.l #-1,d1
  644.   sub.l   a2,a2
  645.   jsr     _LVOAddGList(a6)
  646.   bsr     RefreshGadgets
  647.   rts
  648.  
  649.  
  650. CreateGadgets2
  651.   moveq.l #CHECKBOX_KIND,d0
  652. CreateGadgets2.2
  653.   move.l  VisualInfo(pc),22(a1)
  654.   move.l  LastGadget(pc),a0
  655.   jsr     _LVOCreateGadgetA(a6)
  656.   move.l  d0,LastGadget
  657.   rts
  658.  
  659.  
  660. ResetBefore
  661.   bchg    #0,ResetBeforeFlag
  662.   rts
  663.  
  664. ResetAfter
  665.   bchg    #0,ResetAfterFlag
  666.   rts
  667.  
  668. SetScreenFlag
  669.   bchg    #0,ActiveScreenFlag
  670.   move.l  GadToolsBase(pc),a6
  671.   move.l  a1,a0
  672.   move.l  MyWindow(pc),a1
  673.   sub.l   a2,a2
  674.   lea     ActiveScreenTags(pc),a3
  675.   move.b  ActiveScreenFlag(pc),7(a3)
  676.   jsr     _LVOGT_SetGadgetAttrsA(a6)
  677.   bsr     RefreshGadgets
  678.   rts
  679.  
  680. SetSaveFileFlag
  681.   bchg    #0,SaveFileFlag
  682.   move.l  GadToolsBase(pc),a6
  683.   move.l  a1,a0
  684.   move.l  MyWindow(pc),a1
  685.   sub.l   a2,a2
  686.   lea     SaveFileTags(pc),a3
  687.   move.b  SaveFileFlag(pc),7(a3)
  688.   jsr     _LVOGT_SetGadgetAttrsA(a6)
  689.   bsr     RefreshGadgets
  690.   rts
  691.  
  692. SetAspectFlag
  693.   bchg    #7,SpecialFlags2
  694.   rts
  695.  
  696. SetCenterFlag
  697.   bchg    #6,SpecialFlags2
  698.   rts
  699.  
  700. SetNoFormFeedFlag
  701.   bchg    #3,SpecialFlags
  702.   rts
  703.  
  704. SetFullColumnsFlag
  705.   bchg    #2,SpecialFlags2
  706.   rts
  707.  
  708. SetFullRowsFlag
  709.   bchg    #3,SpecialFlags2
  710.   rts
  711.  
  712. ResetIt                ; Reset the printer
  713.   move.l  Request3(pc),a1
  714.   move.w  #PRD_PRTCOMMAND,io_Command(a1)
  715.   move.w  #0,io_PrtCommand(a1)
  716.   move.l  #0,io_Parm0(a1)
  717.   jsr     _LVODoIO(a6)
  718.   rts
  719.  
  720.  
  721. RefreshGadgets
  722.   movem.l a0-a2/a6/d0-d1,-(sp)
  723.   move.l  IntuitionBase(pc),a6
  724.   move.l  GList(pc),a0
  725.   move.l  MyWindow(pc),a1
  726.   move.l  #0,a2
  727.   move.l  #-1,d0
  728.   jsr     _LVORefreshGList(a6)
  729.   movem.l (sp)+,a0-a2/a6/d0-d1
  730.   rts
  731.  
  732.  
  733.  
  734. MyHandler            ; The handler itself
  735.   move.l  a0,-(sp)            ; Store event list
  736. CheckLoop
  737.   cmp.b   #IECLASS_RAWKEY,ie_Class(a0)    ; Is this a key event?
  738.   bne.s   CheckNext            ; No, get the next event
  739.   cmp.w   #$5d,ie_Code(a0)        ; NumPad '*' pressed?
  740.   bne.s   CheckNext            ; No, get the next event
  741.   move.w  ie_Qualifier(a0),d0        ; Get the qualifiers
  742.   btst    #IEQUALIFIER_LSHIFT,d0    ; Left Shift?
  743.   bne.s   SendPrintSignal        ; Yes
  744.   btst    #IEQUALIFIER_RSHIFT,d0    ; Right Shift?
  745.   bne.s   SendPrintSignal        ; Yes
  746.   btst    #IEQUALIFIER_LALT,d0        ; Left Alt?
  747.   bne.s   SendWindowSignal        ; Yes
  748.   btst    #IEQUALIFIER_RALT,d0        ; Right Alt?
  749.   bne.s   SendWindowSignal        ; Yes
  750.   bra.s   CheckNext
  751. EatIt
  752.   move.b  #IECLASS_NULL,ie_Class(a0)    ; Nobody knows anything about any key event...
  753. CheckNext
  754.   move.l  (a0),d0            ; Get next event
  755.   move.l  d0,a0                ; Into a0
  756.   bne.s   CheckLoop            ; If there is a next one, check it
  757.  
  758.   move.l  (sp)+,d0            ; Restore event list
  759.   rts
  760. SendPrintSignal
  761.   movem.l d0-d1/a0-a1/a6,-(sp)
  762.   move.l  4,a6
  763.   moveq.l #0,d0
  764.   move.l  PrintSignal(pc),d1
  765.   bset    d1,d0
  766.   move.l  MyTask(pc),a1
  767.   jsr     _LVOSignal(a6)
  768.   movem.l (sp)+,d0-d1/a0-a1/a6
  769.   bra.s   EatIt
  770. SendWindowSignal
  771.   movem.l d0-d1/a0-a1/a6,-(sp)
  772.   move.l  4,a6
  773.   moveq.l #0,d0
  774.   move.l  WindowSignal(pc),d1
  775.   bset    d1,d0
  776.   move.l  MyTask(pc),a1
  777.   jsr     _LVOSignal(a6)
  778.   movem.l (sp)+,d0-d1/a0-a1/a6
  779.   bra.s   EatIt
  780.  
  781.  
  782.  
  783. SaveFile
  784.   move.l  IntuitionBase(pc),a5
  785.   move.l  56(a5),a4            ; ActiveScreen
  786.   tst.b   ActiveScreenFlag
  787.   beq.s   SaveFile2
  788.   move.l  60(a5),a4            ; FirstScreen
  789. SaveFile2
  790.   move.l  a4,ActiveScreen
  791.   add.l   #44,a4
  792.   move.l  a4,ActiveVPort
  793.  
  794.   move.l  ActiveScreen(pc),a0
  795.   move.w  12(a0),ScreenWidth
  796.   move.w  14(a0),ScreenHeight
  797.   lea     184(a0),a0            ; BitMap
  798.   move.w  (a0),d0            ; BytesPerRow
  799.   asl.w   #3,d0                ; =>Pixels
  800.   move.w  d0,PicWidth
  801.   move.w  2(a0),PicHeight
  802.   move.b  5(a0),ScreenDepth
  803.  
  804.   move.l  DosBase(pc),a6
  805.   move.l  #FileName,d1
  806.   move.l  #1006,d2
  807.   jsr     _LVOOpen(a6)
  808.   move.l  d0,d7
  809.   tst.l   d0
  810.   beq     SaveFile3
  811.  
  812.   move.l  d7,d1
  813.   move.l  #FileHeader,d2
  814.   moveq.l #44,d3
  815.   jsr     _LVOWrite(a6)
  816.  
  817.   moveq.l #2,d4
  818.   move.b  ScreenDepth(pc),d3
  819.   sub.b   #1,d3
  820.   asl.l   d3,d4
  821.   move.l  d4,d5
  822.   subq.l  #1,d5
  823.   mulu    #3,d4
  824.   move.l  d4,Buffer
  825.   bsr     WriteBuffer
  826.   lea     Buffer(pc),a4
  827.   move.l  ActiveVPort(pc),a3
  828.   move.l  4(a3),a3            ; ColorMap
  829.   move.l  4(a3),a3            ; ColorTable
  830. SaveFile4
  831.   move.b  (a3)+,d0
  832.   asl.b   #4,d0
  833.   move.b  (a3)+,d1
  834.   move.b  d1,d2
  835.   and.b   #$F0,d1
  836.   asl.b   #4,d2
  837.   move.b  d0,(a4)            ; Store R
  838.   move.b  d1,1(a4)            ; Store G
  839.   move.b  d2,2(a4)            ; Store B
  840.   move.l  d7,d1
  841.   move.l  a4,d2
  842.   moveq.l #3,d3                ; Save 'em
  843.   jsr     _LVOWrite(a6)
  844.   dbf     d5,SaveFile4
  845.  
  846.   move.l  #'CAMG',Buffer
  847.   bsr     WriteBuffer
  848.   move.l  #4,Buffer
  849.   bsr     WriteBuffer
  850.   move.l  GfxBase(pc),a6
  851.   move.l  ActiveVPort(pc),a0
  852.   jsr     _LVOGetVPModeID(a6)
  853.   move.l  d0,Buffer
  854.   bsr     WriteBuffer
  855.  
  856.   move.l  #'BODY',Buffer
  857.   bsr     WriteBuffer
  858.   move.w  PicWidth(pc),d0
  859.   asr.w   #3,d0                ; =>Bytes
  860.   move.b  ScreenDepth(pc),d1
  861.   ext.w   d1
  862.   mulu    d1,d0
  863.   move.w  PicHeight(pc),d1
  864.   mulu    d1,d0
  865.   move.l  d0,Buffer
  866.   bsr     WriteBuffer
  867.  
  868.   move.l  ActiveScreen(pc),a4
  869.   move.w  184(a4),d3            ; pic width
  870.   lea     192(a4),a4            ; BitMap.Planes
  871.   moveq.l #0,d4
  872.   move.w  PicHeight(pc),d6
  873.   subq.w  #1,d6
  874. SaveFile5
  875.   move.b  ScreenDepth(pc),d5
  876.   ext.w   d5
  877.   subq.w  #1,d5
  878.   move.l  a4,a3
  879. SaveFile6
  880.   move.l  d7,d1
  881.   move.l  (a3)+,d2
  882.   add.l   d4,d2
  883.   jsr     _LVOWrite(a6)
  884.   dbf     d5,SaveFile6
  885.   add.l   d3,d4
  886.   dbf     d6,SaveFile5
  887.  
  888.   move.l  d7,d1
  889.   moveq.l #0,d2
  890.   moveq.l #1,d3
  891.   jsr     _LVOSeek(a6)
  892.   subq.l  #8,d0
  893.   move.l  d0,Buffer            ; File size
  894.   move.l  d7,d1
  895.   moveq.l #4,d2
  896.   moveq.l #-1,d3
  897.   jsr     _LVOSeek(a6)
  898.   bsr     WriteBuffer            ; Write FORM size
  899.  
  900.   move.l  d7,d1
  901.   jsr     _LVOClose(a6)
  902. SaveFile3
  903.   rts
  904.  
  905.  
  906.  
  907. WriteBuffer
  908.   move.l  DosBase(pc),a6
  909.   move.l  d7,d1
  910.   move.l  #Buffer,d2
  911.   moveq.l #4,d3
  912.   jsr     _LVOWrite(a6)
  913.   rts
  914.  
  915.  
  916.  
  917. CopyString                ; in: a0=from, a1=to
  918.   movem.l a0-a1,-(sp)
  919. CopyString2
  920.   tst.b   (a0)
  921.   beq.s   CopyString3
  922.   move.b  (a0)+,(a1)+
  923.   bra.s   CopyString2
  924. CopyString3
  925.   move.b  (a0),(a1)            ; Copy null too
  926.   movem.l (sp)+,a0-a1
  927.   rts
  928.  
  929.  
  930.  
  931. StoreFileName
  932.   move.l  FileNameGadgetBase(pc),a0
  933.   move.l  34(a0),a0
  934.   move.l  (a0),a0
  935.   lea     FileName,a1
  936.   bsr     CopyString
  937.   rts
  938.  
  939.  
  940.  
  941. IntuitionBase        dc.l 0
  942. GfxBase            dc.l 0
  943. DosBase            dc.l 0
  944. GadToolsBase        dc.l 0
  945. MsgPort            dc.l 0
  946. Request            dc.l 0
  947. Request3        dc.l 0
  948. ActiveScreen        dc.l 0
  949. ActiveVPort        dc.l 0
  950. ActiveRPort        dc.l 0
  951. MsgPort2        dc.l 0
  952. Request2        dc.l 0
  953. MyWindow        dc.l 0
  954. MyUserPort        dc.l 0
  955. PrintSignal        dc.l 0
  956. WindowSignal        dc.l 0
  957. SignalMask        dc.l 0
  958. MyTask            dc.l 0
  959. WorkbenchMsg        dc.l 0
  960. LastGadget        dc.l 0
  961. GList            dc.l 0
  962. VisualInfo        dc.l 0
  963. FileNameGadgetBase    dc.l 0
  964. Buffer            dc.l 0
  965. PreviousPlace        dc.w 160,40    ; The previous place of the window
  966.  
  967. Class            dc.l 0
  968. IAddress        dc.l 0
  969. Code            dc.w 0
  970. Qualifier        dc.w 0
  971.  
  972. FileHeader        dc.b 'FORMSPY!ILBMBMHD'
  973.             dc.l 20
  974. PicWidth        dc.w 0
  975. PicHeight        dc.w 0,0,0
  976. ScreenDepth        dc.b 0,0,0,0
  977.             dc.w 0,0
  978. ScreenWidth        dc.w 0
  979. ScreenHeight        dc.w 0
  980.             dc.b 'CMAP'
  981.  
  982.  
  983. NewWindow
  984.   dc.w 152,56,304,110
  985.   dc.b 1,2
  986.   dc.l IDCMP_GADGETUP!IDCMP_CLOSEWINDOW
  987.   dc.l WFLG_DRAGBAR!WFLG_DEPTHGADGET!WFLG_CLOSEGADGET!WFLG_ACTIVATE!WFLG_RMBTRAP!WFLG_NOCAREREFRESH!WFLG_SIMPLE_REFRESH
  988.   dc.l 0,0,WindowTitle,0,0
  989.   dc.w 304,88,304,88,WBENCHSCREEN
  990.  
  991.  
  992. ResetBeforeGadget            ; GadgetUp!
  993.   dc.w 10,15,16,10
  994.   dc.l ResetBeforeName,Font0
  995.   dc.w 0
  996.   dc.l PLACETEXT_RIGHT,0,ResetBefore
  997.  
  998. ResetAfterGadget            ; GadgetUp!
  999.   dc.w 10,28,16,10
  1000.   dc.l ResetAfterName,Font0
  1001.   dc.w 0
  1002.   dc.l PLACETEXT_RIGHT,0,ResetAfter
  1003.  
  1004. AspectGadget            ; GadgetUp!
  1005.   dc.w 10,45,16,10
  1006.   dc.l AspectName,Font0
  1007.   dc.w 0
  1008.   dc.l PLACETEXT_RIGHT,0,SetAspectFlag
  1009.  
  1010. CenterGadget            ; GadgetUp!
  1011.   dc.w 10,58,16,10
  1012.   dc.l CenterName,Font0
  1013.   dc.w 0
  1014.   dc.l PLACETEXT_RIGHT,0,SetCenterFlag
  1015.  
  1016. NoFormFeedGadget            ; GadgetUp!
  1017.   dc.w 10,71,16,10
  1018.   dc.l NoFormFeedName,Font0
  1019.   dc.w 0
  1020.   dc.l PLACETEXT_RIGHT,0,SetNoFormFeedFlag
  1021.  
  1022. FullRowsGadget            ; GadgetUp!
  1023.   dc.w 158,15,16,10
  1024.   dc.l FullRowsName,Font0
  1025.   dc.w 0
  1026.   dc.l PLACETEXT_RIGHT,0,SetFullRowsFlag
  1027.  
  1028. FullColumnsGadget            ; GadgetUp!
  1029.   dc.w 158,28,16,10
  1030.   dc.l FullColumnsName,Font0
  1031.   dc.w 0
  1032.   dc.l PLACETEXT_RIGHT,0,SetFullColumnsFlag
  1033.  
  1034. ActiveScreenGadget            ; GadgetUp!
  1035.   dc.w 158,45,136,14
  1036.   dc.l 0,Font0
  1037.   dc.w 0
  1038.   dc.l 0,0,SetScreenFlag
  1039.  
  1040. SaveFileGadget            ; GadgetUp!
  1041.   dc.w 158,67,136,14
  1042.   dc.l 0,Font0
  1043.   dc.w 0
  1044.   dc.l 0,0,SetSaveFileFlag
  1045.  
  1046. FileNameGadget            ; GadgetUp!
  1047.   dc.w 192,88,102,14
  1048.   dc.l FileNameName,Font0
  1049.   dc.w 0
  1050.   dc.l 0,0,StoreFileName
  1051.  
  1052. SaveGadget            ; GadgetUp!
  1053.   dc.w 10,88,65,14
  1054.   dc.l SaveName,Font0
  1055.   dc.w 0
  1056.   dc.l PLACETEXT_IN,0,SaveConfig
  1057.  
  1058. QuitGadget            ; GadgetUp!
  1059.   dc.w 81,88,65,14
  1060.   dc.l QuitName,Font0
  1061.   dc.w 0
  1062.   dc.l PLACETEXT_IN,0,SetQuitFlag
  1063.  
  1064.  
  1065. SelectedTags
  1066.   dc.l GTCB_Checked,1
  1067.   dc.l TAG_DONE
  1068.  
  1069. ActiveScreenTags
  1070.   dc.l GTCY_Active,0
  1071.   dc.l GTCY_Labels,ScreenLabels
  1072.   dc.l TAG_DONE
  1073.  
  1074. SaveFileTags
  1075.   dc.l GTCY_Active,0
  1076.   dc.l GTCY_Labels,SaveFileLabels
  1077.   dc.l TAG_DONE
  1078.  
  1079. FileNameTags
  1080.   dc.l GTST_String,FileName
  1081.   dc.l GTST_MaxChars,104
  1082.   dc.l TAG_DONE
  1083.  
  1084. ScreenLabels
  1085.   dc.l ActiveScreenName,FirstScreenName,0
  1086.  
  1087. SaveFileLabels
  1088.   dc.l DumpScreenName,SaveScreenName,0
  1089.  
  1090. Font0
  1091.   dc.l Font0Name
  1092.   dc.w 8
  1093.   dc.b 0,1
  1094.  
  1095.  
  1096. SpecialFlags        dc.b 0            ; 1
  1097. SpecialFlags2        dc.b 0            ; 2
  1098. ResetBeforeFlag        dc.b 0            ; 3
  1099. ResetAfterFlag        dc.b 0            ; 4
  1100. ActiveScreenFlag    dc.b 0            ; 5
  1101. SaveFileFlag        dc.b 0            ; 6 bytes
  1102. QuitFlag        dc.b 0
  1103.  
  1104. IntuitionName        dc.b 'intuition.library',0
  1105. GfxName            dc.b 'graphics.library',0
  1106. DosName            dc.b 'dos.library',0
  1107. GadToolsName        dc.b 'gadtools.library',0
  1108. PrinterName        dc.b 'printer.device',0
  1109. InputName        dc.b 'input.device',0
  1110. Font0Name        dc.b 'topaz.font',0
  1111.  
  1112. NoGfx36Text        dc.b 0,170,14,'Can''t open graphics.library V36+',0,0
  1113. NoDosText        dc.b 0,210,14,'Can''t open dos.library',0,0
  1114. NoGadToolsText        dc.b 0,202,14,'Can''t open gadtools.library',0,0
  1115. NoMsgPortText        dc.b 0,198,14,'Can''t create message port',0,0
  1116. NoRequestText        dc.b 0,210,14,'Can''t create IORequest',0,0
  1117. NoPrinterText        dc.b 0,210,14,'Can''t open printer.device',0,0
  1118. NoWindowText        dc.b 0,202,14,'Can''t open window, quitting',0,0
  1119. NoSignalText        dc.b 0,214,14,'Can''t allocate signal',0,0
  1120. VersionString        dc.b '$VER: PrintScreen V1.75 (12.3.94) ©1993-1994 Jan Hagqvist',10,0
  1121.  
  1122. ResetBeforeName        dc.b 'Reset before',0
  1123. ResetAfterName        dc.b 'Reset after',0
  1124. AspectName        dc.b 'Aspect',0
  1125. CenterName        dc.b 'Center',0
  1126. NoFormFeedName        dc.b 'No formfeed',0
  1127. FullRowsName        dc.b 'Full rows',0
  1128. FullColumnsName        dc.b 'Full columns',0
  1129. SaveName        dc.b 'Save',0
  1130. QuitName        dc.b 'Quit',0
  1131. ActiveScreenName    dc.b 'ActiveScreen',0
  1132. FirstScreenName        dc.b 'FirstScreen',0
  1133. DumpScreenName        dc.b 'Dump screen',0
  1134. SaveScreenName        dc.b 'Save screen',0
  1135. FileNameName        dc.b 'File',0
  1136. ConfigFile        dc.b 's:PrtSc.cfg',0
  1137. MyHandlerName        dc.b 'PrtSc-key eater',0
  1138. WindowTitle        dc.b 'PrtSc V1.75, Shareware.',0
  1139.  
  1140.   SECTION 2,data
  1141.  
  1142. Interrupt        dcb.b 22,0
  1143. FileName        dcb.b 104,0
  1144.  
  1145.   END
  1146.