home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 632.lha / KCommodity_v1.63 / source.LZH / source / KCommodity.Asm
Encoding:
Assembly Source File  |  1992-03-15  |  312.9 KB  |  12,941 lines

  1. * This can only be assembled under DEVPAC V3.01 since there are many opcodes
  2. * only DEVPAC 3.01 understands. As far as I know.
  3.  
  4.         NOLIST
  5.         OPT    ow-,o+,ow6+,NODEBUG,NOLINE
  6.  
  7. *AUTO:        make KCommodity
  8.  
  9. ;* $Revision Header built by KCommodity by Kai Iske *** (do not edit) ************
  10. ;*
  11. ;* © Copyright by GuntherSoft
  12. ;*
  13. ;* File             : KCommodity.Asm
  14. ;* Created on       : Sunday, 05-Jan-92 14:22:48
  15. ;* Created by       : Kai Iske
  16. ;* Current revision : V1.63
  17. ;*
  18. ;*
  19. ;* Purpose
  20. ;* -------
  21. ;*     This is a multifunctional Commodity including many useful tools.
  22. ;*     The best part of it is the revision control system this header was made
  23. ;*     with. All previous LogMessages got lost due to change to KCommodity to
  24. ;*     arrange the new ones.
  25. ;*
  26. ;* Revision V1.63
  27. ;* --------------
  28. ;* changed on Sunday, 15-Mar-92 01:14:29  by  Kai Iske.   LogMessage :
  29. ;*     Bugs in ESC-WindowClose, LeftyMouse and MouseBlanking removed.
  30. ;*     When Mouse is blanked no other sprites will be turned off now.
  31. ;*     Shell created now gets all the paths you used a PATH for.
  32. ;*
  33. ;* Revision V1.62
  34. ;* --------------
  35. ;* changed on Friday, 13-Mar-92 01:18:36  by  Kai Iske.   LogMessage :
  36. ;*     Added an Online-Help function giving help for almost every function
  37. ;*     KCommodity provides. Some bug fixes and remakes.
  38. ;*
  39. ;* Revision V1.61
  40. ;* --------------
  41. ;* changed on Wednesday, 11-Mar-92 22:33:00  by  Kai Iske.   LogMessage :
  42. ;*     All windows (except for Clock-Window) are menu driven now. The old shortcuts
  43. ;*     are kept. Improved StringGadget-Editing by adding a StringEdit-Hook. Menu-
  44. ;*     ShortCuts may be used while editing a StringGadget. Normal ShortCuts may
  45. ;*     still be used for convenience.
  46. ;*
  47. ;* Revision V1.60
  48. ;* --------------
  49. ;* changed on Wednesday, 11-Mar-92 02:09:43  by  Kai Iske.   LogMessage :
  50. ;*     Added function to map german "Umlauts" so that these are translated into
  51. ;*     "normal" chars. Registration may be printed out now.
  52. ;*
  53. ;* Revision V1.59
  54. ;* --------------
  55. ;* changed on Friday, 21-Feb-92 00:24:52  by  Kai Iske.   LogMessage :
  56. ;*     Removed most of the ToolTypes, since all settings may be stored to a file.
  57. ;*     Added an AppIcon and an AppMenuItem for easy popup of the control-window
  58. ;*     (for people who can`t remember HotKeys)
  59. ;*
  60. ;* Revision V1.58
  61. ;* --------------
  62. ;* changed on Tuesday, 18-Feb-92 01:32:26  by  Kai Iske.   LogMessage :
  63. ;*     Added HotKeys for all windows of KCommodity. HotKey for Shell added.
  64. ;*     HotKey definitions may be done within a window now
  65. ;*
  66. ;* Revision V1.57
  67. ;* --------------
  68. ;* changed on Sunday, 16-Feb-92 04:25:26  by  Kai Iske.   LogMessage :
  69. ;*     Preferences can be saved to alternative files to have several settings
  70. ;*     available. Interfaces between routines enhanced. KCommodity didn`t get
  71. ;*     quite larger (due to optimaziation). Control window now has menues.
  72. ;*
  73. ;* Revision V1.56
  74. ;* --------------
  75. ;* changed on Monday, 10-Feb-92 02:58:12  by  Kai Iske.   LogMessage :
  76. ;*     Shortened KCommodity. Added Window-Close via ESC-Key. Bugs removed.
  77. ;*     Layout changed.
  78. ;*
  79. ;* Revision V1.55
  80. ;* --------------
  81. ;* changed on Sunday, 09-Feb-92 03:32:21  by  Kai Iske.   LogMessage :
  82. ;*     Bugs removed. Added function to display costs for one day in telefone bill.
  83. ;*     Lefty mouse function added. When channels get stolen KCommodity will try
  84. ;*     to reallocate new ones the next time.
  85. ;*
  86. ;* Revision V1.54
  87. ;* --------------
  88. ;* changed on 02-Feb-92, Sunday 02-Feb-92  by  Kai Iske.   LogMessage :
  89. ;*     TimeZone/Tariff defaults can be set and will be saved to PREFSFILE.
  90. ;*     Position of PrefsWindow may be changed via ToolType/ARexx. ESC-Key is the
  91. ;*     terminator for a window. WB can be popped to fron when control window
  92. ;*     should be (re)opened. PrefsWindow-Pos may be set.
  93. ;*
  94. ;* Revision V1.53
  95. ;* --------------
  96. ;* changed on 31-Jan-92, Friday 31-Jan-92  by  23:10:34.   LogMessage :
  97. ;*     Now also generates Revision Headers for Pascal/Modula programs.
  98. ;*     Revision defines for Assembler improved since now macros are created.
  99. ;*     Added a gadget and an ARexx command to clear the logfile.
  100. ;*
  101. ;* Revision V1.52
  102. ;* --------------
  103. ;* changed on Friday, 31-Jan-92 22:02:26  by  Kai Iske.   LogMessage :
  104. ;*     Now the time and online displays and checks area handeled by a spererate
  105. ;*     process so that the displays and values are always adjusted correctly.
  106. ;*     Move the bill-checkbox-gadgets to the preferences window.
  107. ;*
  108. ;* Revision V1.51
  109. ;* --------------
  110. ;* changed on Sunday, 26-Jan-92 00:05:39  by  Kai Iske.   LogMessage :
  111. ;*     Added a telefone bill calculator, which keeps track of all logins made and
  112. ;*     saves them to a logfile. 3 definable times/unit for normal or cheap tariff.
  113. ;*     Accumulated costs can be retrieved. Writing to log file can be turned off.
  114. ;*
  115. ;* Revision V1.50
  116. ;* --------------
  117. ;* changed on Sunday, 19-Jan-92 23:19:59  by  Kai Iske.   LogMessage :
  118. ;*     Added new displaymodes in (Window)-TitleBar. Total amount of free memory,
  119. ;*     graphical display of free memory and accumulated online time.
  120. ;*
  121. ;* Revision V1.49
  122. ;* --------------
  123. ;* changed on Saturday, 18-Jan-92 23:23:55  by  Kai Iske.   LogMessage :
  124. ;*     Again some stupid bugs removed (why not). Added KeyStroke-Clicker with
  125. ;*     userdefinable volume. Changed layout. Screen/Mouse-Times are reset to
  126. ;*     previous values if a wrong one was entered.
  127. ;*
  128. ;* Revision V1.48
  129. ;* --------------
  130. ;* changed on Saturday, 18-Jan-92 02:28:32  by  Kai Iske.   LogMessage :
  131. ;*     Now includes Window-Cycling with user-definable Qualifiers.
  132. ;*     Bug hunting, but I still don`t know why it sometimes crashes on other
  133. ;*     machines, but not on mine.
  134. ;*
  135. ;* Revision V1.47
  136. ;* --------------
  137. ;* changed on Monday, 13-Jan-92 23:05:42  by  Kai Iske.   LogMessage :
  138. ;*     Now adds revision date within defines and skips defines if commented out
  139. ;*     or just thrown away. Bug in finding the current dir removed.
  140. ;*
  141. ;* Revision V1.46
  142. ;* --------------
  143. ;* changed on Monday, 13-Jan-92 17:15:37  by  Kai Iske.   LogMessage :
  144. ;*     Bug hunting. But still XOper displays some weird info. I think that`s a bug
  145. ;*     of XOper2.3 since it displays these infos while KCommodity isn`t running.
  146. ;*     Revision control system now gives one more define : DATE of revision
  147. ;*
  148. ;* Revision V1.45
  149. ;* --------------
  150. ;* changed on Monday, 13-Jan-92 13:50:39  by  Kai Iske.   LogMessage :
  151. ;*     Removed some weird bugs which made KCommodity crash the system.
  152. ;*
  153. ;* Revision V1.44
  154. ;* --------------
  155. ;* changed on Sunday, 12-Jan-92 00:04:32  by  Kai Iske.   LogMessage :
  156. ;*     Bug hunt (I hope the final). Some modifications the user probably won`t
  157. ;*     notice
  158. ;*
  159. ;* Revision V1.43
  160. ;* --------------
  161. ;* changed on Saturday, 11-Jan-92 03:26:14  by  Kai Iske.   LogMessage :
  162. ;*     Error in Event-Handler removed due to the fact that not all registers have
  163. ;*     been stored on stack before workthrough of routine
  164. ;*
  165. ;* Revision V1.42
  166. ;* --------------
  167. ;* changed on Friday, 10-Jan-92 23:23:00  by  Kai Iske.   LogMessage :
  168. ;*     Added a Screen/Mouseblanker. Mouse is either blanked after the given period
  169. ;*     of time or when key pressed. Blanking is turned off when pressing a key
  170. ;*     or moving the mouse.
  171. ;*
  172. ;* Revision V1.41
  173. ;* --------------
  174. ;* changed on Friday, 10-Jan-92 16:09:29  by  Kai Iske.   LogMessage :
  175. ;*     Did some 'tuning'. ARexx ClockWinPos wasn`t recognized just after a
  176. ;*     ClockWin 1. Control window comes to front if already active and HotKey is
  177. ;*     pressed.
  178. ;*
  179. ;* Revision V1.40
  180. ;* --------------
  181. ;* changed on Thursday, 09-Jan-92 18:33:19  by  Kai Iske.   LogMessage :
  182. ;*     Did some fine things on layout :-). Now a screentitle is set for all
  183. ;*     windows used by KCommodity. Also all windows are centered when poped up
  184. ;*     but they will keep their positions moved to during runtime
  185. ;*
  186. ;* Revision V1.39
  187. ;* --------------
  188. ;* changed on Thursday, 09-Jan-92 15:39:22  by  Kai Iske.   LogMessage :
  189. ;*     Bad errors removed. KCommodity didn`t keep track of absolute path of file.
  190. ;*     Now uses CurrentDir if no ???: is specified to get a correct lock to a
  191. ;*     file. It gets the lock of ARexx`s Process->pr_CurrentDir. Clock is now
  192. ;*     visible again :-)
  193. ;*
  194. ;* Revision V1.38
  195. ;* --------------
  196. ;* changed on Monday, 06-Jan-92 14:40:20  by  Kai Iske.   LogMessage :
  197. ;*     Corrected a little bug in environment variable settings
  198. ;*
  199. ;* Revision V1.37
  200. ;* --------------
  201. ;* changed on Sunday, 05-Jan-92 15:22:13  by  Kai Iske.   LogMessage :
  202. ;*     Added possibilty to 'jump over' some revisions by inserting the next
  203. ;*     revision number into gadgets
  204. ;*
  205. ;* Revision V1.36
  206. ;* --------------
  207. ;*     --- Initial release ---
  208. ;*
  209. ;*********************************************************************************
  210. REVISION  MACRO        ; This is the macro for the revision number
  211.           dc.b "1.63"
  212.           ENDM
  213. REVDATE   MACRO        ; This is the macro for the revision date
  214.           dc.b "15-Mar-92"
  215.           ENDM
  216.  
  217.  
  218.         INCLUDE    KCommodity.i            ; Include our Headers
  219.                             ; For DevPac >= 3 the preincludes
  220.                             ; will be loaded
  221.                             ; Otherwise the includes will be taken
  222.  
  223.         INCDIR    AH:
  224.         INCLUDE    Misc/MyMacros.i            ; Include MyMacros
  225.  
  226.  
  227. **********************************************************************
  228. *                   Versionnumber of libs, we need                   *
  229. **********************************************************************
  230. NEED_LIBVER    EQU    37
  231.  
  232.  
  233. DEPTHWIDTH    EQU    28
  234. READBUFFSIZE    EQU    8192
  235. MAXBARLEN    EQU    150
  236. MAXPAGES    EQU    5
  237. TIMEPAGE    EQU    0
  238. DMEMPAGE    EQU    1
  239. TMEMPAGE    EQU    2
  240. GMEMPAGE    EQU    3
  241. ONLINEPAGE    EQU    4
  242.  
  243. ESCKEY        EQU    $1B
  244. HELPKEY        EQU    $5f
  245.  
  246. SIGTIMEREMAKE    EQU    SIGBREAKF_CTRL_F
  247. SIGHANDSHAKE    EQU    SIGBREAKF_CTRL_E
  248. SIGBILLWIN    EQU    SIGBREAKF_CTRL_D
  249.  
  250.  
  251.         SECTION    MyCode,CODE
  252.  
  253.         INCLUDE    Misc/BigStartUp.i        ; Include the standard startup code
  254.  
  255. **********************************************************************
  256. *                            Main program                            *
  257. **********************************************************************
  258. START        move.l    $4,a6                ; Test, if we`re running under 2.x
  259.         cmp.w    #36,LIB_VERSION(a6)
  260.         bge.s    .IsOver20
  261.  
  262.         bsr    OnlyKick20
  263.         move.l    #10,-(sp)
  264.         bra    .ShownHelp
  265.  
  266. .IsOver20    bsr    OpenLibs            ; Open libs
  267.         tst.l    d0
  268.         beq    .OpenError
  269.  
  270.         move.l    _OurTask(pc),a0            ; Came from CLI ?
  271.         tst.l    pr_CLI(a0)
  272.         beq.s    .GoOn                ; Nope -> go on
  273.         move.l    _ArgV(pc),a0            ; User requesting help ?
  274.         move.l    4(a0),a0
  275.         cmp.b    #'?',(a0)
  276.         bne.s    .GoOn
  277.         move.l    _stdout(pc),d1
  278.         move.l    #Template,d2
  279.         move.l    #TemplateEnd-Template,d3
  280.         LNKLIB    Write,_DOSBase
  281.         move.l    #0,-(sp)
  282.         bra    .ShownHelp
  283.  
  284. .GoOn        bsr    InitMem                ; Initialize the memory
  285.         tst.l    d0
  286.         beq    .OpenError
  287.  
  288.         bsr    MakeHotKeys            ; Copy defaults to hotkey buffs
  289.  
  290.         lea    StrEditHook,a0            ; Initialize the StringEdit-Hook
  291.         move.l    #StrEditFunc,h_Entry(a0)
  292.         move.l    #StrEditFunc,h_SubEntry(a0)
  293.         move.l    #0,h_Data(a0)
  294.  
  295.         bsr    LoadPrefs            ; Read in log preferences
  296.         move.l    PTimeZone,d0            ; Set new modes and timezone
  297.         move.l    d0,TimeZone
  298.         move.l    PTariff,d0
  299.         move.b    d0,CheapMode
  300.  
  301.         bsr    GetToolTypes            ; Get tooltypes
  302.  
  303.         bsr    InitGfx                ; Initialize graphics
  304.         tst.l    d0
  305.         beq.s    .OpenError
  306.  
  307.         bsr    InitARexx            ; Create our ARexx Port
  308.         tst.l    d0
  309.         beq.s    .OpenError
  310.  
  311.         bsr    InitAudio            ; Init Audio-Stuff
  312.         tst.l    d0
  313.         beq.s    .OpenError
  314.  
  315.         bsr    InitConsole            ; Open Console-Device
  316.         tst.l    d0
  317.         beq.s    .OpenError
  318.  
  319.         bsr    InitBroker            ; Start broker
  320.         tst.l    d0
  321.         beq.s    .OpenError
  322.  
  323.         bsr    InitChecker            ; Init the timer process
  324.         tst.l    d0
  325.         beq.s    .OpenError
  326.  
  327.         bsr    InitAppIcon            ; Init our AppIcon
  328.         tst.l    d0
  329.         beq.s    .OpenError
  330.  
  331.         bsr    InitAppItems
  332.         tst.l    d0
  333.         beq.s    .OpenError
  334.  
  335.         tst.b    DoPopUp                ; If pop up was requested
  336.         beq.s    .NoInitPop
  337.         bsr    OpenOurWindow            ; Do so
  338.         tst.l    d0
  339.         bne.s    .OpenError
  340. .NoInitPop    bsr    CheckBroker            ; Check Broker Messages
  341.         bra.s    .EndPrg
  342.  
  343. .OpenError    tst.l    ErrorNum
  344.         blt.s    .NoErrorDisp
  345.         bsr    DisplayError
  346. .NoErrorDisp    moveq    #10,d0
  347.         bra.s    .CloseDown
  348.  
  349. .EndPrg        moveq    #0,d0
  350. .CloseDown    move.l    d0,-(sp)
  351.         CALLSYS    Forbid                ; Disable any messages to our stuff
  352.         bsr    RemoveAppItems
  353.         bsr    RemoveAppIcon            ; Remove AppIcon-Stuff
  354.         bsr    RemoveBroker            ; Close resources
  355.         bsr    RemoveConsole            ; Remove Console-Device
  356.         bsr    RemoveAudio            ; Remove Audio-Stuff
  357.         bsr    RemoveARexx            ; Remove ARexx port
  358.         bsr    RemoveGfx            ; Remove our gfx
  359.         CALLSYS    Permit                ; So, that`s ok.
  360.         bsr    DeleteEnvs            ; Remove environment vars
  361.         bsr    RemoveMem
  362. .ShownHelp    bsr    CloseLibs
  363.         move.l    (sp)+,d0
  364.         rts
  365.  
  366.  
  367.  
  368.  
  369.  
  370. **********************************************************************
  371. *                      Attempt to load the libs                      *
  372. **********************************************************************
  373. OpenLibs    move.l    #0,ErrorNum
  374.         lea    IntName,a1
  375.         move.l    a1,EasyArg
  376.         move.l    #NEED_LIBVER,d0
  377.         CALLSYS    OpenLibrary
  378.         tst.l    d0
  379.         beq    .LibError
  380.         move.l    d0,_IntuitionBase
  381.  
  382.         lea    ComName,a1
  383.         move.l    a1,EasyArg
  384.         move.l    #NEED_LIBVER,d0
  385.         DOLIB    OpenLibrary
  386.         tst.l    d0
  387.         beq    .LibError
  388.         move.l    d0,_CxBase
  389.  
  390.         lea    LayerName,a1
  391.         move.l    a1,EasyArg
  392.         move.l    #NEED_LIBVER,d0
  393.         DOLIB    OpenLibrary
  394.         tst.l    d0
  395.         beq    .LibError
  396.         move.l    d0,_LayersBase
  397.  
  398.         lea    GadName,a1
  399.         move.l    a1,EasyArg
  400.         moveq    #NEED_LIBVER,d0
  401.         DOLIB    OpenLibrary
  402.         tst.l    d0
  403.         beq.s    .LibError
  404.         move.l    d0,_GadToolsBase
  405.  
  406.         lea    GfxName,a1
  407.         move.l    a1,EasyArg
  408.         move.l    #NEED_LIBVER,d0
  409.         DOLIB    OpenLibrary
  410.         tst.l    d0
  411.         beq.s    .LibError
  412.         move.l    d0,_GfxBase
  413.  
  414.         lea    RexxSysName,a1
  415.         move.l    a1,EasyArg
  416.         move.l    #0,d0
  417.         DOLIB    OpenLibrary
  418.         tst.l    d0
  419.         beq.s    .LibError
  420.         move.l    d0,_RexxSysBase
  421.  
  422.         lea    AslName,a1
  423.         move.l    a1,EasyArg
  424.         move.l    #NEED_LIBVER,d0
  425.         DOLIB    OpenLibrary
  426.         tst.l    d0
  427.         beq.s    .LibError
  428.         move.l    d0,_AslBase
  429.  
  430.         lea    WBName,a1
  431.         move.l    a1,EasyArg
  432.         move.l    #NEED_LIBVER,d0
  433.         DOLIB    OpenLibrary
  434.         move.l    d0,_WorkBenchBase
  435.         tst.l    d0
  436.         beq.s    .LibError
  437. .LibError    rts
  438.  
  439.  
  440.  
  441. **********************************************************************
  442. *                          Close Libs again                          *
  443. **********************************************************************
  444. CloseLibs    tst.l    _WorkBenchBase
  445.         beq.s    .NoWBBase
  446.         move.l    _WorkBenchBase,a1
  447.         CALLSYS    CloseLibrary
  448.  
  449. .NoWBBase    tst.l    _AslBase
  450.         beq.s    .NoAslBase
  451.         move.l    _AslBase,a1
  452.         CALLSYS    CloseLibrary
  453.  
  454. .NoAslBase    tst.l    _RexxSysBase
  455.         beq.s    .NoRexxSysBase
  456.         move.l    _RexxSysBase,a1
  457.         CALLSYS    CloseLibrary
  458.  
  459. .NoRexxSysBase    tst.l    _GfxBase
  460.         beq.s    .NoGfxBase
  461.         move.l    _GfxBase,a1
  462.         CALLSYS    CloseLibrary
  463.  
  464. .NoGfxBase    tst.l    _GadToolsBase
  465.         beq.s    .NoGadToolsBase
  466.         move.l    _GadToolsBase,a1
  467.         CALLSYS    CloseLibrary
  468.  
  469. .NoGadToolsBase    tst.l    _LayersBase
  470.         beq.s    .NoLayersBase
  471.         move.l    _LayersBase,a1
  472.         CALLSYS    CloseLibrary
  473.  
  474. .NoLayersBase    tst.l    _CxBase
  475.         beq.s    .NoCxBase
  476.         move.l    _CxBase,a1
  477.         CALLSYS    CloseLibrary
  478.  
  479. .NoCxBase    tst.l    _IntuitionBase
  480.         beq.s    .NoIntBase
  481.         move.l    _IntuitionBase,a1
  482.         CALLSYS    CloseLibrary
  483. .NoIntBase    rts
  484.  
  485.  
  486.  
  487.  
  488. **********************************************************************
  489. *           Initialize some structures from system-memory            *
  490. **********************************************************************
  491. InitMem        move.l    #18,ErrorNum            ; A small dummy buffer
  492.         move.l    #READBUFFSIZE,d0
  493.         move.l    #MEMF_CLEAR|MEMF_PUBLIC,d1
  494.         CALLSYS    AllocMem
  495.         move.l    d0,ReadBuffer
  496.         tst.l    d0
  497.         beq.s    .Error
  498.  
  499.         move.l    #19,ErrorNum            ; Timer Request
  500.         move.l    #IOTV_SIZE,d0
  501.         move.l    #MEMF_CLEAR|MEMF_PUBLIC,d1
  502.         DOLIB    AllocMem
  503.         move.l    d0,TimerReq
  504.         tst.l    d0
  505.         beq.s    .Error
  506.  
  507.         move.l    #20,ErrorNum            ; Audio Request
  508.         move.l    #ioa_SIZEOF,d0
  509.         move.l    #MEMF_CLEAR|MEMF_PUBLIC,d1
  510.         DOLIB    AllocMem
  511.         move.l    d0,AudioReq
  512.         tst.l    d0
  513.         beq.s    .Error
  514.  
  515.         move.l    #21,ErrorNum            ; Console Request
  516.         move.l    #IOSTD_SIZE,d0
  517.         move.l    #MEMF_CLEAR|MEMF_PUBLIC,d1
  518.         DOLIB    AllocMem
  519.         move.l    d0,ConsoleReq
  520.         tst.l    d0
  521.         beq.s    .Error
  522.         moveq    #1,d0
  523. .Error        rts
  524.  
  525.  
  526.  
  527.  
  528. **********************************************************************
  529. *                       Remove used resources                        *
  530. **********************************************************************
  531. RemoveMem    tst.l    ConsoleReq
  532.         beq.s    .NoConsoleReq
  533.         move.l    ConsoleReq,a1
  534.         move.l    #IOSTD_SIZE,d0
  535.         CALLSYS    FreeMem
  536.  
  537. .NoConsoleReq    tst.l    AudioReq
  538.         beq.s    .NoAudioReq
  539.         move.l    AudioReq,a1
  540.         move.l    #ioa_SIZEOF,d0
  541.         CALLSYS    FreeMem
  542.  
  543. .NoAudioReq    tst.l    TimerReq
  544.         beq.s    .NoTimerReq
  545.         move.l    TimerReq,a1
  546.         move.l    #IOTV_SIZE,d0
  547.         CALLSYS    FreeMem
  548.  
  549. .NoTimerReq    tst.l    ReadBuffer
  550.         beq.s    .NoReadBuff
  551.         move.l    ReadBuffer,a1
  552.         move.l    #READBUFFSIZE,d0
  553.         CALLSYS    FreeMem
  554. .NoReadBuff    rts
  555.  
  556.  
  557.  
  558.  
  559. **********************************************************************
  560. *                Init the Rastport for the title bar                 *
  561. **********************************************************************
  562. InitGfx        link    a5,#-4
  563.         bsr    LockScreen
  564.         tst.l    d0
  565.         beq    .NoGfx
  566.  
  567.         move.l    d0,a0                ; Get font for titlebar
  568.         move.l    sc_BarLayer(a0),a0
  569.         move.l    lr_rp(a0),a0
  570.         move.l    rp_Font(a0),a0            ; A0 = Font used in bar layer-rastport
  571.         lea    TxtAttr,a1            ; Store attributes of font
  572.         move.l    LN_NAME(a0),ta_Name(a1)
  573.         moveq    #0,d7
  574.         move.w    tf_YSize(a0),d7            ; Get height of font
  575.         move.w    d7,ta_YSize(a1)            ; and for bitplanes of title
  576.         move.b    tf_Style(a0),ta_Style(a1)
  577.         move.b    tf_Flags(a0),ta_Flags(a1)
  578.  
  579.         move.l    -4(a5),a0
  580.         moveq    #0,d0
  581.         moveq    #0,d1
  582.         move.w    sc_Width(a0),d0            ; Center control window
  583.         move.w    sc_Height(a0),d1        ; on first popup
  584.         move.w    d0,d2
  585.         move.w    d1,d3
  586.         move.w    d0,d4
  587.         move.w    d1,d5
  588.         sub.w    #WINWIDTH,d0
  589.         sub.w    #WINHEIGHT,d1
  590.         asr.w    #1,d0
  591.         asr.w    #1,d1
  592.         lea    MyWindowDef,a1
  593.         move.w    d0,nw_LeftEdge(a1)
  594.         move.w    d1,nw_TopEdge(a1)
  595.         sub.w    #LOGWINWIDTH,d2            ; Center logmessage window
  596.         sub.w    #LOGWINHEIGHT,d3        ; on first popup
  597.         asr.w    #1,d2
  598.         asr.w    #1,d3
  599.         lea    LogWinDef,a1
  600.         move.w    d2,nw_LeftEdge(a1)
  601.         move.w    d3,nw_TopEdge(a1)
  602.         sub.w    #HELPWINWIDTH,d4        ; Center help window on popup
  603.         sub.w    #HELPWINHEIGHT,d5
  604.         asr.w    #1,d4
  605.         asr.w    #1,d5
  606.         lea    HelpWinDef,a1
  607.         move.w    d4,nw_LeftEdge(a1)
  608.         move.w    d5,nw_TopEdge(a1)
  609.         move.l    sc_FirstWindow(a0),a0
  610.         move.l    wd_RPort(a0),a0            ; Get depth of workbench
  611.         move.l    rp_BitMap(a0),a0
  612.         moveq    #0,d0
  613.         move.b    bm_Depth(a0),d0
  614.         move.w    d0,BitMapDepth
  615.  
  616.         moveq    #0,d1
  617.         move.l    -4(a5),a0
  618.         move.w    sc_Width(a0),d1
  619.         move.w    d1,BitMapWidth            ; Store sized
  620.         move.w    d7,BitMapHeight            ; To get the full width and height
  621.                             ; isn`t quite intelligent, but
  622.                             ; it doesn`t take too much memory. SO WHAT
  623.  
  624.         move.l    #13,ErrorNum
  625.         move.l    #bm_SIZEOF,d0
  626.         move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  627.         CALLSYS    AllocMem
  628.         move.l    d0,MyBitMap
  629.         tst.l    d0
  630.         beq    .NoGfx
  631.  
  632.         move.l    #14,ErrorNum
  633.         move.l    #rp_SIZEOF,d0
  634.         move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  635.         CALLSYS    AllocMem
  636.         move.l    d0,MyRastPort
  637.         tst.l    d0
  638.         beq    .NoGfx
  639.  
  640.         move.l    MyBitMap,a0            ; Initialize our BitMap
  641.         move.w    BitMapDepth,d0
  642.         move.w    BitMapWidth,d1
  643.         move.w    BitMapHeight,d2
  644.         LNKLIB    InitBitMap,_GfxBase
  645.  
  646.         move.l    #7,ErrorNum
  647.         move.l    MyBitMap,a4
  648.         move.w    bm_BytesPerRow(a4),d1        ; Get bytes per row
  649.         mulu    BitMapHeight,d1
  650.         move.l    d1,BitMapSize            ; Store size for one plane
  651.         lea    bm_Planes(a4),a4        ; Get address of Planes array
  652.         move.w    BitMapDepth,d7            ; Make all planes
  653.         subq.w    #1,d7
  654. .MakeBitMaps    move.l    BitMapSize,d0
  655.         move.l    #MEMF_CHIP|MEMF_CLEAR,d1
  656.         CALLSYS    AllocMem
  657.         tst.l    d0
  658.         beq    .NoGfx
  659.         move.l    d0,(a4)+
  660.         dbf    d7,.MakeBitMaps
  661.  
  662.         move.l    MyRastPort,a1            ; Init RPort
  663.         LNKLIB    InitRastPort,_GfxBase
  664.  
  665.         move.l    MyRastPort,a1
  666.         move.l    MyBitMap,a0
  667.         move.l    a0,rp_BitMap(a1)        ; Add pointer of BitMap to RPort
  668.         moveq    #1,d0
  669.         DOLIB    SetRast                ; Clear RPort
  670.  
  671.         move.l    #8,ErrorNum
  672.         lea    TxtAttr,a0            ; Try to open font in RAM first
  673.         DOLIB    OpenFont
  674.         move.l    d0,MyFont
  675.         tst.l    d0
  676.         bne.s    .GotFont
  677.  
  678.         lea    DiskFontName,a1            ; If it failed try to open
  679.         moveq    #NEED_LIBVER,d0            ; diskfont.library
  680.         CALLSYS    OpenLibrary
  681.         tst.l    d0
  682.         beq    .NoGfx                ; If that also fails -> quit
  683.         move.l    d0,_DiskFontBase
  684.  
  685.         lea    TxtAttr,a0            ; Try to get font from disk
  686.         LNKLIB    OpenDiskFont,_DiskFontBase
  687.         move.l    d0,MyFont
  688.         tst.l    d0
  689.         bne.s    .GotDiskFont            ; Ok -> go on
  690.         move.l    _DiskFontBase,a1        ; Close lib and quit
  691.         CALLSYS    CloseLibrary
  692.         bra.s    .NoGfx
  693.  
  694. .GotDiskFont    move.l    _DiskFontBase,a1        ; Close lib
  695.         CALLSYS    CloseLibrary
  696.  
  697. .GotFont    move.l    MyRastPort,a1            ; Set font for rastport
  698.         move.l    MyFont,a0
  699.         LNKLIB    SetFont,_GfxBase
  700.  
  701.         move.l    MyRastPort,a1            ; Set draw mode
  702.         move.l    #RP_JAM2,d0
  703.         DOLIB    SetDrMd
  704.  
  705.         move.l    MyRastPort,a1            ; and now front and back pen
  706.         move.l    #0,d0
  707.         DOLIB    SetAPen
  708.         move.l    MyRastPort,a1
  709.         move.l    #1,d0
  710.         DOLIB    SetBPen
  711.  
  712.         move.l    #MEMF_TOTAL,d1            ; Get total available mem
  713.         CALLSYS    AvailMem
  714.         move.l    d0,MaxMem
  715.  
  716.         moveq    #1,d0
  717. .NoGfx        move.l    d0,-(sp)
  718.         bsr    UnlockScreen
  719.         move.l    (sp)+,d0
  720.         unlk    a5
  721.         rts
  722.  
  723.  
  724.  
  725.  
  726. **********************************************************************
  727. *                    Removes the Gfx areas again                     *
  728. **********************************************************************
  729. RemoveGfx    bsr    OnScreen            ; UnBlank Screen
  730.         bsr    OnMouse                ; UnBlank mouse
  731.         bsr    ClearTitleBar            ; Clear title bar
  732.         bsr    CloseHotKeyWin            ; Close HotKey window
  733.         bsr    CloseClockWin            ; Close clock window
  734.         bsr    ClosePrefsWin            ; Close preferences window
  735.         bsr    CloseOurWindow            ; Close down the window
  736.  
  737.         tst.l    MyFont                ; Did we have a font
  738.         beq.s    .GotNoFont
  739.  
  740.         move.l    MyFont,a1            ; Close font
  741.         LNKLIB    CloseFont,_GfxBase
  742.  
  743. .GotNoFont    tst.l    MyRastPort            ; Free rastport
  744.         beq.s    .GotNoRastPort
  745.         move.l    MyRastPort,a1
  746.         move.l    #rp_SIZEOF,d0
  747.         CALLSYS    FreeMem
  748.  
  749. .GotNoRastPort    tst.l    MyBitMap
  750.         beq.s    .AllFreed
  751.         move.l    MyBitMap,a4            ; Free bitplanes of BitMap
  752.         lea    bm_Planes(a4),a4
  753.         move.w    BitMapDepth,d7
  754.         subq.w    #1,d7
  755. .ClearBitPlanes    move.l    (a4)+,d0
  756.         beq.s    .FreeBitMap
  757.         move.l    d0,a1
  758.         move.l    BitMapSize,d0
  759.         CALLSYS    FreeMem
  760.         dbf    d7,.ClearBitPlanes
  761. .FreeBitMap    move.l    MyBitMap,a1            ; Free bitmap
  762.         move.l    #bm_SIZEOF,d0
  763.         CALLSYS    FreeMem
  764. .AllFreed    rts
  765.  
  766.  
  767.  
  768. **********************************************************************
  769. *                    Initialize the timer device                     *
  770. **********************************************************************
  771. InitTimer    move.l    #6,ErrorNum
  772.         CALLSYS    CreateMsgPort            ; Try to create a msg port
  773.         move.l    d0,TimerPort
  774.         tst.l    d0
  775.         beq    .NoTimer
  776.         move.l    d0,a1
  777.         moveq    #1,d0
  778.         moveq    #0,d1
  779.         move.b    MP_SIGBIT(a1),d1        ; Get sig flag
  780.         asl.l    d1,d0
  781.         move.l    d0,TimerSigFlag
  782.         move.l    #TimerPortName,LN_NAME(a1)
  783.         move.b    #0,LN_PRI(a1)
  784.         DOLIB    AddPort
  785.  
  786.         move.l    #0,ErrorNum
  787.         lea    TimerName,a0            ; Try to open timer.device
  788.         move.l    a0,EasyArg
  789.         move.l    #UNIT_VBLANK,d0
  790.         move.l    TimerReq,a1
  791.         move.l    TimerPort,MN_REPLYPORT(a1)
  792.         move.b    #0,LN_PRI(a1)
  793.         moveq    #0,d1
  794.         DOLIB    OpenDevice
  795.         tst.l    d0
  796.         beq.s    .GotDevice
  797.         moveq    #0,d0
  798.         bra.s    .NoTimer
  799. .GotDevice    move.l    TimerReq,a1            ; Set structure
  800.         move.w    #TR_ADDREQUEST,IO_COMMAND(a1)
  801.         move.b    #0,IO_FLAGS(a1)
  802.         move.b    #0,IO_ERROR(a1)
  803.         move.l    #0,IOTV_TIME+TV_SECS(a1)    ; Set first timer amount
  804.         move.l    #1000,IOTV_TIME+TV_MICRO(a1)    ; for task wakeup
  805.         DOLIB    SendIO
  806.         moveq    #1,d0
  807. .NoTimer    rts
  808.  
  809.  
  810.  
  811.  
  812. **********************************************************************
  813. *                   Remove timer device resources                    *
  814. **********************************************************************
  815. RemoveTimer    move.l    TimerReq,a1            ; Did we have a device ?
  816.         tst.l    IO_DEVICE(a1)
  817.         ble.s    .NoTimerDevice
  818.         move.l    TimerReq,a1            ; Request still running ?
  819.         CALLSYS    AbortIO
  820.         move.l    TimerReq,a1            ; Wait for request to end
  821.         DOLIB    WaitIO
  822.         move.l    TimerReq,a1
  823.         DOLIB    CloseDevice            ; Close it a fast as possible, so
  824. .NoTimerDevice    tst.l    TimerPort            ; that no more msgs can arrive
  825.         beq.s    .NoTimerPort
  826.         move.l    TimerPort,a1
  827.         CALLSYS    RemPort                ; Remove port from system
  828.         move.l    TimerPort,a0
  829.         DOLIB    DeleteMsgPort
  830. .NoTimerPort    rts
  831.  
  832.  
  833.  
  834.  
  835.  
  836. **********************************************************************
  837. *              Open Up console device for RAWKEYCONVERT              *
  838. **********************************************************************
  839. InitConsole    move.l    #0,ErrorNum
  840.         lea    ConsoleName,a0
  841.         move.l    a0,EasyArg
  842.         move.l    #CONU_LIBRARY,d0        ; We don`t need no unit
  843.         move.l    ConsoleReq,a1
  844.         move.l    #0,d1
  845.         CALLSYS    OpenDevice
  846.         tst.l    d0
  847.         bne.s    .ConsoleError
  848.         move.l    ConsoleReq,a1
  849.         move.l    IO_DEVICE(a1),_ConsoleBase    ; Get base
  850.         moveq    #1,d0
  851.         rts
  852. .ConsoleError    moveq    #0,d0
  853.         rts
  854.  
  855.  
  856.  
  857.  
  858. **********************************************************************
  859. *                     Close ConsoleDevice again                      *
  860. **********************************************************************
  861. RemoveConsole    move.l    ConsoleReq,a1
  862.         tst.l    IO_DEVICE(a1)
  863.         ble.s    .Error
  864.         CALLSYS    CloseDevice
  865. .Error        rts
  866.  
  867.  
  868.  
  869.  
  870. **********************************************************************
  871. *                          Init Audio-Datas                          *
  872. **********************************************************************
  873. InitAudio    move.l    #15,ErrorNum
  874.         CALLSYS    CreateMsgPort            ; Create port
  875.         move.l    d0,AudioPort
  876.         tst.l    d0
  877.         beq    .AudioError
  878.         move.l    d0,a1
  879.         move.b    MP_SIGBIT(a1),d0        ; Get sigmask
  880.         move.l    #AudioPortName,LN_NAME(a1)
  881.         move.b    #0,LN_PRI(a1)
  882.         DOLIB    AddPort
  883.  
  884.         move.l    #0,ErrorNum
  885.         lea    AudioName,a0
  886.         move.l    a0,EasyArg
  887.         move.l    #0,d0
  888.         move.l    AudioReq,a1
  889.         move.w    #0,ioa_AllocKey(a1)
  890.         move.l    #0,ioa_Data(a1)
  891.         move.l    #0,ioa_Length(a1)
  892.         move.l    AudioPort,MN_REPLYPORT(a1)
  893.         move.b    #80,LN_PRI(a1)
  894.         move.l    #0,d1
  895.         DOLIB    OpenDevice            ; Open device
  896.         tst.l    d0
  897.         bne.s    .AudioError
  898.  
  899.         move.l    #16,ErrorNum
  900.         bsr.s    AllocChannel            ; Try to allocate a channel
  901.         tst.l    d0
  902.         bne.s    .GoOn
  903.         bsr    DisplayError            ; Display error on failure
  904. .GoOn        move.l    #17,ErrorNum
  905.         move.l    AudioReq,a1            ; Initial soundwrite for setup
  906.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  907.         move.b    #ADIOF_PERVOL|ADIOF_NOWAIT,IO_FLAGS(a1)
  908.         move.w    #100,ioa_Period(a1)
  909.         move.w    #0,ioa_Volume(a1)
  910.         move.l    #100,ioa_Length(a1)
  911.         move.l    #ClickData,ioa_Data(a1)
  912.         move.w    #1,ioa_Cycles(a1)
  913.         move.l    IO_DEVICE(a1),a6
  914.         jsr    DEV_BEGINIO(a6)
  915.         move.l    AudioReq,a1
  916.         CALLSYS    WaitIO
  917.         moveq    #1,d0
  918.         rts
  919. .AudioError    moveq    #0,d0
  920.         rts
  921.  
  922.  
  923.  
  924.  
  925. **********************************************************************
  926. *                     Try to allocate a channel                      *
  927. **********************************************************************
  928. AllocChannel    move.l    AudioReq,a1
  929.         move.w    #ADCMD_ALLOCATE,IO_COMMAND(a1)
  930.         move.b    #ADIOF_NOWAIT|IOF_QUICK,IO_FLAGS(a1)
  931.         move.l    #AnyChannel,ioa_Data(a1)
  932.         move.l    #8,ioa_Length(a1)
  933.         move.l    IO_DEVICE(a1),a6
  934.         jsr    DEV_BEGINIO(a6)
  935.         move.l    AudioReq,a1
  936.         move.w    ioa_AllocKey(a1),AllocKey
  937.         tst.b    IO_ERROR(a1)
  938.         beq.s    .NoError
  939.         move.w    #0,AllocKey            ; On error clear the allockey
  940.         moveq    #0,d0
  941.         move.b    d0,KeyClick            ; ... the click function
  942.         move.l    #CLICKGAD,d1            ; and the gadget tick
  943.         bsr    SetControlBox
  944.         moveq    #0,d0
  945.         rts
  946. .NoError    moveq    #1,d0
  947.         rts
  948.  
  949.  
  950.  
  951.  
  952. **********************************************************************
  953. *                         Remove Audio-Stuff                         *
  954. **********************************************************************
  955. RemoveAudio    tst.l    AudioPort            ; Remove port
  956.         beq.s    .NoAudioPort
  957.         move.l    AudioPort,a1
  958.         CALLSYS    RemPort
  959.         move.l    AudioPort,a0
  960.         DOLIB    DeleteMsgPort
  961. .NoAudioPort    move.l    AudioReq,a1
  962.         tst.l    IO_DEVICE(a1)
  963.         ble.s    .NoAudioDevice
  964.         move.l    AudioReq,a1            ; Wait for request to be finished
  965.         CALLSYS    CheckIO
  966.         tst.l    d0
  967.         bne.s    .End
  968.         move.l    AudioReq,a1
  969.         DOLIB    WaitIO
  970. .End        move.l    AudioReq,a1            ; Close device
  971.         DOLIB    CloseDevice
  972. .NoAudioDevice    rts
  973.  
  974.  
  975.  
  976.  
  977.  
  978. **********************************************************************
  979. *                     Initialize the ARexx Port                      *
  980. **********************************************************************
  981. InitARexx    move.l    #11,ErrorNum
  982.         CALLSYS    CreateMsgPort            ; Create a Msg Port for ARexx
  983.         move.l    d0,ARexxPort
  984.         tst.l    d0
  985.         beq.s    .ARexxError
  986.         move.l    d0,a1
  987.         moveq    #0,d0
  988.         moveq    #1,d1
  989.         move.b    MP_SIGBIT(a1),d0        ; Get Sig flag
  990.         asl.l    d0,d1
  991.         move.l    d1,ARexxSigFlag
  992.         lea    ARexxPortName,a0
  993.         move.l    a0,LN_NAME(a1)
  994.         move.b    #0,LN_PRI(a1)
  995.         DOLIB    AddPort                ; Add port to system
  996.         moveq    #1,d0
  997. .ARexxError    rts
  998.  
  999.  
  1000.  
  1001. **********************************************************************
  1002. *                 Remove our ARexx port from System                  *
  1003. **********************************************************************
  1004. RemoveARexx    tst.l    ARexxPort
  1005.         beq.s    .NoARexxPort
  1006.         move.l    ARexxPort,a1
  1007.         bsr    KillMessages            ; Kill remaining messages
  1008.         CALLSYS    RemPort                ; Remove port
  1009.         move.l    ARexxPort,a0
  1010.         DOLIB    DeleteMsgPort
  1011. .NoARexxPort    rts
  1012.  
  1013.  
  1014.  
  1015. **********************************************************************
  1016. *                    Initialize and start broker                     *
  1017. **********************************************************************
  1018. InitBroker    bsr    RemoveBroker            ; Begin from scratch
  1019.  
  1020.         move.l    #-1,d0                ; Try to allocate signal for
  1021.         CALLSYS    AllocSignal            ; alarm
  1022.         move.l    d0,AlarmSigBit
  1023.         tst.l    d0
  1024.         blt    .NoBroker
  1025.         moveq    #1,d1
  1026.         asl.l    d0,d1
  1027.         move.l    d1,AlarmSigFlag
  1028.  
  1029.         move.l    #-1,d0                ; Try to allocate signal for
  1030.         DOLIB    AllocSignal            ; Help
  1031.         move.l    d0,HelpSigBit
  1032.         tst.l    d0
  1033.         blt    .NoBroker
  1034.         moveq    #1,d1
  1035.         asl.l    d0,d1
  1036.         move.l    d1,HelpSigFlag
  1037.  
  1038.         lea    PortName,a1            ; Find port name
  1039.         CALLSYS    FindPort            ; This is for identification
  1040.         move.l    d0,DoublePort            ; whether we are to quit
  1041.  
  1042.         move.l    _OurTask(pc),a1            ; We have to be faster than
  1043.         move.l    ToolPri,d0            ; the Input-Device
  1044.         CALLSYS    SetTaskPri
  1045.  
  1046.         move.l    #1,ErrorNum
  1047.         DOLIB    CreateMsgPort            ; Try to set msg-port
  1048.         move.l    d0,BrokerPort
  1049.         tst.l    d0
  1050.         beq    .NoBroker
  1051.         move.l    d0,a1
  1052.         moveq    #1,d0
  1053.         moveq    #0,d1
  1054.         move.b    MP_SIGBIT(a1),d1
  1055.         asl.l    d1,d0
  1056.         move.l    d0,BrokerSigFlag        ; Calc sig-flag
  1057.         lea    PortName,a0
  1058.         move.l    a0,LN_NAME(a1)
  1059.         move.b    #0,LN_PRI(a1)
  1060.         DOLIB    AddPort                ; Add port to system
  1061.  
  1062.         move.l    #2,ErrorNum
  1063.         lea    MyBrokerDef,a0            ; Create broker
  1064.         move.l    BrokerPort,nb_Port(a0)        ; add Port-Address
  1065.         move.l    CXPri,d0
  1066.         move.b    d0,nb_Pri(a0)            ; and Priority
  1067.         moveq    #0,d0                ; No errors
  1068.         LNKLIB    CxBroker,_CxBase        ; install broker structure
  1069.         tst.l    d0
  1070.         beq    .NoBroker
  1071.         move.l    d0,MyBroker
  1072.  
  1073.         move.l    #3,ErrorNum            ; Generate CUSTOM object
  1074.         lea    RawEventAction(pc),a5        ; for Input-Events
  1075.         move.l    #RAWEVENTID,d7
  1076.         bsr    InitCustom
  1077.         tst.l    d0
  1078.         beq    .NoBroker
  1079.         move.l    a4,EventFilter
  1080.  
  1081.         pea    9                ; Set PopUp key
  1082.         pea    PopUpFilter
  1083.         pea    POPUPKEYID
  1084.         pea    DefaultPopUpKey
  1085.         pea    PopUpKey
  1086.         jsr    SetHotKey
  1087.         lea    20(sp),sp
  1088.         tst.l    d0
  1089.         beq    .NoBroker
  1090.  
  1091.         pea    10                ; Set Page-Key
  1092.         pea    PageFilter
  1093.         pea    PAGEKEYID
  1094.         pea    DefPageHotKey
  1095.         pea    PageHotKey
  1096.         jsr    SetHotKey
  1097.         lea    20(sp),sp
  1098.         tst.l    d0
  1099.         beq    .NoBroker
  1100.  
  1101.         pea    22                ; Set prefs hotkey
  1102.         pea    PrefsFilter
  1103.         pea    PREFSKEYID
  1104.         pea    DefPrefsHotKey
  1105.         pea    PrefsHotKey
  1106.         jsr    SetHotKey
  1107.         lea    20(sp),sp
  1108.         tst.l    d0
  1109.         beq    .NoBroker
  1110.  
  1111.         pea    23                ; Set bill hotkey
  1112.         pea    BillFilter
  1113.         pea    BILLKEYID
  1114.         pea    DefBillHotKey
  1115.         pea    BillHotKey
  1116.         jsr    SetHotKey
  1117.         lea    20(sp),sp
  1118.         tst.l    d0
  1119.         beq    .NoBroker
  1120.  
  1121.         pea    24                ; Set HotWin hotkey
  1122.         pea    HotKeyFilter
  1123.         pea    HOTWINKEYID
  1124.         pea    DefHotWinHotKey
  1125.         pea    HotWinHotKey
  1126.         jsr    SetHotKey
  1127.         lea    20(sp),sp
  1128.         tst.l    d0
  1129.         beq    .NoBroker
  1130.  
  1131.         pea    25                ; Set Shell HotKey
  1132.         pea    ShellFilter
  1133.         pea    SHELLKEYID
  1134.         pea    DefShellHotKey
  1135.         pea    ShellHotKey
  1136.         jsr    SetHotKey
  1137.         lea    20(sp),sp
  1138.         tst.l    d0
  1139.         beq.s    .NoBroker
  1140.  
  1141.         pea    27                ; Set Umlaut HotKey
  1142.         pea    UmlautFilter
  1143.         pea    UMLAUTKEYID
  1144.         pea    DefUmlautHK
  1145.         pea    UmlautHotKey
  1146.         jsr    SetHotKey
  1147.         lea    20(sp),sp
  1148.         tst.l    d0
  1149.         beq.s    .NoBroker
  1150.  
  1151.         move.l    #4,ErrorNum
  1152.         move.l    EventFilter,a0            ; Check for an error in filter
  1153.         DOLIB    CxObjError,_CxBase        ; For activation stuff
  1154.         tst.l    d0
  1155.         bne.s    .NoBroker
  1156.  
  1157.         move.l    #5,ErrorNum
  1158.         move.l    MyBroker,a0            ; Check for an error in broker
  1159.         DOLIB    CxObjError,_CxBase
  1160.         tst.l    d0
  1161.         bne.s    .NoBroker
  1162.  
  1163.         move.b    #0,Disabled
  1164.         bsr    EnableBroker            ; Enable broker
  1165.  
  1166.         moveq    #1,d0                ; No error
  1167.         rts
  1168. .NoBroker    moveq    #0,d0                ; error occured
  1169.         rts
  1170.  
  1171.  
  1172.  
  1173. **********************************************************************
  1174. *                         Remove the broker                          *
  1175. **********************************************************************
  1176. RemoveBroker    tst.l    BrokerPort            ; Remove broker and all
  1177.         beq.s    .NoPort                ; attached objects
  1178.  
  1179.         move.b    #0,Disabled            ; Disable broker
  1180.         bsr    DisableBroker
  1181.  
  1182.         move.l    MyBroker,a0            ; Delete broker
  1183.         LNKLIB    DeleteCxObjAll,_CxBase
  1184.  
  1185.         move.l    BrokerPort,a1
  1186.         bsr    KillMessages            ; remove messages
  1187.         CALLSYS    RemPort
  1188.         move.l    BrokerPort,a0            ; Finally delete the
  1189.         DOLIB    DeleteMsgPort            ; Messageport
  1190. .NoPort        tst.l    AlarmSigBit
  1191.         blt.s    .NoSigBit
  1192.         move.l    AlarmSigBit,d0
  1193.         CALLSYS    FreeSignal            ; Free Help-Signal
  1194. .NoSigBit    tst.l    HelpSigBit
  1195.         blt.s    .NoHelpSig
  1196.         move.l    HelpSigBit,d0
  1197.         CALLSYS    FreeSignal
  1198. .NoHelpSig    rts
  1199.  
  1200.  
  1201.  
  1202. **********************************************************************
  1203. *           Add an AppIcon. This one uses the Broker-Port            *
  1204. **********************************************************************
  1205. InitAppIcon    tst.l    AppPort
  1206.         bne.s    .PortThere
  1207.         CALLSYS    CreateMsgPort
  1208.         tst.l    d0
  1209.         beq.s    .Error
  1210.         move.l    d0,AppPort
  1211.         move.l    d0,a1
  1212.         move.b    #0,LN_PRI(a1)
  1213.         move.l    #AppPortName,LN_NAME(a1)
  1214.         moveq    #0,d0
  1215.         moveq    #1,d1
  1216.         move.b    MP_SIGBIT(a1),d0
  1217.         asl.l    d0,d1
  1218.         move.l    d1,AppSigFlag
  1219.         moveq    #1,d0
  1220.         moveq    #0,d1
  1221.         DOLIB    AddPort
  1222. .PortThere    tst.l    KCXAppIcon
  1223.         bne.s    .Error
  1224.         moveq    #1,d0
  1225.         tst.b    DispAppIcon
  1226.         beq.s    .Error
  1227.         lea    AppIconText,a0            ; Display AppIcon
  1228.         move.l    AppPort,a1
  1229.         sub.l    a2,a2
  1230.         lea    KCXAppIconDef,a3
  1231.         sub.l    a4,a4
  1232.         LNKLIB    AddAppIconA,_WorkBenchBase
  1233.         move.l    d0,KCXAppIcon
  1234. .Error        rts
  1235.  
  1236.  
  1237.  
  1238.  
  1239. **********************************************************************
  1240. *                         Remove our AppIcon                         *
  1241. **********************************************************************
  1242. RemoveAppIcon    tst.l    KCXAppIcon            ; First remove icon
  1243.         beq.s    .NoIcon
  1244.         move.l    KCXAppIcon,a0
  1245.         LNKLIB    RemoveAppIcon,_WorkBenchBase
  1246.         move.l    #0,KCXAppIcon
  1247. .NoIcon        tst.l    AppPort
  1248.         beq.s    .NoPort
  1249.         move.l    AppPort,a1            ; Clear all pending messages
  1250.         bsr    KillMessages
  1251.         move.l    AppPort,a1            ; Remove port
  1252.         CALLSYS    RemPort
  1253.         move.l    AppPort,a0
  1254.         DOLIB    DeleteMsgPort
  1255. .NoPort        rts
  1256.  
  1257.  
  1258.  
  1259.  
  1260. **********************************************************************
  1261. *               Add some menu items to the tools menu                *
  1262. **********************************************************************
  1263. InitAppItems    lea    AppItemID,a3            ; Create all items
  1264.         lea    AppItemTxt,a4
  1265.         lea    AppItemPtr,a5
  1266.         move.l    #APPITEMNUM-1,d6
  1267. .MakeAppItems    move.l    (a3)+,d0
  1268.         move.l    #0,d1
  1269.         move.l    (a4)+,a0
  1270.         move.l    AppPort,a1
  1271.         sub.l    a2,a2
  1272.         LNKLIB    AddAppMenuItemA,_WorkBenchBase
  1273.         move.l    d0,(a5)+
  1274.         tst.l    d0
  1275.         beq.s    .Error
  1276.         dbf    d6,.MakeAppItems
  1277. .Error        rts
  1278.  
  1279.  
  1280.  
  1281.  
  1282. **********************************************************************
  1283. *                    Remove our menu items again                     *
  1284. **********************************************************************
  1285. RemoveAppItems    lea    AppItemPtr,a4            ; Loop for all items
  1286.         move.l    #APPITEMNUM-1,d6
  1287. .RemAppItems    tst.l    (a4)
  1288.         beq.s    .NoRemove
  1289.         move.l    (a4),a0
  1290.         LNKLIB    RemoveAppMenuItem,_WorkBenchBase
  1291. .NoRemove    addq.l    #4,a4
  1292.         dbf    d6,.RemAppItems
  1293.         rts
  1294.  
  1295.  
  1296.  
  1297.  
  1298. **********************************************************************
  1299. *          Try to set a hotkey. Inputs are given on stack :          *
  1300. * 1. HotKey Definition                                               *
  1301. * 2. Default HotKey Definition                                       *
  1302. * 3. HotKey ID                                                       *
  1303. * 4. Address of filter                                               *
  1304. * 5. Errornumber                                                     *
  1305. **********************************************************************
  1306. SetHotKey    CARGS    #8,HotKey.l,DefHotKey.l,ID.l,Filter.l,Error.l
  1307.         link    a5,#0
  1308.         move.l    #26,ErrorNum
  1309.         move.l    HotKey(a5),EasyArg
  1310.         move.l    HotKey(a5),a0            ; Try to set "user" hotkey
  1311.         move.l    ID(a5),d7
  1312.         bsr.s    InitHotKey
  1313.         tst.l    d0
  1314.         bne.s    .GotUserHotKey            ; Got it -> go on
  1315.         move.l    HotKey(a5),a0            ; Clone user-hotkey
  1316.         move.l    ReadBuffer,a1
  1317.         bsr    StrCpy
  1318.         move.l    DefHotKey(a5),a0        ; Try default
  1319.         move.l    HotKey(a5),a1
  1320.         bsr    StrCpy                ; First copy it
  1321.         move.l    DefHotKey(a5),a0
  1322.         move.l    ID(a5),d7
  1323.         bsr.s    InitHotKey
  1324.         tst.l    d0
  1325.         bne.s    .GotDefHotKey            ; Error ???
  1326.         bsr    DisplayError            ; Display error
  1327.         bra.s    .Error
  1328. .GotDefHotKey    move.l    Error(a5),ErrorNum        ; Tell user we`re using ours
  1329.         move.l    ReadBuffer,d0
  1330.         move.l    d0,EasyArg
  1331.         bsr    DisplayError
  1332. .GotUserHotKey    move.l    Filter(a5),a0
  1333.         move.l    a4,(a0)
  1334.         move.l    MyBroker,a0
  1335.         move.l    a4,a1
  1336.         LNKLIB    AttachCxObj,_CxBase        ; Attach hotkey stuff
  1337.         unlk    a5
  1338.         moveq    #1,d0
  1339.         rts
  1340. .Error        unlk    a5
  1341.         moveq    #0,d0
  1342.         rts
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348. **********************************************************************
  1349. *                       Try to create a hotkey                       *
  1350. **********************************************************************
  1351. InitHotKey    move.l    #CX_FILTER,d0            ; Try to create the hotkey for popup
  1352.         sub.l    a1,a1
  1353.         DOLIB    CreateCxObj,_CxBase        ; Create a filter for descriptive string
  1354.         tst.l    d0
  1355.         beq.s    .Error
  1356.         move.l    d0,a4
  1357.         moveq    #CX_SEND,d0
  1358.         move.l    BrokerPort(pc),a0
  1359.         move.l    d7,a1                ; Set ID for HotKey
  1360.         DOLIB    CreateCxObj,_CxBase        ; Create a SENDER object to our port
  1361.         move.l    a4,a0
  1362.         move.l    d0,a1
  1363.         DOLIB    AttachCxObj,_CxBase        ; Attach it to the filter
  1364.         moveq    #CX_TRANSLATE,d0
  1365.         sub.l    a0,a0
  1366.         move.l    a0,a1
  1367.         DOLIB    CreateCxObj,_CxBase        ; Create a translator for msg
  1368.         move.l    a4,a0
  1369.         move.l    d0,a1
  1370.         DOLIB    AttachCxObj,_CxBase        ; Attach it
  1371.         move.l    a4,a0
  1372.         DOLIB    CxObjError,_CxBase        ; Any errors ??
  1373.         tst.l    d0
  1374.         beq.s    .GotHotKey            ; Nope -> go on
  1375.         move.l    a4,a0
  1376.         DOLIB    DeleteCxObjAll,_CxBase        ; Delete hotkey
  1377. .Error        moveq    #0,d0
  1378.         rts
  1379. .GotHotKey    moveq    #1,d0
  1380.         rts
  1381.  
  1382.  
  1383.  
  1384.  
  1385. **********+***********************************************************
  1386. *                 Try to initialize a CUSTOM-Filter                  *
  1387. **********************************************************************
  1388. InitCustom    move.l    #CX_FILTER,d0            ; Install a Commodities-Object
  1389.         sub.l    a0,a0                ; which works as a filter
  1390.         sub.l    a1,a1                ; for Input-Events
  1391.         DOLIB    CreateCxObj
  1392.         tst.l    d0
  1393.         beq.s    .End
  1394.         move.l    d0,a4
  1395.  
  1396.         move.l    MyBroker(pc),a0            ; Attach Filter to Broker
  1397.         move.l    a4,a1
  1398.         DOLIB    AttachCxObj
  1399.  
  1400.         move.l    a4,a0                ; Init Filter with values
  1401.         lea    MyCustomIXDef,a1
  1402.         DOLIB    SetFilterIX
  1403.  
  1404.         move.l    #CX_CUSTOM,d0            ; Create signal-object
  1405.         move.l    a5,a0
  1406.         move.l    d7,a1
  1407.         DOLIB    CreateCxObj
  1408.         tst.l    d0
  1409.         beq.s    .End
  1410.  
  1411.         move.l    a4,a0                ; Attach new object
  1412.         move.l    d0,a1
  1413.         DOLIB    AttachCxObj
  1414. .End        rts
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420. **********************************************************************
  1421. *               Copy default hotkeys to "user" buffers               *
  1422. **********************************************************************
  1423. MakeHotKeys    lea    DefaultPopUpKey,a0
  1424.         lea    PopUpKey,a1
  1425.         bsr    StrCpy
  1426.         lea    DefPageHotKey,a0
  1427.         lea    PageHotKey,a1
  1428.         bsr    StrCpy
  1429.         lea    DefPrefsHotKey,a0
  1430.         lea    PrefsHotKey,a1
  1431.         bsr    StrCpy
  1432.         lea    DefBillHotKey,a0
  1433.         lea    BillHotKey,a1
  1434.         bsr    StrCpy
  1435.         lea    DefHotWinHotKey,a0
  1436.         lea    HotWinHotKey,a1
  1437.         bsr    StrCpy
  1438.         lea    DefShellHotKey,a0
  1439.         lea    ShellHotKey,a1
  1440.         bsr    StrCpy
  1441.         lea    DefUmlautHK,a0
  1442.         lea    UmlautHotKey,a1
  1443.         bsr    StrCpy
  1444.         rts
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450. **********************************************************************
  1451. *                      Get the given tooltypes                       *
  1452. **********************************************************************
  1453. GetToolTypes    move.l    _ArgV(pc),a0
  1454.         lea    ToolPriStr,a1            ; Change the Tool-Pri ?
  1455.         LNKLIB    FindToolType,_IconBase
  1456.         tst.l    d0
  1457.         beq.s    NoToolPri            ; No -> go on
  1458.         move.l    d0,d1
  1459.         move.l    #ToolPri,d2
  1460.         LNKLIB    StrToLong,_DOSBase
  1461.         cmp.l    #21,ToolPri            ; Pri < 21 ???
  1462.         bge.s    NoToolPri
  1463.         move.l    #21,ToolPri            ; Yep -> 21 is minimum
  1464. NoToolPri    move.l    _ArgV(pc),a0
  1465.         lea    PriStr,a1            ; Change broker pri ?
  1466.         LNKLIB    FindToolType,_IconBase
  1467.         tst.l    d0
  1468.         beq.s    NoCxPri                ; No -> go on
  1469.         move.l    d0,d1
  1470.         move.l    #CXPri,d2
  1471.         LNKLIB    StrToLong,_DOSBase        ; Set pri
  1472.         tst.l    d0
  1473.         bge.s    NoCxPri
  1474.         move.l    #0,CXPri
  1475. NoCxPri        move.l    _ArgV(pc),a0
  1476.         lea    PortNameStr,a1
  1477.         LNKLIB    FindToolType,_IconBase        ; New ARexx-PortName ?
  1478.         tst.l    d0
  1479.         beq.s    NoPortName
  1480.         move.l    d0,a0
  1481.         lea    ARexxPortName(pc),a1
  1482.         bsr    StrCpy
  1483. NoPortName    move.l    _ArgV(pc),a0
  1484.         lea    KeyStr,a1
  1485.         DOLIB    FindToolType            ; Do we have a new pop up key ?
  1486.         tst.l    d0
  1487.         beq.s    NoPopKey            ; Nope -> go on
  1488.         move.l    d0,a0
  1489.         lea    PopUpKey,a1            ; Copy PopUpKey
  1490.         bsr    StrCpy
  1491. NoPopKey    move.l    _ArgV(pc),a0            ; Check for PopUp flag
  1492.         lea    PopUpStr(pc),a1
  1493.         DOLIB    FindToolType
  1494.         tst.l    d0
  1495.         beq.s    DoNotPopUp
  1496.         move.l    d0,a0                ; Do we have a NO flag
  1497.         lea    NoString,a1
  1498.         DOLIB    MatchToolValue
  1499.         tst.l    d0
  1500.         beq.s    DoNotPopUp
  1501.         move.b    #0,DoPopUp            ; Let the window pop up
  1502. DoNotPopUp    move.l    _ArgV(pc),a0            ; Display AppIcon ?
  1503.         lea    IconStr,a1
  1504.         DOLIB    FindToolType
  1505.         tst.l    d0
  1506.         beq.s    NoAppIcon
  1507.         move.b    #0,DispAppIcon
  1508. NoAppIcon    rts
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515. **********************************************************************
  1516. *                Try to read in the default PrefsFile                *
  1517. **********************************************************************
  1518. LoadPrefs    move.l    #PrefsFileName,d1        ; Try to open file
  1519.         move.l    d1,EasyArg
  1520.         move.l    #MODE_OLDFILE,d2
  1521.         LNKLIB    Open,_DOSBase
  1522.         move.l    d0,d7
  1523.         tst.l    d0
  1524.         beq    .AOk
  1525.         move.l    d7,d1                ; Read flags
  1526.         move.l    #DoActivate,d2
  1527.         move.l    #FLAGSET,d3
  1528.         DOLIB    Read
  1529.         cmp.l    #FLAGSET,d0
  1530.         bne    .AOk
  1531.         move.l    d7,d1
  1532.         move.l    #ScreenTime,d2
  1533.         move.l    #LONGQUAL,d3
  1534.         DOLIB    Read
  1535.         cmp.l    #LONGQUAL,d0
  1536.         bne    .AOk
  1537.         move.l    d7,d1                ; Read bill win pos
  1538.         move.l    #BillWinDef,d2
  1539.         move.l    #4,d3
  1540.         DOLIB    Read
  1541.         cmp.l    #4,d0
  1542.         bne    .AOk
  1543.         move.l    d7,d1                ; Read clock win pos
  1544.         move.l    #ClockWinDef,d2
  1545.         move.l    #4,d3
  1546.         DOLIB    Read
  1547.         cmp.l    #4,d0
  1548.         bne    .AOk
  1549.         move.l    d7,d1                ; Read in rest
  1550.         move.l    ReadBuffer,d2
  1551.         move.l    #$FFFFFF,d3
  1552.         DOLIB    Read
  1553.         tst.l    d0
  1554.         ble    .AOk
  1555.         lea    HotKeyGadStat,a4        ; Copy new HotKeys
  1556.         move.l    ReadBuffer,a0
  1557.         move.l    #6,d6
  1558. .NewHotKeys    move.l    (a4)+,a1
  1559.         bsr    StrCpy
  1560.         dbf    d6,.NewHotKeys
  1561.         lea    SystemParam,a1            ; Copy new Shell-Command
  1562.         bsr    StrCpy
  1563.         lea    AlarmStartVal,a1        ; Copy new alarm time
  1564.         bsr    StrCpy
  1565.         lea    LogFileName,a1            ; Copy full name to buffer
  1566.         bsr    StrCpy
  1567.         move.l    a0,a4                ; Store pointer to values
  1568.         lea    LogFileName,a0            ; Extract dir name
  1569.         sub.l    a2,a2
  1570. .ExtractFile    tst.b    (a0)
  1571.         beq.s    .FileEnd
  1572.         cmp.b    #':',(a0)
  1573.         beq.s    .GotDir
  1574.         cmp.b    #'/',(a0)
  1575.         bne.s    .NoDir
  1576. .GotDir        move.l    a0,a2                ; Store pointer to last dir symbol
  1577. .NoDir        addq.l    #1,a0
  1578.         bra.s    .ExtractFile
  1579. .FileEnd    cmp.l    #0,a2                ; Dir symbol found ?
  1580.         beq.s    .NoPath                ; Nope -> go on
  1581.         move.b    1(a2),d6            ; Store char
  1582.         move.b    #0,1(a2)            ; Set end of dir name
  1583.         lea    LogFileName,a0            ; Copy dir name
  1584.         lea    LogPath,a1
  1585.         bsr    StrCpy
  1586.         move.b    d6,1(a2)            ; Restore file name
  1587.         bra.s    .EndDir
  1588. .NoPath        move.b    #0,LogPath            ; No dir name given
  1589. .EndDir        lea    1(a2),a0            ; Copy filename
  1590.         lea    LogFile,a1
  1591.         bsr    StrCpy
  1592.         move.l    a4,a0
  1593.         lea    CostUnit1,a1            ; Copy values
  1594.         move.l    #27,d6
  1595. .CopyRest    move.b    (a0)+,(a1)+
  1596.         dbf    d6,.CopyRest
  1597.         lea    PTimeZone,a1            ; Copy timezone and tariff
  1598.         move.l    #7,d6
  1599. .CopyModes    move.b    (a0)+,(a1)+
  1600.         dbf    d6,.CopyModes
  1601.         lea    FileReqWidth,a1            ; Copy width and height of filereq
  1602.         lea    FileReqHeight,a2
  1603.         lea    4(a0),a3
  1604.         move.l    #3,d6
  1605. .CopySize    move.b    (a0)+,(a1)+
  1606.         move.b    (a3)+,(a2)+
  1607.         dbf    d6,.CopySize
  1608.         lea    4(a0),a0
  1609.         lea    FileReqLeft,a1            ; Copy position of filereq
  1610.         lea    FileReqTop,a2
  1611.         lea    4(a0),a3
  1612.         move.l    #3,d6
  1613. .CopyPos    move.b    (a0)+,(a1)+
  1614.         move.b    (a3)+,(a2)+
  1615.         dbf    d6,.CopyPos
  1616. .AOk        tst.l    d7                ; Close file
  1617.         beq    .End
  1618.         move.l    d7,d1
  1619.         LNKLIB    Close,_DOSBase
  1620.  
  1621.         bsr    RemakeGadgets            ; Remake checkboxes
  1622.  
  1623.         move.l    #FRONTGAD,d0            ; Remake POP qualifier
  1624.         lea    ControlGads,a0
  1625.         move.l    WndHandle,a1
  1626.         move.l    PopQualNum,d1
  1627.         lea    PopQualList,a2
  1628.         bsr    SetCycleGad
  1629.  
  1630.         move.l    #ESCQUALGAD,d0            ; Remake close qualifier
  1631.         move.l    ESCQualNum,d1
  1632.         lea    ControlGads,a0
  1633.         move.l    WndHandle,a1
  1634.         lea    ESCQualList,a2
  1635.         bsr    SetCycleGad
  1636.  
  1637.         move.l    #SCREENGAD,d0            ; Remake screentime gadget
  1638.         lea    ControlGads,a0
  1639.         move.l    WndHandle(pc),a1
  1640.         move.l    #3,d1
  1641.         move.l    ScreenTime,d2
  1642.         bsr    SetIntegerGad
  1643.  
  1644.         move.l    #MOUSEGAD,d0            ; Remake mousetime gadget
  1645.         lea    ControlGads,a0
  1646.         move.l    WndHandle,a1
  1647.         moveq    #3,d1
  1648.         move.l    MouseTime,d2
  1649.         bsr    SetIntegerGad
  1650.  
  1651.         move.l    #VOLGAD,d0            ; Remake volume gadget
  1652.         lea    ControlGads,a0
  1653.         move.l    WndHandle,a1
  1654.         moveq    #2,d1
  1655.         move.l    ClickVol,d2
  1656.         bsr    SetIntegerGad
  1657.  
  1658.         lea    CostUnit1,a3            ; Remake these 6 cost gadgets
  1659.         moveq    #1,d7
  1660.         moveq    #5,d6
  1661. .RemakeCosts    move.l    d7,d0
  1662.         lea    PrefsGads,a0
  1663.         move.l    PrefsHandle,a1
  1664.         moveq    #4,d1
  1665.         move.l    (a3)+,d2
  1666.         addq.l    #1,d7
  1667.         bsr    SetIntegerGad
  1668.         dbf    d6,.RemakeCosts
  1669.  
  1670.         move.l    #COSTGAD,d0            ; Remake cost/unit gad
  1671.         lea    PrefsGads,a0
  1672.         move.l    PrefsHandle,a1
  1673.         moveq    #4,d1
  1674.         move.l    CostUnit,d2
  1675.         bsr    SetIntegerGad
  1676.  
  1677.         move.l    #LOGFILEGAD,d0            ; Remake Log-FileName
  1678.         lea    PrefsGads,a0
  1679.         move.l    PrefsHandle,a1
  1680.         move.l    #286,d1
  1681.         lea    LogFileName,a2
  1682.         bsr    SetStringGad
  1683.  
  1684.         move.l    #PTIMEGAD,d1            ; Set Prefs time gad
  1685.         lea    PrefsGads,a0
  1686.         move.l    PrefsHandle,a1
  1687.         move.l    PTimeZone,d0
  1688.         lea    PrefsTimeLabels,a2
  1689.         bsr    SetMXGad
  1690.  
  1691.         move.l    #PMODEGAD,d1            ; Set Prefs mode gad
  1692.         lea    PrefsGads,a0
  1693.         move.l    PrefsHandle,a1
  1694.         move.l    PTariff,d0
  1695.         lea    PrefsModeLabels,a2
  1696.         bsr    SetMXGad
  1697.  
  1698.         move.l    #BILLPOPGAD,d1            ; Set POPUP gadget
  1699.         lea    PrefsGads,a0
  1700.         move.l    PrefsHandle,a1
  1701.         move.b    BillPopUp,d0
  1702.         bsr    SetCheckBox
  1703.  
  1704.         move.l    #LOGCALLGAD,d1            ; Set LogCalls gadget
  1705.         lea    PrefsGads,a0
  1706.         move.l    PrefsHandle,a1
  1707.         move.b    LogCalls,d0
  1708.         bsr    SetCheckBox
  1709.  
  1710.         move.b    #1,DoRemakeCosts
  1711.         bsr    RemakeCosts            ; Remake costs to new values
  1712.  
  1713.         move.l    ReadBuffer,a3            ; Remake new HotKeys
  1714.         move.l    a3,a0
  1715.         move.l    ReadBuffer,a1
  1716.         bsr    StrCpy
  1717.         move.l    a0,a3
  1718.         move.l    #POPUPGAD,d7
  1719.         move.l    HotKeyHandle,a0
  1720.         lea    HotWinTitle,a1
  1721.         move.l    PopUpFilter,a4
  1722.         lea    PopUpKey,a5
  1723.         bsr    RemakeHotKey
  1724.  
  1725.         move.l    a3,a0
  1726.         move.l    ReadBuffer,a1
  1727.         bsr    StrCpy
  1728.         move.l    a0,a3
  1729.         move.l    #PAGEGAD,d7
  1730.         sub.l    a0,a0
  1731.         sub.l    a1,a1
  1732.         move.l    PageFilter,a4
  1733.         lea    PageHotKey,a5
  1734.         bsr    RemakeHotKey
  1735.  
  1736.         move.l    a3,a0
  1737.         move.l    ReadBuffer,a1
  1738.         bsr    StrCpy
  1739.         move.l    a0,a3
  1740.         move.l    #BILLKEYGAD,d7
  1741.         move.l    BillHandle,a0
  1742.         lea    BillTitle,a1
  1743.         move.l    BillFilter,a4
  1744.         lea    BillHotKey,a5
  1745.         bsr    RemakeHotKey
  1746.  
  1747.         move.l    a3,a0
  1748.         move.l    ReadBuffer,a1
  1749.         bsr    StrCpy
  1750.         move.l    a0,a3
  1751.         move.l    #PREFSKEYGAD,d7
  1752.         move.l    PrefsHandle,a0
  1753.         lea    PrefsTitle,a1
  1754.         move.l    PrefsFilter,a4
  1755.         lea    PrefsHotKey,a5
  1756.         bsr    RemakeHotKey
  1757.  
  1758.         move.l    a3,a0
  1759.         move.l    ReadBuffer,a1
  1760.         bsr    StrCpy
  1761.         move.l    a0,a3
  1762.         move.l    #HOTKEYGAD,d7
  1763.         move.l    HotKeyHandle,a0
  1764.         lea    HotWinTitle,a1
  1765.         move.l    HotKeyFilter,a4
  1766.         lea    HotWinHotKey,a5
  1767.         bsr    RemakeHotKey
  1768.  
  1769.         move.l    a3,a0
  1770.         move.l    ReadBuffer,a1
  1771.         bsr    StrCpy
  1772.         move.l    a0,a3
  1773.         move.l    #SHELLGAD,d7
  1774.         sub.l    a0,a0
  1775.         sub.l    a1,a1
  1776.         move.l    ShellFilter,a4
  1777.         lea    ShellHotKey,a5
  1778.         bsr    RemakeHotKey
  1779.  
  1780.         move.l    a3,a0
  1781.         move.l    ReadBuffer,a1
  1782.         bsr    StrCpy
  1783.         move.l    a0,a3
  1784.         move.l    #UMLAUTKEYGAD,d7
  1785.         sub.l    a0,a0
  1786.         sub.l    a1,a1
  1787.         move.l    UmlautFilter,a4
  1788.         lea    UmlautHotKey,a5
  1789.         bsr    RemakeHotKey
  1790.  
  1791.         move.l    #USERSHELLGAD,d0        ; Remake shell command
  1792.         lea    ControlGads,a0
  1793.         move.l    WndHandle,a1
  1794.         move.l    #64,d1
  1795.         lea    SystemParam,a2
  1796.         bsr    SetStringGad
  1797.  
  1798.         tst.l    BillHandle
  1799.         beq.s    .NoBillRePos
  1800.         lea    BillWinDef,a1
  1801.         move.w    nw_LeftEdge(a1),d0
  1802.         move.w    nw_TopEdge(a1),d1
  1803.         move.l    BillHandle,a0
  1804.         move.w    wd_Width(a0),d2
  1805.         move.w    wd_Height(a0),d3
  1806.         LNKLIB    ChangeWindowBox,_IntuitionBase
  1807. .NoBillRePos    tst.l    ClockHandle
  1808.         beq.s    .End
  1809.         lea    ClockWinDef,a1
  1810.         move.w    nw_LeftEdge(a1),d0
  1811.         move.w    nw_TopEdge(a1),d1
  1812.         move.l    ClockHandle,a0
  1813.         move.w    wd_Width(a0),d2
  1814.         move.w    wd_Height(a0),d3
  1815.         LNKLIB    ChangeWindowBox,_IntuitionBase
  1816. .End        rts
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823. **********************************************************************
  1824. *                      Save preferences to disk                      *
  1825. **********************************************************************
  1826. SavePrefs    move.l    #PrefsFileName,d1        ; Write new prefs to file
  1827.         move.l    d1,EasyArg
  1828.         move.l    #MODE_NEWFILE,d2
  1829.         LNKLIB    Open,_DOSBase
  1830.         move.l    d0,d7
  1831.         tst.l    d0
  1832.         beq    .Error
  1833.         move.l    d7,d1
  1834.         move.l    #DoActivate,d2            ; Write bool-flags
  1835.         move.l    #FLAGSET,d3
  1836.         DOLIB    Write
  1837.         cmp.l    #FLAGSET,d0
  1838.         blt    .Error
  1839.         move.l    d7,d1
  1840.         move.l    #ScreenTime,d2            ; Long values
  1841.         move.l    #LONGQUAL,d3
  1842.         DOLIB    Write
  1843.         cmp.l    #LONGQUAL,d0
  1844.         blt    .Error
  1845.         lea    BillWinDef,a0
  1846.         lea    nw_LeftEdge(a0),a0
  1847.         move.l    d7,d1                ; Store bill window pos
  1848.         move.l    a0,d2
  1849.         move.l    #4,d3
  1850.         DOLIB    Write
  1851.         cmp.l    #4,d0
  1852.         blt    .Error
  1853.         lea    ClockWinDef,a0
  1854.         lea    nw_LeftEdge(a0),a0
  1855.         move.l    d7,d1                ; Store clock win pos
  1856.         move.l    a0,d2
  1857.         move.l    #4,d3
  1858.         DOLIB    Write
  1859.         cmp.l    #4,d0
  1860.         blt    .Error
  1861.         lea    HotKeyGadStat,a4        ; Store HotKeys
  1862.         moveq    #6,d5
  1863. .WriteHotKeys    move.l    d7,d1
  1864.         move.l    (a4)+,a0
  1865.         bsr    StrLen
  1866.         move.l    a0,d2
  1867.         move.l    d0,d3
  1868.         addq.l    #1,d3
  1869.         move.l    d3,d6
  1870.         DOLIB    Write
  1871.         cmp.l    d6,d0
  1872.         bne    .Error
  1873.         dbf    d5,.WriteHotKeys
  1874.         move.l    d7,d1                ; Write NewShell command
  1875.         lea    SystemParam,a0
  1876.         bsr    StrLen
  1877.         move.l    a0,d2
  1878.         move.l    d0,d3
  1879.         addq.l    #1,d3
  1880.         move.l    d3,d6
  1881.         DOLIB    Write
  1882.         cmp.l    d6,d0
  1883.         bne    .Error
  1884.         move.l    d7,d1                ; Write Alarm time
  1885.         lea    AlarmStartVal,a0
  1886.         bsr    StrLen
  1887.         move.l    a0,d2
  1888.         move.l    d0,d3
  1889.         addq.l    #1,d3
  1890.         move.l    d3,d6
  1891.         DOLIB    Write
  1892.         cmp.l    d6,d0
  1893.         bne    .Error
  1894.         move.l    d7,d1
  1895.         lea    LogFileName,a0            ; Write filename for LogFile
  1896.         bsr    StrLen
  1897.         move.l    d0,d3
  1898.         move.l    d0,d6
  1899.         addq.l    #1,d3
  1900.         move.l    a0,d2
  1901.         DOLIB    Write
  1902.         cmp.l    d6,d0
  1903.         blt    .Error
  1904.         move.l    d7,d1
  1905.         move.l    #CostUnit1,d2            ; Write new settings
  1906.         move.l    #28,d3
  1907.         DOLIB    Write
  1908.         cmp.l    #28,d0
  1909.         blt.s    .Error
  1910.         move.l    d7,d1
  1911.         move.l    #PTimeZone,d2            ; Write timezone and tariff
  1912.         move.l    #8,d3
  1913.         DOLIB    Write
  1914.         cmp.l    #8,d0
  1915.         blt.s    .Error
  1916.         move.l    d7,d1
  1917.         move.l    #FileReqWidth,d2        ; Write FileReq-Width
  1918.         move.l    #4,d3
  1919.         DOLIB    Write
  1920.         cmp.l    #4,d0
  1921.         blt.s    .Error
  1922.         move.l    d7,d1
  1923.         move.l    #FileReqHeight,d2        ; Write FileReq-Height
  1924.         move.l    #4,d3
  1925.         DOLIB    Write
  1926.         cmp.l    #4,d0
  1927.         blt.s    .Error
  1928.         move.l    d7,d1
  1929.         move.l    #FileReqLeft,d2            ; Write FileReq-LeftEdge
  1930.         move.l    #4,d3
  1931.         DOLIB    Write
  1932.         cmp.l    #4,d0
  1933.         blt.s    .Error
  1934.         move.l    d7,d1
  1935.         move.l    #FileReqTop,d2            ; Write FileReq-TopEdge
  1936.         move.l    #4,d3
  1937.         DOLIB    Write
  1938.         cmp.l    #4,d0
  1939.         blt.s    .Error
  1940.         bra.s    .AOk
  1941. .Error        DOLIB    IoErr                ; Error occured ?
  1942.         move.l    d0,ErrorNum
  1943.         move.l    d7,-(sp)
  1944.         bsr    DisplayError
  1945.         move.l    (sp)+,d7
  1946. .AOk        tst.l    d7
  1947.         beq.s    .End
  1948.         move.l    d7,d1                ; Close file
  1949.         LNKLIB    Close,_DOSBase
  1950. .End        rts
  1951.  
  1952.  
  1953.  
  1954.  
  1955. **********************************************************************
  1956. *  This routine initializes the process to handle all timer events   *
  1957. **********************************************************************
  1958. InitChecker    move.l    #CheckerTags,d1            ; Start Process with tags
  1959.         LNKLIB    CreateNewProc,_DOSBase
  1960.         tst.l    d0
  1961.         beq.s    .Error
  1962.         move.l    #10,d1                ; Wait a bit until set up
  1963.         DOLIB    Delay
  1964.         lea    CheckerName(pc),a1        ; Find Task structure of Process
  1965.         CALLSYS    FindTask
  1966.         move.l    d0,CheckerProc
  1967. .Error        rts
  1968.  
  1969.  
  1970.  
  1971.  
  1972. **********************************************************************
  1973. *          This is the small process to handle timer events          *
  1974. **********************************************************************
  1975. TimeChecker    movem.l    RegsAll,-(sp)
  1976.  
  1977.         bsr    InitTimer            ; Init timer
  1978.         tst.l    d0
  1979.         beq    CheckerError
  1980.  
  1981. .Loop        move.l    TimerSigFlag(pc),d0        ; Wait for signal of timer
  1982.         or.l    #SIGHANDSHAKE,d0        ; for signal to go away
  1983.         or.l    #SIGTIMEREMAKE,d0        ; for signal to remake display
  1984.         or.l    #SIGBILLWIN,d0            ; pop up bill window
  1985.         or.l    BillSigFlag(pc),d0        ; message from bill window
  1986.         or.l    ClockSigFlag(pc),d0        ; message from clock window
  1987.         CALLSYS    Wait
  1988.         move.l    d0,CheckerProcSig
  1989.  
  1990.         move.l    CheckerProcSig(pc),d0        ; Are we to go away ?
  1991.         and.l    #SIGHANDSHAKE,d0
  1992.         bne    CheckerError            ; Yep -> do so
  1993.  
  1994.         move.l    CheckerProcSig(pc),d0        ; Signal of timer device ?
  1995.         and.l    TimerSigFlag(pc),d0
  1996.         beq.s    .NoTimerMsg
  1997.         move.l    TimerPort(pc),a0        ; Get message pending
  1998.         CALLSYS    GetMsg
  1999.         bsr    SetTime                ; Set new time
  2000.         bsr    CheckOnline            ; Set new online time
  2001.  
  2002.         move.l    TimerReq(pc),a1            ; Reset timer for wakeup
  2003.         move.l    #1,IOTV_TIME+TV_SECS(a1)    ; the next second
  2004.         move.l    #0,IOTV_TIME+TV_MICRO(a1)
  2005.         CALLSYS    SendIO
  2006.         bra    .Loop
  2007.  
  2008. .NoTimerMsg    move.l    CheckerProcSig(pc),d0        ; Only remake time display ?
  2009.         and.l    #SIGTIMEREMAKE,d0
  2010.         beq.s    .NoTimeRemake
  2011.         bsr    SetTime                ; Yep -> do so
  2012.         bsr    RemakeCosts            ; Also redisplay billstuff
  2013.  
  2014. .NoTimeRemake    move.l    CheckerProcSig(pc),d0        ; Pop up bill window ?
  2015.         and.l    #SIGBILLWIN,d0
  2016.         beq.s    .NoBillOpenUp
  2017.         bsr    OpenBillWin
  2018.  
  2019. .NoBillOpenUp    move.l    CheckerProcSig,d0        ; Window from clock window ?
  2020.         and.l    ClockSigFlag,d0
  2021.         beq.s    .NoClockMsg
  2022.  
  2023. .LoopClockMsg    move.l    ClockHandle(pc),a0
  2024.         move.l    wd_UserPort(a0),a0
  2025.         CALLSYS    GetMsg
  2026.         tst.l    d0
  2027.         beq.s    .NoClockMsg
  2028.  
  2029.         move.l    d0,a1
  2030.         move.l    im_Class(a1),d7
  2031.  
  2032.         DOLIB    ReplyMsg
  2033.  
  2034.         cmp.l    #IDCMP_CLOSEWINDOW,d7        ; Clock window closed ?
  2035.         bne.s    .NoClockClose
  2036.         move.b    #0,ClockWin
  2037.         bsr    CloseClockWin
  2038.         tst.l    WndHandle
  2039.         beq.s    .NoClockMsg
  2040.         move.b    ClockWin(pc),d0
  2041.         move.l    #WINDOWGAD,d1            ; Set checkbox tick
  2042.         bsr    SetControlBox
  2043.         bra.s    .NoClockMsg
  2044.  
  2045. .NoClockClose    cmp.l    #IDCMP_CHANGEWINDOW,d7        ; Window moved ?
  2046.         bne.s    .LoopClockMsg
  2047.         move.l    ClockHandle,a0
  2048.         lea    ClockWinDef,a1
  2049.         bsr    StoreWinPos
  2050.         bra    .LoopClockMsg
  2051.  
  2052. .NoClockMsg    move.l    CheckerProcSig(pc),d0        ; Did it come from the
  2053.         and.l    BillSigFlag(pc),d0        ; Bill window ?
  2054.         beq    .Loop
  2055.         bsr.s    CheckBillWindow
  2056.         bra    .Loop
  2057.  
  2058. CheckerError    bsr    CloseBillWin            ; Close the billwindow
  2059.         bsr    RemoveTimer            ; Remove timer device
  2060.  
  2061.         move.l    _OurTask(pc),a1            ; Signal mother that we`re fine
  2062.         move.l    #SIGHANDSHAKE,d0
  2063.         CALLSYS    Signal
  2064.  
  2065.         movem.l    (sp)+,RegsAll
  2066.         rts
  2067.  
  2068.  
  2069.  
  2070.  
  2071. **********************************************************************
  2072. *                   Check the BillWindow-Messages                    *
  2073. **********************************************************************
  2074. CheckBillWindow    move.l    BillHandle(pc),a0
  2075.         move.l    wd_UserPort(a0),a0
  2076.         LNKLIB    GT_GetIMsg,_GadToolsBase
  2077.         tst.l    d0
  2078.         beq    NoBillMsg
  2079.         move.l    d0,a1
  2080.  
  2081.         move.l    im_Class(a1),d6
  2082.         move.w    im_Code(a1),d5
  2083.         cmp.w    #'a',d5
  2084.         blt.s    End
  2085.         and.w    #~$20,d5
  2086. End        move.l    im_IAddress(a1),a4
  2087.         move.w    gg_GadgetID(a4),d7
  2088.  
  2089.         DOLIB    GT_ReplyIMsg
  2090.  
  2091.         cmp.l    #IDCMP_CLOSEWINDOW,d6        ; Window close ???
  2092.         bne.s    NoBillClose
  2093.         bsr    CloseBillWin
  2094.         bra    NoBillMsg
  2095.  
  2096. NoBillClose    cmp.l    #IDCMP_CHANGEWINDOW,d6        ; Window moved ?
  2097.         bne.s    NoBillChange
  2098.         move.l    BillHandle,a0
  2099.         lea    BillWinDef,a1
  2100.         bsr    StoreWinPos
  2101.         bra    NoBillMsg
  2102.  
  2103. NoBillChange    cmp.l    #GADGETDOWN,d6
  2104.         bne.s    NoBillGadDown
  2105.  
  2106.         cmp.w    #TIMEZONEGAD,d7            ; Changed timezone ?
  2107.         bne.s    NoTimeZoneGad
  2108.         move.b    #1,DoRemakeCosts
  2109.         ext.l    d5
  2110.         move.l    d5,TimeZone
  2111.         bsr    RemakeCosts
  2112.         bra    CheckBillWindow
  2113.  
  2114. NoTimeZoneGad    cmp.w    #CHEAPMODEGAD,d7        ; Changed timemode
  2115.         bne    CheckBillWindow
  2116.         move.b    #1,DoRemakeCosts
  2117.         move.b    d5,CheapMode
  2118.         bsr    RemakeCosts
  2119.         bra    CheckBillWindow
  2120.  
  2121. NoBillGadDown    cmp.l    #IDCMP_VANILLAKEY,d6
  2122.         bne    NoBillVKey
  2123.  
  2124.         cmp.w    #ESCKEY,d5            ; Hide window ?
  2125.         bne.s    BNoEscKey
  2126. BEscKey        bsr    CloseBillWin
  2127.         bra    NoBillMsg
  2128.  
  2129. BNoEscKey    cmp.w    #TIME1KEY,d5            ; Change time zone ?
  2130.         blt.s    NoTimeKeys
  2131.         cmp.w    #TIME3KEY,d5
  2132.         bgt.s    NoTimeKeys
  2133.         sub.w    #'1',d5                ; Calc new zone
  2134. BTime        move.b    #1,DoRemakeCosts
  2135.         ext.l    d5
  2136.         move.l    d5,TimeZone
  2137.         move.l    d5,d0
  2138.         move.l    #TIMEZONEGAD,d1
  2139.         lea    TimeZoneLabels,a2
  2140.         lea    BillGads,a0
  2141.         move.l    BillHandle,a1
  2142.         bsr    SetMXGad
  2143.         bsr    RemakeCosts
  2144.         bra    CheckBillWindow
  2145.  
  2146. NoTimeKeys    cmp.w    #NORMALKEY,d5            ; Activate normal time mode ?
  2147.         bne.s    NoNormalKey
  2148.  
  2149. NormalKey    move.b    #1,DoRemakeCosts
  2150.         move.b    #0,CheapMode
  2151.         bsr    RemakeCosts
  2152.         moveq    #0,d0
  2153.         move.l    #CHEAPMODEGAD,d1
  2154.         lea    CheapLabels,a2
  2155.         lea    BillGads,a0
  2156.         move.l    BillHandle,a1
  2157.         bsr    SetMXGad
  2158.         bra    CheckBillWindow
  2159.  
  2160. NoNormalKey    cmp.w    #CHEAPKEY,d5            ; Activate cheap time mode ?
  2161.         bne    CheckBillWindow
  2162.  
  2163. CheapKey    move.b    #1,DoRemakeCosts
  2164.         move.b    #1,CheapMode
  2165.         bsr    RemakeCosts
  2166.         moveq    #1,d0
  2167.         move.l    #CHEAPMODEGAD,d1
  2168.         lea    CheapLabels,a2
  2169.         lea    BillGads,a0
  2170.         move.l    BillHandle,a1
  2171.         bsr    SetMXGad
  2172.         bra    CheckBillWindow
  2173.  
  2174. NoBillVKey    cmp.l    #IDCMP_RAWKEY,d6        ; User pressed help
  2175.         bne.s    NoBillRKey
  2176.  
  2177.         cmp.w    #HELPKEY,d5
  2178.         bne    CheckBillWindow
  2179.         lea    BillHelpFile,a0
  2180.         lea    HelpName,a1
  2181.         bsr    StrCpy
  2182.         move.b    #1,HelpPage
  2183.         move.l    _OurTask,a1
  2184.         move.l    HelpSigFlag,d0
  2185.         CALLSYS    Signal
  2186.         bra    CheckBillWindow
  2187.  
  2188. NoBillRKey    cmp.l    #IDCMP_MENUHELP,d6        ; User needs help
  2189.         bne.s    NoBillMenuHelp
  2190.         move.w    d5,HelpItem
  2191.         move.l    _OurTask,a1
  2192.         move.l    HelpSigFlag,d0
  2193.         CALLSYS    Signal
  2194.         bra    CheckBillWindow
  2195.  
  2196. NoBillMenuHelp    cmp.l    #IDCMP_MENUPICK,d6
  2197.         bne    CheckBillWindow
  2198.         cmp.w    #-1,d5
  2199.         beq.s    EndBillMenu
  2200.         move.w    d5,d2
  2201.         and.w    #$1f,d2                ; Get menunumber
  2202.         move.w    d5,d1
  2203.         asr.w    #5,d1
  2204.         and.w    #$3f,d1                ; Get itemnumber
  2205.         move.w    d1,d5
  2206.         move.l    BillMenu,a1
  2207.         bsr    GetMenuPtr
  2208.         GTMENUITEM_USERDATA a2,a0
  2209.         cmp.l    #0,a0
  2210.         beq.s    EndBillMenu
  2211.         jmp    (a0)
  2212. EndBillMenu    bra    CheckBillWindow
  2213.  
  2214. NoBillMsg    rts
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223. **********************************************************************
  2224. *                         Wait for a signal                          *
  2225. **********************************************************************
  2226. CheckBroker    tst.w    QuitBroker            ; Quit our broker ?
  2227.         bne    AbortBroker
  2228.  
  2229.         move.l    #SIGBREAKF_CTRL_C,d0        ; Accept a BREAK (like from c:break)
  2230.         or.l    BrokerSigFlag(pc),d0        ; Wait for sig on port of
  2231.         or.l    WindowSigFlag(pc),d0        ; ... window
  2232.         or.l    ARexxSigFlag(pc),d0        ; ... ARexx Port
  2233.         or.l    PrefsSigFlag(pc),d0        ; ... Preferences window
  2234.         or.l    HotKeySigFlag(pc),d0        ; ... HotKey window
  2235.         or.l    AlarmSigFlag(pc),d0        ; ... Display alarm
  2236.         or.l    HelpSigFlag(pc),d0        ; ... Help for Bill window
  2237.         or.l    AppSigFlag(pc),d0        ; ... of App-Icon
  2238.         CALLSYS    Wait
  2239.         move.l    d0,ThisSig
  2240.  
  2241.         move.l    ThisSig(pc),d0            ; Got signal from child to
  2242.         and.l    AlarmSigFlag(pc),d0        ; alarm
  2243.         beq.s    NoAlarmDisp
  2244.  
  2245.         bsr    OnScreen
  2246.         bsr    OnMouse
  2247.  
  2248.         link    a5,#-4
  2249.         bsr    LockScreen
  2250.         tst.l    d0
  2251.         beq.s    .Error
  2252.  
  2253.         move.l    -4(a5),d7
  2254.  
  2255.         move.l    d7,a0
  2256.         LNKLIB    ScreenToFront,_IntuitionBase
  2257.  
  2258.         move.l    d7,a0
  2259.         DOLIB    DisplayBeep
  2260.  
  2261.         move.l    WndHandle(pc),a0
  2262.         bsr    SetBusy
  2263.  
  2264.         lea    MyEasyRequest,a1        ; Display Easy-Requester
  2265.         move.l    #EasyTitle,es_Title(a1)
  2266.         move.l    #AlarmText,es_TextFormat(a1)
  2267.         move.l    #EasyGadget,es_GadgetFormat(a1)
  2268.         sub.l    a0,a0
  2269.         sub.l    a2,a2
  2270.         sub.l    a3,a3
  2271.         DOLIB    EasyRequestArgs
  2272.  
  2273.         move.l    WndHandle(pc),a0
  2274.         bsr    UnBusy
  2275.  
  2276. .Error        bsr    UnlockScreen
  2277.         unlk    a5
  2278.  
  2279. NoAlarmDisp    move.l    ThisSig(pc),d0
  2280.         and.l    BrokerSigFlag(pc),d0        ; If it was on the Msg-Port
  2281.         beq    NoCxMsgs
  2282.  
  2283. WorkAllMsgs    move.l    BrokerPort(pc),a0        ; Check the msgs
  2284.         CALLSYS    GetMsg
  2285.         tst.l    d0
  2286.         beq    NoCxMsgs
  2287.         move.l    d0,a4
  2288.  
  2289.         move.l    a4,a0                ; Get Msg-Type
  2290.         LNKLIB    CxMsgType,_CxBase
  2291.         move.l    d0,MsgType
  2292.  
  2293.         move.l    a4,a0                ; Get ID of msg
  2294.         DOLIB    CxMsgID
  2295.         move.l    d0,MsgID
  2296.  
  2297.         move.l    a4,a1
  2298.         CALLSYS    ReplyMsg
  2299.  
  2300.         cmp.l    #CXM_COMMAND,MsgType        ; Commodities command ?
  2301.         bne    NoXCommand            ; Yep -> go on
  2302.  
  2303.         move.l    MsgID(pc),d0
  2304.  
  2305.         cmp.l    #CXCMD_KILL,d0            ; Are we to go away ?
  2306.         bne.s    NoKill
  2307.         move.w    #1,QuitBroker
  2308.         bra    WorkAllMsgs
  2309.  
  2310. NoKill        cmp.l    #CXCMD_DISABLE,d0        ; Disable broker ?
  2311.         bne.s    DontDisable
  2312.         bsr    DisableBroker
  2313.         move.b    #1,Disabled
  2314.         bra    WorkAllMsgs
  2315.  
  2316. DontDisable    cmp.l    #CXCMD_ENABLE,d0        ; Enable ???
  2317.         bne.s    DontEnable
  2318.         move.b    #0,Disabled
  2319.         move.b    #1,TimeReset
  2320.         bsr    EnableBroker
  2321.         bra    WorkAllMsgs
  2322.  
  2323. DontEnable    cmp.l    #CXCMD_UNIQUE,d0        ; Another broker with same name
  2324.         bne.s    NoUnique            ; -> Quit program
  2325.         move.w    #1,QuitBroker
  2326.         bra    WorkAllMsgs
  2327.  
  2328. NoUnique    cmp.l    #CXCMD_APPEAR,d0        ; Open our window ?
  2329.         bne.s    NoAppear
  2330.         bsr    OpenOurWindow
  2331.         bra    WorkAllMsgs
  2332.  
  2333. NoAppear    cmp.l    #CXCMD_DISAPPEAR,d0        ; Close our window ?
  2334.         bne.s    NoDisappear
  2335.  
  2336.         bsr    CloseOurWindow            ; Close it
  2337.         bra    WorkAllMsgs
  2338.  
  2339. NoDisappear    bra    WorkAllMsgs
  2340.  
  2341. NoXCommand    cmp.l    #CXM_IEVENT,MsgType        ; Pop up key used ???
  2342.         bne    WorkAllMsgs            ; Nope -> Loop for msgs
  2343.  
  2344.         cmp.l    #POPUPKEYID,MsgID        ; Are we to pop up ?
  2345.         bne.s    NoPopUpWindow
  2346.         bsr    OpenOurWindow            ; Open our window
  2347.         bra    WorkAllMsgs
  2348.  
  2349. NoPopUpWindow    cmp.l    #PAGEKEYID,MsgID        ; Change display mode of time ?
  2350.         bne.s    NoPageChange
  2351.         addq.l    #1,PageNum
  2352.         cmp.l    #MAXPAGES,PageNum
  2353.         blt.s    .End
  2354.         move.l    #0,PageNum
  2355. .End        bsr    ClearTitleBar
  2356.         bsr    SigTime
  2357.         bra    WorkAllMsgs
  2358.  
  2359. NoPageChange    cmp.l    #PREFSKEYID,MsgID        ; Pop Up prefs window ?
  2360.         bne.s    NoPrefsPopUp
  2361.         bsr    OpenPrefsWin
  2362.         bra    WorkAllMsgs
  2363.  
  2364. NoPrefsPopUp    cmp.l    #BILLKEYID,MsgID        ; Pop Up Bill window ?
  2365.         bne.s    NoBillHotKey
  2366.         move.l    CheckerProc(pc),a1
  2367.         move.l    #SIGBILLWIN,d0
  2368.         CALLSYS    Signal
  2369.         bra    WorkAllMsgs
  2370.  
  2371. NoBillHotKey    cmp.l    #HOTWINKEYID,MsgID        ; Pop Up HotKey window ?
  2372.         bne.s    NoHotWinPop
  2373.         bsr    OpenHotKeyWin
  2374.         bra    WorkAllMsgs
  2375.  
  2376. NoHotWinPop    cmp.l    #SHELLKEYID,MsgID        ; Pop Up Shell ?
  2377.         bne    NoShellPop
  2378.         move.l    #SystemInOut,d1            ; Open the dummy Files NIL:
  2379.         move.l    #MODE_NEWFILE,d2
  2380.         LNKLIB    Open,_DOSBase
  2381.         move.l    d0,SysInput
  2382.         move.l    #SystemInOut,d1
  2383.         move.l    #MODE_NEWFILE,d2
  2384.         DOLIB    Open
  2385.         move.l    d0,SysOutput
  2386.         lea    WBPName,a1            ; Try to get a pointer to a process
  2387.         CALLSYS    FindTask            ; we can clone the pathlist from
  2388.         tst.l    d0                ; Try to get the Workbench,
  2389.         bne.s    .GotProc            ; AmigaShell, InitialCLI,
  2390.         lea    ICLIName,a1            ; Background CLI or New CLI processes
  2391.         DOLIB    FindTask            ; This is needed, so that the new
  2392.         tst.l    d0                ; shell may execute Prgs, which
  2393.         bne.s    .GotProc            ; are located in dirs you
  2394.         lea    NCLIName,a1            ; worked a PATH on.
  2395.         DOLIB    FindTask            ; We have to arrange a pathlist
  2396.         tst.l    d0                ; which looks like this :
  2397.         bne.s    .GotProc            ; Size of block, Link to next, Lock-BPTR
  2398.         lea    AShellName,a1
  2399.         DOLIB    FindTask
  2400.         tst.l    d0
  2401.         bne.s    .GotProc
  2402.         lea    BCLIName,a1
  2403.         DOLIB    FindTask
  2404.         tst.l    d0
  2405.         beq.s    .NoProc
  2406. .GotProc    move.l    d0,a0                ; So we have a process -> go on
  2407.         move.l    pr_CLI(a0),d0            ; Get pointer to it`s CLI-Structure
  2408.         asl.l    #2,d0                ; Convert the BPTR
  2409.         move.l    d0,a0                ; Get pointer to A0
  2410.         move.l    cli_CommandDir(a0),d0        ; Get pointer to CommandDir
  2411.         asl.l    #2,d0                ; Convert to normal Pointer
  2412.         move.l    d0,a4                ; Store pointer
  2413.         lea    SysPath,a5            ; Get Pointer to Tags-Entry
  2414. .GetPath    cmp.l    #0,a4                ; No (more) path ?
  2415.         beq.s    .GotPath            ; -> Start Shell
  2416.         moveq    #12,d0                ; Allocate a small link-structure
  2417.         move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  2418.         CALLSYS    AllocMem
  2419.         tst.l    d0                ; Could not get mem for one more path
  2420.         beq.s    .GotPath            ; lock -> start Shell
  2421.         move.l    d0,d1                ; Get pointer to memory block
  2422.         addq.l    #4,d1                ; Point to middle of these 4 LongWords
  2423.         asr.l    #2,d1                ; Convert to BPTR
  2424.         move.l    d1,(a5)                ; Store Pointer to structure
  2425.         move.l    d0,a5                ; Let A5 point to new memory block
  2426.         addq.l    #4,a5                ; -> right to the middle
  2427.         move.l    d0,a3                ; Store pointer
  2428.         move.l    4(a4),d1            ; Duplicate Lock to Path
  2429.         LNKLIB    DupLock,_DOSBase
  2430.         move.l    d0,8(a3)            ; Store LockPointer
  2431.         move.l    #0,4(a3)            ; Clear link-pointer
  2432.         move.l    #12,0(a3)            ; Store length of one Path-Entry
  2433.         move.l    (a4),d0                ; Get pointer to father`s next path
  2434.         asl.l    #2,d0                ; Convert to normal pointer
  2435.         move.l    d0,a4                ; Now restart for next path
  2436.         bra.s    .GetPath
  2437. .GotPath    move.l    #SystemComm,d1            ; Start Shell...
  2438.         move.l    #SystemTags,d2
  2439.         DOLIB    SystemTagList,_DOSBase
  2440. .NoProc        bra    WorkAllMsgs
  2441.  
  2442. NoShellPop    cmp.l    #UMLAUTKEYID,MsgID        ; Change "Umlaut" mode ?
  2443.         bne.s    NoUmlautMode
  2444.         bchg    #0,MapUmlaut
  2445.         move.b    MapUmlaut,d0
  2446.         move.l    #UMLAUTGAD,d1
  2447.         bsr    SetControlBox
  2448.         bra    WorkAllMsgs
  2449. NoUmlautMode    bra    WorkAllMsgs
  2450.  
  2451. NoCxMsgs    move.l    ThisSig(pc),d0
  2452.         and.l    WindowSigFlag(pc),d0        ; Sig from window ?
  2453.         beq    NoWindowMsg
  2454.  
  2455. LoopWndMsg    move.l    WndHandle(pc),a0        ; Loop for all messages
  2456.         move.l    wd_UserPort(a0),a0
  2457.         LNKLIB    GT_GetIMsg,_GadToolsBase    ; Get gadtools message
  2458.         tst.l    d0
  2459.         beq    NoWindowMsg
  2460.         move.l    d0,a1
  2461.  
  2462.         move.l    im_Class(a1),d6            ; Get class
  2463.         move.w    im_Code(a1),d5            ; Get code
  2464.         cmp.w    #'a',d5
  2465.         blt.s    .End
  2466.         and.w    #~$20,d5
  2467. .End        move.l    im_IAddress(a1),a4        ; Get gadget id
  2468.         move.w    gg_GadgetID(a4),d7
  2469.  
  2470.         DOLIB    GT_ReplyIMsg            ; Reply gadtools msg
  2471.  
  2472.         cmp.l    #IDCMP_CLOSEWINDOW,d6        ; Close gadget selected
  2473.         bne.s    NoRemoveWin
  2474.         bsr    CloseOurWindow
  2475.         bra    NoWindowMsg            ; Skip the rest
  2476.  
  2477. NoRemoveWin    cmp.l    #IDCMP_CHANGEWINDOW,d6        ; Window moved ?
  2478.         bne.s    NoControlMove
  2479.         move.l    WndHandle,a0
  2480.         lea    MyWindowDef,a1
  2481.         bsr    StoreWinPos
  2482.         bra    LoopWndMsg
  2483.  
  2484. NoControlMove    cmp.l    #IDCMP_MENUHELP,d6
  2485.         bne.s    NoMenuHelp
  2486.         bsr    RemakeGadgets            ; Remake possible changes to toggle entries
  2487.         moveq    #1,d0
  2488.         bsr    OnlineHelp
  2489.         bra    LoopWndMsg
  2490.  
  2491. NoMenuHelp    cmp.l    #IDCMP_MENUPICK,d6
  2492.         bne    NoMenuPick
  2493.         cmp.w    #-1,d5
  2494.         beq    EndMainMenu
  2495.         move.w    d5,d2
  2496.         and.w    #$1f,d2                ; Get menunumber
  2497.         move.w    d5,d1
  2498.         asr.w    #5,d1
  2499.         and.w    #$3f,d1                ; Get itemnumber
  2500.         move.l    MainMenu,a1
  2501.         bsr    GetMenuPtr
  2502.         GTMENUITEM_USERDATA a2,a0
  2503.         cmp.l    #0,a0
  2504.         beq.s    EndMainMenu
  2505.         jmp    (a0)
  2506.  
  2507. DisplayAbout    move.l    WndHandle(pc),a0        ; Display about
  2508.         bsr    SetBusy
  2509.  
  2510.         lea    MyEasyRequest,a1        ; Display Easy-Requester
  2511.         move.l    #EasyTitle,es_Title(a1)
  2512.         move.l    #AboutText,es_TextFormat(a1)
  2513.         move.l    #AboutGadgets,es_GadgetFormat(a1)
  2514.         sub.l    a0,a0
  2515.         sub.l    a2,a2
  2516.         sub.l    a3,a3
  2517.         LNKLIB    EasyRequestArgs,_IntuitionBase
  2518.         tst.l    d0
  2519.         bne.s    .NoRegister
  2520.         move.l    #PrtName,d1
  2521.         move.l    #MODE_NEWFILE,d2
  2522.         LNKLIB    Open,_DOSBase
  2523.         tst.l    d0
  2524.         beq.s    .NoRegister
  2525.         move.l    d0,d7
  2526.         move.l    d0,d1
  2527.         move.l    #RegisterTxt,d2
  2528.         move.l    #REGISTERLEN,d3
  2529.         DOLIB    Write
  2530. .Error        move.l    d7,d1
  2531.         DOLIB    Close
  2532. .NoRegister    move.l    WndHandle(pc),a0
  2533.         bsr    UnBusy
  2534.         bra.s    EndMainMenu
  2535. ReSavePrefs    bsr    SavePrefs
  2536. EndMainMenu    move.l    DoActWindow,a1
  2537.         cmp.l    #0,a1
  2538.         beq.s    .End
  2539.         cmp.l    WndHandle,a1
  2540.         bne.s    .End
  2541.         move.l    DoActGadget,a0
  2542.         sub.l    a2,a2
  2543.         LNKLIB    ActivateGadget,_IntuitionBase
  2544.         move.l    #0,DoActWindow
  2545.         move.l    #0,DoActGadget
  2546. .End        bra    LoopWndMsg
  2547.  
  2548. NoMenuPick    cmp.l    #IDCMP_GADGETUP,d6        ; Gadget released
  2549.         bne    NoGadgetUp
  2550.  
  2551.         cmp.w    #ACTIGAD,d7            ; Do activations ?
  2552.         bne.s    NoActiGad
  2553.         bchg    #0,DoActivate
  2554.         bra    LoopWndMsg
  2555.  
  2556. NoActiGad    cmp.w    #MODEGAD,d7            ; Change activation mode ?
  2557.         bne.s    NoModeGad
  2558.         bchg    #0,MouseMode            ; Invert flag of Activation-Mode
  2559.         bra    LoopWndMsg
  2560.  
  2561. NoModeGad    cmp.w    #DISPLAYGAD,d7            ; Clock on/off ?
  2562.         bne.s    NoDisplayGad
  2563.         bchg    #0,ShowClock
  2564.         tst.b    ShowClock
  2565.         bne.s    .End
  2566.         bsr    ClearTitleBar
  2567.         bsr    CloseClockWin
  2568. .End        bsr    SigTime
  2569.         bra    LoopWndMsg
  2570.  
  2571. NoDisplayGad    cmp.w    #WINDOWGAD,d7            ; Display clock in window ?
  2572.         bne.s    NoWindowGad
  2573.         bchg    #0,ClockWin
  2574.         move.b    #1,ShowClock
  2575.         moveq    #1,d0
  2576.         move.l    #DISPLAYGAD,d1
  2577.         bsr    SetControlBox
  2578.         bsr    ClearTitleBar
  2579.         bsr    SigTime
  2580.         bra    LoopWndMsg
  2581.  
  2582. NoWindowGad    cmp.w    #SECSGAD,d7            ; Display seconds ?
  2583.         bne.s    NoSecGad
  2584.         bchg    #0,ShowSecs
  2585.         bsr    ClearTitleBar
  2586.         bsr    SigTime
  2587.         bra    LoopWndMsg
  2588.  
  2589. NoSecGad    cmp.w    #AMIGAD,d7            ; Set to american date ?
  2590.         bne.s    NoAmiGad
  2591.         bchg    #0,AmiDate
  2592.         bsr    ClearTitleBar
  2593.         bsr    SigTime
  2594.         bra    LoopWndMsg
  2595.  
  2596. NoAmiGad    cmp.w    #CLICKGAD,d7            ; Enable/Disable Key-Click ?
  2597.         bne.s    NoClickGad
  2598.         bchg    #0,KeyClick
  2599.         bra    LoopWndMsg
  2600.  
  2601. NoClickGad    cmp.w    #DAYGAD,d7            ; Display day ?
  2602.         bne.s    NoDayGad
  2603.         bchg    #0,ShowDay
  2604.         bsr    ClearTitleBar
  2605.         bsr    SigTime
  2606.         bra    LoopWndMsg
  2607.  
  2608. NoDayGad    cmp.w    #SHORTGAD,d7            ; Shorten the day ?
  2609.         bne.s    NoShortGad
  2610.         bchg    #0,ShortDay
  2611.         bsr    ClearTitleBar
  2612.         bsr    SigTime
  2613.         bra    LoopWndMsg
  2614.  
  2615. NoShortGad    cmp.w    #DATEGAD,d7            ; Display date ?
  2616.         bne.s    NoDateGad
  2617.         bchg    #0,ShowDate
  2618.         bsr    ClearTitleBar
  2619.         bsr    SigTime
  2620.         bra    LoopWndMsg
  2621.  
  2622. NoDateGad    cmp.w    #ALARMMODEGAD,d7        ; Enable/Disable alarm ?
  2623.         bne.s    NoAlarmModeGad
  2624.         bchg    #0,DoAlarm
  2625.         bra    LoopWndMsg
  2626.  
  2627. NoAlarmModeGad    cmp.w    #BILLGAD,d7            ; Open bill window ?
  2628.         bne.s    NoBillGad
  2629.         move.l    CheckerProc(pc),a1
  2630.         move.l    #SIGBILLWIN,d0
  2631.         CALLSYS    Signal
  2632.         bra    LoopWndMsg
  2633.  
  2634. NoBillGad    cmp.w    #PREFSGAD,d7            ; Activate preferences ?
  2635.         bne.s    NoPrefsGad
  2636.         bsr    OpenPrefsWin
  2637.         bra    LoopWndMsg
  2638.  
  2639. NoPrefsGad    cmp.w    #ENVGAD,d7            ; Enable/Disable env vars ?
  2640.         bne.s    NoEnvGad
  2641.         bchg    #0,SetEnv
  2642.         tst.b    SetEnv
  2643.         bne.s    .NoDel
  2644.         bsr    DeleteEnvs
  2645. .NoDel        bsr    SigTime
  2646.         bra    LoopWndMsg
  2647.  
  2648. NoEnvGad    cmp.w    #CYCLEGAD,d7            ; Enable/Disable Window-Cycling ?
  2649.         bne.s    NoCycleGad
  2650.         bchg    #0,CycleWin
  2651.         bra    LoopWndMsg
  2652.  
  2653. NoCycleGad    cmp.w    #WBFRONTGAD,d7            ; Enable/Disable WB to front ?
  2654.         bne.s    NoWBFrontGad
  2655.         bchg    #0,WBFront
  2656.         bra    LoopWndMsg
  2657.  
  2658. NoWBFrontGad    cmp.w    #LEFTYGAD,d7            ; Enable/Disable LeftyMouse ?
  2659.         bne.s    NoLeftyGad
  2660.         bchg    #0,LeftyMouse
  2661.         bra    LoopWndMsg
  2662.  
  2663. NoLeftyGad    cmp.w    #WESCGAD,d7            ; Enable/Disable ESC-Close ?
  2664.         bne.s    NoEscGad
  2665.         bchg    #0,ESCClose
  2666.         bra    LoopWndMsg
  2667.  
  2668. NoEscGad    cmp.w    #UMLAUTGAD,d7            ; Enable/Disable "Umaluts" ?
  2669.         bne.s    NoUmlautGad
  2670.         bchg    #0,MapUmlaut
  2671.         bra    LoopWndMsg
  2672.  
  2673. NoUmlautGad    cmp.w    #LOADGAD,d7            ; Load prefs
  2674.         bne.s    NoLoadGad
  2675.         move.l    #0,-(sp)
  2676.         move.w    #0,-(sp)
  2677.         pea    PrefsFileName
  2678.         pea    PrefsFile
  2679.         pea    PrefsPath
  2680.         pea    PrefsLoadHeader
  2681.         move.l    WndHandle,-(sp)
  2682.         jsr    GetFileName
  2683.         lea    26(sp),sp
  2684.         tst.l    d0
  2685.         beq.s    .End
  2686.         bsr    LoadPrefs
  2687. .End        bra    LoopWndMsg
  2688.  
  2689. NoLoadGad    cmp.w    #SAVEGAD,d7            ; Save prefs
  2690.         bne.s    NoSaveGad
  2691.         move.l    #0,-(sp)
  2692.         move.w    #0,-(sp)
  2693.         pea    PrefsFileName
  2694.         pea    PrefsFile
  2695.         pea    PrefsPath
  2696.         pea    PrefsSaveHeader
  2697.         move.l    WndHandle,-(sp)
  2698.         jsr    GetFileName
  2699.         lea    26(sp),sp
  2700.         tst.l    d0
  2701.         beq.s    .End
  2702.         bsr    SavePrefs
  2703. .End        bra    LoopWndMsg
  2704.  
  2705. NoSaveGad    cmp.w    #ENABLEGAD,d7            ; Enable broker ?
  2706.         bne.s    NoEnGad
  2707.         move.b    #0,Disabled
  2708.         move.b    #1,TimeReset
  2709.         bsr    EnableBroker
  2710.         bra    LoopWndMsg
  2711.  
  2712. NoEnGad        cmp.w    #DISABLEGAD,d7            ; Disable broker ?
  2713.         bne.s    NoDisGad
  2714.         bsr    DisableBroker
  2715.         move.b    #1,Disabled
  2716.         bra    LoopWndMsg
  2717.  
  2718. NoDisGad    cmp.w    #HIDEGAD,d7            ; Hide window again
  2719.         bne.s    NoHideGad
  2720.         bsr    CloseOurWindow
  2721.         bra    NoWindowMsg
  2722.  
  2723. NoHideGad    cmp.w    #QUITGAD,d7            ; Quit hole stuff ?
  2724.         bne.s    NoQuitGad
  2725.         move.w    #1,QuitBroker
  2726.         bra    LoopWndMsg
  2727.  
  2728. NoQuitGad    cmp.w    #SETALARMGAD,d7            ; Alarm time altered ?
  2729.         bne.s    NoSetAlarmGad
  2730.         move.l    #SETALARMGAD,d0
  2731.         lea    ControlGads,a0
  2732.         bsr    GetGadgetPtr
  2733.         move.l    gg_SpecialInfo(a0),a0
  2734.         move.l    si_Buffer(a0),a0
  2735.         bsr    CheckAlarmTime
  2736.         bra    LoopWndMsg
  2737.  
  2738. NoSetAlarmGad    cmp.w    #SCREENGAD,d7            ; Screen time altered ?
  2739.         bne.s    NoScreenGad
  2740.         move.l    ScreenTime,d7
  2741.         move.l    #SCREENGAD,d0
  2742.         lea    ControlGads,a0
  2743.         bsr    GetGadgetPtr
  2744.         move.l    a0,a4
  2745.         move.l    gg_SpecialInfo(a4),a5
  2746.         move.l    si_LongInt(a5),d0        ; Retrieve data entered
  2747.         tst.l    d0
  2748.         blt.s    .Error                ; negative value -> error
  2749.         move.l    d0,ScreenTime            ; store new time
  2750.         bra.s    .End
  2751. .Error        move.l    d7,ScreenTime            ; disable screen blanker
  2752.         move.l    #SCREENGAD,d0
  2753.         lea    ControlGads,a0
  2754.         move.l    WndHandle(pc),a1
  2755.         move.l    #3,d1
  2756.         move.l    d7,d2
  2757.         bsr    SetIntegerGad
  2758. .End        move.b    #1,TimeReset
  2759.         bra    LoopWndMsg
  2760.  
  2761. NoScreenGad    cmp.w    #MOUSEGAD,d7            ; Change mouse time ?
  2762.         bne.s    NoMouseGad
  2763.         move.l    MouseTime,d7
  2764.         move.l    #MOUSEGAD,d0
  2765.         lea    ControlGads,a0
  2766.         bsr    GetGadgetPtr
  2767.         move.l    a0,a4
  2768.         move.l    gg_SpecialInfo(a4),a5
  2769.         move.l    si_LongInt(a5),d0        ; retrieve time entered
  2770.         tst.l    d0
  2771.         blt.s    .Error                ; negative value -> error
  2772.         move.l    d0,MouseTime            ; Store new time
  2773.         bra.s    .End
  2774. .Error        move.l    d7,MouseTime            ; deactivate timer
  2775.         move.l    #MOUSEGAD,d0
  2776.         lea    ControlGads,a0
  2777.         move.l    WndHandle,a1
  2778.         moveq    #3,d1
  2779.         move.l    d7,d2
  2780.         bsr    SetIntegerGad
  2781. .End        move.b    #1,TimeReset
  2782.         bra    LoopWndMsg
  2783.  
  2784. NoMouseGad    cmp.w    #FRONTGAD,d7            ; Cycle gadget for
  2785.         bne.s    NoFrontGad            ; Click qualifier pressed ?
  2786.         addq.l    #1,PopQualNum            ; Increase Qualifier number
  2787.         cmp.l    #POPQUALCNT,PopQualNum        ; Exceited maxmum ?
  2788.         blt.s    .End
  2789.         move.l    #0,PopQualNum            ; Reset number
  2790. .End        bra    LoopWndMsg
  2791.  
  2792. NoFrontGad    cmp.w    #ESCQUALGAD,d7            ; Cycle gadget for
  2793.         bne.s    NoESCQualGad            ; ESC qualifier pressed ?
  2794.         addq.l    #1,ESCQualNum            ; Increase Qualifier number
  2795.         cmp.l    #ESCQUALCNT,ESCQualNum        ; Exceited maxmum ?
  2796.         blt.s    .End
  2797.         move.l    #0,ESCQualNum            ; Reset number
  2798. .End        bra    LoopWndMsg
  2799.  
  2800. NoESCQualGad    cmp.w    #HOTWINGAD,d7            ; Open HotKeys window ?
  2801.         bne.s    NoHotKeysGad
  2802.         bsr    OpenHotKeyWin
  2803.         bra    LoopWndMsg
  2804.  
  2805. NoHotKeysGad    cmp.w    #VOLGAD,d7            ; Change click volume ?
  2806.         bne.s    NoVolGad
  2807.         move.l    #VOLGAD,d0
  2808.         lea    ControlGads,a0
  2809.         bsr    GetGadgetPtr
  2810.         move.l    a0,a4
  2811.         move.l    gg_SpecialInfo(a4),a5
  2812.         move.l    si_LongInt(a5),d0        ; Check for invalid number
  2813.         tst.l    d0
  2814.         blt.s    .Error
  2815.         cmp.l    #64,d0
  2816.         bgt.s    .Error
  2817.         move.l    d0,ClickVol
  2818.         bra    LoopWndMsg
  2819. .Error        move.l    ClickVol,si_LongInt(a5)        ; Remake string
  2820.         move.l    #VOLGAD,d0
  2821.         lea    ControlGads,a0
  2822.         move.l    WndHandle,a1
  2823.         moveq    #2,d1
  2824.         move.l    ClickVol,d2
  2825.         bsr    SetIntegerGad
  2826.  
  2827. NoVolGad    cmp.w    #USERSHELLGAD,d7        ; Change Shell-Command ?
  2828.         bne    LoopWndMsg
  2829.         move.l    gg_SpecialInfo(a4),a0
  2830.         move.l    si_Buffer(a0),a0
  2831.         lea    SystemParam,a1
  2832.         bsr    StrCpy
  2833.         bra    LoopWndMsg
  2834.  
  2835. NoGadgetUp    cmp.l    #IDCMP_RAWKEY,d6
  2836.         bne.s    NoCRawKey
  2837.  
  2838.         cmp.w    #HELPKEY,d5            ; Display help ?
  2839.         bne    LoopWndMsg
  2840.         lea    MainHelpFile,a0
  2841.         lea    HelpName,a1
  2842.         bsr    StrCpy
  2843.         bsr    OtherHelp
  2844.         bra    LoopWndMsg
  2845.  
  2846. NoCRawKey    cmp.l    #IDCMP_VANILLAKEY,d6        ; Any keys pressed
  2847.         bne    LoopWndMsg
  2848.  
  2849.         cmp.w    #ACTIKEY,d5            ; Do activations ?
  2850.         bne.s    NoActiKey
  2851. ActiKey        bchg    #0,DoActivate
  2852.         move.b    DoActivate(pc),d0
  2853.         move.l    #ACTIGAD,d1
  2854.         bsr    SetControlBox
  2855.         bra    EndMainMenu
  2856.  
  2857. NoActiKey    cmp.w    #MODEKEY,d5            ; Change activation mode ?
  2858.         bne.s    NoModeKey
  2859. ModeKey        bchg    #0,MouseMode            ; Invert flag of Activation-Mode
  2860.         move.b    MouseMode(pc),d0        ; Get mode
  2861.         move.l    #MODEGAD,d1
  2862.         bsr    SetControlBox
  2863.         bra    EndMainMenu
  2864.  
  2865. NoModeKey    cmp.w    #DISPLAYKEY,d5            ; Clock on/off ?
  2866.         bne.s    NoDisplayKey
  2867. DisplayKey    bchg    #0,ShowClock
  2868.         move.b    ShowClock(pc),d0        ; reflect new choice
  2869.         move.l    #DISPLAYGAD,d1
  2870.         bsr    SetControlBox
  2871.         bsr    ClearTitleBar            ; Clear titlebar
  2872.         bsr    CloseClockWin            ; Close clock window
  2873.         bsr    SigTime
  2874.         bra    EndMainMenu
  2875.  
  2876. NoDisplayKey    cmp.w    #WINDOWKEY,d5            ; Display clock in window ?
  2877.         bne.s    NoWindowKey
  2878. WindowKey    bchg    #0,ClockWin
  2879.         move.b    #1,ShowClock
  2880.         move.b    ClockWin(pc),d0
  2881.         move.l    #WINDOWGAD,d1
  2882.         bsr    SetControlBox
  2883.         moveq    #1,d0
  2884.         move.l    #DISPLAYGAD,d1
  2885.         bsr    SetControlBox
  2886.         bsr    ClearTitleBar
  2887.         bsr    SigTime
  2888.         bra    EndMainMenu
  2889.  
  2890. NoWindowKey    cmp.w    #SECSKEY,d5            ; Display seconds ?
  2891.         bne.s    NoSecKey
  2892. SecsKey        bchg    #0,ShowSecs
  2893.         move.b    ShowSecs(pc),d0
  2894.         move.l    #SECSGAD,d1
  2895.         bsr    SetControlBox
  2896.         bsr    ClearTitleBar
  2897.         bsr    SigTime
  2898.         bra    EndMainMenu
  2899.  
  2900. NoSecKey    cmp.w    #AMIKEY,d5            ; Set to american date ?
  2901.         bne.s    NoAmiKey
  2902. AmiKey        bchg    #0,AmiDate
  2903.         move.b    AmiDate(pc),d0
  2904.         move.l    #AMIGAD,d1
  2905.         bsr    SetControlBox
  2906.         bsr    ClearTitleBar
  2907.         bsr    SigTime
  2908.         bra    EndMainMenu
  2909.  
  2910. NoAmiKey    cmp.w    #CLICKKEY,d5            ; Enable/Disable Key-Click ?
  2911.         bne.s    NoClickKey
  2912. ClickKey    bchg    #0,KeyClick
  2913.         move.b    KeyClick(pc),d0
  2914.         move.l    #CLICKGAD,d1
  2915.         bsr    SetControlBox
  2916.         bra    EndMainMenu
  2917.  
  2918. NoClickKey    cmp.w    #DAYKEY,d5            ; Display day ?
  2919.         bne.s    NoDayKey
  2920. DayKey        bchg    #0,ShowDay
  2921.         move.b    ShowDay(pc),d0
  2922.         move.l    #DAYGAD,d1
  2923.         bsr    SetControlBox
  2924.         bsr    ClearTitleBar
  2925.         bsr    SigTime
  2926.         bra    EndMainMenu
  2927.  
  2928. NoDayKey    cmp.w    #SHORTKEY,d5            ; Shorten day ?
  2929.         bne.s    NoShortKey
  2930. ShortKey    bchg    #0,ShortDay
  2931.         move.b    ShortDay(pc),d0
  2932.         move.l    #SHORTGAD,d1
  2933.         bsr    SetControlBox
  2934.         bsr    ClearTitleBar
  2935.         bsr    SigTime
  2936.         bra    EndMainMenu
  2937.  
  2938. NoShortKey    cmp.w    #DATEKEY,d5            ; Display date ?
  2939.         bne.s    NoDateKey
  2940. DateKey        bchg    #0,ShowDate
  2941.         move.b    ShowDate(pc),d0
  2942.         move.l    #DATEGAD,d1
  2943.         bsr    SetControlBox
  2944.         bsr    ClearTitleBar
  2945.         bsr    SigTime
  2946.         bra    EndMainMenu
  2947.  
  2948. NoDateKey    cmp.w    #ALARMMODEKEY,d5        ; Enable/Disable alarm ?
  2949.         bne.s    NoAlarmModeKey
  2950. AlarmModeKey    bchg    #0,DoAlarm
  2951.         move.b    DoAlarm(pc),d0
  2952.         move.l    #ALARMMODEGAD,d1
  2953.         bsr    SetControlBox
  2954.         bra    EndMainMenu
  2955.  
  2956. NoAlarmModeKey    cmp.w    #BILLKEY,d5            ; Open bill window ?
  2957.         bne.s    NoBillKey
  2958. BillKey        move.l    #BILLGAD,d0
  2959.         lea    ControlGads,a0
  2960.         move.l    WndHandle,a5
  2961.         bsr    ButtonCheck
  2962.         move.l    CheckerProc(pc),a1
  2963.         move.l    #SIGBILLWIN,d0
  2964.         CALLSYS    Signal
  2965.         bra    EndMainMenu
  2966.  
  2967. NoBillKey    cmp.w    #PREFSKEY,d5            ; Open prefs window ?
  2968.         bne.s    NoPrefsKey
  2969. PrefsKey    move.l    #PREFSGAD,d0
  2970.         lea    ControlGads,a0
  2971.         move.l    WndHandle,a5
  2972.         bsr    ButtonCheck
  2973.         bsr    OpenPrefsWin
  2974.         bra    EndMainMenu
  2975.  
  2976. NoPrefsKey    cmp.w    #ENVKEY,d5            ; Enable/Disable env vars ?
  2977.         bne.s    NoEnvKey
  2978. EnvKey        bchg    #0,SetEnv
  2979.         tst.b    SetEnv
  2980.         bne.s    .NoDel
  2981.         bsr    DeleteEnvs            ; Delete vars, if turned off
  2982. .NoDel        move.b    SetEnv(pc),d0
  2983.         move.l    #ENVGAD,d1
  2984.         bsr    SetControlBox
  2985.         bsr    ClearTitleBar
  2986.         bsr    SigTime
  2987.         bra    EndMainMenu
  2988.  
  2989. NoEnvKey    cmp.w    #CYCLEKEY,d5            ; Enable/Disable Window-Cycling ?
  2990.         bne.s    NoCycleKey
  2991. CycleKey    bchg    #0,CycleWin
  2992.         move.b    CycleWin(pc),d0
  2993.         move.l    #CYCLEGAD,d1
  2994.         bsr    SetControlBox
  2995.         bra    EndMainMenu
  2996.  
  2997. NoCycleKey    cmp.w    #VOLKEY,d5            ; Enter new volume ?
  2998.         bne.s    NoVolKey
  2999. VolKey        move.l    #VOLGAD,d0
  3000.         lea    ControlGads,a0
  3001.         move.l    WndHandle,a1
  3002.         bsr    ActStringGad
  3003.         bra    EndMainMenu
  3004.  
  3005. NoVolKey    cmp.w    #WBFRONTKEY,d5            ; Enable/Disable WB front ?
  3006.         bne.s    NoWBFrontKey
  3007. WBFrontKey    bchg    #0,WBFront
  3008.         move.b    WBFront(pc),d0
  3009.         move.l    #WBFRONTGAD,d1
  3010.         bsr    SetControlBox
  3011.         bra    EndMainMenu
  3012.  
  3013. NoWBFrontKey    cmp.w    #LEFTYKEY,d5            ; Enable/Disable LeftyMouse ?
  3014.         bne.s    NoLeftyKey
  3015. LeftyKey    bchg    #0,LeftyMouse
  3016.         move.b    LeftyMouse(pc),d0
  3017.         move.l    #LEFTYGAD,d1
  3018.         bsr    SetControlBox
  3019.         bra    EndMainMenu
  3020.  
  3021. NoLeftyKey    cmp.w    #WESCKEY,d5            ; Enable/Disable ESC-Close ?
  3022.         bne.s    NoEscKey
  3023. WESCKey        bchg    #0,ESCClose
  3024.         move.b    ESCClose(pc),d0
  3025.         move.l    #WESCGAD,d1
  3026.         bsr    SetControlBox
  3027.         bra    EndMainMenu
  3028.  
  3029. NoEscKey    cmp.w    #UMLAUTKEY,d5            ; Enable/Disable Umlauts ?
  3030.         bne.s    NoUmlautKey
  3031. UmlautKey    bchg    #0,MapUmlaut
  3032.         move.b    MapUmlaut(pc),d0
  3033.         move.l    #UMLAUTGAD,d1
  3034.         bsr    SetControlBox
  3035.         bra    EndMainMenu
  3036.  
  3037. NoUmlautKey    cmp.w    #LOADKEY,d5            ; Load prefs ?
  3038.         bne.s    NoLoadKey
  3039. DoLoadPrefs    move.l    #LOADGAD,d0
  3040.         lea    ControlGads,a0
  3041.         move.l    WndHandle,a5
  3042.         bsr    ButtonCheck
  3043.         move.l    #0,-(sp)
  3044.         move.w    #0,-(sp)
  3045.         pea    PrefsFileName
  3046.         pea    PrefsFile
  3047.         pea    PrefsPath
  3048.         pea    PrefsLoadHeader
  3049.         move.l    WndHandle,-(sp)
  3050.         jsr    GetFileName
  3051.         lea    26(sp),sp
  3052.         tst.l    d0
  3053.         beq.s    .End
  3054.         bsr    LoadPrefs
  3055. .End        bra    EndMainMenu
  3056.  
  3057. NoLoadKey    cmp.w    #SAVEKEY,d5            ; save prefs ?
  3058.         bne.s    NoSaveKey
  3059. DoSaveAsPrefs    move.l    #SAVEGAD,d0
  3060.         lea    ControlGads,a0
  3061.         move.l    WndHandle,a5
  3062.         bsr    ButtonCheck
  3063.         move.l    #0,-(sp)
  3064.         move.w    #0,-(sp)
  3065.         pea    PrefsFileName
  3066.         pea    PrefsFile
  3067.         pea    PrefsPath
  3068.         pea    PrefsSaveHeader
  3069.         move.l    WndHandle,-(sp)
  3070.         jsr    GetFileName
  3071.         lea    26(sp),sp
  3072.         tst.l    d0
  3073.         beq.s    .End
  3074.         bsr    SavePrefs
  3075. .End        bra    EndMainMenu
  3076.  
  3077. NoSaveKey    cmp.w    #HOTWINKEY,d5            ; Open HotKey window ?
  3078.         bne.s    NoHotWinKey
  3079. HotWinKey    move.l    #HOTWINGAD,d0
  3080.         lea    ControlGads,a0
  3081.         move.l    WndHandle,a5
  3082.         bsr    ButtonCheck
  3083.         bsr    OpenHotKeyWin
  3084.         bra    EndMainMenu
  3085.  
  3086. NoHotWinKey    cmp.w    #ENABLEKEY,d5            ; Enable ?
  3087.         bne.s    NoEnKey
  3088. EnableKey    move.b    #0,Disabled
  3089.         move.b    #1,TimeReset
  3090.         bsr    EnableBroker
  3091.         move.l    #ENABLEGAD,d0
  3092.         lea    ControlGads,a0
  3093.         move.l    WndHandle,a5
  3094.         bsr    ButtonCheck
  3095.         bra    EndMainMenu
  3096.  
  3097. NoEnKey        cmp.w    #DISABLEKEY,d5            ; Disable ?
  3098.         bne.s    NoDisKey
  3099. DisableKey    bsr    DisableBroker
  3100.         move.b    #1,Disabled
  3101.         move.l    #DISABLEGAD,d0
  3102.         lea    ControlGads,a0
  3103.         move.l    WndHandle,a5
  3104.         bsr    ButtonCheck
  3105.         bra    EndMainMenu
  3106.  
  3107. NoDisKey    cmp.w    #ESCKEY,d5            ; Hide stuff ?
  3108.         beq.s    HideKey
  3109.         cmp.w    #HIDEKEY,d5
  3110.         bne.s    NoHideKey
  3111. HideKey        move.l    #HIDEGAD,d0
  3112.         lea    ControlGads,a0
  3113.         move.l    WndHandle,a5
  3114.         bsr    ButtonCheck
  3115. EndControl    bsr    CloseOurWindow
  3116.         bra    NoWindowMsg
  3117.  
  3118. NoHideKey    cmp.w    #QUITKEY,d5            ; Quit stuff ?
  3119.         bne.s    NoQuitKey
  3120. QuitKey        move.l    #QUITGAD,d0
  3121.         lea    ControlGads,a0
  3122.         move.l    WndHandle,a5
  3123.         bsr    ButtonCheck
  3124.         move.w    #1,QuitBroker
  3125.         bra    EndMainMenu
  3126.  
  3127. NoQuitKey    cmp.w    #SETALARMKEY,d5            ; Enter new alarm time ?
  3128.         bne.s    NoSetAlarmKey
  3129. SetAlarmKey    move.l    #SETALARMGAD,d0            ; Activate gadget
  3130.         lea    ControlGads,a0
  3131.         move.l    WndHandle,a1
  3132.         bsr    ActStringGad
  3133.         bra    EndMainMenu
  3134.  
  3135. NoSetAlarmKey    cmp.w    #SCREENKEY,d5            ; Enter new screentimeout ?
  3136.         bne.s    NoScreenKey
  3137. ScreenKey    move.l    #SCREENGAD,d0
  3138.         lea    ControlGads,a0
  3139.         move.l    WndHandle,a1
  3140.         bsr    ActStringGad
  3141.         bra    EndMainMenu
  3142.  
  3143. NoScreenKey    cmp.w    #MOUSEKEY,d5            ; Enter new mousetimeout ?
  3144.         bne.s    NoMouseKey
  3145. MouseKey    move.l    #MOUSEGAD,d0
  3146.         lea    ControlGads,a0
  3147.         move.l    WndHandle,a1
  3148.         bsr    ActStringGad
  3149.         bra    EndMainMenu
  3150.  
  3151. NoMouseKey    cmp.w    #FRONTKEY,d5            ; Change Front/Back qualifier
  3152.         bne.s    NoFrontKey
  3153. FrontKey    addq.l    #1,PopQualNum            ; Increase Qualifier number
  3154.         cmp.l    #POPQUALCNT,PopQualNum
  3155.         blt.s    .End
  3156.         move.l    #0,PopQualNum
  3157. .End        move.l    #FRONTGAD,d0
  3158.         lea    ControlGads,a0
  3159.         move.l    WndHandle,a1
  3160.         move.l    PopQualNum(pc),d1
  3161.         lea    PopQualList,a2
  3162.         bsr    SetCycleGad
  3163.         bra    EndMainMenu
  3164.  
  3165. NoFrontKey    cmp.w    #ESCQUALKEY,d5            ; Change ESC-Qualifier ?
  3166.         bne.s    NoESCQualKey
  3167. ESCKey        addq.l    #1,ESCQualNum            ; Increase Qualifier number
  3168.         cmp.l    #ESCQUALCNT,ESCQualNum
  3169.         blt.s    .End
  3170.         move.l    #0,ESCQualNum
  3171. .End        move.l    #ESCQUALGAD,d0
  3172.         move.l    ESCQualNum(pc),d1
  3173.         lea    ControlGads,a0
  3174.         move.l    WndHandle,a1
  3175.         lea    ESCQualList,a2
  3176.         bsr    SetCycleGad
  3177.         bra    EndMainMenu
  3178.  
  3179. NoESCQualKey    cmp.w    #USERSHELLKEY,d5        ; Change User shell ?
  3180.         bne    LoopWndMsg
  3181. UserShellKey    move.l    #USERSHELLGAD,d0
  3182.         lea    ControlGads,a0
  3183.         move.l    WndHandle,a1
  3184.         bsr    ActStringGad
  3185.         bra    EndMainMenu
  3186.  
  3187. NoWindowMsg    move.l    ThisSig(pc),d0            ; Did it come from ARexx ?
  3188.         and.l    ARexxSigFlag(pc),d0
  3189.         beq.s    NoARexxMsg
  3190.         bsr    HandleARexx            ; Handle ARexx commands
  3191.         bra    CheckBroker
  3192.  
  3193. NoARexxMsg    move.l    ThisSig(pc),d0            ; Did it come from the preferences
  3194.         and.l    PrefsSigFlag(pc),d0        ; window ?
  3195.         beq    NoPrefsMsg
  3196.  
  3197. LoopPrefsMsg    move.l    PrefsHandle(pc),a0        ; Get message
  3198.         move.l    wd_UserPort(a0),a0
  3199.         LNKLIB    GT_GetIMsg,_GadToolsBase
  3200.         tst.l    d0
  3201.         beq    NoPrefsMsg
  3202.  
  3203.         move.l    d0,a1                ; Get important data
  3204.         move.l    im_Class(a1),d6
  3205.         move.w    im_Code(a1),d5
  3206.         cmp.w    #'a',d5
  3207.         blt.s    .End
  3208.         and.w    #~$20,d5
  3209. .End        move.l    im_IAddress(a1),a4
  3210.         move.w    gg_GadgetID(a4),d7
  3211.  
  3212.         DOLIB    GT_ReplyIMsg
  3213.  
  3214. DoLogMsgs    cmp.l    #IDCMP_CLOSEWINDOW,d6        ; Window to be closed ?
  3215.         bne.s    NoPrefsClose
  3216.         bsr    ClosePrefsWin
  3217.         bra    NoPrefsMsg
  3218.  
  3219. NoPrefsClose    cmp.l    #IDCMP_ACTIVEWINDOW,d6        ; Window activated ?
  3220.         beq    Normal1Key
  3221.  
  3222.         cmp.l    #IDCMP_CHANGEWINDOW,d6        ; Window moved ?
  3223.         bne.s    NoPrefsMove
  3224.         move.l    PrefsHandle,a0
  3225.         lea    PrefsWinDef,a1
  3226.         bsr    StoreWinPos
  3227.         bra    LoopPrefsMsg
  3228.  
  3229. NoPrefsMove    cmp.l    #IDCMP_GADGETUP,d6        ; Gadget released ?
  3230.         bne    NoPrefsGadUp
  3231.  
  3232.         cmp.w    #CHEAP3GAD,d7            ; One of the cost gadgets ?
  3233.         bgt.s    NoCostTimeGad
  3234.  
  3235.         ext.l    d7                ; Calc offset to time
  3236.         move.l    d7,d6                ; Copy number of gadget
  3237.         subq.w    #1,d7                ; within structure
  3238.         move.l    d7,d0
  3239.         asr.w    #1,d0                ; D0 = Offset to timezone
  3240.         move.l    d0,d1
  3241.         asl.w    #1,d1
  3242.         sub.l    d1,d7                ; D7 = Offset to normal/cheap
  3243.  
  3244.         lea    CostUnit1,a0
  3245.         asl.l    #3,d0
  3246.         asl.l    #2,d7
  3247.         lea    0(a0,d0),a0
  3248.         move.l    0(a0,d7),d1            ; Get old cost
  3249.         move.l    gg_SpecialInfo(a4),a3
  3250.         move.l    si_LongInt(a3),d0        ; Get new one
  3251.         tst.l    d0                ; Less zero or even equal ?
  3252.         ble.s    .Error
  3253.         move.l    d0,0(a0,d7)            ; Store new time
  3254.         bra.s    .End
  3255. .Error        move.l    d6,d0
  3256.         lea    PrefsGads,a0
  3257.         move.l    PrefsHandle,a1
  3258.         move.l    d1,d2
  3259.         move.l    #4,d1
  3260.         bsr    SetIntegerGad
  3261. .End        move.b    #1,DoRemakeCosts
  3262.         bsr    RemakeCosts
  3263.         bra    LoopPrefsMsg
  3264.  
  3265. NoCostTimeGad    cmp.w    #COSTGAD,d7            ; New cost/unit entered ?
  3266.         bne.s    NoCostGad
  3267.  
  3268.         move.l    gg_SpecialInfo(a4),a3
  3269.         move.l    si_LongInt(a3),d0        ; Get new value
  3270.         tst.l    d0                ; <= 0 ?
  3271.         ble.s    .Error
  3272.         move.l    d0,CostUnit            ; Store new value
  3273.         bra.s    .End
  3274. .Error        move.l    #COSTGAD,d0
  3275.         lea    PrefsGads,a0
  3276.         move.l    PrefsHandle,a1
  3277.         moveq    #4,d1
  3278.         move.l    CostUnit,d2
  3279.         bsr    SetIntegerGad
  3280. .End        move.b    #1,DoRemakeCosts
  3281.         bsr    RemakeCosts
  3282.         bra    LoopPrefsMsg
  3283.  
  3284. NoCostGad    cmp.w    #CLEARLOGGAD,d7            ; Clear log file ?
  3285.         bne.s    NoClearGad
  3286.         move.l    #LogFileName,d1
  3287.         LNKLIB    DeleteFile,_DOSBase
  3288.         bra    LoopPrefsMsg
  3289.  
  3290. NoClearGad    cmp.w    #BILLPOPGAD,d7            ; Enable/Disable PopUp fo BillWin
  3291.         bne.s    NoBillPopGad
  3292.         bchg    #0,BillPopUp
  3293.         bra    LoopPrefsMsg
  3294.  
  3295. NoBillPopGad    cmp.w    #LOGCALLGAD,d7            ; Enable/Disable phone logs ?
  3296.         bne.s    NoLogGad
  3297.         bchg    #0,LogCalls
  3298.         bra    LoopPrefsMsg
  3299.  
  3300. NoLogGad    cmp.w    #SAVETOGAD,d7            ; Select a file via ASL-Request ?
  3301.         bne.s    NoSaveToGad
  3302.         pea    PrefsGads
  3303.         move.w    #LOGFILEGAD,-(sp)
  3304.         pea    LogFileName
  3305.         pea    LogFile
  3306.         pea    LogPath
  3307.         pea    LogFileHeader
  3308.         move.l    PrefsHandle,-(sp)
  3309.         jsr    GetFileName
  3310.         lea    26(sp),sp
  3311.         bra    LoopPrefsMsg
  3312.  
  3313. NoSaveToGad    cmp.w    #LOGFILEGAD,d7            ; Entered new logfilename ?
  3314.         bne    NoLogFileGad
  3315.  
  3316.         move.l    gg_SpecialInfo(a4),a5        ; Check if can be saved to dir
  3317.         move.l    si_Buffer(a5),a0
  3318.         move.l    ReadBuffer(pc),a1
  3319.         bsr    StrCpy                ; copy new filename
  3320.         move.l    ReadBuffer(pc),a0
  3321.         bsr    StrLen
  3322.         subq.l    #1,d0
  3323. .CheckLoop    cmp.b    #':',(a0)            ; Dir entered ?
  3324.         beq.s    .DoDirCheck
  3325.         cmp.b    #'/',(a0)
  3326.         beq.s    .DoDirCheck
  3327.         addq.l    #1,a0
  3328.         dbf    d0,.CheckLoop
  3329.         bra.s    .OnlyFile
  3330. .DoDirCheck    move.l    a0,a1                ; Yep...Extract dir name
  3331. .FindDir    tst.b    (a0)
  3332.         beq.s    .NameEnd
  3333.         cmp.b    #'/',(a0)
  3334.         bne.s    .Loop
  3335.         move.l    a0,a1
  3336. .Loop        addq.l    #1,a0
  3337.         bra.s    .FindDir
  3338. .NameEnd    move.b    #0,1(a1)            ; Dir name extracted
  3339.         move.l    ReadBuffer,d1            ; Try to lock it
  3340.         move.l    d1,EasyArg
  3341.         move.l    #ACCESS_READ,d2
  3342.         LNKLIB    Lock,_DOSBase
  3343.         tst.l    d0
  3344.         bne.s    .Ok
  3345.         DOLIB    IoErr                ; Error
  3346.         move.l    d0,ErrorNum
  3347.         bsr    DisplayError
  3348.         bra.s    .Error
  3349. .Ok        move.l    d0,d1                ; No Error
  3350.         DOLIB    UnLock
  3351. .OnlyFile    move.l    si_Buffer(a5),a0        ; Copy new filename
  3352.         lea    LogFileName,a1
  3353.         bsr    StrCpy
  3354.         bra    LoopPrefsMsg
  3355. .Error        move.l    #LOGFILEGAD,d0
  3356.         lea    PrefsGads,a0
  3357.         move.l    PrefsHandle,a1
  3358.         move.l    #286,d1
  3359.         lea    LogFileName,a2
  3360.         bsr    SetStringGad
  3361.         bra    LoopPrefsMsg
  3362.  
  3363. NoLogFileGad    cmp.w    #TOTALSUMGAD,d7            ; Display total sum ?
  3364.         bne    LoopPrefsMsg
  3365.  
  3366.         bsr    DisplayTotalSum
  3367.         bra    LoopPrefsMsg
  3368.  
  3369. NoPrefsGadUp    cmp.l    #IDCMP_GADGETDOWN,d6        ; MX gadget used ?
  3370.         bne.s    NoPrefsGadDown
  3371.  
  3372.         cmp.w    #PTIMEGAD,d7            ; Changed time ?
  3373.         bne.s    NoPTimeGad
  3374.         ext.l    d5
  3375.         move.l    d5,PTimeZone
  3376.         bra    LoopPrefsMsg
  3377.  
  3378. NoPTimeGad    cmp.w    #PMODEGAD,d7            ; Changed tariff ?
  3379.         bne    LoopPrefsMsg
  3380.         ext.l    d5
  3381.         move.l    d5,PTariff
  3382.         bra    LoopPrefsMsg
  3383.  
  3384. NoPrefsGadDown    cmp.l    #IDCMP_VANILLAKEY,d6        ; Key pressed ?
  3385.         bne    NoPrefsVKey
  3386.  
  3387.         cmp.w    #ESCKEY,d5            ; Hide window ?
  3388.         bne.s    PNoEscKey
  3389. PEscKey        bsr    ClosePrefsWin
  3390.         bra    NoPrefsMsg
  3391.  
  3392. PNoEscKey    cmp.w    #NORMAL1KEY,d5            ; Activate first integer gad ?
  3393.         bne.s    NoNormal1Key
  3394. Normal1Key    move.l    #NORMAL1GAD,d0
  3395.         lea    PrefsGads,a0
  3396.         move.l    PrefsHandle(pc),a1
  3397.         bsr    ActStringGad
  3398.         bra    EndPrefsMenu
  3399.  
  3400. NoNormal1Key    cmp.w    #SAVETOKEY,d5            ; Select new log filename ?
  3401.         bne.s    NoSaveToKey
  3402.  
  3403. SaveToKey    move.l    #SAVETOGAD,d0
  3404.         lea    PrefsGads,a0
  3405.         move.l    PrefsHandle,a5
  3406.         bsr    ButtonCheck
  3407.         pea    PrefsGads
  3408.         move.w    #LOGFILEGAD,-(sp)
  3409.         pea    LogFileName
  3410.         pea    LogFile
  3411.         pea    LogPath
  3412.         pea    LogFileHeader
  3413.         move.l    PrefsHandle,-(sp)
  3414.         jsr    GetFileName
  3415.         lea    26(sp),sp
  3416.         bra    EndPrefsMenu
  3417.  
  3418. NoSaveToKey    cmp.w    #TOTALSUMKEY,d5            ; Display total costs ?
  3419.         bne.s    NoTotalSumGad
  3420. TotalSumKey    move.l    #TOTALSUMGAD,d0
  3421.         lea    PrefsGads,a0
  3422.         move.l    PrefsHandle,a5
  3423.         bsr    ButtonCheck
  3424.         bsr    DisplayTotalSum
  3425.         bra    EndPrefsMenu
  3426.  
  3427. NoTotalSumGad    cmp.w    #CLEARLOGKEY,d5            ; Clear log file ?
  3428.         bne.s    NoClearKey
  3429. ClearLogKey    move.l    #CLEARLOGGAD,d0
  3430.         lea    PrefsGads,a0
  3431.         move.l    PrefsHandle,a5
  3432.         bsr    ButtonCheck
  3433.         move.l    #LogFileName,d1
  3434.         LNKLIB    DeleteFile,_DOSBase
  3435.         bra    EndPrefsMenu
  3436.  
  3437. NoClearKey    cmp.w    #LOGCALLKEY,d5            ; Enable/Disable phone logs ?
  3438.         bne.s    NoLogKey
  3439. LogCallKey    bchg    #0,LogCalls
  3440.         move.b    LogCalls(pc),d0
  3441.         move.l    #LOGCALLGAD,d1
  3442.         bra.s    SetPrefsBox
  3443.  
  3444. NoLogKey    cmp.w    #BILLPOPKEY,d5            ; Enable/Disable PopUp of BillWin
  3445.         bne.s    NoBillPopKey
  3446. BillPopKey    bchg    #0,BillPopUp
  3447.         move.b    BillPopUp(pc),d0
  3448.         move.l    #BILLPOPGAD,d1
  3449. SetPrefsBox    lea    PrefsGads,a0
  3450.         move.l    PrefsHandle,a1
  3451.         movem.l    d0/d1,-(sp)
  3452.         bsr    SetCheckBox
  3453.         movem.l    (sp)+,d0/d1
  3454.         sub.l    #10,d1
  3455.         moveq    #1,d2
  3456.         move.l    PrefsHandle,a0
  3457.         move.l    PrefsMenu,a1
  3458.         bsr    SetToggleMenu
  3459.         bra    EndPrefsMenu
  3460.  
  3461. NoBillPopKey    cmp.w    #TIME1KEY,d5            ; Changed time zone ?
  3462.         blt.s    NoPTimeKey
  3463.         cmp.w    #TIME3KEY,d5
  3464.         bgt.s    NoPTimeKey
  3465.         sub.w    #'1',d5
  3466. DoTime123Key    ext.l    d5
  3467.         move.l    d5,PTimeZone
  3468.         move.l    d5,d0
  3469.         move.l    #PTIMEGAD,d1
  3470.         lea    PrefsTimeLabels,a2
  3471.         bra.s    RemakePMx
  3472.  
  3473. NoPTimeKey    cmp.w    #PNORMALKEY,d5            ; Change tariff ?
  3474.         blt    EndPrefsMenu
  3475.         cmp.w    #PCHEAPKEY,d5
  3476.         bgt    EndPrefsMenu
  3477.         sub.w    #'4',d5
  3478. DoTariff45Key    ext.l    d5
  3479.         move.l    d5,PTariff
  3480.         move.l    d5,d0
  3481.         move.l    #PMODEGAD,d1
  3482.         lea    PrefsModeLabels,a2
  3483. RemakePMx    lea    PrefsGads,a0
  3484.         move.l    PrefsHandle(pc),a1
  3485.         bsr    SetMXGad
  3486.         bra    EndPrefsMenu
  3487.  
  3488. NoPrefsVKey    cmp.l    #IDCMP_RAWKEY,d6
  3489.         bne.s    NoPrefsRKey
  3490.  
  3491.         cmp.w    #HELPKEY,d5            ; User pressed help ?
  3492.         bne    LoopPrefsMsg
  3493.         lea    PrefsHelpFile,a0
  3494.         lea    HelpName,a1
  3495.         bsr    StrCpy
  3496.         bsr    OtherHelp
  3497.         bra    LoopPrefsMsg
  3498.  
  3499. NoPrefsRKey    cmp.l    #IDCMP_MENUHELP,d6        ; User pressed help in menu ?
  3500.         bne.s    NoPrefsHelp
  3501.         moveq    #0,d0                ; Remake possible
  3502.         move.b    BillPopUp,d0            ; changes to toggle entries
  3503.         moveq    #0,d1
  3504.         moveq    #1,d2
  3505.         move.l    PrefsHandle,a0
  3506.         move.l    PrefsMenu,a1
  3507.         bsr    SetToggleMenu
  3508.         moveq    #0,d0
  3509.         move.b    LogCalls,d0
  3510.         moveq    #1,d1
  3511.         moveq    #1,d2
  3512.         move.l    PrefsHandle,a0
  3513.         move.l    PrefsMenu,a1
  3514.         bsr    SetToggleMenu
  3515.         moveq    #2,d0
  3516.         bsr    OnlineHelp
  3517.         bra    LoopPrefsMsg
  3518.  
  3519. NoPrefsHelp    cmp.l    #IDCMP_MENUPICK,d6
  3520.         bne    LoopPrefsMsg
  3521.  
  3522.         cmp.w    #-1,d5
  3523.         beq.s    EndPrefsMenu
  3524.         move.w    d5,d2
  3525.         and.w    #$1f,d2                ; Get menunumber
  3526.         move.w    d5,d1
  3527.         asr.w    #5,d1
  3528.         and.w    #$3f,d1                ; Get itemnumber
  3529.         move.w    d1,d5
  3530.         move.l    PrefsMenu,a1
  3531.         bsr    GetMenuPtr
  3532.         GTMENUITEM_USERDATA a2,a0
  3533.         cmp.l    #0,a0
  3534.         beq.s    EndPrefsMenu
  3535.         jmp    (a0)
  3536.  
  3537. Time123Key    subq.w    #2,d5                ; Change timezone
  3538.         bra    DoTime123Key
  3539. Tariff45Key    subq.w    #6,d5                ; Change tariff
  3540.         bra    DoTariff45Key
  3541. ChangeLogName    lea    PrefsGads,a0
  3542.         move.l    #LOGFILEGAD,d0
  3543.         bsr    GetGadgetPtr
  3544.         move.l    PrefsHandle,a1
  3545.         sub.l    a2,a2
  3546.         LNKLIB    ActivateGadget,_IntuitionBase
  3547.         bra.s    EndPrefsMenu
  3548. EndPrefsMenu    move.l    DoActWindow,a1
  3549.         cmp.l    #0,a1
  3550.         beq.s    .End
  3551.         cmp.l    PrefsHandle,a1
  3552.         bne.s    .End
  3553.         move.l    DoActGadget,a0
  3554.         sub.l    a2,a2
  3555.         LNKLIB    ActivateGadget,_IntuitionBase
  3556.         move.l    #0,DoActWindow
  3557.         move.l    #0,DoActGadget
  3558. .End        bra    LoopPrefsMsg
  3559.  
  3560. NoPrefsMsg    move.l    ThisSig,d0            ; Msg from HotKey window ?
  3561.         and.l    HotKeySigFlag,d0
  3562.         beq    NoHotKeyMsg
  3563.  
  3564. LoopHotKeyMsg    move.l    HotKeyHandle,a0
  3565.         move.l    wd_UserPort(a0),a0
  3566.         LNKLIB    GT_GetIMsg,_GadToolsBase
  3567.         tst.l    d0
  3568.         beq    NoHotKeyMsg
  3569.  
  3570.         move.l    d0,a1                ; Get important data
  3571.         move.l    im_Class(a1),d6
  3572.         move.w    im_Code(a1),d5
  3573.         cmp.w    #'a',d5
  3574.         blt.s    .End
  3575.         and.w    #~$20,d5
  3576. .End        move.l    im_IAddress(a1),a4
  3577.         move.w    gg_GadgetID(a4),d7
  3578.  
  3579.         DOLIB    GT_ReplyIMsg
  3580.  
  3581.         cmp.l    #IDCMP_CLOSEWINDOW,d6        ; Close window ?
  3582.         bne.s    NoHotKeyClose
  3583.         bsr    CloseHotKeyWin
  3584.         bra    NoHotKeyMsg
  3585.  
  3586. NoHotKeyClose    cmp.l    #IDCMP_ACTIVEWINDOW,d6        ; Window active ?
  3587.         beq    HPopUpKey
  3588.  
  3589.         cmp.l    #IDCMP_CHANGEWINDOW,d6        ; Window moved ?
  3590.         bne.s    NoHotKeyMove
  3591.         move.l    HotKeyHandle,a0
  3592.         lea    HotKeyWinDef,a1
  3593.         bsr    StoreWinPos
  3594.         bra    LoopHotKeyMsg
  3595.  
  3596. NoHotKeyMove    cmp.l    #IDCMP_GADGETUP,d6        ; Gadget released ?
  3597.         bne    NoHotKeyGadUp
  3598.  
  3599.         cmp.w    #POPUPGAD,d7            ; Change PopUp HotKey ?
  3600.         bne.s    NoPopUpGad
  3601.         move.l    gg_SpecialInfo(a4),a0
  3602.         move.l    si_Buffer(a0),a0
  3603.         move.l    ReadBuffer(pc),a1        ; Copy new one to hotkey
  3604.         bsr    StrCpy
  3605.         move.l    WndHandle,a0
  3606.         lea    ControlTitle,a1
  3607.         move.l    PopUpFilter,a4
  3608.         lea    PopUpKey,a5
  3609.         bsr    RemakeHotKey
  3610.         bra    LoopHotKeyMsg
  3611.  
  3612. NoPopUpGad    cmp.w    #PAGEGAD,d7            ; Released Page-Gadget
  3613.         bne.s    NoPageGad
  3614.         move.l    gg_SpecialInfo(a4),a0
  3615.         move.l    si_Buffer(a0),a0
  3616.         move.l    ReadBuffer(pc),a1        ; Copy new one to hotkey
  3617.         bsr    StrCpy
  3618.         sub.l    a0,a0
  3619.         sub.l    a1,a1
  3620.         move.l    PageFilter,a4
  3621.         lea    PageHotKey,a5
  3622.         bsr    RemakeHotKey
  3623.         bra    LoopHotKeyMsg
  3624.  
  3625. NoPageGad    cmp.w    #BILLKEYGAD,d7            ; Changed Bill HotKey ?
  3626.         bne.s    NoBillKeyGad
  3627.         move.l    gg_SpecialInfo(a4),a0
  3628.         move.l    si_Buffer(a0),a0
  3629.         move.l    ReadBuffer(pc),a1        ; Copy new one to hotkey
  3630.         bsr    StrCpy
  3631.         move.l    BillHandle,a0
  3632.         lea    BillTitle,a1
  3633.         move.l    BillFilter,a4
  3634.         lea    BillHotKey,a5
  3635.         bsr    RemakeHotKey
  3636.         bra    LoopHotKeyMsg
  3637.  
  3638. NoBillKeyGad    cmp.w    #PREFSKEYGAD,d7            ; Changed preferences HotKey ?
  3639.         bne.s    NoPrefsKeyGad
  3640.         move.l    gg_SpecialInfo(a4),a0
  3641.         move.l    si_Buffer(a0),a0
  3642.         move.l    ReadBuffer(pc),a1        ; Copy new one to hotkey
  3643.         bsr    StrCpy
  3644.         move.l    PrefsHandle,a0
  3645.         lea    PrefsTitle,a1
  3646.         move.l    PrefsFilter,a4
  3647.         lea    PrefsHotKey,a5
  3648.         bsr    RemakeHotKey
  3649.         bra    LoopHotKeyMsg
  3650.  
  3651. NoPrefsKeyGad    cmp.w    #HOTKEYGAD,d7            ; Changed HotWin HotKey ?
  3652.         bne.s    NoHotKeyGad
  3653.         move.l    gg_SpecialInfo(a4),a0
  3654.         move.l    si_Buffer(a0),a0
  3655.         move.l    ReadBuffer(pc),a1        ; Copy new one to hotkey
  3656.         bsr    StrCpy
  3657.         move.l    HotKeyHandle,a0
  3658.         lea    HotWinTitle,a1
  3659.         move.l    HotKeyFilter,a4
  3660.         lea    HotWinHotKey,a5
  3661.         bsr    RemakeHotKey
  3662.         bra    LoopHotKeyMsg
  3663.  
  3664. NoHotKeyGad    cmp.w    #SHELLGAD,d7            ; Change Shell HotKey ?
  3665.         bne.s    NoShellGad
  3666.         move.l    gg_SpecialInfo(a4),a0
  3667.         move.l    si_Buffer(a0),a0
  3668.         move.l    ReadBuffer(pc),a1        ; Copy new one to hotkey
  3669.         bsr    StrCpy
  3670.         sub.l    a0,a0
  3671.         sub.l    a1,a1
  3672.         move.l    ShellFilter,a4
  3673.         lea    ShellHotKey,a5
  3674.         bsr    RemakeHotKey
  3675.         bra    LoopHotKeyMsg
  3676.  
  3677. NoShellGad    cmp.w    #UMLAUTKEYGAD,d7        ; Change Umlaut HotKey ?
  3678.         bne    LoopHotKeyMsg
  3679.         move.l    gg_SpecialInfo(a4),a0
  3680.         move.l    si_Buffer(a0),a0
  3681.         move.l    ReadBuffer(pc),a1
  3682.         bsr    StrCpy
  3683.         sub.l    a0,a0
  3684.         sub.l    a1,a1
  3685.         move.l    UmlautFilter,a4
  3686.         lea    UmlautHotKey,a5
  3687.         bsr    RemakeHotKey
  3688.         bra    LoopHotKeyMsg
  3689.  
  3690. NoHotKeyGadUp    cmp.l    #IDCMP_VANILLAKEY,d6        ; Key Pressed ?
  3691.         bne    NoHotVKey
  3692.  
  3693.         cmp.w    #POPUPKEY,d5            ; Change PopUp-Key ?
  3694.         bne.s    NoPopUpKey
  3695. HPopUpKey    move.l    #POPUPGAD,d0
  3696.         bra.s    ActHotKeyGad
  3697.  
  3698. NoPopUpKey    cmp.w    #PAGEKEY,d5            ; Change Page-Key ?
  3699.         bne.s    NoPageKey
  3700. HPageKey    move.l    #PAGEGAD,d0
  3701.         bra.s    ActHotKeyGad
  3702.  
  3703. NoPageKey    cmp.w    #BILLKEYKEY,d5            ; Change Bill-Key ?
  3704.         bne.s    NoBillKeyKey
  3705. HBillKey    move.l    #BILLKEYGAD,d0
  3706.         bra.s    ActHotKeyGad
  3707.  
  3708. NoBillKeyKey    cmp.w    #PREFSKEYKEY,d5            ; Change Prefs-Key ?
  3709.         bne.s    NoPrefsKeyKey
  3710. HPrefsKey    move.l    #PREFSKEYGAD,d0
  3711.         bra.s    ActHotKeyGad
  3712.  
  3713. NoPrefsKeyKey    cmp.w    #HOTKEYKEY,d5            ; Change HotKey-Key ?
  3714.         bne.s    NoHotKeyKey
  3715. HHotKey        move.l    #HOTKEYGAD,d0
  3716.         bra.s    ActHotKeyGad
  3717.  
  3718. NoHotKeyKey    cmp.w    #SHELLKEY,d5            ; Change Shell-Key ?
  3719.         bne.s    NoShellKey
  3720. HShellKey    move.l    #SHELLGAD,d0
  3721.         bra.s    ActHotKeyGad
  3722.  
  3723. NoShellKey    cmp.w    #UMLAUTKEYKEY,d5        ; Change Umlaut HotKey ?
  3724.         bne.s    NoUmlautKeyKey
  3725. HUmlautKey    move.l    #UMLAUTKEYGAD,d0
  3726. ActHotKeyGad    lea    HotKeyGads,a0
  3727.         move.l    HotKeyHandle,a1
  3728.         bsr    ActStringGad
  3729.         bra    LoopHotKeyMsg
  3730.  
  3731. NoUmlautKeyKey    cmp.w    #ESCKEY,d5            ; Close window ?
  3732.         bne    LoopHotKeyMsg
  3733. HEscKey        bsr    CloseHotKeyWin
  3734.         bra.s    NoHotKeyMsg
  3735.  
  3736. NoHotVKey    cmp.l    #IDCMP_RAWKEY,d6        ; User pressed help ?
  3737.         bne.s    NoHotRKey
  3738.  
  3739.         cmp.w    #HELPKEY,d5
  3740.         bne    LoopHotKeyMsg
  3741.         lea    HotKeyHelpFile,a0
  3742.         lea    HelpName,a1
  3743.         bsr    StrCpy
  3744.         bsr    OtherHelp
  3745.         bra    LoopHotKeyMsg
  3746.  
  3747. NoHotRKey    cmp.l    #IDCMP_MENUHELP,d6        ; Menu help ?
  3748.         bne.s    NoHotKeyHelp
  3749.         moveq    #4,d0
  3750.         bsr    OnlineHelp
  3751.         bra    LoopHotKeyMsg
  3752.  
  3753. NoHotKeyHelp    cmp.l    #IDCMP_MENUPICK,d6        ; Menu picked ?
  3754.         bne    LoopHotKeyMsg
  3755.         cmp.w    #-1,d5
  3756.         beq.s    EndHotKeyMenu
  3757.         move.w    d5,d2
  3758.         and.w    #$1f,d2                ; Get menunumber
  3759.         move.w    d5,d1
  3760.         asr.w    #5,d1
  3761.         and.w    #$3f,d1                ; Get itemnumber
  3762.         move.w    d1,d5
  3763.         move.l    HotKeyMenu,a1
  3764.         bsr    GetMenuPtr
  3765.         GTMENUITEM_USERDATA a2,a0
  3766.         cmp.l    #0,a0
  3767.         beq.s    EndHotKeyMenu
  3768.         jmp    (a0)
  3769. EndHotKeyMenu    bra    LoopHotKeyMsg
  3770.  
  3771. NoHotKeyMsg    move.l    ThisSig(pc),d0            ; App-Message ?
  3772.         and.l    AppSigFlag(pc),d0
  3773.         beq.s    NoAppMsg
  3774.  
  3775. .LoopAppMsg    move.l    AppPort,a0            ; Get message
  3776.         CALLSYS    GetMsg
  3777.         tst.l    d0
  3778.         beq.s    NoAppMsg
  3779.         move.l    d0,a1
  3780.         cmp.w    #MTYPE_APPICON,am_Type(a1)    ; Did it come from window ?
  3781.         bne.s    .NoAppIcon
  3782.         tst.l    am_NumArgs(a1)
  3783.         bne.s    .ReplyAppMsg
  3784.         tst.l    am_ArgList(a1)
  3785.         bne.s    .ReplyAppMsg
  3786.         move.l    a1,-(sp)
  3787.         bsr    OpenOurWindow            ; Open our window
  3788.         move.l    (sp)+,a1
  3789.         bra.s    .ReplyAppMsg
  3790. .NoAppIcon    cmp.w    #MTYPE_APPMENUITEM,am_Type(a1)    ; Was a menu item ?
  3791.         bne.s    .ReplyAppMsg
  3792.         cmp.l    #MAINITEM,am_ID(a1)        ; The control-window ?
  3793.         bne.s    .ReplyAppMsg
  3794.         move.l    a1,-(sp)
  3795.         bsr.s    OpenOurWindow            ; Open it
  3796.         move.l    (sp)+,a1
  3797. .ReplyAppMsg    CALLSYS    ReplyMsg
  3798.         bra    .LoopAppMsg
  3799.  
  3800. NoAppMsg    move.l    ThisSig(pc),d0            ; Display Help for Bill ?
  3801.         and.l    HelpSigFlag(pc),d0
  3802.         beq.s    NoHelpMsg
  3803.         move.w    HelpItem,d5
  3804.         moveq    #3,d0
  3805.         bsr    OnlineHelp
  3806. NoHelpMsg    bra    CheckBroker            ; Loop for all stuff
  3807.  
  3808. AbortBroker    move.b    #0,Disabled            ; Disable broker
  3809.         bsr    DisableBroker
  3810.         bsr    OnMouse
  3811.         move.l    WndHandle(pc),a0        ; Set control window to busy
  3812.         bsr    SetBusy
  3813.         move.l    CheckerProc(pc),a1        ; Tell son to go away
  3814.         move.l    #SIGHANDSHAKE,d0
  3815.         CALLSYS    Signal
  3816.         move.l    #SIGHANDSHAKE,d0        ; Wait for reply
  3817.         DOLIB    Wait
  3818.         move.l    #10,d1                ; Wait a bit
  3819.         LNKLIB    Delay,_DOSBase
  3820.         rts
  3821.  
  3822.  
  3823.  
  3824.  
  3825. **********************************************************************
  3826. *              Open our window. if not already open :-)              *
  3827. **********************************************************************
  3828. OpenOurWindow    tst.l    WndHandle            ; Window already open ?
  3829.         beq.s    .End
  3830.         move.l    WndHandle(pc),a0
  3831.         LNKLIB    WindowToFront,_IntuitionBase
  3832.         tst.b    WBFront
  3833.         beq.s    .NoWB
  3834.         move.l    WndHandle(pc),a0
  3835.         move.l    wd_WScreen(a0),a0
  3836.         DOLIB    ScreenToFront,_IntuitionBase
  3837. .NoWB        rts
  3838. .End        link    a5,#-4
  3839.         bsr    LockScreen
  3840.         tst.l    d0
  3841.         beq    NoWindow2Open
  3842.  
  3843.         tst.b    WBFront
  3844.         beq.s    .NoWBFront
  3845.         move.l    -4(a5),a0
  3846.         LNKLIB    ScreenToFront,_IntuitionBase
  3847.  
  3848. .NoWBFront    move.l    -4(a5),a0            ; Get visual info for screen
  3849.         sub.l    a1,a1
  3850.         LNKLIB    GetVisualInfoA,_GadToolsBase
  3851.         tst.l    d0
  3852.         beq    NoWindow2Open
  3853.         move.l    d0,VisInfo
  3854.         lea    DummyNewGadget,a0        ; Store visual info in newgadget
  3855.         move.l    d0,gng_VisualInfo(a0)
  3856.  
  3857.         lea    MyWindowDef(pc),a0        ; Try to open our window
  3858.         move.l    #WINWIDTH,WinWidth
  3859.         move.l    #WINHEIGHT,WinHeight
  3860.         move.l    #WINIDCMP,WinIDCMP
  3861.         move.l    #WINFLAGS,WinFlags
  3862.         move.l    #1,DoMenuHelp
  3863.         lea    WindowTags,a1
  3864.         LNKLIB    OpenWindowTagList,_IntuitionBase
  3865.         move.l    d0,WndHandle
  3866.         tst.l    d0
  3867.         beq    NoWindow2Open
  3868.         move.l    d0,a0                ; Get the sig flag for port
  3869.         move.l    wd_UserPort(a0),a0
  3870.         moveq    #0,d0
  3871.         move.b    MP_SIGBIT(a0),d0
  3872.         moveq    #1,d1
  3873.         asl.l    d0,d1
  3874.         move.l    d1,WindowSigFlag
  3875.  
  3876.         lea    MainMenuDef,a0            ; Create menu strip
  3877.         sub.l    a1,a1                ; No tags
  3878.         LNKLIB    CreateMenusA,_GadToolsBase
  3879.         move.l    d0,MainMenu
  3880.         tst.l    d0
  3881.         beq    NoWindow2Open
  3882.  
  3883.         move.l    MainMenu(pc),a0            ; Do the layout on window
  3884.         move.l    VisInfo(pc),a1
  3885.         sub.l    a2,a2
  3886.         DOLIB    LayoutMenusA
  3887.         tst.l    d0
  3888.         beq    NoWindow2Open
  3889.  
  3890.         move.l    WindowSigFlag(pc),d0        ; Wait until window popped up
  3891.         CALLSYS    Wait
  3892. .WLoop        move.l    WndHandle(pc),a0
  3893.         move.l    wd_UserPort(a0),a0
  3894.         DOLIB    GetMsg
  3895.         tst.l    d0
  3896.         beq.s    .WEnd
  3897.         move.l    d0,a1
  3898.         DOLIB    ReplyMsg
  3899.         bra.s    .WLoop
  3900.  
  3901. .WEnd        move.l    WndHandle(pc),a0
  3902.         moveq    #0,d7
  3903.         move.b    wd_BorderTop(a0),d7
  3904.  
  3905.         lea    FirstGadget(pc),a0        ; Create a context gadget
  3906.         LNKLIB    CreateContext,_GadToolsBase
  3907.         tst.l    d0
  3908.         beq    NoWindow2Open
  3909.         move.l    d0,ThisGadget
  3910.  
  3911.         move.w    #1,GadNum            ; Reset Gadget ID
  3912.  
  3913.         lea    GadgetAttrs,a4            ; List of attributes for new gads
  3914.         lea    ControlGads,a3
  3915. CreateGads    move.l    (a4)+,d0            ; Get address of gad-text
  3916.         beq.s    AllGadsDone            ; = 0 ? -> No more gads
  3917.         lea    DummyNewGadget,a1
  3918.         move.l    d0,gng_GadgetText(a1)        ; Store text
  3919.         move.w    #GADWIDTH,gng_Width(a1)        ; Store width
  3920.         move.w    #GADHEIGHT,gng_Height(a1)
  3921.         move.l    (a4)+,gng_Flags(a1)        ; Store new flags
  3922.         move.l    (a4)+,d0            ; Get gadget kind
  3923.         move.w    (a4)+,gng_LeftEdge(a1)        ; Store left and top edge
  3924.         move.w    (a4)+,d6
  3925.         add.w    d7,d6                ; Remake for height of window border
  3926.         move.w    d6,gng_TopEdge(a1)
  3927.         move.l    ThisGadget(pc),a0        ; Get pointer of prev. gad
  3928.         lea    ButtonTags,a2            ; Get pointer to tags
  3929.         DOLIB    CreateGadgetA            ; Create gadget
  3930.         tst.l    d0                ; A Ok ? -> Go on
  3931.         beq    NoWindow2Open
  3932.         move.l    d0,(a3)+
  3933.         move.l    d0,ThisGadget            ; Store pointer for next gadget
  3934.         addq.w    #1,GadNum            ; increase ID
  3935.         bra    CreateGads            ; Loop for all
  3936.  
  3937. AllGadsDone    lea    AlarmStartVal,a0        ; Create AlarmTime string gadget
  3938.         move.l    a0,StringConts
  3939.         move.l    #8,StrMax
  3940.         lea    DummyNewGadget,a1
  3941.         move.l    #AlarmGadTxt,gng_GadgetText(a1)
  3942.         move.w    #STRGADWIDTH,gng_Width(a1)
  3943.         move.w    #INTERWIDTH+154,gng_LeftEdge(a1)
  3944.         move.w    #97,d6
  3945.         add.w    d7,d6
  3946.         move.w    d6,gng_TopEdge(a1)
  3947.         move.l    #PLACETEXT_LEFT,gng_Flags(a1)
  3948.         move.l    #STRING_KIND,d0
  3949.         move.l    ThisGadget(pc),a0
  3950.         lea    StringTags,a2
  3951.         DOLIB    CreateGadgetA
  3952.         tst.l    d0
  3953.         beq    NoWindow2Open
  3954.         move.l    d0,(a3)+
  3955.         move.l    d0,ThisGadget
  3956.         addq.w    #1,GadNum
  3957.  
  3958.         lea    SystemParam,a0            ; Create User Shell string gadget
  3959.         move.l    a0,StringConts
  3960.         move.l    #64,StrMax
  3961.         lea    DummyNewGadget,a1
  3962.         move.l    #ShellGadTxt,gng_GadgetText(a1)
  3963.         move.w    #STRGADWIDTH,gng_Width(a1)
  3964.         move.w    #INTERWIDTH+154,gng_LeftEdge(a1)
  3965.         move.w    #110,d6
  3966.         add.w    d7,d6
  3967.         move.w    d6,gng_TopEdge(a1)
  3968.         move.l    #PLACETEXT_LEFT,gng_Flags(a1)
  3969.         move.l    #STRING_KIND,d0
  3970.         move.l    ThisGadget(pc),a0
  3971.         lea    StringTags,a2
  3972.         DOLIB    CreateGadgetA
  3973.         tst.l    d0
  3974.         beq    NoWindow2Open
  3975.         move.l    d0,(a3)+
  3976.         move.l    d0,ThisGadget
  3977.         addq.w    #1,GadNum
  3978.  
  3979.         move.l    ScreenTime,d0            ; Create screenblank gadget
  3980.         move.l    d0,IntConts
  3981.         move.l    #3,IntMax
  3982.         lea    DummyNewGadget,a1
  3983.         move.l    #ScrBTxt,gng_GadgetText(a1)
  3984.         move.w    #INTGADWIDTH,gng_Width(a1)
  3985.         move.w    #WINWIDTH-37-INTERWIDTH,gng_LeftEdge(a1)
  3986.         move.w    #97,d6
  3987.         add.w    d7,d6
  3988.         move.w    d6,gng_TopEdge(a1)
  3989.         move.l    #INTEGER_KIND,d0
  3990.         move.l    ThisGadget(pc),a0
  3991.         lea    IntegerTags,a2
  3992.         DOLIB    CreateGadgetA
  3993.         tst.l    d0
  3994.         beq    NoWindow2Open
  3995.         move.l    d0,(a3)+
  3996.         move.l    d0,ThisGadget
  3997.         addq.w    #1,GadNum
  3998.  
  3999.         move.l    MouseTime,d0            ; Create mouseblank gadget
  4000.         move.l    d0,IntConts
  4001.         lea    DummyNewGadget(pc),a1
  4002.         move.l    #MouseBTxt,gng_GadgetText(a1)
  4003.         move.w    #INTGADWIDTH,gng_Width(a1)
  4004.         move.w    #110,d6
  4005.         add.w    d7,d6
  4006.         move.w    d6,gng_TopEdge(a1)
  4007.         move.w    #WINWIDTH-37-INTERWIDTH,gng_LeftEdge(a1)
  4008.         move.l    #INTEGER_KIND,d0
  4009.         move.l    ThisGadget(pc),a0
  4010.         lea    IntegerTags,a2
  4011.         DOLIB    CreateGadgetA
  4012.         tst.l    d0
  4013.         beq    NoWindow2Open
  4014.         move.l    d0,(a3)+
  4015.         move.l    d0,ThisGadget
  4016.         addq.w    #1,GadNum
  4017.  
  4018.         move.l    ClickVol,d0            ; Create clickvolume
  4019.         move.l    d0,IntConts
  4020.         move.l    #2,IntMax
  4021.         lea    DummyNewGadget(pc),a1
  4022.         move.l    #ClickVolTxt,gng_GadgetText(a1)
  4023.         move.w    #INTGADWIDTH,gng_Width(a1)
  4024.         move.w    #123,d6
  4025.         add.w    d7,d6
  4026.         move.w    d6,gng_TopEdge(a1)
  4027.         move.w    #WINWIDTH-INTERWIDTH-37,gng_LeftEdge(a1)
  4028.         move.l    #INTEGER_KIND,d0
  4029.         move.l    ThisGadget(pc),a0
  4030.         lea    IntegerTags(pc),a2
  4031.         DOLIB    CreateGadgetA
  4032.         tst.l    d0
  4033.         beq    NoWindow2Open
  4034.         move.l    d0,(a3)+
  4035.         move.l    d0,ThisGadget
  4036.         addq.w    #1,GadNum
  4037.  
  4038.         move.l    #PopQualList,CycLabels        ; Create front gadget
  4039.         move.l    PopQualNum(pc),d0        ; Set label to be
  4040.         move.l    d0,CycActive            ; the active one
  4041.         lea    DummyNewGadget(pc),a1
  4042.         move.l    #FrontGadTxt,gng_GadgetText(a1)
  4043.         move.w    #CYCLEWIDTH,gng_Width(a1)
  4044.         move.w    #84,d6
  4045.         add.w    d7,d6
  4046.         move.w    d6,gng_TopEdge(a1)
  4047.         move.w    #INTERWIDTH+154,gng_LeftEdge(a1)
  4048.         move.l    #PLACETEXT_LEFT,gng_Flags(a1)
  4049.         move.l    #CYCLE_KIND,d0
  4050.         move.l    ThisGadget(pc),a0
  4051.         lea    CycleTags(pc),a2
  4052.         DOLIB    CreateGadgetA
  4053.         tst.l    d0
  4054.         beq    NoWindow2Open
  4055.         move.l    d0,(a3)+
  4056.         move.l    d0,ThisGadget
  4057.         addq.w    #1,GadNum
  4058.  
  4059.         lea    DummyNewGadget(pc),a1        ; Create bill gadget
  4060.         move.l    #TeleBillTxt,gng_GadgetText(a1)
  4061.         move.w    #140,gng_Width(a1)
  4062.         move.w    #123,d6
  4063.         add.w    d7,d6
  4064.         move.w    d6,gng_TopEdge(a1)
  4065.         move.w    #INTERWIDTH,gng_LeftEdge(a1)
  4066.         move.l    #PLACETEXT_IN,gng_Flags(a1)
  4067.         move.l    #BUTTON_KIND,d0
  4068.         move.l    ThisGadget(pc),a0
  4069.         lea    ButtonTags(pc),a2
  4070.         DOLIB    CreateGadgetA
  4071.         tst.l    d0
  4072.         beq    NoWindow2Open
  4073.         move.l    d0,(a3)+
  4074.         move.l    d0,ThisGadget
  4075.         addq.w    #1,GadNum
  4076.  
  4077.         lea    DummyNewGadget(pc),a1        ; Create preferences gadget
  4078.         move.l    #TelePrefsTxt,gng_GadgetText(a1)
  4079.         move.w    #164,gng_Width(a1)
  4080.         move.w    #123,d6
  4081.         add.w    d7,d6
  4082.         move.w    d6,gng_TopEdge(a1)
  4083.         move.w    #INTERWIDTH*2+140,gng_LeftEdge(a1)
  4084.         move.l    #PLACETEXT_IN,gng_Flags(a1)
  4085.         move.l    #BUTTON_KIND,d0
  4086.         move.l    ThisGadget(pc),a0
  4087.         lea    ButtonTags(pc),a2
  4088.         DOLIB    CreateGadgetA
  4089.         tst.l    d0
  4090.         beq    NoWindow2Open
  4091.         move.l    d0,(a3)+
  4092.         move.l    d0,ThisGadget
  4093.         addq.w    #1,GadNum
  4094.  
  4095.         move.l    #ESCQualList,CycLabels        ; Create ESC-Qualifier gadget
  4096.         move.l    ESCQualNum(pc),d0        ; Set label to be
  4097.         move.l    d0,CycActive            ; the active one
  4098.         lea    DummyNewGadget(pc),a1
  4099.         move.l    #ESCGadTxt,gng_GadgetText(a1)
  4100.         move.w    #CYCLEWIDTH,gng_Width(a1)
  4101.         move.w    #84,d6
  4102.         add.w    d7,d6
  4103.         move.w    d6,gng_TopEdge(a1)
  4104.         move.w    #WINWIDTH-CYCLEWIDTH,gng_LeftEdge(a1)
  4105.         move.l    #PLACETEXT_LEFT,gng_Flags(a1)
  4106.         move.l    #CYCLE_KIND,d0
  4107.         move.l    ThisGadget(pc),a0
  4108.         lea    CycleTags(pc),a2
  4109.         DOLIB    CreateGadgetA
  4110.         tst.l    d0
  4111.         beq    NoWindow2Open
  4112.         move.l    d0,(a3)+
  4113.         move.l    d0,ThisGadget
  4114.         addq.w    #1,GadNum
  4115.  
  4116.         lea    DummyNewGadget(pc),a1        ; Create HotKeys gadget
  4117.         move.l    #HotKeyGadTxt,gng_GadgetText(a1)
  4118.         move.w    #120,gng_Width(a1)
  4119.         move.w    #123,d6
  4120.         add.w    d7,d6
  4121.         move.w    d6,gng_TopEdge(a1)
  4122.         move.w    #INTERWIDTH*3+140+164,gng_LeftEdge(a1)
  4123.         move.l    #PLACETEXT_IN,gng_Flags(a1)
  4124.         move.l    #BUTTON_KIND,d0
  4125.         move.l    ThisGadget(pc),a0
  4126.         lea    ButtonTags(pc),a2
  4127.         DOLIB    CreateGadgetA
  4128.         tst.l    d0
  4129.         beq.s    NoWindow2Open
  4130.         move.l    d0,(a3)+
  4131.         move.l    d0,ThisGadget
  4132.         addq.w    #1,GadNum
  4133.  
  4134.         move.l    WndHandle(pc),a0        ; Add gadgets to window
  4135.         move.l    FirstGadget(pc),a1
  4136.         move.l    #-1,d0
  4137.         move.l    #-1,d1
  4138.         sub.l    a2,a2
  4139.         LNKLIB    AddGList,_IntuitionBase
  4140.  
  4141.         move.l    FirstGadget(pc),a0        ; Make them appear
  4142.         move.l    WndHandle(pc),a1
  4143.         sub.l    a2,a2
  4144.         move.l    #-1,d0
  4145.         DOLIB    RefreshGList
  4146.  
  4147.         move.l    WndHandle(pc),a0        ; Append menu to window
  4148.         move.l    MainMenu(pc),a1
  4149.         LNKLIB    SetMenuStrip,_IntuitionBase
  4150.  
  4151.         bsr    RemakeGadgets
  4152.         bsr    UnlockScreen
  4153.         moveq    #0,d0
  4154.         unlk    a5
  4155.         rts
  4156. NoWindow2Open    bsr.s    CloseOurWindow
  4157.         bsr    UnlockScreen
  4158.         move.l    #12,ErrorNum
  4159.         bsr    DisplayError
  4160.         moveq    #-1,d0
  4161.         unlk    a5
  4162.         rts
  4163.  
  4164.  
  4165.  
  4166.  
  4167.  
  4168. **********************************************************************
  4169. *                    This part closes our window                     *
  4170. **********************************************************************
  4171. CloseOurWindow    tst.l    WndHandle
  4172.         beq.s    NoWindow2Close
  4173.         move.l    WndHandle(pc),a0        ; Store new coords in structure
  4174.         lea    MyWindowDef(pc),a1        ; So that window appears at same
  4175.         bsr    StoreWinPos
  4176.  
  4177.         move.l    WndHandle(pc),a0        ; Remove remaining msgs
  4178.         LNKLIB    CloseWindow,_IntuitionBase    ; Close Window
  4179.  
  4180. NoWindow2Close    tst.l    FirstGadget
  4181.         beq.s    GotNoGadgets
  4182.         move.l    FirstGadget(pc),a0        ; Free GadTools-Gadgets
  4183.         LNKLIB    FreeGadgets,_GadToolsBase
  4184.  
  4185. GotNoGadgets    tst.l    MainMenu            ; Free GadTools-Menus
  4186.         beq.s    .NoMenu
  4187.         move.l    MainMenu(pc),a0
  4188.         LNKLIB    FreeMenus,_GadToolsBase
  4189.  
  4190. .NoMenu        tst.l    VisInfo                ; Free Visual-Info
  4191.         beq.s    NoVisInfo
  4192.         move.l    VisInfo(pc),a0
  4193.         LNKLIB    FreeVisualInfo,_GadToolsBase
  4194.  
  4195. NoVisInfo    move.l    #0,WndHandle            ; Clear flags for later
  4196.         move.l    #0,WindowSigFlag        ; identification
  4197.         move.l    #0,FirstGadget
  4198.         move.l    #0,MainMenu
  4199.         move.l    #0,VisInfo
  4200.         rts
  4201.  
  4202.  
  4203.  
  4204.  
  4205. **********************************************************************
  4206. *                   Open clock window. Width in D6                   *
  4207. **********************************************************************
  4208. OpenClockWin    add.w    #DEPTHWIDTH*2+8,d6        ; approximate width of close/depth gadgets
  4209.         move.w    d6,ClockWidth            ; Store for compare
  4210.  
  4211.         tst.l    ClockHandle            ; Window already open ?
  4212.         bne    ClockWinOpen
  4213.  
  4214.         bsr    ClearTitleBar            ; Clear titlebar first
  4215.  
  4216.         link    a5,#-4
  4217.         bsr    LockScreen
  4218.         tst.l    d0
  4219.         beq    ClockError
  4220.  
  4221.         lea    ClockWinDef(pc),a0        ; Set width to time width
  4222.         move.w    ClockWidth(pc),nw_Width(a0)
  4223.         move.l    MyFont(pc),a1
  4224.         move.w    tf_YSize(a1),d1
  4225.         addq.w    #3,d1
  4226.         move.w    d1,nw_Height(a0)
  4227.         move.l    -4(a5),a1
  4228.         bsr    AdjustWinPos
  4229.         move.l    #CLOCKWIDTH,WinWidth
  4230.         move.l    #CLOCKHEIGHT,WinHeight
  4231.         move.l    #CLOCKIDCMP,WinIDCMP
  4232.         move.l    #CLOCKFLAGS,WinFlags
  4233.         move.l    #0,DoMenuHelp
  4234.         lea    WindowTags(pc),a1
  4235.         LNKLIB    OpenWindowTagList,_IntuitionBase
  4236.         move.l    d0,ClockHandle
  4237.         tst.l    d0
  4238.         bne.s    GotClockWin
  4239.         move.b    #0,ClockWin            ; On failure close
  4240.         moveq    #0,d0                ; disable clockwin mode
  4241.         move.l    #WINDOWGAD,d1
  4242.         bsr    SetControlBox
  4243.         bra.s    ClockError
  4244. GotClockWin    move.l    ClockHandle(pc),a0        ; Get sig flag
  4245.         moveq    #0,d0
  4246.         move.l    wd_UserPort(a0),a0
  4247.         move.b    MP_SIGBIT(a0),d0
  4248.         moveq    #1,d1
  4249.         asl.l    d0,d1
  4250.         move.l    d1,ClockSigFlag
  4251.         bsr    UnlockScreen
  4252.         unlk    a5
  4253. ClockWinOpen    move.l    ClockHandle(pc),a0        ; Current width not equal
  4254.         moveq    #0,d0                ; to width needed
  4255.         moveq    #0,d1
  4256.         moveq    #0,d2
  4257.         moveq    #0,d3
  4258.         move.w    wd_LeftEdge(a0),d0
  4259.         move.w    wd_TopEdge(a0),d1
  4260.         move.w    ClockWidth(pc),d2
  4261.         cmp.w    wd_Width(a0),d2
  4262.         beq.s    CWidthOk
  4263.         moveq    #0,d3
  4264.         move.b    wd_BorderTop(a0),d3
  4265.         LNKLIB    ChangeWindowBox,_IntuitionBase    ; so readjust width
  4266.         bsr    ClockRemake            ; Wait until window has been remade
  4267. CWidthOk    moveq    #1,d0
  4268.         rts
  4269. ClockError    bsr    UnlockScreen
  4270.         moveq    #0,d0
  4271.         unlk    a5
  4272.         rts
  4273.  
  4274.  
  4275.  
  4276. **********************************************************************
  4277. *                Close clockwindow and remove pointer                *
  4278. **********************************************************************
  4279. CloseClockWin    tst.l    ClockHandle
  4280.         beq.s    NoCWOpen
  4281.         move.l    ClockHandle(pc),a0        ; Store new coords in structure
  4282.         lea    ClockWinDef(pc),a1        ; so that window appears at
  4283.         bsr    StoreWinPos
  4284.         LNKLIB    CloseWindow,_IntuitionBase    ; and now....CLOSE IT
  4285. NoCWOpen    move.l    #0,ClockHandle
  4286.         move.l    #0,ClockSigFlag
  4287.         rts
  4288.  
  4289.  
  4290.  
  4291.  
  4292. **********************************************************************
  4293. *                        Open the bill window                        *
  4294. **********************************************************************
  4295. OpenBillWin    tst.l    BillHandle
  4296.         beq.s    .End
  4297.         move.l    BillHandle,a0
  4298.         LNKLIB    WindowToFront,_IntuitionBase
  4299.         rts
  4300. .End        link    a5,#-4
  4301.         bsr    LockScreen
  4302.         tst.l    d0
  4303.         beq    .BillWinError
  4304.  
  4305.         move.l    -4(a5),a0            ; Get Visual Info
  4306.         sub.l    a1,a1
  4307.         LNKLIB    GetVisualInfoA,_GadToolsBase
  4308.         move.l    d0,BillVisInfo
  4309.         tst.l    d0
  4310.         beq    .BillWinError
  4311.         lea    DummyNewGadget(pc),a0
  4312.         move.l    d0,gng_VisualInfo(a0)
  4313.         move.l    d0,BevelVisInfo
  4314.  
  4315.         move.l    #BILLWINWIDTH,WinWidth        ; Open the window
  4316.         move.l    #BILLWINHEIGHT,WinHeight
  4317.         move.l    #BILLWINIDCMP,WinIDCMP
  4318.         move.l    #BILLWINFLAGS,WinFlags
  4319.         move.l    #1,DoMenuHelp
  4320.  
  4321.         lea    BillMenuDef,a0            ; Create menu strip
  4322.         sub.l    a1,a1                ; No tags
  4323.         LNKLIB    CreateMenusA,_GadToolsBase
  4324.         move.l    d0,BillMenu
  4325.         tst.l    d0
  4326.         beq    .BillWinError
  4327.  
  4328.         move.l    BillMenu(pc),a0            ; Do the layout on window
  4329.         move.l    BillVisInfo(pc),a1
  4330.         sub.l    a2,a2
  4331.         DOLIB    LayoutMenusA
  4332.         tst.l    d0
  4333.         beq    .BillWinError
  4334.  
  4335.         lea    BillWinDef(pc),a0
  4336.         move.l    -4(a5),a1
  4337.         bsr    AdjustWinPos
  4338.         lea    WindowTags(pc),a1
  4339.         LNKLIB    OpenWindowTagList,_IntuitionBase
  4340.         move.l    d0,BillHandle
  4341.         tst.l    d0
  4342.         beq    .BillWinError
  4343.         move.l    BillHandle(pc),a0
  4344.         move.l    wd_UserPort(a0),a0
  4345.         moveq    #0,d0
  4346.         moveq    #1,d1
  4347.         move.b    MP_SIGBIT(a0),d0        ; Get Sig flag
  4348.         asl.l    d0,d1
  4349.         move.l    d1,BillSigFlag
  4350.  
  4351.         move.l    BillHandle(pc),a0
  4352.         moveq    #0,d7
  4353.         move.b    wd_BorderTop(a0),d7
  4354.         move.l    wd_RPort(a0),BillRPort
  4355.  
  4356.         move.l    BillRPort(pc),a0        ; Print ITexts
  4357.         lea    BillITxts,a1
  4358.         moveq    #0,d0
  4359.         move.l    d7,d1
  4360.         LNKLIB    PrintIText,_IntuitionBase
  4361.  
  4362.         move.l    BillRPort(pc),a0        ; Draw bevel boxes
  4363.         move.l    #INTERWIDTH,d0
  4364.         move.l    #BEVELHEIGHT,d1
  4365.         add.l    d7,d1
  4366.         move.l    #BEVELWIDTH,d2
  4367.         move.l    #BEVELHEIGHT,d3
  4368.         lea    BevelTag(pc),a1
  4369.         LNKLIB    DrawBevelBoxA,_GadToolsBase
  4370.  
  4371.         move.l    BillRPort(pc),a0
  4372.         move.l    #INTERWIDTH+BEVELWIDTH+INTERWIDTH,d0
  4373.         move.l    #BEVELHEIGHT,d1
  4374.         add.l    d7,d1
  4375.         move.l    #BEVELWIDTH,d2
  4376.         move.l    #BEVELHEIGHT,d3
  4377.         lea    BevelTag(pc),a1
  4378.         DOLIB    DrawBevelBoxA
  4379.  
  4380.         move.l    BillRPort(pc),a0
  4381.         move.l    #INTERWIDTH+((BEVELWIDTH+INTERWIDTH)*2),d0
  4382.         move.l    #BEVELHEIGHT,d1
  4383.         add.l    d7,d1
  4384.         move.l    #BEVELWIDTH,d2
  4385.         move.l    #BEVELHEIGHT,d3
  4386.         lea    BevelTag(pc),a1
  4387.         DOLIB    DrawBevelBoxA
  4388.  
  4389.         move.l    BillRPort(pc),a0
  4390.         move.l    #INTERWIDTH,d0
  4391.         move.l    #BEVELHEIGHT*4+10,d1
  4392.         add.l    d7,d1
  4393.         move.l    #(BEVELWIDTH*3)+(INTERWIDTH*2),d2
  4394.         move.l    #BEVELHEIGHT,d3
  4395.         lea    BevelTag(pc),a1
  4396.         DOLIB    DrawBevelBoxA
  4397.  
  4398.         lea    BillGadget(pc),a0        ; Create Context gadget
  4399.         DOLIB    CreateContext
  4400.         move.l    d0,ThisGadget
  4401.         tst.l    d0
  4402.         beq    .BillWinError
  4403.  
  4404.         move.w    #1,GadNum
  4405.  
  4406.         lea    DummyNewGadget(pc),a1        ; Creat Time MX gadgets
  4407.         lea    BillGads,a4
  4408.         move.l    #TimeZoneLabels,MxLabels
  4409.         move.l    TimeZone,MxActive
  4410.         move.w    #BEVELHEIGHT*2+2,d0
  4411.         add.w    d7,d0
  4412.         move.w    d0,gng_TopEdge(a1)
  4413.         move.w    #INTERWIDTH,gng_LeftEdge(a1)
  4414.         move.w    #17,gng_Width(a1)
  4415.         move.w    #9,gng_Height(a1)
  4416.         move.l    #PLACETEXT_RIGHT,gng_Flags(a1)
  4417.         move.l    #MX_KIND,d0
  4418.         move.l    ThisGadget(pc),a0
  4419.         lea    MxTags(pc),a2
  4420.         DOLIB    CreateGadgetA
  4421.         tst.l    d0
  4422.         beq    .BillWinError
  4423.         move.l    d0,(a4)+
  4424.         move.l    d0,ThisGadget
  4425.         addq.w    #1,GadNum
  4426.  
  4427.         lea    DummyNewGadget(pc),a1        ; Create CHEAP MX gadgets
  4428.         move.l    #CheapLabels,MxLabels
  4429.         moveq    #0,d0
  4430.         move.b    CheapMode(pc),d0
  4431.         move.l    d0,MxActive
  4432.         move.w    #BEVELHEIGHT*2+2,d0
  4433.         add.w    d7,d0
  4434.         move.w    d0,gng_TopEdge(a1)
  4435.         move.w    #INTERWIDTH+(INTERWIDTH+BEVELWIDTH)*2,gng_LeftEdge(a1)
  4436.         move.w    #17,gng_Width(a1)
  4437.         move.w    #9,gng_Height(a1)
  4438.         move.l    #PLACETEXT_RIGHT,gng_Flags(a1)
  4439.         move.l    #MX_KIND,d0
  4440.         move.l    ThisGadget(pc),a0
  4441.         lea    MxTags(pc),a2
  4442.         DOLIB    CreateGadgetA
  4443.         tst.l    d0
  4444.         beq.s    .BillWinError
  4445.         move.l    d0,(a4)+
  4446.         move.l    d0,ThisGadget
  4447.         addq.w    #1,GadNum
  4448.  
  4449.         move.l    BillHandle(pc),a0        ; Add gadgets to window
  4450.         move.l    BillGadget(pc),a1
  4451.         sub.l    a2,a2
  4452.         moveq    #-1,d0
  4453.         moveq    #-1,d1
  4454.         LNKLIB    AddGList,_IntuitionBase
  4455.  
  4456.         move.l    BillGadget(pc),a0        ; Make `em appear
  4457.         move.l    BillHandle(pc),a1
  4458.         sub.l    a2,a2
  4459.         moveq    #-1,d0
  4460.         DOLIB    RefreshGList
  4461.  
  4462.         move.l    BillHandle(pc),a0        ; Append menu to window
  4463.         move.l    BillMenu(pc),a1
  4464.         LNKLIB    SetMenuStrip,_IntuitionBase
  4465.  
  4466.         bra.s    .NoBillClose
  4467.  
  4468. .BillWinError    bsr.s    CloseBillWin
  4469. .NoBillClose    bsr    UnlockScreen
  4470.         unlk    a5
  4471.         rts
  4472.  
  4473.  
  4474.  
  4475. **********************************************************************
  4476. *                    Close the Bill window again                     *
  4477. **********************************************************************
  4478. CloseBillWin    tst.l    BillHandle            ; Close window
  4479.         beq.s    .NoWin
  4480.         move.l    BillHandle(pc),a0        ; Store new coords of window
  4481.         lea    BillWinDef,a1
  4482.         bsr    StoreWinPos
  4483.         LNKLIB    CloseWindow,_IntuitionBase
  4484. .NoWin        tst.l    BillGadget            ; Free gadgets
  4485.         beq.s    .NoGads
  4486.         move.l    BillGadget(pc),a0
  4487.         LNKLIB    FreeGadgets,_GadToolsBase
  4488. .NoGads        tst.l    BillMenu            ; Free GadTools-Menus
  4489.         beq.s    .NoMenu
  4490.         move.l    BillMenu(pc),a0
  4491.         LNKLIB    FreeMenus,_GadToolsBase
  4492. .NoMenu        tst.l    BillVisInfo            ; Free visual info
  4493.         beq.s    .NoVisInfo
  4494.         move.l    BillVisInfo(pc),a0
  4495.         LNKLIB    FreeVisualInfo,_GadToolsBase
  4496. .NoVisInfo    move.l    #0,BillHandle            ; Reset stuff
  4497.         move.l    #0,BillSigFlag
  4498.         move.l    #0,BillGadget
  4499.         move.l    #0,BillVisInfo
  4500.         move.l    #0,BillMenu
  4501.         rts
  4502.  
  4503.  
  4504.  
  4505.  
  4506. **********************************************************************
  4507. *                    Open the preferences window                     *
  4508. **********************************************************************
  4509. OpenPrefsWin    tst.l    PrefsHandle
  4510.         beq.s    .GoOn
  4511.         move.l    PrefsHandle,a0
  4512.         LNKLIB    WindowToFront,_IntuitionBase
  4513.         rts
  4514. .GoOn        link    a5,#-4
  4515.         bsr    LockScreen
  4516.         tst.l    d0
  4517.         beq    .PrefsWinError
  4518.  
  4519.         move.l    -4(a5),a0            ; Get visual info
  4520.         sub.l    a1,a1
  4521.         LNKLIB    GetVisualInfoA,_GadToolsBase
  4522.         tst.l    d0
  4523.         beq    .PrefsWinError
  4524.         move.l    d0,PrefsVisInfo
  4525.         lea    DummyNewGadget(pc),a0
  4526.         move.l    d0,gng_VisualInfo(a0)
  4527.  
  4528.         move.l    #PREFSWINWIDTH,WinWidth        ; Try to open the window
  4529.         move.l    #PREFSWINHEIGHT,WinHeight
  4530.         move.l    #PREFSWINIDCMP,WinIDCMP
  4531.         move.l    #PREFSWINFLAGS,WinFlags
  4532.         move.l    #1,DoMenuHelp
  4533.  
  4534.         lea    PrefsWinDef(pc),a0
  4535.         move.l    -4(a5),a1
  4536.         bsr    AdjustWinPos
  4537.         lea    WindowTags(pc),a1
  4538.         LNKLIB    OpenWindowTagList,_IntuitionBase
  4539.         move.l    d0,PrefsHandle
  4540.         tst.l    d0
  4541.         beq    .PrefsWinError
  4542.         move.l    PrefsHandle(pc),a0
  4543.         moveq    #0,d0
  4544.         moveq    #1,d1
  4545.         move.l    wd_UserPort(a0),a0
  4546.         move.b    MP_SIGBIT(a0),d0        ; Get the sigmask
  4547.         asl.l    d0,d1
  4548.         move.l    d1,PrefsSigFlag
  4549.  
  4550.         lea    PrefsMenuDef,a0            ; Create menu strip
  4551.         sub.l    a1,a1                ; No tags
  4552.         LNKLIB    CreateMenusA,_GadToolsBase
  4553.         move.l    d0,PrefsMenu
  4554.         tst.l    d0
  4555.         beq    .PrefsWinError
  4556.  
  4557.         move.l    PrefsMenu(pc),a0        ; Do the layout on window
  4558.         move.l    PrefsVisInfo(pc),a1
  4559.         sub.l    a2,a2
  4560.         DOLIB    LayoutMenusA
  4561.         tst.l    d0
  4562.         beq    .PrefsWinError
  4563.  
  4564.         lea    PrefsGadget(pc),a0
  4565.         LNKLIB    CreateContext,_GadToolsBase
  4566.         move.l    d0,ThisGadget
  4567.         tst.l    d0
  4568.         beq    .PrefsWinError
  4569.  
  4570.         move.l    PrefsHandle(pc),a0
  4571.         moveq    #0,d7
  4572.         move.b    wd_BorderTop(a0),d7
  4573.  
  4574.         move.w    #1,GadNum
  4575.  
  4576.         lea    CostUnit1,a4            ; Loop for all integer gads
  4577.         lea    PrefsGadTxts,a3
  4578.         move.l    d7,d5
  4579.         addq.l    #2,d5
  4580.         move.l    #2,d6
  4581.         moveq    #0,d4
  4582. .GadLoop    lea    DummyNewGadget(pc),a1        ; Create normal gad
  4583.         move.l    cu_Normal(a4),IntConts
  4584.         move.l    #4,IntMax
  4585.         move.w    #PREFINTGADWIDTH,gng_Width(a1)
  4586.         move.w    #GADHEIGHT,gng_Height(a1)
  4587.         move.w    #160,gng_LeftEdge(a1)
  4588.         move.w    d5,gng_TopEdge(a1)
  4589.         move.l    (a3)+,gng_GadgetText(a1)
  4590.         move.l    #PLACETEXT_LEFT,gng_Flags(a1)
  4591.         move.l    #INTEGER_KIND,d0
  4592.         move.l    ThisGadget(pc),a0
  4593.         lea    IntegerTags(pc),a2
  4594.         DOLIB    CreateGadgetA
  4595.         tst.l    d0
  4596.         beq    .PrefsWinError
  4597.         move.l    d0,ThisGadget
  4598.         lea    PrefsGads,a0
  4599.         move.l    d0,0(a0,d4)
  4600.         addq.l    #4,d4
  4601.         addq.w    #1,GadNum
  4602.  
  4603.         lea    DummyNewGadget(pc),a1        ; Create cheap gad
  4604.         move.l    cu_Cheap(a4),IntConts
  4605.         move.w    #368,gng_LeftEdge(a1)
  4606.         move.l    (a3)+,gng_GadgetText(a1)
  4607.         move.l    #INTEGER_KIND,d0
  4608.         move.l    ThisGadget(pc),a0
  4609.         lea    IntegerTags(pc),a2
  4610.         DOLIB    CreateGadgetA
  4611.         tst.l    d0
  4612.         beq    .PrefsWinError
  4613.         move.l    d0,ThisGadget
  4614.         lea    PrefsGads,a0
  4615.         move.l    d0,0(a0,d4)
  4616.         addq.l    #4,d4
  4617.         addq.w    #1,GadNum
  4618.         addq.l    #8,a4
  4619.         add.l    #GADHEIGHT+INTERHEIGHT,d5
  4620.         dbf    d6,.GadLoop
  4621.  
  4622.         move.l    CostUnit,d0            ; Create cost/unit gad
  4623.         move.l    d0,IntConts
  4624.         lea    DummyNewGadget(pc),a1
  4625.         move.w    d5,gng_TopEdge(a1)
  4626.         move.w    #200,gng_LeftEdge(a1)
  4627.         move.l    (a3)+,gng_GadgetText(a1)
  4628.         move.l    #INTEGER_KIND,d0
  4629.         move.l    ThisGadget(pc),a0
  4630.         lea    IntegerTags(pc),a2
  4631.         DOLIB    CreateGadgetA
  4632.         tst.l    d0
  4633.         beq    .PrefsWinError
  4634.         lea    PrefsGads,a0
  4635.         move.l    d0,0(a0,d4)
  4636.         addq.l    #4,d4
  4637.         move.l    d0,ThisGadget
  4638.         addq.w    #1,GadNum
  4639.         add.l    #GADHEIGHT+INTERHEIGHT,d5
  4640.  
  4641.         lea    DummyNewGadget(pc),a1        ; Creat Time MX gadgets
  4642.         move.l    #PrefsTimeLabels,MxLabels
  4643.         move.l    PTimeZone,MxActive
  4644.         move.w    #GADWIDTH,gng_Width(a1)
  4645.         move.w    d5,gng_TopEdge(a1)
  4646.         move.w    #INTERWIDTH,gng_LeftEdge(a1)
  4647.         move.w    #17,gng_Width(a1)
  4648.         move.w    #9,gng_Height(a1)
  4649.         move.l    #PLACETEXT_RIGHT,gng_Flags(a1)
  4650.         move.l    #MX_KIND,d0
  4651.         move.l    ThisGadget(pc),a0
  4652.         lea    MxTags(pc),a2
  4653.         DOLIB    CreateGadgetA
  4654.         tst.l    d0
  4655.         beq    .PrefsWinError
  4656.         lea    PrefsGads,a0
  4657.         move.l    d0,0(a0,d4)
  4658.         addq.l    #4,d4
  4659.         move.l    d0,ThisGadget
  4660.         addq.w    #1,GadNum
  4661.  
  4662.         lea    DummyNewGadget(pc),a1        ; Create CHEAP MX gadgets
  4663.         move.l    #PrefsModeLabels,MxLabels
  4664.         moveq    #0,d0
  4665.         move.l    PTariff,d0
  4666.         move.l    d0,MxActive
  4667.         move.w    #PREFSWINWIDTH-18,gng_LeftEdge(a1)
  4668.         move.w    #17,gng_Width(a1)
  4669.         move.w    #9,gng_Height(a1)
  4670.         move.l    #PLACETEXT_LEFT,gng_Flags(a1)
  4671.         move.l    #MX_KIND,d0
  4672.         move.l    ThisGadget(pc),a0
  4673.         lea    MxTags(pc),a2
  4674.         DOLIB    CreateGadgetA
  4675.         tst.l    d0
  4676.         beq    .PrefsWinError
  4677.         lea    PrefsGads,a0
  4678.         move.l    d0,0(a0,d4)
  4679.         addq.l    #4,d4
  4680.         move.l    d0,ThisGadget
  4681.         addq.w    #1,GadNum
  4682.         add.l    #INTERHEIGHT*2+(10*3),d5
  4683.  
  4684.         lea    DummyNewGadget(pc),a1        ; Create PopBill-Win gadget
  4685.         move.w    #GADWIDTH,gng_Width(a1)
  4686.         move.w    #GADHEIGHT,gng_Height(a1)
  4687.         move.w    #INTERWIDTH,gng_LeftEdge(a1)
  4688.         move.w    d5,gng_TopEdge(a1)
  4689.         move.l    (a3)+,gng_GadgetText(a1)
  4690.         move.l    #PLACETEXT_RIGHT,gng_Flags(a1)
  4691.         moveq    #0,d0                ; Set state of gadget
  4692.         move.b    BillPopUp(pc),d0
  4693.         move.l    d0,SelectMode
  4694.         move.l    #CHECKBOX_KIND,d0
  4695.         move.l    ThisGadget(pc),a0
  4696.         lea    CheckBoxTags(pc),a2
  4697.         DOLIB    CreateGadgetA
  4698.         tst.l    d0
  4699.         beq    .PrefsWinError
  4700.         lea    PrefsGads,a0
  4701.         move.l    d0,0(a0,d4)
  4702.         addq.l    #4,d4
  4703.         move.l    d0,ThisGadget
  4704.         addq.w    #1,GadNum
  4705.  
  4706.         lea    DummyNewGadget(pc),a1        ; Create LogCalls gadget
  4707.         move.w    #INTERWIDTH+190,gng_LeftEdge(a1)
  4708.         move.l    (a3)+,gng_GadgetText(a1)
  4709.         moveq    #0,d0                ; Set mode of gadget
  4710.         move.b    LogCalls(pc),d0
  4711.         move.l    d0,SelectMode
  4712.         move.l    #CHECKBOX_KIND,d0
  4713.         move.l    ThisGadget(pc),a0
  4714.         lea    CheckBoxTags(pc),a2
  4715.         DOLIB    CreateGadgetA
  4716.         tst.l    d0
  4717.         beq    .PrefsWinError
  4718.         lea    PrefsGads,a0
  4719.         move.l    d0,0(a0,d4)
  4720.         addq.l    #4,d4
  4721.         move.l    d0,ThisGadget
  4722.         addq.w    #1,GadNum
  4723.  
  4724.         lea    DummyNewGadget(pc),a1        ; Create Clear Log gadget
  4725.         move.w    #PREFSWINWIDTH-GADWIDTH-1,gng_LeftEdge(a1)
  4726.         move.l    (a3)+,gng_GadgetText(a1)
  4727.         move.l    #PLACETEXT_IN,gng_Flags(a1)
  4728.         move.l    #BUTTON_KIND,d0
  4729.         move.l    ThisGadget(pc),a0
  4730.         lea    ButtonTags(pc),a2
  4731.         DOLIB    CreateGadgetA
  4732.         tst.l    d0
  4733.         beq    .PrefsWinError
  4734.         lea    PrefsGads,a0
  4735.         move.l    d0,0(a0,d4)
  4736.         addq.l    #4,d4
  4737.         move.l    d0,ThisGadget
  4738.         addq.w    #1,GadNum
  4739.         add.l    #GADHEIGHT+INTERHEIGHT,d5
  4740.  
  4741.         lea    DummyNewGadget(pc),a1        ; Create save to gad
  4742.         move.w    d5,gng_TopEdge(a1)
  4743.         move.w    #GADWIDTH+32,gng_Width(a1)
  4744.         move.w    #INTERWIDTH,gng_LeftEdge(a1)
  4745.         move.l    (a3)+,gng_GadgetText(a1)
  4746.         move.l    #PLACETEXT_IN,gng_Flags(a1)
  4747.         move.l    #BUTTON_KIND,d0
  4748.         move.l    ThisGadget(pc),a0
  4749.         lea    ButtonTags(pc),a2
  4750.         DOLIB    CreateGadgetA
  4751.         tst.l    d0
  4752.         beq    .PrefsWinError
  4753.         lea    PrefsGads,a0
  4754.         move.l    d0,0(a0,d4)
  4755.         addq.l    #4,d4
  4756.         move.l    d0,ThisGadget
  4757.         addq.w    #1,GadNum
  4758.  
  4759.         move.l    #LogFileName,StringConts    ; Create string gad
  4760.         move.l    #286,StrMax
  4761.         lea    DummyNewGadget(pc),a1
  4762.         move.w    #164,gng_Width(a1)
  4763.         move.w    #GADWIDTH+32+INTERWIDTH*2,gng_LeftEdge(a1)
  4764.         move.l    #0,gng_GadgetText(a1)
  4765.         move.l    #0,gng_Flags(a1)
  4766.         move.l    #STRING_KIND,d0
  4767.         move.l    ThisGadget(pc),a0
  4768.         lea    StringTags(pc),a2
  4769.         DOLIB    CreateGadgetA
  4770.         tst.l    d0
  4771.         beq    .PrefsWinError
  4772.         lea    PrefsGads,a0
  4773.         move.l    d0,0(a0,d4)
  4774.         addq.l    #4,d4
  4775.         move.l    d0,ThisGadget
  4776.         addq.w    #1,GadNum
  4777.  
  4778.         lea    DummyNewGadget(pc),a1        ; Create total sum gad
  4779.         move.w    #GADWIDTH+24,gng_Width(a1)
  4780.         move.w    #GADWIDTH+INTERWIDTH*3+194,gng_LeftEdge(a1)
  4781.         move.l    (a3)+,gng_GadgetText(a1)
  4782.         move.l    #PLACETEXT_IN,gng_Flags(a1)
  4783.         move.l    #BUTTON_KIND,d0
  4784.         move.l    ThisGadget(pc),a0
  4785.         lea    ButtonTags(pc),a2
  4786.         DOLIB    CreateGadgetA
  4787.         tst.l    d0
  4788.         beq    .PrefsWinError
  4789.         lea    PrefsGads,a0
  4790.         move.l    d0,0(a0,d4)
  4791.         addq.l    #4,d4
  4792.         move.l    d0,ThisGadget
  4793.         addq.w    #1,GadNum
  4794.         add.l    #GADHEIGHT+INTERHEIGHT,d5
  4795.  
  4796.         move.l    PrefsHandle(pc),a0        ; Add gadgets to window
  4797.         move.l    PrefsGadget(pc),a1
  4798.         sub.l    a2,a2
  4799.         moveq    #-1,d0
  4800.         moveq    #-1,d1
  4801.         LNKLIB    AddGList,_IntuitionBase
  4802.  
  4803.         move.l    PrefsGadget(pc),a0        ; Display them
  4804.         move.l    PrefsHandle(pc),a1
  4805.         sub.l    a2,a2
  4806.         moveq    #-1,d0
  4807.         DOLIB    RefreshGList
  4808.  
  4809.         move.l    PrefsHandle(pc),a0        ; Append menu to window
  4810.         move.l    PrefsMenu(pc),a1
  4811.         LNKLIB    SetMenuStrip,_IntuitionBase
  4812.  
  4813.         moveq    #0,d0
  4814.         move.b    BillPopUp,d0
  4815.         moveq    #0,d1
  4816.         moveq    #1,d2
  4817.         move.l    PrefsHandle,a0
  4818.         move.l    PrefsMenu,a1
  4819.         bsr    SetToggleMenu
  4820.  
  4821.         moveq    #0,d0
  4822.         move.b    LogCalls,d0
  4823.         moveq    #1,d1
  4824.         moveq    #1,d2
  4825.         move.l    PrefsHandle,a0
  4826.         move.l    PrefsMenu,a1
  4827.         bsr    SetToggleMenu
  4828.  
  4829.         bra.s    .End
  4830.  
  4831. .PrefsWinError    bsr.s    ClosePrefsWin
  4832. .End        bsr    UnlockScreen
  4833.         unlk    a5
  4834.         rts
  4835.  
  4836.  
  4837.  
  4838. **********************************************************************
  4839. *                    Close the preferences window                    *
  4840. **********************************************************************
  4841. ClosePrefsWin    tst.l    PrefsHandle            ; Close window if there
  4842.         beq.s    .NoWindow
  4843.         move.l    PrefsHandle(pc),a0        ; Store new coords
  4844.         lea    PrefsWinDef(pc),a1
  4845.         bsr    StoreWinPos
  4846.         LNKLIB    CloseWindow,_IntuitionBase
  4847. .NoWindow    tst.l    PrefsGadget            ; Remove gadgets, if there
  4848.         beq.s    .NoGadgets
  4849.         move.l    PrefsGadget(pc),a0
  4850.         LNKLIB    FreeGadgets,_GadToolsBase
  4851. .NoGadgets    tst.l    PrefsMenu            ; Free GadTools-Menus
  4852.         beq.s    .NoMenu
  4853.         move.l    PrefsMenu(pc),a0
  4854.         LNKLIB    FreeMenus,_GadToolsBase
  4855. .NoMenu        tst.l    PrefsVisInfo            ; And free visual info
  4856.         beq.s    .NoVisInfo
  4857.         move.l    PrefsVisInfo(pc),a0
  4858.         LNKLIB    FreeVisualInfo,_GadToolsBase
  4859. .NoVisInfo    move.l    #0,PrefsHandle
  4860.         move.l    #0,PrefsSigFlag
  4861.         move.l    #0,PrefsGadget
  4862.         move.l    #0,PrefsVisInfo
  4863.         move.l    #0,PrefsMenu
  4864.         rts
  4865.  
  4866.  
  4867.  
  4868.  
  4869. **********************************************************************
  4870. *                     Open up the HotKeys window                     *
  4871. **********************************************************************
  4872. OpenHotKeyWin    tst.l    HotKeyHandle
  4873.         beq.s    .GoOn
  4874.         move.l    HotKeyHandle,a0
  4875.         LNKLIB    WindowToFront,_IntuitionBase
  4876.         rts
  4877. .GoOn        link    a5,#-4
  4878.         bsr    LockScreen
  4879.         tst.l    d0
  4880.         beq    .KeyWinError
  4881.  
  4882.         move.l    -4(a5),a0            ; Get visual info
  4883.         sub.l    a1,a1
  4884.         LNKLIB    GetVisualInfoA,_GadToolsBase
  4885.         tst.l    d0
  4886.         beq    .KeyWinError
  4887.         move.l    d0,HotKeyVisInfo
  4888.         lea    DummyNewGadget(pc),a0
  4889.         move.l    d0,gng_VisualInfo(a0)
  4890.  
  4891.         move.l    #KEYWINWIDTH,WinWidth        ; Try to open the window
  4892.         move.l    #KEYWINHEIGHT,WinHeight
  4893.         move.l    #KEYWINIDCMP,WinIDCMP
  4894.         move.l    #KEYWINFLAGS,WinFlags
  4895.         move.l    #1,DoMenuHelp
  4896.  
  4897.         lea    HotKeyWinDef(pc),a0
  4898.         move.l    -4(a5),a1
  4899.         bsr    AdjustWinPos
  4900.         lea    WindowTags(pc),a1
  4901.         LNKLIB    OpenWindowTagList,_IntuitionBase
  4902.         move.l    d0,HotKeyHandle
  4903.         tst.l    d0
  4904.         beq    .KeyWinError
  4905.         move.l    HotKeyHandle(pc),a0
  4906.         moveq    #0,d0
  4907.         moveq    #1,d1
  4908.         move.l    wd_UserPort(a0),a0
  4909.         move.b    MP_SIGBIT(a0),d0        ; Get the sigmask
  4910.         asl.l    d0,d1
  4911.         move.l    d1,HotKeySigFlag
  4912.  
  4913.         lea    HotKeyMenuDef,a0        ; Create menu strip
  4914.         sub.l    a1,a1                ; No tags
  4915.         LNKLIB    CreateMenusA,_GadToolsBase
  4916.         move.l    d0,HotKeyMenu
  4917.         tst.l    d0
  4918.         beq    .KeyWinError
  4919.  
  4920.         move.l    HotKeyMenu(pc),a0        ; Do the layout on window
  4921.         move.l    HotKeyVisInfo(pc),a1
  4922.         sub.l    a2,a2
  4923.         DOLIB    LayoutMenusA
  4924.         tst.l    d0
  4925.         beq    .KeyWinError
  4926.  
  4927.         lea    HotKeyGadget(pc),a0
  4928.         LNKLIB    CreateContext,_GadToolsBase
  4929.         move.l    d0,ThisGadget
  4930.         tst.l    d0
  4931.         beq    .KeyWinError
  4932.  
  4933.         move.l    HotKeyHandle(pc),a0
  4934.         moveq    #0,d7
  4935.         move.b    wd_BorderTop(a0),d7
  4936.  
  4937.         move.w    #1,GadNum
  4938.         add.w    #INTERHEIGHT,d7
  4939.         lea    HotKeyGads,a4
  4940.         lea    HotKeyGadStat,a3
  4941.         moveq    #0,d5
  4942.         move.l    #6,d6
  4943. .DoHotKeyGads    move.l    (a3)+,StringConts
  4944.         move.l    #80,StrMax
  4945.         lea    DummyNewGadget(pc),a1
  4946.         lea    HotKeyGadTxts,a0
  4947.         move.l    0(a0,d5),gng_GadgetText(a1)
  4948.         move.w    #STRGADWIDTH,gng_Width(a1)
  4949.         move.w    #GADHEIGHT,gng_Height(a1)
  4950.         move.w    #KEYWINWIDTH-INTERWIDTH-STRGADWIDTH,gng_LeftEdge(a1)
  4951.         move.w    d7,gng_TopEdge(a1)
  4952.         move.l    #PLACETEXT_LEFT,gng_Flags(a1)
  4953.         move.l    #STRING_KIND,d0
  4954.         move.l    ThisGadget(pc),a0
  4955.         lea    StringTags(pc),a2
  4956.         DOLIB    CreateGadgetA
  4957.         tst.l    d0
  4958.         beq.s    .KeyWinError
  4959.         move.l    d0,(a4)+
  4960.         move.l    d0,ThisGadget
  4961.         addq.w    #1,GadNum
  4962.         add.w    #13,d7
  4963.         addq.l    #4,d5
  4964.         dbf    d6,.DoHotKeyGads
  4965.  
  4966.         move.l    HotKeyHandle(pc),a0        ; Add gadgets to window
  4967.         move.l    HotKeyGadget(pc),a1
  4968.         sub.l    a2,a2
  4969.         moveq    #-1,d0
  4970.         moveq    #-1,d1
  4971.         LNKLIB    AddGList,_IntuitionBase
  4972.  
  4973.         move.l    HotKeyGadget(pc),a0        ; Display them
  4974.         move.l    HotKeyHandle(pc),a1
  4975.         sub.l    a2,a2
  4976.         moveq    #-1,d0
  4977.         DOLIB    RefreshGList
  4978.  
  4979.         move.l    HotKeyHandle(pc),a0        ; Append menu to window
  4980.         move.l    HotKeyMenu(pc),a1
  4981.         LNKLIB    SetMenuStrip,_IntuitionBase
  4982.  
  4983.         bra.s    .End
  4984. .KeyWinError    bsr.s    CloseHotKeyWin
  4985. .End        bsr    UnlockScreen
  4986.         unlk    a5
  4987.         rts
  4988.  
  4989.  
  4990.  
  4991. **********************************************************************
  4992. *                     Close HotKey-Window again                      *
  4993. **********************************************************************
  4994. CloseHotKeyWin    tst.l    HotKeyHandle            ; Close window if there
  4995.         beq.s    .NoWindow
  4996.         move.l    HotKeyHandle(pc),a0        ; Store new coords
  4997.         lea    HotKeyWinDef(pc),a1
  4998.         bsr    StoreWinPos
  4999.         LNKLIB    CloseWindow,_IntuitionBase
  5000. .NoWindow    tst.l    HotKeyGadget            ; Remove gadgets, if there
  5001.         beq.s    .NoGadgets
  5002.         move.l    HotKeyGadget(pc),a0
  5003.         LNKLIB    FreeGadgets,_GadToolsBase
  5004. .NoGadgets    tst.l    HotKeyMenu            ; Free GadTools-Menus
  5005.         beq.s    .NoMenu
  5006.         move.l    HotKeyMenu(pc),a0
  5007.         LNKLIB    FreeMenus,_GadToolsBase
  5008. .NoMenu        tst.l    HotKeyVisInfo            ; And free visual info
  5009.         beq.s    .NoVisInfo
  5010.         move.l    HotKeyVisInfo(pc),a0
  5011.         LNKLIB    FreeVisualInfo,_GadToolsBase
  5012. .NoVisInfo    move.l    #0,HotKeyHandle
  5013.         move.l    #0,HotKeySigFlag
  5014.         move.l    #0,HotKeyGadget
  5015.         move.l    #0,HotKeyVisInfo
  5016.         move.l    #0,HotKeyMenu
  5017.         rts
  5018.  
  5019.  
  5020.  
  5021.  
  5022. **********************************************************************
  5023. *                   Close the message window again                   *
  5024. **********************************************************************
  5025. CloseLogWin    tst.l    LogHandle            ; Close window again
  5026.         beq.s    .NoWin
  5027.         move.l    LogHandle(pc),a0
  5028.         LNKLIB    CloseWindow,_IntuitionBase
  5029. .NoWin        tst.l    LogGadget
  5030.         beq.s    .NoGads
  5031.         move.l    LogGadget(pc),a0
  5032.         LNKLIB    FreeGadgets,_GadToolsBase
  5033. .NoGads        tst.l    LogMenu                ; Free GadTools-Menus
  5034.         beq.s    .NoMenu
  5035.         move.l    LogMenu(pc),a0
  5036.         LNKLIB    FreeMenus,_GadToolsBase
  5037. .NoMenu        tst.l    LogVisInfo
  5038.         beq.s    .NoVisInfo
  5039.         move.l    LogVisInfo(pc),a0
  5040.         LNKLIB    FreeVisualInfo,_GadToolsBase
  5041. .NoVisInfo    move.l    #0,LogHandle
  5042.         move.l    #0,LogGadget
  5043.         move.l    #0,LogVisInfo
  5044.         move.l    #0,LogMenu
  5045.         rts
  5046.  
  5047.  
  5048. **********************************************************************
  5049. *             Wait until remakes on clockwindow are made             *
  5050. **********************************************************************
  5051. ClockRemake    move.l    ClockHandle(pc),a0        ; Wait until window popped up
  5052.         move.l    wd_UserPort(a0),a0
  5053.         CALLSYS    WaitPort
  5054. .Loop        move.l    ClockHandle(pc),a0
  5055.         move.l    wd_UserPort(a0),a0
  5056.         DOLIB    GetMsg
  5057.         tst.l    d0
  5058.         beq.s    .End
  5059.         move.l    d0,a1
  5060.         DOLIB    ReplyMsg
  5061.         bra.s    .Loop
  5062. .End        rts
  5063.  
  5064.  
  5065. **********************************************************************
  5066. *          This is the routine to handle RAW-Mouse actions           *
  5067. **********************************************************************
  5068. RawEventAction    CARGS    CxMsg.l,CxObj.l
  5069.         move.l    CxMsg(sp),a0
  5070.         movem.l    d0-d7/a1-a6,-(sp)
  5071.         LNKLIB    CxMsgData,_CxBase
  5072.         tst.l    d0                ; Got an event ?
  5073.         beq    NoEvent
  5074.         move.l    d0,a0
  5075.         move.l    a0,IEvent            ; Store event address
  5076.  
  5077. EventLoop    move.l    IEvent(pc),a0
  5078.         moveq    #0,d0
  5079.         move.b    ie_Class(a0),d0
  5080.         move.w    d0,IEClass            ; Store class
  5081.  
  5082.         tst.b    LeftyMouse            ; We have to swap Buttonqualifiers
  5083.         beq.s    .NoLeftyAll            ; for every message if needed
  5084.         move.w    ie_Qualifier(a0),d0
  5085.         move.w    d0,d1
  5086.         btst    #IEQUALIFIERB_RBUTTON,d1    ; Pressed right button ?
  5087.         beq.s    .NoRight
  5088.         bset    #IEQUALIFIERB_LEFTBUTTON,d0    ; Set left button press
  5089.         beq.s    .CheckLeft
  5090. .NoRight    bclr    #IEQUALIFIERB_LEFTBUTTON,d0
  5091. .CheckLeft    btst    #IEQUALIFIERB_LEFTBUTTON,d1    ; Pressed left button ?
  5092.         beq.s    .NoLeft
  5093.         bset    #IEQUALIFIERB_RBUTTON,d0    ; Set right button
  5094.         beq.s    .SaveButton
  5095. .NoLeft        bclr    #IEQUALIFIERB_RBUTTON,d0
  5096. .SaveButton    move.w    d0,ie_Qualifier(a0)
  5097.  
  5098. .NoLeftyAll    cmp.w    #IECLASS_RAWMOUSE,IEClass    ; Mouse moved ???
  5099.         bne    NoRawMouse
  5100.  
  5101.         tst.b    LeftyMouse            ; Swap buttoncodes for rawmouse
  5102.         beq.s    .NoLeftyMouse
  5103.         move.l    IEvent(pc),a0
  5104.         move.w    ie_Code(a0),d0
  5105.         move.w    d0,d1
  5106.         and.w    #$7f,d0
  5107.         cmp.w    #IECODE_LBUTTON,d0
  5108.         beq.s    .SwapButton
  5109.         cmp.w    #IECODE_RBUTTON,d0
  5110.         bne.s    .NoLeftyMouse
  5111. .SwapButton    eor.w    #1,d1
  5112.         move.w    d1,ie_Code(a0)
  5113.  
  5114. .NoLeftyMouse    tst.b    DoActivate
  5115.         beq.s    .End1
  5116.         tst.b    MouseMode
  5117.         beq.s    .End1
  5118.         bsr    Activate            ; Activate window if needed
  5119. .End1        bsr    ResetTimer
  5120.         tst.b    ScrTimeOut
  5121.         beq.s    .NoScr
  5122.         bsr    OnScreen            ; Activate screen if not blanked
  5123. .NoScr        tst.b    MouseTimeOut            ; Mouse still blanked ?
  5124.         bne.s    .NoMouse
  5125.         bsr    OnMouse                ; Allways ctivate mouse
  5126. .NoMouse    move.b    #0,MouseTimeOut            ; Mouse and screen are not timed
  5127.         move.b    #0,ScrTimeOut            ; out anymore
  5128.  
  5129.         tst.b    CycleWin            ; Window-Cycling enabled ?
  5130.         beq    NoTimerEvent
  5131.         move.l    IEvent(pc),a1
  5132.         move.w    ie_Code(a1),d1
  5133.         cmp.w    #IECODE_LBUTTON,d1        ; Left button pressed ?
  5134.         bne.s    .NoPopFront
  5135.         lea    PopQualFlags(pc),a0        ; Get current qualifier
  5136.         move.l    PopQualNum(pc),d0
  5137.         asl.l    #2,d0
  5138.         move.w    0(a0,d0),d2
  5139.         move.w    ie_Qualifier(a1),d1
  5140.         and.w    d2,d1
  5141.         bne.s    .DoPopFront            ; Left one pressed ?
  5142.         move.w    2(a0,d0),d2
  5143.         move.w    ie_Qualifier(a1),d1
  5144.         and.w    d2,d1
  5145.         beq.s    .NoPopFront            ; Right one pressed ?
  5146. .DoPopFront    move.b    #IECLASS_NULL,ie_Class(a1)    ; Clear Event for other
  5147.         move.w    #0,ie_Code(a1)
  5148.         move.w    #0,ie_Qualifier(a1)
  5149.         bsr    FindWindow            ; Find window underneith layer
  5150.         tst.l    d0
  5151.         beq.s    .NoPopFront            ; No layer, no window
  5152.         move.l    d0,a1
  5153.         tst.l    lr_ClipRect(a1)            ; window hidden by others ?
  5154.         beq.s    .NoPopFront            ; Nope -> no movement to front
  5155.         move.l    lr_ClipRect(a1),a1
  5156.         tst.l    cr_Next(a1)
  5157.         beq.s    .NoPopFront            ; REALLY ???
  5158.         move.l    d0,a0
  5159.         move.l    lr_Window(a0),a0
  5160.         move.l    wd_Flags(a0),d0
  5161.         move.l    d0,d1
  5162.         and.l    #WFLG_BACKDROP,d0        ; BackDrop window ???
  5163.         bne.s    .NoPopFront
  5164.         and.l    #WFLG_DEPTHGADGET,d1        ; Does the window have a DEPTH-Gad ???
  5165.         beq.s    .NoPopFront            ; Nope -> no pop to front
  5166.         LNKLIB    WindowToFront,_IntuitionBase
  5167.         bra    NoTimerEvent
  5168.  
  5169. .NoPopFront    move.l    IEvent(pc),a1
  5170.         move.w    ie_Code(a1),d1
  5171.         cmp.w    #IECODE_RBUTTON,d1        ; Right button pressed ?
  5172.         bne.s    .NoPopBack
  5173.         lea    PopQualFlags(pc),a0
  5174.         move.l    PopQualNum(pc),d0        ; Get current qualifier
  5175.         asl.l    #2,d0
  5176.         move.w    0(a0,d0),d2
  5177.         move.w    ie_Qualifier(a1),d1
  5178.         and.w    d2,d1                ; Left one pressed ?
  5179.         bne.s    .DoPopBack
  5180.         move.w    2(a0,d0),d2
  5181.         move.w    ie_Qualifier(a1),d1
  5182.         and.w    d2,d1                ; Right one pressed ?
  5183.         beq.s    .NoPopBack
  5184. .DoPopBack    move.b    #IECLASS_NULL,ie_Class(a1)    ; Clear event for others
  5185.         move.w    #0,ie_Code(a1)
  5186.         move.w    #0,ie_Qualifier(a1)
  5187.         bsr    FindWindow            ; Find layer
  5188.         tst.l    d0
  5189.         beq.s    .NoPopBack            ; No layer, no window
  5190.         move.l    d0,a0
  5191.         move.l    lr_Window(a0),a0
  5192.         move.l    wd_Flags(a0),d0
  5193.         move.l    d0,d1
  5194.         and.l    #WFLG_BACKDROP,d0        ; BackDrop window ?
  5195.         bne.s    .NoPopBack
  5196.         and.l    #WFLG_DEPTHGADGET,d1        ; DEPTH-Gad there ?
  5197.         beq.s    .NoPopBack            ; Nope -> go on
  5198.         LNKLIB    WindowToBack,_IntuitionBase
  5199. .NoPopBack    bra    NoTimerEvent
  5200.  
  5201. NoRawMouse    cmp.w    #IECLASS_RAWKEY,IEClass        ; Key pressed ???
  5202.         bne    NoRawKey
  5203.  
  5204.         move.l    IEvent(pc),a1            ; If key released -> break
  5205.         move.w    ie_Code(a1),d0
  5206.         and.w    #IECODE_UP_PREFIX,d0
  5207.         bne    NoTimerEvent
  5208.  
  5209.         move.l    IEvent(pc),a0
  5210.         lea    ie_TimeStamp(a0),a0        ; Reset screen delay
  5211.         move.l    TV_SECS(a0),d0
  5212.         add.l    ScreenTime(pc),d0
  5213.         move.l    d0,ScreenOff
  5214.         tst.b    ScrTimeOut            ; Screen blanked ?
  5215.         beq.s    .NoScr
  5216.         bsr    OnScreen            ; UnBlank it
  5217. .NoScr        move.b    #0,ScrTimeOut            ; Screen timed out
  5218.         bsr    OffMouse            ; On key-press allways blank mouse
  5219.  
  5220.         tst.b    DoActivate
  5221.         beq.s    .End1
  5222.         tst.b    MouseMode
  5223.         bne.s    .End1
  5224.         bsr    Activate            ; Activate window if needed
  5225. .End1        tst.b    KeyClick            ; Enabled Key-Click ?
  5226.         beq    .NoClickYet
  5227.         move.l    AudioReq(pc),a1            ; Request still running ?
  5228.         CALLSYS    CheckIO
  5229.         tst.l    d0
  5230.         beq    .NoClickYet            ; Yep-> no click
  5231.         link    a5,#-128
  5232.         move.l    IEvent(pc),a0            ; Convert RAW-Key
  5233.         lea    -128(a5),a1
  5234.         move.b    #0,(a1)                ; Clear previous keys
  5235.         move.l    #128,d1
  5236.         sub.l    a2,a2
  5237.         LNKLIB    RawKeyConvert,_ConsoleBase    ; Convert raw key
  5238.         lea    -128(a5),a1
  5239.         move.b    (a1),d0
  5240.         unlk    a5
  5241.         tst.b    d0                ; No keys ?
  5242.         beq.s    .NoClickYet
  5243.         cmp.b    #$9b,d0                ; Initial ANSI-Code
  5244.         beq.s    .NoClickYet            ; No click
  5245.         cmp.b    #$09,d0                ; TAB-Key pressed ?
  5246.         beq.s    .NoClickYet
  5247.  
  5248.         move.l    IEvent(pc),a1            ; Let it click
  5249.         tst.w    ie_Code(a1)
  5250.         beq.s    .NoClickYet
  5251.  
  5252.         tst.w    AllocKey            ; Lost allockey ?
  5253.         bne.s    .ReClick            ; Nope -> go on
  5254.         bsr    AllocChannel            ; Try to reallocate a channel
  5255.         tst.l    d0                ; Failure ?
  5256.         beq.s    .NoClickYet            ; Yep -> sorry, no sound
  5257. .ReClick    move.l    AudioReq(pc),a1            ; Let`s hear it for the click
  5258.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  5259.         move.b    #ADIOF_PERVOL|ADIOF_NOWAIT,IO_FLAGS(a1)
  5260.         move.w    #120,ioa_Period(a1)
  5261.         move.l    ClickVol(pc),d0
  5262.         move.w    d0,ioa_Volume(a1)
  5263.         move.l    #100,ioa_Length(a1)
  5264.         move.l    #ClickData,ioa_Data(a1)
  5265.         move.w    #1,ioa_Cycles(a1)
  5266.         move.l    IO_DEVICE(a1),a6
  5267.         jsr    DEV_BEGINIO(a6)
  5268.         move.l    AudioReq(pc),a1            ; Error ?
  5269.         tst.b    IO_ERROR(a1)
  5270.         beq.s    .NoClickYet
  5271.         bsr    AllocChannel            ; Yep -> so try to reget a channel
  5272.  
  5273. .NoClickYet    tst.b    ESCClose            ; ESC for closing windows ?
  5274.         beq    .NoEscape
  5275.         move.l    IEvent(pc),a1            ; Get event
  5276.         move.w    ie_Code(a1),d0            ; Get code
  5277.         cmp.w    #$45,d0                ; ESC pressed ?
  5278.         bne    .NoEscape            ; Nope -> go on
  5279.         lea    PopQualFlags(pc),a0
  5280.         move.l    ESCQualNum(pc),d0        ; Get current qualifier
  5281.         asl.l    #2,d0
  5282.         move.w    0(a0,d0),d2
  5283.         move.w    ie_Qualifier(a1),d1
  5284.         and.w    d2,d1                ; Left one pressed ?
  5285.         bne.s    .DoEscape
  5286.         move.w    2(a0,d0),d2
  5287.         move.w    ie_Qualifier(a1),d1
  5288.         and.w    d2,d1                ; Right one pressed ?
  5289.         beq    .NoEscape
  5290. .DoEscape    bsr    FindWindow            ; Find window underneith mouse
  5291.         tst.l    d0                ; No layer -> no close
  5292.         beq    .NoEscape
  5293.         move.l    d0,a0
  5294.         move.l    lr_Window(a0),a3        ; Not a window-layer ???
  5295.         cmp.l    #0,a3
  5296.         beq    .NoEscape            ; Yep -> no close
  5297.         move.l    wd_Flags(a3),d0            ; Window has a closegadget ?
  5298.         and.l    #WFLG_CLOSEGADGET,d0
  5299.         beq    .NoEscape            ; Nope -> go on
  5300.         tst.l    wd_FirstRequest(a3)        ; Requester visible ???
  5301.         bne    .NoEscape
  5302.         move.l    a3,a0                ; Only active windows can be closed
  5303.         LNKLIB    ActivateWindow,_IntuitionBase
  5304.         moveq    #0,d7                ; Clear flag for GADGETUP
  5305.         move.l    wd_FirstGadget(a3),a3
  5306. .CheckGads    cmp.l    #0,a3                ; Search for a selected gadget
  5307.         beq.s    .GadsChecked
  5308.         move.w    gg_Flags(a3),d0
  5309.         and.w    #GFLG_SELECTED,d0
  5310.         beq.s    .NotSelected
  5311.         move.l    a3,d7                ; Got one
  5312.         bra.s    .GadsChecked            ; No other Gadget can be selected
  5313. .NotSelected    move.l    gg_NextGadget(a3),a3
  5314.         bra.s    .CheckGads
  5315. .GadsChecked    link    a5,#-ie_SIZEOF
  5316.         tst.l    d7                ; If no selected gadget was found
  5317.         beq.s    .NoGadgetUp            ; -> go on
  5318.         lea    -ie_SIZEOF(a5),a0        ; fill in Event structure
  5319.         move.l    #0,ie_NextEvent(a0)
  5320.         move.b    #IECLASS_GADGETUP,ie_Class(a0)
  5321.         move.b    #0,ie_SubClass(a0)
  5322.         move.w    #0,ie_Code(a0)
  5323.         move.w    #0,ie_Qualifier(a0)
  5324.         move.l    d7,ie_EventAddress(a0)        ; Add address of gadget
  5325.         move.l    IEvent(pc),a1            ; Copy time
  5326.         lea    ie_TimeStamp(a1),a1
  5327.         lea    ie_TimeStamp(a0),a2
  5328.         move.l    TV_SECS(a1),TV_SECS(a2)
  5329.         move.l    TV_MICRO(a1),TV_MICRO(a2)
  5330.         LNKLIB    AddIEvents,_CxBase        ; Add event
  5331. .NoGadgetUp    lea    -ie_SIZEOF(a5),a0        ; fill in Event structure
  5332.         move.l    #0,ie_NextEvent(a0)
  5333.         move.b    #IECLASS_CLOSEWINDOW,ie_Class(a0)
  5334.         move.b    #0,ie_SubClass(a0)
  5335.         move.w    #0,ie_Code(a0)
  5336.         move.w    #0,ie_Qualifier(a0)
  5337.         move.l    #0,ie_EventAddress(a0)        ; Add address of window
  5338.         move.l    IEvent(pc),a1            ; Copy time
  5339.         lea    ie_TimeStamp(a1),a1
  5340.         lea    ie_TimeStamp(a0),a2
  5341.         move.l    TV_SECS(a1),TV_SECS(a2)
  5342.         move.l    TV_MICRO(a1),TV_MICRO(a2)
  5343.         LNKLIB    AddIEvents,_CxBase        ; Add event
  5344.         unlk    a5
  5345.         move.l    IEvent(pc),a0            ; Clear this event, so that
  5346.         move.b    #IECLASS_NULL,ie_Class(a0)    ; CLI windows don`t get mixed up
  5347.         move.b    #0,ie_SubClass(a0)        ; and go away appropriately
  5348.         move.w    #0,ie_Qualifier(a0)
  5349.         move.l    #0,ie_EventAddress(a0)
  5350.         bra    NoTimerEvent
  5351.  
  5352. .NoEscape    tst.b    MapUmlaut            ; Map "Umlauts" ?
  5353.         beq    NoTimerEvent
  5354.         move.l    IEvent(pc),a1            ; Check for "Umlauts"
  5355.         move.w    ie_Code(a1),d0
  5356.         lea    UmlautTab,a3            ; Get UmlautTab
  5357.         moveq    #7,d7
  5358. .GetUmlaut    cmp.w    (a3),d0                ; Got "Umlaut" ?
  5359.         beq.s    .GotUmlaut            ; Yep -> go on
  5360.         addq.l    #6,a3                ; Next one
  5361.         dbf    d7,.GetUmlaut
  5362.         bra    NoTimerEvent            ; No "Umlaut"
  5363. .GotUmlaut    move.w    ie_Qualifier(a1),d1        ; Get qualifier
  5364.         move.w    d1,d0                ; Shifted ?
  5365.         and.w    #(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT),d0
  5366.         beq.s    .NoShift
  5367.         addq.l    #6,a3                ; Get corresponding shifted char
  5368.         tst.w    (a3)                ; Skip shifted ß
  5369.         beq    NoTimerEvent
  5370.  
  5371. .NoShift    link    a5,#-(ie_SIZEOF*2)        ; Get space for two IEs
  5372.         lea    -(ie_SIZEOF*2)(a5),a4
  5373.         move.b    ie_SubClass(a1),d0        ; Get subclass
  5374.         move.l    ie_EventAddress(a1),d2        ; Address
  5375.         lea    ie_TimeStamp(a1),a2
  5376.         move.l    TV_SECS(a2),d3            ; And seconds
  5377.  
  5378.         move.l    a4,d7                ; Link IEs
  5379.         add.l    #ie_SIZEOF,d7
  5380.         move.l    d7,ie_NextEvent(a4)
  5381.         move.b    #IECLASS_RAWKEY,ie_Class(a4)    ; Set class
  5382.         move.b    d0,ie_SubClass(a4)
  5383.         move.w    2(a3),ie_Code(a4)        ; Get first char
  5384.         move.w    d1,ie_Qualifier(a4)
  5385.         move.l    d2,ie_EventAddress(a4)
  5386.         lea    ie_TimeStamp(a4),a2        ; Set time for correct blanking
  5387.         move.l    d3,TV_SECS(a2)
  5388.         move.l    #0,TV_MICRO(a2)
  5389.  
  5390.         lea    ie_SIZEOF(a4),a0        ; Clear link to next
  5391.         move.l    #0,ie_NextEvent(a0)
  5392.         move.b    #IECLASS_RAWKEY,ie_Class(a0)
  5393.         move.b    d0,ie_SubClass(a0)
  5394.         move.w    4(a3),ie_Code(a0)        ; Get second char for "Umlaut"
  5395.         move.w    #0,ie_Qualifier(a0)
  5396.         move.l    d2,ie_EventAddress(a0)
  5397.         lea    ie_TimeStamp(a0),a2
  5398.         addq.l    #1,d3
  5399.         move.l    d3,TV_SECS(a2)            ; One second past last event :-)
  5400.         move.l    #0,TV_MICRO(a2)
  5401.  
  5402.         move.l    a4,a0
  5403.         LNKLIB    AddIEvents,_CxBase        ; Add events
  5404.         unlk    a5
  5405.  
  5406.         move.l    IEvent(pc),a0            ; Clear current event
  5407.         move.b    #IECLASS_NULL,ie_Class(a0)
  5408.         move.b    #0,ie_SubClass(a0)
  5409.         move.w    #0,ie_Qualifier(a0)
  5410.         move.l    #0,ie_EventAddress(a0)
  5411.         bra    NoTimerEvent
  5412.  
  5413. NoRawKey    cmp.w    #IECLASS_TIMER,IEClass        ; Timer event ?
  5414.         bne    NoTimerEvent
  5415.         tst.b    TimeReset            ; Reset timers ?
  5416.         beq.s    .NoTime                ; (if times were altered)
  5417.         bsr    ResetTimer
  5418.         bra    NoTimerEvent
  5419.  
  5420. .NoTime        move.l    IEvent(pc),a0
  5421.         lea    ie_TimeStamp(a0),a0
  5422.         tst.l    ScreenTime            ; Screen to be blanked ?
  5423.         beq    .NoScreenOff            ; nope -> go on
  5424.         move.l    ScreenOff(pc),d0        ; Screen timeout ?
  5425.         sub.l    TV_SECS(a0),d0
  5426.         bge    .NoScreenOff            ; Nope -> go on
  5427.         move.l    TV_SECS(a0),d1            ; Set time for next timeout
  5428.         add.l    ScreenTime(pc),d1
  5429.         add.l    #10,d1
  5430.         move.l    d0,ScreenOff
  5431.         move.b    #1,ScrTimeOut            ; Screen and mouse are timed out
  5432.         move.b    #1,MouseTimeOut
  5433.         cmp.l    #-10,d0                ; Within range of 10
  5434.         ble.s    .NoScreenOff
  5435.         tst.l    BlankHandle            ; Screen already blanked ?
  5436.         bne.s    .End                ; Yep -> pop it to front
  5437.         lea    BlankScreenDef(pc),a0        ; Open dummy (Blank) screen
  5438.         LNKLIB    OpenScreen,_IntuitionBase
  5439.         move.l    d0,BlankHandle
  5440.         tst.l    d0
  5441.         beq.s    NoTimerEvent
  5442.         move.l    d0,a0
  5443.         lea    sc_ViewPort(a0),a0        ; Set all cols to black
  5444.         moveq    #0,d0
  5445.         moveq    #0,d1
  5446.         moveq    #0,d2
  5447.         moveq    #0,d3
  5448.         LNKLIB    SetRGB4,_GfxBase
  5449.         DOLIB    WaitTOF                ; Delay the thingy
  5450.         move.b    #0,SprOff            ; ReBlank mouse pointer
  5451.         bsr    OffMouse            ; Disable mouse
  5452.         bra.s    NoTimerEvent
  5453. .End        move.l    BlankHandle(pc),a0        ; Get screen to front :-)
  5454.         LNKLIB    ScreenToFront,_IntuitionBase
  5455.         move.b    #0,SprOff            ; ReBlank Mouse
  5456.         bsr.s    OffMouse
  5457.  
  5458. .NoScreenOff    tst.l    MouseTime            ; Mouse to be blanked ?
  5459.         beq.s    .NoMouseOff            ; Nope -> go on
  5460.         move.l    IEvent(pc),a0            ; Check, whether time for
  5461.         lea    ie_TimeStamp(a0),a0        ; blank has come
  5462.         move.l    MouseOff(pc),d0
  5463.         sub.l    TV_SECS(a0),d0
  5464.         bge.s    .NoMouseOff            ; Nope -> go on
  5465.         move.l    TV_SECS(a0),d1            ; Store new values for next
  5466.         add.l    MouseTime(pc),d1        ; blank.
  5467.         addq.l    #1,d1
  5468.         move.l    d1,MouseOff
  5469.         move.b    #1,MouseTimeOut            ; Only mouse is blanked now
  5470.         cmp.l    #-10,d0                ; Timeout within range of
  5471.         ble.s    .NoMouseOff            ; about 10
  5472.         bsr.s    OffMouse            ; Blank mouse
  5473. .NoMouseOff
  5474.  
  5475. NoTimerEvent    move.l    IEvent(pc),a0            ; Try to get next event linked
  5476.         move.l    ie_NextEvent(a0),d0        ; to this one
  5477.         beq.s    NoEvent                ; No other one -> that`s it
  5478.         move.l    d0,IEvent            ; Store address
  5479.         bra    EventLoop            ; Loop
  5480.  
  5481. NoEvent        movem.l    (sp)+,d0-d7/a1-a6
  5482.         rts
  5483.  
  5484.  
  5485.  
  5486. **********************************************************************
  5487. *                          Reset the timers                          *
  5488. **********************************************************************
  5489. ResetTimer    move.l    IEvent(pc),a0
  5490.         lea    ie_TimeStamp(a0),a0
  5491.         move.l    TV_SECS(a0),d0            ; Get current seconds
  5492.         move.l    d0,d1
  5493.         add.l    ScreenTime(pc),d0        ; add delay for screen blank
  5494.         move.l    d0,ScreenOff
  5495.         add.l    MouseTime(pc),d1        ; add delay for mouse blank
  5496.         move.l    d1,MouseOff
  5497.         move.b    #0,TimeReset
  5498.         rts
  5499.  
  5500.  
  5501.  
  5502. **********************************************************************
  5503. *                          Blank the mouse                           *
  5504. **********************************************************************
  5505. OffMouse    CALLSYS    Forbid                ; Disable stuff for a while
  5506.         tst.b    SprOff
  5507.         bne.s    .NoSpr0
  5508.         move.l    _GfxBase(pc),a0
  5509.         move.l    gb_copinit(a0),a0
  5510.         lea    copinit_sprstrtup(a0),a0    ; Get pointer to copper-sprite-list
  5511.         moveq    #7,d7                ; Check for 8 Sprite-Ptrs
  5512. .Spr0Loop    cmp.w    #$0120,(a0)
  5513.         bne.s    .FindSpr0
  5514.         cmp.w    #$0122,4(a0)
  5515.         beq.s    .GotSpr0
  5516. .FindSpr0    addq.l    #8,a0
  5517.         bra.s    .Spr0Loop
  5518. .GotSpr0    lea    OldSprite,a1            ; Store old pointer to sprite
  5519.         move.w    2(a0),(a1)+
  5520.         move.w    6(a0),(a1)
  5521.         move.l    #NoSpriteDat,d0            ; We would like to have a
  5522.         move.w    d0,6(a0)            ; blank sprite
  5523.         swap    d0
  5524.         move.w    d0,2(a0)
  5525. .NoSpr0        CALLSYS    Permit                ; Reenable things
  5526.         rts
  5527.  
  5528.  
  5529. **********************************************************************
  5530. *                           UnBlank mouse                            *
  5531. **********************************************************************
  5532. OnMouse        CALLSYS    Forbid
  5533.         move.l    _GfxBase,a0
  5534.         move.l    gb_copinit(a0),a0
  5535.         lea    copinit_sprstrtup(a0),a0
  5536.         moveq    #7,d7                ; Check for 8 Sprite-Ptrs
  5537. .Spr0Loop    cmp.w    #$0120,(a0)
  5538.         bne.s    .FindSpr0
  5539.         cmp.w    #$0122,4(a0)
  5540.         beq.s    .GotSpr0
  5541. .FindSpr0    addq.l    #8,a0
  5542.         bra.s    .Spr0Loop
  5543. .GotSpr0    lea    OldSprite(pc),a1
  5544.         tst.w    (a1)
  5545.         blt.s    .NoSpr0
  5546.         move.w    (a1)+,2(a0)            ; Restore old pointer
  5547.         move.w    (a1),6(a0)
  5548. .NoSpr0        CALLSYS    Permit
  5549.         rts
  5550.  
  5551.  
  5552. **********************************************************************
  5553. *                           UnBlank screen                           *
  5554. **********************************************************************
  5555. OnScreen    tst.l    BlankHandle            ; Close blank-screen if there
  5556.         beq.s    .End
  5557.         move.l    BlankHandle(pc),a0
  5558.         LNKLIB    CloseScreen,_IntuitionBase
  5559.         LNKLIB    WaitTOF,_GfxBase        ; a little delay
  5560.         move.l    #0,BlankHandle
  5561. .End        rts
  5562.  
  5563.  
  5564.  
  5565.  
  5566. **********************************************************************
  5567. *                   This is the activation-routine                   *
  5568. **********************************************************************
  5569. Activate    bsr    FindWindow
  5570.         tst.l    d0
  5571.         beq.s    .NotAct
  5572.  
  5573.         movem.l    d0/a0,-(sp)
  5574.         moveq    #0,d0
  5575.         LNKLIB    LockIBase,_IntuitionBase
  5576.         move.l    d0,MyILock
  5577.         movem.l    (sp)+,d0/a0
  5578.  
  5579.         move.l    ActWindow(pc),a1
  5580.         tst.l    wd_FirstRequest(a1)        ; active window ?
  5581.         beq.s    .GoOn                ; No -> go on
  5582.         sub.l    a0,a0                ; Yep -> no activation
  5583.         bra.s    .GotWindow
  5584.  
  5585. .GoOn        move.l    sc_FirstWindow(a0),a0
  5586. .CheckWindows    cmp.l    #0,a0
  5587.         beq.s    .WindowOK
  5588.  
  5589.         bsr.s    CheckWinGads
  5590.         cmp.l    #0,a0
  5591.         beq.s    .GotWindow
  5592.  
  5593.         move.l    wd_NextWindow(a0),a0        ; Get next window
  5594.         bra.s    .CheckWindows            ; Check all windows on screen
  5595.  
  5596. .WindowOK    move.l    d0,a0
  5597.         move.l    lr_Window(a0),a0
  5598.         cmp.l    ActWindow(pc),a0        ; Window already active ?
  5599.         bne.s    .GotWindow            ; -> don`t activate
  5600.         sub.l    a0,a0
  5601. .GotWindow    move.l    a0,-(sp)
  5602.         move.l    MyILock(pc),a0
  5603.         DOLIB    UnlockIBase
  5604.         move.l    (sp)+,a0
  5605.         cmp.l    #0,a0
  5606.         beq.s    .NotAct
  5607.         DOLIB    ActivateWindow            ; activate window
  5608. .NotAct        rts
  5609.  
  5610.  
  5611.  
  5612.  
  5613. **********************************************************************
  5614. *           Checks for any active gadgets within a window            *
  5615. **********************************************************************
  5616. CheckWinGads    movem.l    d1/a1,-(sp)
  5617.         move.l    wd_FirstGadget(a0),a1        ; First gadget of window
  5618.  
  5619. .CheckGadgets    cmp.l    #0,a1
  5620.         beq.s    .GadgetsChecked
  5621.  
  5622.         move.w    gg_GadgetType(a1),d1        ; Is it a string-gadget ?
  5623.         and.w    #STRGADGET,d1
  5624.         beq.s    .NoStrGad            ; No -> go on
  5625.  
  5626.         move.w    gg_Flags(a1),d1            ; Is it selected ?
  5627.         and.w    #SELECTED,d1
  5628.         bne.s    .NoWindow            ; Yep -> No activation
  5629.  
  5630. .NoStrGad    move.l    gg_NextGadget(a1),a1        ; Check all gads in window
  5631.         bra    .CheckGadgets
  5632. .NoWindow    sub.l    a0,a0
  5633. .GadgetsChecked    movem.l    (sp)+,d1/a1
  5634.         rts
  5635.  
  5636.  
  5637.  
  5638.  
  5639.  
  5640. **********************************************************************
  5641. *                    Find underneith mousepointer                    *
  5642. **********************************************************************
  5643. FindWindow    moveq    #0,d0                ; Lock Intuition-Base
  5644.         LNKLIB    LockIBase,_IntuitionBase
  5645.         move.l    d0,MyILock
  5646.  
  5647.         move.l    _IntuitionBase(pc),a0
  5648.  
  5649.         moveq    #0,d0
  5650.         moveq    #0,d1
  5651.         move.w    ib_MouseX(a0),d0        ; Get mouse-koords
  5652.         move.w    ib_MouseY(a0),d1
  5653.         move.l    d0,MouseX
  5654.         move.l    d1,MouseY
  5655.  
  5656.         move.l    ib_ActiveWindow(a0),ActWindow    ; Is a requester active on
  5657.         move.l    ib_FirstScreen(a0),a0
  5658. CheckScreens    move.l    MouseX(pc),d0
  5659.         move.l    MouseY(pc),d1
  5660.  
  5661.         lea    sc_ViewPort(a0),a1
  5662.         move.w    vp_Modes(a1),d2
  5663.  
  5664.         move.w    d2,d3                ; Recalc mouse-coords
  5665.         and.w    #V_HIRES,d3            ; for screen-resolution
  5666.         bne.s    IsHires
  5667.         asr.l    #1,d0
  5668.  
  5669. IsHires        and.w    #V_LACE,d2
  5670.         bne.s    IsLace
  5671.         asr.l    #1,d1
  5672.  
  5673. IsLace        movem.l    a0/a1/d1,-(sp)            ; Check layer
  5674.         moveq    #0,d2
  5675.         move.w    vp_DxOffset(a1),d2        ; Offset of screen
  5676.         sub.l    d2,d0
  5677.         move.w    vp_DyOffset(a1),d2
  5678.         sub.l    d2,d1
  5679.         lea    sc_LayerInfo(a0),a0
  5680.         LNKLIB    WhichLayer,_LayersBase
  5681.         movem.l    (sp)+,a0/a1/d1
  5682.         tst.l    d0
  5683.         bne.s    GotLayer
  5684.  
  5685.         move.w    vp_DyOffset(a1),d0        ; Mouse above ViewPort ?
  5686.         cmp.w    d0,d1
  5687.         blt.s    ScreenError            ; Yep -> There must be an error
  5688.         move.l    sc_NextScreen(a0),a0
  5689.         cmp.l    #0,a0
  5690.         beq.s    ScreenError
  5691.         bra    CheckScreens            ; Find screen
  5692.  
  5693. ScreenError    moveq    #0,d0
  5694. GotLayer    movem.l    d0/a0,-(sp)
  5695.         move.l    MyILock(pc),a0            ; UnLock IntuitionBase
  5696.         LNKLIB    UnlockIBase,_IntuitionBase
  5697.         move.l    #0,MyILock
  5698.         movem.l    (sp)+,d0/a0
  5699.         rts
  5700.  
  5701.  
  5702.  
  5703.  
  5704. **********************************************************************
  5705. *            Signal the timer process to remake the time             *
  5706. **********************************************************************
  5707. SigTime        move.l    CheckerProc(pc),a1
  5708.         move.l    #SIGTIMEREMAKE,d0
  5709.         CALLSYS    Signal
  5710.         rts
  5711.  
  5712.  
  5713.  
  5714.  
  5715. **********************************************************************
  5716. *                          Display new time                          *
  5717. **********************************************************************
  5718. SetTime        lea    MyDateTime(pc),a0        ; Get datestamp
  5719.         move.l    a0,d1
  5720.         LNKLIB    DateStamp,_DOSBase
  5721.  
  5722.         lea    MyDateTime(pc),a0        ; Do the string formatings
  5723.         move.b    #FORMAT_DOS,dat_Format(a0)
  5724.         move.l    #RevDayString,dat_StrDay(a0)    ; First create the whole string
  5725.         move.l    #RevDateString,dat_StrDate(a0)    ; for revision
  5726.         move.l    #RevTimeString,dat_StrTime(a0)
  5727.         move.l    a0,d1
  5728.         DOLIB    DateToStr
  5729.  
  5730.         lea    MyDateTime(pc),a0        ; Do the string formatings
  5731.         tst.b    AmiDate
  5732.         beq.s    .Loop1
  5733.         move.b    #FORMAT_USA,dat_Format(a0)
  5734.         bra.s    .Loop2
  5735. .Loop1        move.b    #FORMAT_CDN,dat_Format(a0)
  5736. .Loop2        move.b    #0,dat_Flags(a0)
  5737.  
  5738.         move.l    #AllDayString,dat_StrDay(a0)    ; First create the whole string
  5739.         move.l    #AllDateString,dat_StrDate(a0)    ; for environment variables
  5740.         move.l    #AllTimeString,dat_StrTime(a0)
  5741.         move.l    a0,d1
  5742.         DOLIB    DateToStr
  5743.         tst.l    d0
  5744.         beq.s    NoEnvTime
  5745.         tst.b    SetEnv
  5746.         beq.s    NoEnvTime
  5747.  
  5748.         move.l    #EnvDayString,d1        ; set env vars
  5749.         move.l    #AllDayString,d2
  5750.         moveq    #-1,d3
  5751.         move.l    #GVF_GLOBAL_ONLY,d4
  5752.         DOLIB    SetVar
  5753.         tst.l    d0
  5754.         beq.s    .Error
  5755.  
  5756.         move.l    #EnvDateString,d1
  5757.         move.l    #AllDateString,d2
  5758.         moveq    #-1,d3
  5759.         move.l    #GVF_GLOBAL_ONLY,d4
  5760.         DOLIB    SetVar
  5761.         tst.l    d0
  5762.         beq.s    .Error
  5763.  
  5764.         move.l    #EnvTimeString,d1
  5765.         move.l    #AllTimeString,d2
  5766.         moveq    #-1,d3
  5767.         move.l    #GVF_GLOBAL_ONLY,d4
  5768.         DOLIB    SetVar
  5769.         tst.l    d0
  5770.         bne.s    NoEnvTime
  5771.  
  5772. .Error        move.b    #0,SetEnv            ; Disable setenv if errors
  5773.         moveq    #0,d0                ; occured
  5774.         move.l    #ENVGAD,d1
  5775.         bsr    SetControlBox
  5776.  
  5777. NoEnvTime    move.b    #0,DayString            ; clear previous strings
  5778.         move.b    #0,DateString
  5779.         move.b    #0,TimeString
  5780.  
  5781.         lea    MyDateTime(pc),a0
  5782.         tst.b    ShowDay                ; Now create the rest for clock
  5783.         beq.s    .Loop3                ; display
  5784.         move.l    #DayString,dat_StrDay(a0)
  5785.         bra.s    .Loop4
  5786. .Loop3        move.l    #0,dat_StrDay(a0)
  5787.  
  5788. .Loop4        tst.b    ShowDate            ; Are we to show a date ?
  5789.         beq.s    .Loop5
  5790.         move.l    #DateString,dat_StrDate(a0)    ; Yep
  5791.         bra.s    .Loop6
  5792. .Loop5        move.l    #0,dat_StrDate(a0)        ; Nope
  5793. .Loop6        move.l    #TimeString,dat_StrTime(a0)
  5794.         move.l    a0,d1
  5795.         DOLIB    DateToStr
  5796.         tst.l    d0
  5797.         beq    NoTime
  5798.  
  5799.         bsr    CheckForAlarm            ; Are we to alarm ?
  5800.  
  5801.         tst.b    ShowClock            ; Show clock ?
  5802.         beq    NoTime
  5803.  
  5804.         tst.l    PageNum                ; Display normal time ?
  5805.         bgt.s    NoClockDisp
  5806.  
  5807.         lea    TimeFormats(pc),a0        ; Change to different
  5808.         tst.b    ShortDay            ; time format strings
  5809.         beq.s    .Loop7
  5810.         addq.l    #8,a0                ; Use the ones with long days
  5811. .Loop7        tst.b    ShowSecs
  5812.         bne.s    .Loop8
  5813.         addq.l    #4,a0                ; use the one without secs
  5814. .Loop8        move.l    (a0),a0
  5815.         lea    FormatData(pc),a1
  5816.         lea    PutChProc(pc),a2
  5817.         lea    FinalString(pc),a3
  5818.         CALLSYS    RawDoFmt
  5819.  
  5820.         bsr    MakeDisplay            ; Display the stuff
  5821.         bra    NoTime
  5822.  
  5823. NoClockDisp    cmp.l    #DMEMPAGE,PageNum        ; Display Chip/Fast mem seperately ?
  5824.         bne.s    NoDoubleMem
  5825.  
  5826.         move.l    #MEMF_CHIP,d1            ; Get available memory
  5827.         CALLSYS    AvailMem
  5828.         move.l    d0,ChipMem
  5829.         move.l    #MEMF_FAST,d1
  5830.         DOLIB    AvailMem
  5831.         move.l    d0,FastMem
  5832.  
  5833.         lea    FormMemString(pc),a0        ; Format string
  5834.         lea    ChipMem,a1
  5835.         lea    PutChProc(pc),a2
  5836.         lea    FinalString(pc),a3
  5837.         DOLIB    RawDoFmt
  5838.  
  5839.         bsr    MakeDisplay            ; Display
  5840.         bra    NoTime
  5841.  
  5842. NoDoubleMem    cmp.l    #TMEMPAGE,PageNum        ; Display total memory ?
  5843.         bne.s    NoTotalMem
  5844.  
  5845.         move.l    #MEMF_CHIP,d1            ; Calc total memory
  5846.         CALLSYS    AvailMem
  5847.         move.l    d0,d7
  5848.         move.l    #MEMF_FAST,d1
  5849.         DOLIB    AvailMem
  5850.         add.l    d0,d7
  5851.         move.l    d7,TotalMem
  5852.  
  5853.         lea    FormTMemString(pc),a0
  5854.         lea    TotalMem,a1
  5855.         lea    PutChProc(pc),a2
  5856.         lea    FinalString(pc),a3
  5857.         DOLIB    RawDoFmt
  5858.  
  5859.         bsr    MakeDisplay
  5860.         bra    NoTime
  5861.  
  5862. NoTotalMem    cmp.l    #GMEMPAGE,PageNum
  5863.         bne    NoGfxMem
  5864.  
  5865.         link    a5,#-4
  5866.         bsr    LockScreen
  5867.         tst.l    d0
  5868.         bne.s    .GoOn
  5869.         move.l    #0,PageNum
  5870.         bra    NoGfxMem
  5871.  
  5872. .GoOn        move.l    MyRastPort(pc),a1
  5873.         moveq    #1,d0
  5874.         LNKLIB    SetRast,_GfxBase
  5875.  
  5876.         move.l    #MEMF_CHIP,d1            ; Calc total memory
  5877.         CALLSYS    AvailMem
  5878.         move.l    d0,d7
  5879.         move.l    #MEMF_FAST,d1
  5880.         DOLIB    AvailMem
  5881.         add.l    d7,d0
  5882.         move.l    MaxMem(pc),d7
  5883.         sub.l    d0,d7
  5884.  
  5885.         move.l    MyRastPort(pc),a1        ; Get length of E and F
  5886.         lea    EString(pc),a0            ; chars
  5887.         moveq    #1,d0
  5888.         LNKLIB    TextLength,_GfxBase
  5889.         move.l    d0,EWidth
  5890.         move.l    d0,d5
  5891.         move.l    MyRastPort(pc),a1
  5892.         lea    FString(pc),a0
  5893.         moveq    #1,d0
  5894.         DOLIB    TextLength
  5895.         move.l    d0,FWidth
  5896.         add.l    d5,d0                ; d0 length of both
  5897.         add.l    #MAXBARLEN,d0
  5898.         addq.l    #4,d0
  5899.         move.l    d0,BlitWidth
  5900.         moveq    #0,d2
  5901.         move.l    -4(a5),a0
  5902.         move.w    sc_Width(a0),d2
  5903.         sub.l    #DEPTHWIDTH,d2
  5904.         sub.l    d0,d2
  5905.         move.l    d2,LeftEdge
  5906.         move.l    #MAXBARLEN,d0            ; Get length of bar
  5907.         move.l    d7,d1
  5908.         bsr    _mulu
  5909.         move.l    MaxMem(pc),d1
  5910.         bsr    _divu
  5911.         move.l    d0,d5
  5912.  
  5913.         move.l    MyRastPort(pc),a1
  5914.         moveq    #2,d0
  5915.         LNKLIB    SetAPen,_GfxBase
  5916.  
  5917.         move.l    MyRastPort(pc),a1        ; Write E
  5918.         moveq    #0,d1
  5919.         move.l    MyFont(pc),a0
  5920.         move.w    tf_Baseline(a0),d1
  5921.         moveq    #0,d0
  5922.         DOLIB    Move
  5923.  
  5924.         move.l    MyRastPort(pc),a1
  5925.         lea    EString(pc),a0
  5926.         moveq    #1,d0
  5927.         DOLIB    Text
  5928.  
  5929.         tst.b    ClockWin            ; Window enabled ?
  5930.         bne.s    .End                ; Yep -> no title colors
  5931.         move.l    MyRastPort(pc),a1        ; Draw "non-filled" rec
  5932.         moveq    #0,d0
  5933.         DOLIB    SetAPen
  5934.  
  5935.         move.l    MyRastPort(pc),a1
  5936.         move.l    EWidth(pc),d0
  5937.         addq.l    #2,d0
  5938.         moveq    #0,d1
  5939.         move.l    d0,d2
  5940.         add.l    #MAXBARLEN,d2
  5941.         moveq    #0,d3
  5942.         move.l    MyFont(pc),a0
  5943.         move.w    tf_YSize(a0),d3
  5944.         subq.l    #1,d3
  5945.         DOLIB    RectFill
  5946.  
  5947. .End        move.l    MyRastPort(pc),a1        ; Draw gauge
  5948.         tst.b    ClockWin
  5949.         beq.s    .InTitle
  5950.         moveq    #2,d0
  5951.         bra.s    .SetPen
  5952. .InTitle    moveq    #3,d0
  5953. .SetPen        DOLIB    SetAPen
  5954.  
  5955.         move.l    MyRastPort(pc),a1
  5956.         move.l    EWidth(pc),d0
  5957.         addq.l    #2,d0
  5958.         moveq    #0,d1
  5959.         move.l    d5,d2
  5960.         add.l    d0,d2
  5961.         moveq    #0,d3
  5962.         move.l    MyFont(pc),a0
  5963.         move.w    tf_YSize(a0),d3
  5964.         subq.l    #1,d3
  5965.         DOLIB    RectFill
  5966.  
  5967.         move.l    MyRastPort(pc),a1        ; Draw F
  5968.         moveq    #2,d0
  5969.         DOLIB    SetAPen
  5970.  
  5971.         move.l    MyRastPort(pc),a1
  5972.         move.l    EWidth(pc),d0
  5973.         addq.l    #4,d0
  5974.         add.l    #MAXBARLEN,d0
  5975.         move.l    MyFont(pc),a0
  5976.         moveq    #0,d1
  5977.         move.w    tf_Baseline(a0),d1
  5978.         DOLIB    Move
  5979.  
  5980.         move.l    MyRastPort(pc),a1
  5981.         lea    FString(pc),a0
  5982.         moveq    #1,d0
  5983.         DOLIB    Text
  5984.  
  5985.         move.l    MyRastPort(pc),a1        ; Reset color for our RastPort
  5986.         moveq    #0,d0
  5987.         DOLIB    SetAPen
  5988.  
  5989.         tst.b    ClockWin            ; Window active ?
  5990.         beq.s    TitleGauge
  5991.  
  5992.         tst.l    ClockHandle            ; Window already there ?
  5993.         bne.s    .Clear
  5994.         lea    ClockWinDef(pc),a0        ; No window title
  5995.         move.l    #0,nw_Title(a0)
  5996.         move.l    BlitWidth(pc),d6
  5997.         bsr    OpenClockWin
  5998.         tst.l    d0
  5999.         beq    NoTime
  6000.         bra.s    .NoClear
  6001. .Clear        move.l    ClockHandle(pc),a0
  6002.         tst.l    wd_Title(a0)            ; Window-Title already cleard ?
  6003.         beq.s    .NoClear
  6004.         sub.l    a1,a1                ; Clear window-title
  6005.         move.l    #-1,a2
  6006.         LNKLIB    SetWindowTitles,_IntuitionBase
  6007.  
  6008. .NoClear    move.l    ClockHandle(pc),a1        ; Blit gauge into window-title
  6009.         move.l    wd_RPort(a1),a1
  6010.         move.l    #DEPTHWIDTH,d2
  6011.         bra.s    DoGauge
  6012.  
  6013. TitleGauge    bsr    CloseClockWin
  6014.         move.l    -4(a5),a1            ; Blit gauge into screentitle
  6015.         move.l    sc_BarLayer(a1),a1
  6016.         move.l    lr_rp(a1),a1
  6017.         move.l    LeftEdge(pc),d2
  6018.  
  6019. DoGauge        move.l    MyRastPort(pc),a0        ; Blit our rastport into
  6020.         moveq    #0,d0
  6021.         moveq    #0,d1
  6022.         move.l    #1,d3
  6023.         move.l    BlitWidth(pc),d4
  6024.         moveq    #0,d5
  6025.         move.w    BitMapHeight(pc),d5
  6026.         move.l    #$c0,d6
  6027.         LNKLIB    ClipBlit,_GfxBase
  6028.  
  6029.         bsr    UnlockScreen
  6030.         unlk    a5
  6031.         bra.s    NoTime
  6032.  
  6033. NoGfxMem    cmp.l    #ONLINEPAGE,PageNum        ; Display online-time ?
  6034.         bne.s    NoOnlinePage            ; Nope -> go on
  6035.         lea    OnlineFormStr(pc),a0        ; Copy online string
  6036.         lea    FinalString(pc),a1
  6037.         bsr    StrCpy
  6038.         lea    OnlineString(pc),a0        ; Concat time string
  6039.         lea    FinalString(pc),a1
  6040.         bsr    StrCat
  6041.         bsr.s    MakeDisplay
  6042.         bra.s    NoTime
  6043. NoOnlinePage
  6044. NoTime        rts
  6045.  
  6046.  
  6047.  
  6048.  
  6049. **********************************************************************
  6050. *                Make up the display for clock/memory                *
  6051. **********************************************************************
  6052. MakeDisplay    lea    FinalString(pc),a0        ; Get length of time string
  6053.         bsr    StrLen
  6054.         move.l    d0,d7
  6055.         move.l    MyRastPort(pc),a1        ; Get width of string (pixels)
  6056.         LNKLIB    TextLength,_GfxBase
  6057.         move.l    d0,d6
  6058.  
  6059.         tst.b    ClockWin            ; Display in window ?
  6060.         beq.s    DisplayInTitle            ; Nope -> do it in title
  6061.  
  6062.         bsr    OpenClockWin
  6063.         tst.l    d0
  6064.         beq    NoDisplay
  6065.  
  6066.         move.l    ClockHandle(pc),a0        ; Set new title of window
  6067.         lea    FinalString(pc),a1
  6068.         move.l    #-1,a2
  6069.         LNKLIB    SetWindowTitles,_IntuitionBase
  6070.         rts
  6071.  
  6072. DisplayInTitle    link    a5,#-4
  6073.         bsr    LockScreen
  6074.         tst.l    d0
  6075.         beq    NoDisplay
  6076.  
  6077.         movem.l    d6/d7,-(sp)            ; store width/length of string
  6078.         bsr    CloseClockWin
  6079.  
  6080.         move.l    MyRastPort(pc),a1        ; Clear rastport
  6081.         moveq    #1,d0
  6082.         LNKLIB    SetRast,_GfxBase
  6083.  
  6084.         moveq    #0,d1                ; Move cursor to position
  6085.         move.l    MyFont(pc),a0
  6086.         move.w    tf_Baseline(a0),d1
  6087.         move.l    MyRastPort(pc),a1
  6088.         moveq    #0,d0
  6089.         DOLIB    Move
  6090.         movem.l    (sp)+,d6/d7
  6091.  
  6092.         move.l    MyRastPort(pc),a1        ; Draw string
  6093.         lea    FinalString(pc),a0
  6094.         move.l    d7,d0
  6095.         DOLIB    Text
  6096.  
  6097.         moveq    #0,d2
  6098.         move.l    -4(a5),a0
  6099.         move.w    sc_Width(a0),d2            ; Get width of screen
  6100.         sub.l    #DEPTHWIDTH,d2            ; Skip depth gadget
  6101.         sub.l    d6,d2                ; Skip width of string
  6102.         move.l    d2,LeftEdge            ; Store new X-Position in TitleBar
  6103.         move.l    d6,d4
  6104.         add.w    #DEPTHWIDTH,d6
  6105.         cmp.w    BitMapWidth(pc),d6        ; If width to be blitted is
  6106.         ble.s    .End                ; > Plane width : Skip some pixels
  6107.         move.w    BitMapWidth(pc),d4
  6108.         sub.w    #DEPTHWIDTH,d4
  6109. .End        move.l    d4,BlitWidth            ; Store width of string
  6110.  
  6111.         move.l    MyRastPort(pc),a0        ; Blit our rastport into
  6112.         moveq    #0,d0                ; rastport of layer which
  6113.         moveq    #0,d1                ; is the titlebar
  6114.         move.l    -4(a5),a1
  6115.         move.l    sc_BarLayer(a1),a1
  6116.         move.l    lr_rp(a1),a1
  6117.         move.l    #1,d3
  6118.         moveq    #0,d5
  6119.         move.w    BitMapHeight(pc),d5
  6120.         move.l    #$c0,d6
  6121.         DOLIB    ClipBlit
  6122.  
  6123. NoDisplay    bsr    UnlockScreen
  6124.         unlk    a5
  6125.         rts
  6126.  
  6127.  
  6128.  
  6129.  
  6130. **********************************************************************
  6131. *                   Clears the workbench titlebar                    *
  6132. **********************************************************************
  6133. ClearTitleBar    link    a5,#-4
  6134.         bsr    LockScreen
  6135.         tst.l    d0
  6136.         beq.s    .End
  6137.  
  6138.         move.l    MyRastPort(pc),a1
  6139.         moveq    #1,d0                ; Clear rastport
  6140.         LNKLIB    SetRast,_GfxBase
  6141.  
  6142.         move.l    MyRastPort(pc),a0        ; Blit
  6143.         moveq    #0,d0                ; to restore titlebar shape
  6144.         moveq    #0,d1
  6145.         move.l    -4(a5),a1
  6146.         move.l    sc_BarLayer(a1),a1
  6147.         move.l    lr_rp(a1),a1
  6148.         move.l    LeftEdge(pc),d2
  6149.         move.l    #1,d3
  6150.         moveq    #0,d5
  6151.         move.w    BitMapHeight(pc),d5
  6152.         move.l    BlitWidth(pc),d4
  6153.         move.l    #$c0,d6
  6154.         DOLIB    ClipBlit
  6155.  
  6156. .End        bsr    UnlockScreen
  6157.         unlk    a5
  6158.         rts
  6159.  
  6160.  
  6161.  
  6162.  
  6163. **********************************************************************
  6164. *           Routine for keeping up the correct online time           *
  6165. **********************************************************************
  6166. CheckOnline    lea    FormAlarmSStr(pc),a0        ; Create Onlinetime
  6167.         lea    OnlineHour(pc),a1
  6168.         lea    PutChProc(pc),a2
  6169.         lea    OnlineString(pc),a3
  6170.         CALLSYS    RawDoFmt
  6171.  
  6172.         tst.b    Online                ; Already online ?
  6173.         bne    StillOnline
  6174.  
  6175.         lea    $bfd000,a5
  6176.         btst    #CIAB_COMCD,ciapra(a5)
  6177.         bne    NotOnline
  6178.  
  6179.         move.b    #1,Online            ; Reset flags
  6180.         move.l    #0,OnlineHour
  6181.         move.l    #0,OnlineMinute
  6182.         move.l    #3,OnlineSeconds
  6183.         move.l    #0,NextUnit
  6184.         move.l    #0,UnitsDone
  6185.         move.l    #0,TotalCost
  6186.         lea    AllTimeString(pc),a0        ; Copy current time and date
  6187.         lea    LogInTime(pc),a1
  6188.         bsr    StrCpy
  6189.         lea    AllDateString(pc),a0
  6190.         lea    LogInDate(pc),a1
  6191.         bsr    StrCpy
  6192.         lea    AllTimeString+6(pc),a0
  6193.         lea    CopyTime(pc),a1
  6194.         bsr    StrCpy
  6195.         tst.b    BillPopUp
  6196.         beq.s    StillOnline
  6197.         tst.l    BillHandle
  6198.         beq.s    .GoOn
  6199.         move.b    #1,NoBillPopDown
  6200. .GoOn        movem.l    RegsAll,-(sp)
  6201.         bsr    OpenBillWin
  6202.         movem.l    (sp)+,RegsAll
  6203. StillOnline    lea    $bfd000,a5
  6204.         btst    #CIAB_COMCD,ciapra(a5)        ; Still online ?
  6205.         beq    .GoOn
  6206.  
  6207.         move.b    #0,Online            ; Nope....
  6208.  
  6209.         tst.b    LogCalls            ; Save log to file ?
  6210.         beq    .EndLogWrite
  6211.  
  6212.         move.w    #'N',d0                ; Set char for either normal
  6213.         tst.b    CheapMode
  6214.         beq.s    .NoCheap
  6215.         move.w    #'C',d0                ; ... or cheap mode
  6216. .NoCheap    move.w    d0,LogEntryTariff
  6217.         move.l    #0,CostMajor            ; Calc total costs
  6218.         move.l    #0,CostMinor
  6219.         move.l    TotalCost(pc),d0
  6220. .CostLoop    cmp.l    #100,d0
  6221.         blt.s    .CostEnd
  6222.         sub.l    #100,d0
  6223.         addq.l    #1,CostMajor
  6224.         bra.s    .CostLoop
  6225. .CostEnd    move.l    d0,CostMinor
  6226.         lea    LogEntryFormat(pc),a0        ; Format log entry
  6227.         lea    LogEntryDat(pc),a1
  6228.         lea    PutChProc(pc),a2
  6229.         move.l    ReadBuffer(pc),a3
  6230.         CALLSYS    RawDoFmt
  6231.  
  6232.         move.l    #LogFileName,d1            ; Open log file
  6233.         move.l    #MODE_READWRITE,d2
  6234.         LNKLIB    Open,_DOSBase
  6235.         tst.l    d0
  6236.         beq.s    .EndLogWrite
  6237.         move.l    d0,d7
  6238.         move.l    d0,d1
  6239.         moveq    #0,d2
  6240.         move.l    #OFFSET_END,d3            ; Seek to end
  6241.         DOLIB    Seek
  6242.         move.l    d7,d1
  6243.         move.l    ReadBuffer,d2            ; Write new logentry
  6244.         DOLIB    FPuts
  6245.         move.l    d7,d1
  6246.         DOLIB    Close
  6247. .EndLogWrite
  6248.  
  6249. .NoReenable    tst.b    BillPopUp
  6250.         beq.s    .EndLogOff
  6251.         tst.b    NoBillPopDown
  6252.         bne.s    .EndLogOff
  6253.         bsr    CloseBillWin
  6254. .EndLogOff    move.b    #0,NoBillPopDown
  6255.         bra    NotOnline
  6256.  
  6257. .GoOn        move.b    #1,Online            ; Yep, we`re online
  6258.  
  6259.         link    a5,#-4
  6260.         lea    -4(a5),a4
  6261.         lea    AllTimeString+6(pc),a0        ; Get current seconds
  6262.         move.l    a0,d1
  6263.         move.l    a4,d2
  6264.         LNKLIB    StrToLong,_DOSBase
  6265.         move.l    d1,d7                ; Convert to long
  6266.         lea    CopyTime(pc),a0            ; Get last seconds
  6267.         move.l    a0,d1
  6268.         move.l    a4,d2
  6269.         DOLIB    StrToLong            ; Convert to long
  6270.         unlk    a5
  6271.         moveq    #0,d0
  6272. .GetValue    cmp.l    d1,d7                ; Got seconds elapsed ?
  6273.         beq.s    .GotValue            ; Yep -> go on
  6274.         addq.l    #1,d0                ; One more second done
  6275.         addq.l    #1,d1
  6276.         cmp.l    #60,d1                ; Over 60 boundary ?
  6277.         bne.s    .GetValue
  6278.         moveq    #0,d1                ; Restart from scratch
  6279.         bra.s    .GetValue
  6280. .GotValue    add.l    d0,OnlineSeconds        ; Remake online time
  6281.         cmp.l    #60,OnlineSeconds        ; One minute done ?
  6282.         blt.s    .End                ; Nope -> go on
  6283.         sub.l    #60,OnlineSeconds
  6284.         addq.l    #1,OnlineMinute
  6285.         cmp.l    #60,OnlineMinute        ; One our online ? GOSH
  6286.         bne.s    .End                ; Nope -> go on
  6287.         move.l    #0,OnlineMinute
  6288.         addq.l    #1,OnlineHour
  6289.  
  6290. .End        lea    AllTimeString+6(pc),a0        ; Copy current time
  6291.         lea    CopyTime(pc),a1
  6292.         bsr    StrCpy
  6293.  
  6294.         subq.l    #1,NextUnit
  6295.         addq.l    #1,UnitsDone
  6296.  
  6297. NotOnline    bsr.s    RemakeCosts
  6298.         rts
  6299.  
  6300.  
  6301.  
  6302.  
  6303. **********************************************************************
  6304. *                  Remake texts within Bill window                   *
  6305. **********************************************************************
  6306. RemakeCosts    tst.b    Online                ; Are we online ?
  6307.         beq.s    .NotOnline
  6308.         tst.l    NextUnit            ; Next unit
  6309.         bgt.s    .NotOnline            ; Nope...
  6310.         move.l    TimeZone(pc),d0            ; Get timezone
  6311.         asl.l    #3,d0
  6312.         lea    CostUnit1(pc),a0
  6313.         tst.b    CheapMode
  6314.         beq.s    .Normal
  6315.         move.l    cu_Cheap(a0,d0),d0        ; Get costs for cheap mode
  6316.         bra.s    .GoOn
  6317. .Normal        move.l    cu_Normal(a0,d0),d0        ; or for normal mode
  6318.  
  6319. .GoOn        move.l    d0,NextUnit            ; Store for next unit calc
  6320.  
  6321.         move.l    CostUnit(pc),d0            ; Remake costs
  6322.         add.l    d0,TotalCost
  6323.         bsr    DisplayCost
  6324.  
  6325. .NotOnline    tst.b    DoRemakeCosts
  6326.         beq.s    .NoCostRemake
  6327.         move.b    #0,DoRemakeCosts
  6328.         move.l    TimeZone(pc),d0            ; Changed time/cheap mode ?
  6329.         lea    CostUnit1(pc),a0
  6330.         asl.l    #3,d0
  6331.         tst.b    CheapMode
  6332.         beq.s    .RemNormal
  6333.         move.l    cu_Cheap(a0,d0),d0        ; Get new time
  6334.         bra.s    .GoOnRemake
  6335. .RemNormal    move.l    cu_Normal(a0,d0),d0
  6336. .GoOnRemake    move.l    UnitsDone(pc),d2
  6337.         divu    d0,d2
  6338.         and.l    #$0000ffff,d2
  6339.         tst.l    TotalCost
  6340.         bne.s    .DoInitial
  6341.         tst.b    Online
  6342.         beq.s    .NoInitial
  6343. .DoInitial    addq.l    #1,d2                ; D2 = Number of units done for new time
  6344. .NoInitial    move.l    CostUnit(pc),d3
  6345.         mulu    d3,d2                ; Get new costs for new time
  6346.         move.l    d2,TotalCost            ; Store costs
  6347.         move.l    UnitsDone(pc),d2        ; Units done
  6348.         divu    d0,d2                ; Calc overlap for next unit
  6349.         clr.w    d2
  6350.         swap    d2
  6351.         sub.l    d2,d0                ; D0 = Event for next unit
  6352.         move.l    d0,NextUnit
  6353.         bsr    DisplayCost
  6354. .NoCostRemake    move.l    #0,CostMajor
  6355.         move.l    #0,CostMinor
  6356.         move.l    TimeZone(pc),d0            ; Calc total costs
  6357.         asl.l    #3,d0
  6358.         lea    CostUnit1(pc),a0
  6359.         lea    0(a0,d0),a0
  6360.         tst.b    CheapMode
  6361.         beq.s    .StillNormal
  6362.         move.l    cu_Cheap(a0),d1            ; either for cheap mode
  6363.         bra.s    .StillCheap
  6364. .StillNormal    move.l    cu_Normal(a0),d1        ; or for normal mode
  6365. .StillCheap    move.l    #3600,d0
  6366.         divu    d1,d0
  6367.         and.l    #$0000ffff,d0            ; d0 = Number of units/hour
  6368.         move.l    CostUnit(pc),d1
  6369.         mulu    d1,d0                ; d0 = costs/hour
  6370. .TotLoop    cmp.l    #100,d0                ; convert value
  6371.         blt.s    .EndLoop
  6372.         sub.l    #100,d0
  6373.         addq.l    #1,CostMajor
  6374.         bra.s    .TotLoop
  6375. .EndLoop    move.l    d0,CostMinor
  6376.  
  6377.         lea    PerHourForm(pc),a0        ; Convert values to string
  6378.         lea    CostMajor(pc),a1
  6379.         lea    PutChProc(pc),a2
  6380.         lea    PerHourBuff(pc),a3
  6381.         CALLSYS    RawDoFmt
  6382.  
  6383.         tst.l    BillHandle
  6384.         beq.s    NoCostCalc
  6385.         move.l    BillHandle(pc),a0        ; Print out texts
  6386.         moveq    #0,d1
  6387.         move.b    wd_BorderTop(a0),d1
  6388.         move.l    BillRPort(pc),a0
  6389.         lea    BillVarStrings(pc),a1
  6390.         moveq    #0,d0
  6391.         LNKLIB    PrintIText,_IntuitionBase
  6392. NoCostCalc    rts
  6393.  
  6394.  
  6395.  
  6396.  
  6397.  
  6398. **********************************************************************
  6399. *                 Display new costs of telefone call                 *
  6400. **********************************************************************
  6401. DisplayCost    move.l    TotalCost(pc),d0
  6402.         move.l    #0,CostMajor
  6403.         move.l    #0,CostMinor
  6404.  
  6405. .Loop        cmp.l    #100,d0                ; Calc costs
  6406.         blt.s    .LoopEnd
  6407.         sub.l    #100,d0
  6408.         addq.l    #1,CostMajor
  6409.         bra.s    .Loop
  6410. .LoopEnd    move.l    d0,CostMinor
  6411.  
  6412.         lea    CostFormString(pc),a0        ; Convert values
  6413.         lea    CostMajor(pc),a1
  6414.         lea    PutChProc(pc),a2
  6415.         lea    CostString(pc),a3
  6416.         CALLSYS    RawDoFmt
  6417.         rts
  6418.  
  6419.  
  6420.  
  6421. **********************************************************************
  6422. *                Display the total sum of phone calls                *
  6423. **********************************************************************
  6424. DisplayTotalSum    move.l    #LogFileName,d1            ; First check size of file
  6425.         move.l    #ACCESS_READ,d2
  6426.         LNKLIB    Lock,_DOSBase
  6427.         move.l    d0,d7
  6428.         tst.l    d0                ; IS IT THERE ?
  6429.         bne.s    .GotFile
  6430.         rts
  6431. .GotFile    link    a5,#-fib_SIZEOF            ; Get FIB
  6432.         lea    -fib_SIZEOF(a5),a0
  6433.         move.l    d7,d1                ; Get FileInfo
  6434.         move.l    a0,d2
  6435.         DOLIB    Examine
  6436.         move.l    d7,d1
  6437.         DOLIB    UnLock                ; Unlock file
  6438.         lea    -fib_SIZEOF(a5),a0        ; Check size
  6439.         tst.l    fib_Size(a0)            ; on zero quit
  6440.         bne.s    .SizeOk
  6441.         unlk    a5
  6442.         rts
  6443. .SizeOk        unlk    a5
  6444.         move.l    #LogFileName,d1            ; Open Log file
  6445.         move.l    #MODE_OLDFILE,d2
  6446.         DOLIB    Open
  6447.         move.l    d0,FileHand
  6448.         tst.l    d0
  6449.         beq    .EndTotSum
  6450.  
  6451.         move.l    #ConWinDef,d1            ; Open CON: Window
  6452.         move.l    #MODE_OLDFILE,d2
  6453.         DOLIB    Open
  6454.         move.l    d0,TempHand
  6455.         tst.l    d0
  6456.         beq    .EndTotSum
  6457.  
  6458.         move.l    TempHand(pc),d1
  6459.         move.l    #ClearStr,d2
  6460.         move.l    #ClearStrLen,d3
  6461.         DOLIB    Write
  6462.  
  6463.         moveq    #0,d7                ; Clear linenumber
  6464.         moveq    #0,d5
  6465.         move.l    d7,BillMajor            ; and cost
  6466.         move.l    d7,BillMinor
  6467.         move.l    d7,BillTotalCost
  6468.         move.l    d7,BillDayCost
  6469.  
  6470. .SumLoop    move.l    FileHand(pc),d1            ; Get one line
  6471.         move.l    ReadBuffer,d2
  6472.         move.l    #4096,d3
  6473.         DOLIB    FGets
  6474.         tst.l    d0
  6475.         bne.s    .GoOn
  6476.         bsr    DisplayDaySum            ; Display final day costs
  6477.         moveq    #-1,d7                ; Indicate end of file
  6478.         bra.s    .EndOfAll
  6479.  
  6480. .GoOn        bsr    CheckDay
  6481.  
  6482.         move.l    TempHand(pc),d1            ; Display line
  6483.         move.l    ReadBuffer,d2
  6484.         DOLIB    FPuts
  6485.  
  6486.         move.l    ReadBuffer(pc),a4        ; Get start of major cost
  6487.         lea    72(a4),a4
  6488.         move.l    a4,a5
  6489. .LoopMinor    cmp.b    #'.',(a5)+            ; find period
  6490.         beq.s    .GotMinor
  6491.         bra.s    .LoopMinor
  6492. .GotMinor    move.b    #0,-1(a5)            ; Extract minor cost
  6493.         move.b    #0,2(a5)
  6494.  
  6495.         move.l    a4,d1
  6496.         move.l    #BillMajor,d2
  6497.         DOLIB    StrToLong
  6498.         tst.l    d0
  6499.         ble    .EndTotSum
  6500.         mulu    #100,d1
  6501.         move.l    d1,d6                ; Get costs
  6502.  
  6503.         move.l    a5,d1
  6504.         move.l    #BillMinor,d2
  6505.         DOLIB    StrToLong
  6506.         tst.l    d0
  6507.         ble    .EndTotSum
  6508.         add.l    d1,d6                ; ....
  6509.         add.l    d6,BillTotalCost
  6510.         add.l    d6,BillDayCost
  6511.  
  6512.         addq.l    #1,d7                ; One line done
  6513.         cmp.l    #12,d7                ; 12 lines done ?
  6514.         blt    .SumLoop
  6515.         moveq    #0,d7                ; Reset line number
  6516. .EndOfAll    tst.l    d7                ; All lines done ?
  6517.         beq.s    .NoFinalCost
  6518.         move.l    BillTotalCost(pc),d6
  6519.         divu    #100,d6
  6520.         move.w    d6,d5
  6521.         swap    d6
  6522.         ext.l    d6
  6523.         move.l    d6,BillMinor
  6524.         ext.l    d5
  6525.         move.l    d5,BillMajor
  6526.         lea    FinalCostForm(pc),a0        ; Format final cost string
  6527.         lea    BillMajor(pc),a1
  6528.         lea    PutChProc(pc),a2
  6529.         move.l    ReadBuffer(pc),a3
  6530.         CALLSYS    RawDoFmt
  6531.         move.l    TempHand(pc),d1            ; Display string
  6532.         move.l    ReadBuffer,d2
  6533.         LNKLIB    FPuts,_DOSBase
  6534. .NoFinalCost    move.l    TempHand(pc),d1            ; Display prompt
  6535.         move.l    #PressKey,d2
  6536.         move.l    #PressKeyLen,d3
  6537.         DOLIB    Write
  6538.         move.l    TempHand(pc),d1            ; Wait for return
  6539.         DOLIB    FGetC
  6540.         tst.l    d7
  6541.         blt.s    .EndTotSum
  6542.         bra    .SumLoop
  6543.  
  6544. .EndTotSum    tst.l    FileHand            ; Close files
  6545.         beq.s    .NoFileHand
  6546.         move.l    FileHand(pc),d1
  6547.         DOLIB    Close
  6548. .NoFileHand    tst.l    TempHand
  6549.         beq.s    .NoTempHand
  6550.         move.l    TempHand(pc),d1
  6551.         DOLIB    Close
  6552. .NoTempHand    move.l    #0,TempHand
  6553.         move.l    #0,FileHand
  6554.         rts
  6555.  
  6556.  
  6557.  
  6558. **********************************************************************
  6559. *                  Check for a difference in dates                   *
  6560. **********************************************************************
  6561. CheckDay    move.l    d7,d6                ; Store old line number
  6562.         tst.b    d5                ; First day read ?
  6563.         beq.s    .FirstDay
  6564.         move.l    ReadBuffer(pc),a0        ; Compare dates
  6565.         lea    BillDayStr(pc),a1
  6566.         moveq    #7,d7
  6567.         bsr    StrCmp
  6568.         tst.l    d0
  6569.         beq.s    .End                ; On equal -> go on
  6570.         bsr.s    DisplayDaySum            ; Display sum for a day
  6571. .FirstDay    move.l    ReadBuffer(pc),a0        ; Copy date to buffer
  6572.         lea    BillDayStr(pc),a1
  6573.         moveq    #7,d7
  6574.         bsr    StrNCpy
  6575.         moveq    #1,d5                ; Set flag
  6576. .End        move.l    d6,d7
  6577.         rts
  6578.  
  6579.  
  6580.  
  6581.  
  6582. **********************************************************************
  6583. *                     Display the sum for a day                      *
  6584. **********************************************************************
  6585. DisplayDaySum    move.l    BillDayCost(pc),d3        ; Get costs
  6586.         divu    #100,d3                ; convert `em
  6587.         move.w    d3,d4
  6588.         swap    d3
  6589.         ext.l    d3
  6590.         move.l    d3,BillMinor
  6591.         ext.l    d4
  6592.         move.l    d4,BillMajor
  6593.         lea    DayCostForm(pc),a0        ; Format string
  6594.         lea    BillDayPtr(pc),a1
  6595.         lea    PutChProc(pc),a2
  6596.         move.l    ReadBuffer(pc),a3
  6597.         lea    1024(a3),a3
  6598.         CALLSYS    RawDoFmt
  6599.         move.l    #0,BillDayCost
  6600.         move.l    TempHand(pc),d1            ; Make it appear
  6601.         move.l    ReadBuffer,d2
  6602.         add.l    #1024,d2
  6603.         LNKLIB    FPuts,_DOSBase
  6604.         addq.l    #3,d6                ; three more lines written
  6605. .NoNewDay    rts
  6606.  
  6607.  
  6608.  
  6609.  
  6610. **********************************************************************
  6611. *                    Check the entered alarmtime                     *
  6612. **********************************************************************
  6613. CheckAlarmTime    move.l    ReadBuffer(pc),a1
  6614.         bsr    StrCpy
  6615.         move.l    ReadBuffer(pc),a0
  6616.         cmp.b    #':',2(a0)            ; Is a : at correct place ?
  6617.         bne    TimeError
  6618.         move.b    #0,2(a0)
  6619.         lea    3(a0),a1            ; A1 = Pointer to minutes
  6620.         sub.l    a2,a2
  6621.         move.l    #-1,AlarmSecs
  6622.         cmp.b    #':',5(a0)            ; Seconds entered ?
  6623.         bne.s    NoSecs                ; Nope -> leave them alone
  6624.         move.b    #0,5(a0)
  6625.         lea    6(a0),a2            ; A2 = Pointer to secs
  6626.         move.l    a2,a3
  6627.         bsr    CheckDigits
  6628.         tst.l    d0
  6629.         bne    TimeError
  6630.  
  6631. NoSecs        move.l    a0,a3                ; Check if digits are ok
  6632.         bsr    CheckDigits
  6633.         tst.l    d0
  6634.         bne    TimeError
  6635.  
  6636.         move.l    a1,a3
  6637.         bsr    CheckDigits
  6638.         tst.l    d0
  6639.         bne    TimeError
  6640.  
  6641.         movem.l    a1/a2,-(sp)            ; Convert strings to longs
  6642.         move.l    a0,d1
  6643.         move.l    #AlarmHour,d2
  6644.         LNKLIB    StrToLong,_DOSBase
  6645.         movem.l    (sp)+,a1/a2
  6646.  
  6647.         move.l    a2,-(sp)
  6648.         move.l    a1,d1
  6649.         move.l    #AlarmMins,d2
  6650.         DOLIB    StrToLong
  6651.         move.l    (sp)+,a2
  6652.  
  6653.         lea    FormAlarmNSStr(pc),a0
  6654.         cmp.l    #0,a2                ; Skip secs if wanted
  6655.         beq.s    NoNeedSecs
  6656.         move.l    a2,d1
  6657.         move.l    #AlarmSecs,d2
  6658.         DOLIB    StrToLong
  6659.         lea    FormAlarmSStr(pc),a0
  6660.         cmp.l    #59,AlarmSecs
  6661.         ble.s    NoNeedSecs
  6662.         sub.l    #60,AlarmSecs            ; Correct Seconds
  6663. NoNeedSecs    cmp.l    #23,AlarmHour
  6664.         ble.s    HourOk
  6665.         sub.l    #24,AlarmHour            ; Correct hour
  6666.         bra.s    NoNeedSecs
  6667. HourOk        cmp.l    #59,AlarmMins
  6668.         ble.s    MinsOk
  6669.         sub.l    #60,AlarmMins            ; Correct minutes
  6670. MinsOk        lea    AlarmHour(pc),a1        ; Reformat string
  6671.         lea    PutChProc(pc),a2
  6672.         move.l    ReadBuffer(pc),a3
  6673.         CALLSYS    RawDoFmt
  6674.  
  6675.         move.l    ReadBuffer(pc),a0        ; Copy string to startup string
  6676.         lea    AlarmStartVal(pc),a1
  6677.         bsr    StrCpy
  6678.  
  6679.         move.l    #SETALARMGAD,d0
  6680.         lea    ControlGads(pc),a0
  6681.         move.l    WndHandle(pc),a1
  6682.         moveq    #8,d1
  6683.         move.l    ReadBuffer,a2
  6684.         bsr    SetStringGad
  6685.         rts
  6686. TimeError    move.l    #SETALARMGAD,d0
  6687.         lea    ControlGads(pc),a0
  6688.         move.l    WndHandle(pc),a1
  6689.         moveq    #8,d1
  6690.         lea    AlarmStartVal,a2
  6691.         bsr    SetStringGad
  6692.         rts
  6693.  
  6694.  
  6695.  
  6696.  
  6697.  
  6698.  
  6699. **********************************************************************
  6700. *                   Check if only digits are there                   *
  6701. **********************************************************************
  6702. CheckDigits    moveq    #0,d0
  6703.         cmp.b    #'0',(a3)
  6704.         blt.s    DigitError
  6705.         cmp.b    #'9',(a3)
  6706.         bgt.s    DigitError
  6707.         cmp.b    #'0',1(a3)
  6708.         blt.s    DigitError
  6709.         cmp.b    #'9',1(a3)
  6710.         bgt.s    DigitError
  6711.         rts
  6712. DigitError    moveq    #1,d0
  6713.         rts
  6714.  
  6715.  
  6716.  
  6717.  
  6718.  
  6719.  
  6720. **********************************************************************
  6721. *                      Check if we`re to alarm                       *
  6722. **********************************************************************
  6723. CheckForAlarm    tst.b    DoAlarm                ; Are we to alarm ?
  6724.         beq    NoAlarm
  6725.  
  6726.         link    a5,#-LEN_DATSTRING
  6727.  
  6728.         lea    TimeString(pc),a0        ; Get current time
  6729.         lea    -LEN_DATSTRING(a5),a1
  6730.         bsr    StrCpy
  6731.         lea    -LEN_DATSTRING(a5),a4
  6732.         move.b    #0,2(a4)            ; Clear :s
  6733.         move.b    #0,5(a4)
  6734.  
  6735.         move.l    a4,d1                ; make em to longs
  6736.         move.l    #ThisHour,d2
  6737.         LNKLIB    StrToLong,_DOSBase
  6738.         lea    3(a4),a0
  6739.         move.l    a0,d1
  6740.         move.l    #ThisMins,d2
  6741.         DOLIB    StrToLong
  6742.         lea    6(a4),a0
  6743.         move.l    a0,d1
  6744.         move.l    #ThisSecs,d2
  6745.         DOLIB    StrToLong
  6746.  
  6747.         unlk    a5
  6748.  
  6749.         move.l    AlarmHour(pc),d0
  6750.         move.l    AlarmMins(pc),d1
  6751.         move.l    AlarmSecs(pc),d2
  6752.         blt.s    NoSecsComp            ; Compare secs (-1 if not)
  6753.         cmp.l    ThisSecs(pc),d2
  6754.         bne.s    NoAlarm
  6755. NoSecsComp    cmp.l    ThisMins(pc),d1            ; Compare rest
  6756.         bne.s    NoAlarm
  6757.         cmp.l    ThisHour(pc),d0
  6758.         bne.s    NoAlarm
  6759.  
  6760.         move.l    _OurTask(pc),a1            ; Signal mother to alarm
  6761.         move.l    AlarmSigFlag(pc),d0
  6762.         CALLSYS    Signal
  6763. NoAlarm        rts
  6764.  
  6765.  
  6766.  
  6767. **********************************************************************
  6768. *                 Get a file name via ASL-Requester                  *
  6769. * Parameters must be passed on stack in given order                  *
  6770. *  1. Pointer to window                                              *
  6771. *  2. Pointer to requester header                                    *
  6772. *  3. Pointer to path                                                *
  6773. *  4. Pointer to filename                                            *
  6774. **********************************************************************
  6775. GetFileName    CARGS    #8,.Window.l,.Header.l,.Path.l,.FileName.l,.CompleteName.l,.GadgetNum.w,.GadgetList.l
  6776.         link    a5,#0
  6777.         LNKLIB    AllocFileRequest,_AslBase    ; Get structure for filerequester
  6778.         tst.l    d0
  6779.         beq    NoLogFileName
  6780.         move.l    d0,MyAslRequest
  6781.  
  6782.         move.l    .Window(a5),FileReqWin        ; Set up filerequester
  6783.         move.l    .Path(a5),FileReqDir
  6784.         move.l    .FileName(a5),FileReqFile
  6785.         move.l    .Header(a5),FileReqHeader
  6786.         move.l    MyAslRequest(pc),a0
  6787.         lea    AslFileTags(pc),a1
  6788.         LNKLIB    AslRequest,_AslBase        ; Do the request
  6789.         move.l    d0,d7
  6790.         tst.l    d0
  6791.         beq    .Canceled
  6792.         move.l    MyAslRequest(pc),a2
  6793.         move.l    rf_Dir(a2),a0
  6794.         move.l    .Path(a5),a1            ; Copy Dir name
  6795.         bsr    StrCpy
  6796.         move.l    rf_Dir(a2),a0
  6797.         move.l    .CompleteName(a5),a1
  6798.         bsr    StrCpy                ; and to full name
  6799.         move.l    .CompleteName(a5),a0
  6800.         bsr    StrLen
  6801.         tst.l    d0
  6802.         beq.s    .End
  6803.         lea    -1(a0,d0),a0
  6804.         move.b    (a0),d0
  6805.         tst.b    d0                ; No Dir name ?
  6806.         beq.s    .End
  6807.         cmp.b    #':',d0                ; Only device
  6808.         beq.s    .End
  6809.         cmp.b    #'/',d0                ; Path
  6810.         beq.s    .End
  6811.         move.b    #'/',-1(a1)            ; Add a slash to full filename
  6812. .End        move.l    rf_File(a2),a0            ; Copy filename
  6813.         move.l    .FileName(a5),a1
  6814.         bsr    StrCpy
  6815.         move.l    rf_File(a2),a0            ; and concat it to full name
  6816.         move.l    .CompleteName(a5),a1
  6817.         bsr    StrCat
  6818.         move.w    .GadgetNum(a5),d0
  6819.         ext.l    d0
  6820.         tst.l    d0
  6821.         beq.s    .Canceled
  6822.         move.l    .GadgetList(a5),a0
  6823.         move.l    .Window(a5),a1
  6824.         move.l    #286,d1
  6825.         move.l    .CompleteName(a5),a2
  6826.         bsr    SetStringGad
  6827.         moveq    #1,d7
  6828. .Canceled    move.l    MyAslRequest(pc),a0        ; Copy new position of filereq
  6829.         move.w    rf_LeftEdge(a0),d0
  6830.         move.w    rf_TopEdge(a0),d1
  6831.         ext.l    d0
  6832.         ext.l    d1
  6833.         move.l    d0,FileReqLeft
  6834.         move.l    d1,FileReqTop
  6835.         move.w    rf_Width(a0),d0
  6836.         move.w    rf_Height(a0),d1
  6837.         ext.l    d0
  6838.         ext.l    d1
  6839.         move.l    d0,FileReqWidth
  6840.         move.l    d1,FileReqHeight
  6841.         LNKLIB    FreeFileRequest,_AslBase    ; Free request
  6842. NoLogFileName    unlk    a5
  6843.         move.l    d7,d0
  6844.         rts
  6845.  
  6846.  
  6847.  
  6848. **********************************************************************
  6849. *           This part removes all waiting msgs for a port            *
  6850. **********************************************************************
  6851. KillMessages    CARGS    #0,Wnd.L,Port.L,Base.L
  6852.         movem.l    a0/a1/a6,-(sp)            ; Store pointers
  6853. .Loop        move.l    Port(sp),a0            ; Get pointer to port
  6854.         CALLSYS    GetMsg
  6855.         tst.l    d0
  6856.         beq.s    NoMoreMsgs
  6857.         move.l    d0,a1                ; Reply msg
  6858.         DOLIB    ReplyMsg
  6859.         bra    .Loop
  6860. NoMoreMsgs    movem.l    (sp)+,a0/a1/a6            ; Reget pointers
  6861.         rts
  6862.  
  6863.  
  6864.  
  6865. **********************************************************************
  6866. *          This is the routine for handleing ARexx command           *
  6867. **********************************************************************
  6868. HandleARexx    bsr    DisableBroker
  6869. DoAllARexx    move.l    ARexxPort(pc),a0        ; Get ARexx msg
  6870.         CALLSYS    GetMsg
  6871.         tst.l    d0
  6872.         beq    AllARexxDone
  6873.         move.l    d0,MyARexxMsg
  6874.         move.l    d0,a0
  6875.  
  6876.         move.l    ACTION(a0),d0            ; Get action to be taken
  6877.         move.l    d0,ARexxAction
  6878.         move.l    ARG0(a0),ARexxCommand
  6879.  
  6880.         move.l    #RC_OK,AResult1
  6881.         move.l    #0,AResult2
  6882.  
  6883.         and.l    #RXCOMM,d0            ; Is it a command ?
  6884.         beq    ARexxCommDone
  6885.  
  6886.         move.l    ARexxCommand(pc),a0        ; Check for activate command
  6887.         lea    ActivateStr(pc),a1
  6888.         bsr    CheckARexxComm
  6889.         tst.l    d0
  6890.         bne.s    ANoActivate
  6891.  
  6892.         bsr    CheckABool
  6893.         tst.l    d0
  6894.         blt    ACommFail
  6895.         move.b    d0,DoActivate
  6896.         move.l    #ACTIGAD,d1
  6897.         bsr    SetControlBox
  6898.         bra    ARexxCommDone
  6899.  
  6900. ANoActivate    move.l    ARexxCommand(pc),a0        ; Check for MouseMode command
  6901.         lea    MouseStr(pc),a1
  6902.         bsr    CheckARexxComm
  6903.         tst.l    d0
  6904.         bne.s    ANoMouseMode
  6905.  
  6906.         bsr    CheckABool
  6907.         tst.l    d0
  6908.         blt    ACommFail
  6909.         move.b    d0,MouseMode
  6910.         move.l    #MODEGAD,d1
  6911.         bsr    SetControlBox
  6912.         bra    ARexxCommDone
  6913.  
  6914. ANoMouseMode    move.l    ARexxCommand(pc),a0        ; Check for ShowClock command
  6915.         lea    ShowCStr(pc),a1
  6916.         bsr    CheckARexxComm
  6917.         tst.l    d0
  6918.         bne.s    ANoShowClock
  6919.  
  6920.         bsr    CheckABool            ; Check for flags (0/1)
  6921.         tst.l    d0
  6922.         blt    ACommFail
  6923.         move.b    d0,ShowClock            ; Save flags
  6924.         move.l    #DISPLAYGAD,d1
  6925.         bsr    SetControlBox
  6926.         bsr    ClearTitleBar
  6927.         bsr    SigTime
  6928.         tst.b    ShowClock
  6929.         bne.s    ANoWinClose
  6930.         bsr    CloseClockWin
  6931. ANoWinClose    bra    ARexxCommDone
  6932.  
  6933.  
  6934. ANoShowClock    move.l    ARexxCommand(pc),a0        ; Activate ClockWindow ?
  6935.         lea    ClockWStr(pc),a1
  6936.         bsr    CheckARexxComm
  6937.         tst.l    d0
  6938.         bne.s    ANoClockWin
  6939.  
  6940.         bsr    CheckABool
  6941.         tst.l    d0
  6942.         blt    ACommFail
  6943.         move.b    d0,ClockWin
  6944.         move.l    #WINDOWGAD,d1
  6945.         bsr    SetControlBox
  6946.         bsr    ClearTitleBar
  6947.         bsr    SigTime
  6948.         bra    ARexxCommDone
  6949.  
  6950. ANoClockWin    move.l    ARexxCommand(pc),a0        ; Reposition clockwindow ?
  6951.         lea    ClockPosStr(pc),a1
  6952.         bsr    CheckARexxComm
  6953.         tst.l    d0
  6954.         bne.s    ANoWinPos
  6955.         move.l    ReadBuffer(pc),a1
  6956.         bsr    StrCpy
  6957.         bsr    GetWinPos
  6958.         tst.l    d0
  6959.         beq    ACommFail
  6960.         lea    ClockWinDef(pc),a0
  6961.         move.l    WinLeftEdge(pc),d0        ; Store in NewWindow-Structure
  6962.         move.l    WinTopEdge(pc),d1
  6963.         move.w    d0,nw_LeftEdge(a0)
  6964.         move.w    d1,nw_TopEdge(a0)
  6965.         tst.l    ClockHandle            ; Clockwindow open ?
  6966.         beq.s    NoReposClockWin
  6967.         move.l    ClockHandle(pc),a0
  6968.         cmp.w    wd_LeftEdge(a0),d0
  6969.         bne.s    .DoWinRepos
  6970.         cmp.w    wd_TopEdge(a0),d1
  6971.         beq.s    NoReposClockWin
  6972. .DoWinRepos    moveq    #0,d2
  6973.         moveq    #0,d3
  6974.         move.w    wd_Width(a0),d2
  6975.         move.b    wd_BorderTop(a0),d3
  6976.         LNKLIB    ChangeWindowBox,_IntuitionBase    ; Resize
  6977.         bsr    ClockRemake
  6978. NoReposClockWin    bra    ARexxCommDone
  6979.  
  6980. ANoWinPos    move.l    ARexxCommand(pc),a0        ; Display date ?
  6981.         lea    ShowDateStr(pc),a1
  6982.         bsr    CheckARexxComm
  6983.         tst.l    d0
  6984.         bne.s    ANoShowDate
  6985.  
  6986.         bsr    CheckABool
  6987.         tst.l    d0
  6988.         blt    ACommFail
  6989.         move.b    d0,ShowDate
  6990.         move.l    #DATEGAD,d1
  6991.         bsr    SetControlBox
  6992.         bsr    ClearTitleBar
  6993.         bsr    SigTime
  6994.         bra    ARexxCommDone
  6995.  
  6996. ANoShowDate    move.l    ARexxCommand(pc),a0        ; Show day ?
  6997.         lea    ShowDayStr(pc),a1
  6998.         bsr    CheckARexxComm
  6999.         tst.l    d0
  7000.         bne.s    ANoShowDay
  7001.  
  7002.         bsr    CheckABool
  7003.         tst.l    d0
  7004.         blt    ACommFail
  7005.         move.b    d0,ShowDay
  7006.         move.l    #DAYGAD,d1
  7007.         bsr    SetControlBox
  7008.         bsr    ClearTitleBar
  7009.         bsr    SigTime
  7010.         bra    ARexxCommDone
  7011.  
  7012. ANoShowDay    move.l    ARexxCommand(pc),a0        ; Short day string ?
  7013.         lea    ShortDayStr(pc),a1
  7014.         bsr    CheckARexxComm
  7015.         tst.l    d0
  7016.         bne.s    ANoShortDay
  7017.  
  7018.         bsr    CheckABool
  7019.         tst.l    d0
  7020.         blt    ACommFail
  7021.         move.b    d0,ShortDay
  7022.         move.l    #SHORTGAD,d1
  7023.         bsr    SetControlBox
  7024.         bsr    ClearTitleBar
  7025.         bsr    SigTime
  7026.         bra    ARexxCommDone
  7027.  
  7028. ANoShortDay    move.l    ARexxCommand(pc),a0        ; Show seconds ?
  7029.         lea    ShowSecsStr(pc),a1
  7030.         bsr    CheckARexxComm
  7031.         tst.l    d0
  7032.         bne.s    ANoShowSecs
  7033.  
  7034.         bsr    CheckABool
  7035.         tst.l    d0
  7036.         blt    ACommFail
  7037.         move.b    d0,ShowSecs
  7038.         move.l    #SECSGAD,d1
  7039.         bsr    SetControlBox
  7040.         bsr    ClearTitleBar
  7041.         bsr    SigTime
  7042.         bra    ARexxCommDone
  7043.  
  7044. ANoShowSecs    move.l    ARexxCommand(pc),a0        ; Show american date ?
  7045.         lea    AmiDateStr(pc),a1
  7046.         bsr    CheckARexxComm
  7047.         tst.l    d0
  7048.         bne.s    ANoAmiDate
  7049.  
  7050.         bsr    CheckABool
  7051.         tst.l    d0
  7052.         blt    ACommFail
  7053.         move.b    d0,AmiDate
  7054.         move.l    #AMIGAD,d1
  7055.         bsr    SetControlBox
  7056.         bsr    ClearTitleBar
  7057.         bsr    SigTime
  7058.         bra    ARexxCommDone
  7059.  
  7060. ANoAmiDate    move.l    ARexxCommand(pc),a0        ; Change Control HotKey ?
  7061.         lea    KeyStr,a1
  7062.         bsr    CheckARexxComm
  7063.         tst.l    d0
  7064.         bne.s    ANoConKey
  7065.  
  7066.         move.l    ReadBuffer,a1
  7067.         bsr    StrCpy
  7068.         move.l    #POPUPGAD,d7
  7069.         move.l    WndHandle,a0
  7070.         lea    ControlTitle,a1
  7071.         move.l    PopUpFilter,a4
  7072.         lea    PopUpKey,a5
  7073.         bsr    RemakeHotKey
  7074.  
  7075. ANoConKey    move.l    ARexxCommand(pc),a0        ; Change Page HotKey ?
  7076.         lea    PageStr(pc),a1
  7077.         bsr    CheckARexxComm
  7078.         tst.l    d0
  7079.         bne.s    ANoPageKey
  7080.  
  7081.         move.l    ReadBuffer,a1
  7082.         bsr    StrCpy
  7083.         move.l    #PAGEGAD,d7
  7084.         sub.l    a0,a0
  7085.         sub.l    a1,a1
  7086.         move.l    PageFilter,a4
  7087.         lea    PageHotKey,a5
  7088.         bsr    RemakeHotKey
  7089.         bra    ARexxCommDone
  7090.  
  7091. ANoPageKey    move.l    ARexxCommand(pc),a0        ; Change display page ?
  7092.         lea    PageNumStr(pc),a1
  7093.         bsr    CheckARexxComm
  7094.         tst.l    d0
  7095.         bne.s    ANoPageNum
  7096.  
  7097.         move.l    PageNum(pc),d7
  7098.         move.l    a0,d1
  7099.         move.l    #PageNum,d2
  7100.         LNKLIB    StrToLong,_DOSBase
  7101.         tst.l    d0
  7102.         ble.s    .Error
  7103.         tst.l    PageNum
  7104.         blt.s    .Error
  7105.         cmp.l    #MAXPAGES,PageNum
  7106.         blt.s    .End
  7107. .Error        move.l    #0,PageNum
  7108. .End        bsr    ClearTitleBar
  7109.         bsr    SigTime
  7110.         bra    ARexxCommDone
  7111.  
  7112. ANoPageNum    move.l    ARexxCommand(pc),a0        ; Activate alarm
  7113.         lea    AlarmStr(pc),a1
  7114.         bsr    CheckARexxComm
  7115.         tst.l    d0
  7116.         bne.s    ANoAlarm
  7117.  
  7118.         bsr    CheckABool
  7119.         tst.l    d0
  7120.         blt    ACommFail
  7121.         move.b    d0,DoAlarm
  7122.         move.l    #ALARMMODEGAD,d1
  7123.         bsr    SetControlBox
  7124.         bra    ARexxCommDone
  7125.  
  7126. ANoAlarm    move.l    ARexxCommand(pc),a0        ; Set alarm time ?
  7127.         lea    AlarmTimeStr(pc),a1
  7128.         bsr    CheckARexxComm
  7129.         tst.l    d0
  7130.         bne.s    ANoAlarmTime
  7131.         move.l    ReadBuffer(pc),a1
  7132.         bsr    StrCpy
  7133.         move.l    ReadBuffer(pc),a0
  7134.         bsr    StrLen
  7135.         cmp.l    #8,d0                ; StringLen > 8
  7136.         bgt    ACommFail            ; -> error
  7137.         bsr    CheckAlarmTime
  7138.         bra    ARexxCommDone
  7139.  
  7140. ANoAlarmTime    move.l    ARexxCommand(pc),a0        ; Enable/Disable env vars ?
  7141.         lea    SetEnvStr(pc),a1
  7142.         bsr    CheckARexxComm
  7143.         tst.l    d0
  7144.         bne.s    ANoSetEnv
  7145.  
  7146.         bsr    CheckABool            ; Bool flag ???
  7147.         tst.l    d0
  7148.         blt    ACommFail
  7149.         move.b    d0,SetEnv
  7150.         move.l    #ENVGAD,d1
  7151.         bsr    SetControlBox
  7152.         tst.b    SetEnv
  7153.         bne.s    .NoDel
  7154.         bsr    DeleteEnvs            ; Delete vars if setenv is off
  7155. .NoDel        bsr    SigTime                ; Set the time
  7156.         bra    ARexxCommDone
  7157.  
  7158. ANoSetEnv    move.l    ARexxCommand(pc),a0        ; New screenblank time ?
  7159.         lea    ScreenTStr(pc),a1
  7160.         bsr    CheckARexxComm
  7161.         tst.l    d0
  7162.         bne.s    ANoScreenTime
  7163.         move.l    ScreenTime(pc),d7
  7164.         move.l    ReadBuffer(pc),a1
  7165.         bsr    StrCpy
  7166.         move.l    ReadBuffer,d1
  7167.         move.l    #ScreenTime,d2
  7168.         LNKLIB    StrToLong,_DOSBase        ; Get new time
  7169.         tst.l    ScreenTime            ; negative ?
  7170.         ble.s    .Error                ; disable blank
  7171.         tst.l    d0
  7172.         bge.s    .GoOn
  7173. .Error        move.l    d7,ScreenTime
  7174. .GoOn        move.l    #SCREENGAD,d0
  7175.         lea    ControlGads,a0
  7176.         move.l    WndHandle,a1
  7177.         moveq    #3,d1
  7178.         move.l    ScreenTime,d2            ; Display new time
  7179.         bsr    SetIntegerGad
  7180.         move.b    #1,TimeReset
  7181.         bra    ARexxCommDone
  7182.  
  7183. ANoScreenTime    move.l    ARexxCommand(pc),a0        ; New mouseblank time ?
  7184.         lea    MouseTStr(pc),a1
  7185.         bsr    CheckARexxComm
  7186.         tst.l    d0
  7187.         bne.s    ANoMouseTime
  7188.         move.l    MouseTime(pc),d7
  7189.         move.l    ReadBuffer(pc),a1
  7190.         bsr    StrCpy
  7191.         move.l    ReadBuffer,d1
  7192.         move.l    #MouseTime,d2
  7193.         LNKLIB    StrToLong,_DOSBase        ; Get new time
  7194.         tst.l    MouseTime            ; Negative -> disable blank
  7195.         ble.s    .Error
  7196.         tst.l    d0
  7197.         bge.s    .GoOn
  7198. .Error        move.l    d7,MouseTime
  7199. .GoOn        move.l    #MOUSEGAD,d0
  7200.         lea    ControlGads,a0
  7201.         move.l    WndHandle,a1
  7202.         moveq    #3,d1
  7203.         move.l    MouseTime,d2
  7204.         bsr    SetIntegerGad
  7205.         move.b    #1,TimeReset
  7206.         bra    ARexxCommDone
  7207.  
  7208. ANoMouseTime    move.l    ARexxCommand(pc),a0
  7209.         lea    ClickVStr(pc),a1        ; Remake click volume ?
  7210.         bsr    CheckARexxComm
  7211.         tst.l    d0
  7212.         bne.s    ANoClickVol
  7213.         move.l    ClickVol(pc),d7
  7214.         move.l    ReadBuffer(pc),a1
  7215.         bsr    StrCpy
  7216.         move.l    ReadBuffer,d1
  7217.         move.l    #ClickVol,d2
  7218.         LNKLIB    StrToLong,_DOSBase
  7219.         tst.l    d0
  7220.         ble.s    .Error
  7221.         cmp.l    #64,ClickVol
  7222.         bgt.s    .Error
  7223.         tst.l    ClickVol
  7224.         bge.s    .GoOn
  7225. .Error        move.l    d7,ClickVol
  7226. .GoOn        move.l    #VOLGAD,d0
  7227.         lea    ControlGads,a0
  7228.         move.l    WndHandle,a1
  7229.         moveq    #2,d1
  7230.         move.l    ClickVol,d2
  7231.         bsr    SetIntegerGad
  7232.         bra    ARexxCommDone
  7233.  
  7234. ANoClickVol    move.l    ARexxCommand(pc),a0        ; Remake cycle qualifier ?
  7235.         lea    CycleStr(pc),a1
  7236.         bsr    CheckARexxComm
  7237.         tst.l    d0
  7238.         bne.s    ANoCycleQual
  7239.         move.l    ReadBuffer(pc),a1
  7240.         bsr    StrCpy
  7241.         move.l    PopQualNum(pc),d7        ; Get old number
  7242.         move.l    ReadBuffer,d1
  7243.         move.l    #PopQualNum,d2
  7244.         LNKLIB    StrToLong,_DOSBase        ; Get number
  7245.         tst.l    d0
  7246.         blt.s    .Error
  7247.         tst.l    PopQualNum
  7248.         blt.s    .Error
  7249.         cmp.l    #POPQUALCNT,PopQualNum
  7250.         blt.s    .End1
  7251. .Error        move.l    d7,PopQualNum            ; Remake to old value
  7252. .End1        move.l    #FRONTGAD,d0
  7253.         move.l    PopQualNum(pc),d1
  7254.         lea    ControlGads,a0
  7255.         move.l    WndHandle,a1
  7256.         lea    PopQualList,a2
  7257.         bsr    SetCycleGad
  7258.         bra    ARexxCommDone
  7259.  
  7260. ANoCycleQual    move.l    ARexxCommand(pc),a0        ; Enable/Disable Window-Cycling ?
  7261.         lea    CycleWStr(pc),a1
  7262.         bsr    CheckARexxComm
  7263.         tst.l    d0
  7264.         bne.s    ANoCycleWin
  7265.  
  7266.         bsr    CheckABool
  7267.         tst.l    d0
  7268.         blt    ACommFail
  7269.         move.b    d0,CycleWin
  7270.         move.l    #CYCLEGAD,d1
  7271.         bsr    SetControlBox
  7272.         bra    ARexxCommDone
  7273.  
  7274. ANoCycleWin    move.l    ARexxCommand(pc),a0        ; Enable/Disable click ?
  7275.         lea    ClickStr(pc),a1
  7276.         bsr    CheckARexxComm
  7277.         tst.l    d0
  7278.         bne.s    ANoClickOff
  7279.  
  7280.         bsr    CheckABool
  7281.         tst.l    d0
  7282.         blt    ACommFail
  7283.         move.b    d0,KeyClick
  7284.         move.l    #CLICKGAD,d1
  7285.         bsr    SetControlBox
  7286.         bra    ARexxCommDone
  7287.  
  7288. ANoClickOff    move.l    ARexxCommand(pc),a0        ; Enable/Disable phone logs ?
  7289.         lea    LogCallStr(pc),a1
  7290.         bsr    CheckARexxComm
  7291.         tst.l    d0
  7292.         bne.s    ANoLogCalls
  7293.  
  7294.         bsr    CheckABool
  7295.         tst.l    d0
  7296.         blt    ACommFail
  7297.         move.b    d0,LogCalls            ; Set mode
  7298.         move.l    #LOGCALLGAD,d1
  7299.         lea    PrefsGads,a0
  7300.         move.l    PrefsHandle,a1
  7301.         bsr    SetCheckBox
  7302.         bra    ARexxCommDone
  7303.  
  7304. ANoLogCalls    move.l    ARexxCommand(pc),a0        ; Reposition bill window ?
  7305.         lea    BillPosStr(pc),a1
  7306.         bsr    CheckARexxComm
  7307.         tst.l    d0
  7308.         bne.s    ANoBillWinPos
  7309.  
  7310.         move.l    ReadBuffer(pc),a1
  7311.         bsr    StrCpy
  7312.  
  7313.         bsr    GetWinPos
  7314.         tst.l    d0
  7315.         beq    ACommFail
  7316.         lea    BillWinDef(pc),a0
  7317.         move.l    WinLeftEdge(pc),d0        ; Store in NewWindow-Structure
  7318.         move.l    WinTopEdge(pc),d1
  7319.         move.w    d0,nw_LeftEdge(a0)
  7320.         move.w    d1,nw_TopEdge(a0)
  7321.         tst.l    BillHandle            ; BillWindow open ?
  7322.         beq.s    .End
  7323.         move.l    BillHandle(pc),a0
  7324.         cmp.w    wd_LeftEdge(a0),d0
  7325.         bne.s    .DoWinRepos
  7326.         cmp.w    wd_TopEdge(a0),d1
  7327.         beq.s    .End
  7328. .DoWinRepos    moveq    #0,d2
  7329.         moveq    #0,d3
  7330.         move.w    wd_Width(a0),d2
  7331.         move.w    wd_Height(a0),d3
  7332.         LNKLIB    ChangeWindowBox,_IntuitionBase    ; Resize
  7333. .End        bra    ARexxCommDone
  7334.  
  7335. ANoBillWinPos    move.l    ARexxCommand(pc),a0
  7336.         lea    BillWinStr(pc),a1        ; Popup billwindow on carrier detect ?
  7337.         bsr    CheckARexxComm
  7338.         tst.l    d0
  7339.         bne.s    ANoBillPopUp
  7340.  
  7341.         bsr    CheckABool
  7342.         tst.l    d0
  7343.         blt    ACommFail
  7344.         move.b    d0,BillPopUp            ; set new state
  7345.         move.l    #BILLPOPGAD,d1
  7346.         lea    PrefsGads,a0
  7347.         move.l    PrefsHandle,a1
  7348.         bsr    SetCheckBox
  7349.         bra    ARexxCommDone
  7350.  
  7351. ANoBillPopUp    move.l    ARexxCommand(pc),a0        ; Clear log file ?
  7352.         lea    AClearLogStr(pc),a1
  7353.         bsr    CheckARexxComm
  7354.         tst.l    d0
  7355.         bne.s    ANoClearLog
  7356.         move.l    #LogFileName,d1
  7357.         LNKLIB    DeleteFile,_DOSBase
  7358.         bra    ARexxCommDone
  7359.  
  7360. ANoClearLog    move.l    ARexxCommand(pc),a0        ; Reposition Prefs window ?
  7361.         lea    PrefsPosStr(pc),a1
  7362.         bsr    CheckARexxComm
  7363.         tst.l    d0
  7364.         bne.s    ANoPrefsPos
  7365.  
  7366.         move.l    ReadBuffer(pc),a1
  7367.         bsr    StrCpy
  7368.  
  7369.         bsr    GetWinPos
  7370.         tst.l    d0
  7371.         beq    ACommFail
  7372.         lea    BillWinDef(pc),a0
  7373.         move.l    WinLeftEdge(pc),d0        ; Store in NewWindow-Structure
  7374.         move.l    WinTopEdge(pc),d1
  7375.         move.w    d0,nw_LeftEdge(a0)
  7376.         move.w    d1,nw_TopEdge(a0)
  7377.         tst.l    PrefsHandle            ; PrefsWindow open ?
  7378.         beq.s    .End
  7379.         move.l    PrefsHandle(pc),a0
  7380.         cmp.w    wd_LeftEdge(a0),d0
  7381.         bne.s    .DoWinRepos
  7382.         cmp.w    wd_TopEdge(a0),d1
  7383.         beq.s    .End
  7384. .DoWinRepos    moveq    #0,d2
  7385.         moveq    #0,d3
  7386.         move.w    wd_Width(a0),d2
  7387.         move.w    wd_Height(a0),d3
  7388.         LNKLIB    ChangeWindowBox,_IntuitionBase    ; Resize
  7389. .End        bra    ARexxCommDone
  7390.  
  7391. ANoPrefsPos    move.l    ARexxCommand(pc),a0        ; Enable/Disable WB PopUp
  7392.         lea    WBFrontStr(pc),a1
  7393.         bsr    CheckARexxComm
  7394.         tst.l    d0
  7395.         bne.s    ANoWBFront
  7396.  
  7397.         bsr    CheckABool
  7398.         tst.l    d0
  7399.         blt    ACommFail
  7400.         move.b    d0,WBFront            ; set new state
  7401.         move.l    #WBFRONTGAD,d1
  7402.         bsr    SetControlBox
  7403.         bra    ARexxCommDone
  7404.  
  7405. ANoWBFront    move.l    ARexxCommand(pc),a0        ; Enable/Disable LeftyMouse ?
  7406.         lea    LeftyStr(pc),a1
  7407.         bsr    CheckARexxComm
  7408.         tst.l    d0
  7409.         bne.s    ANoLeftyMouse
  7410.  
  7411.         bsr    CheckABool
  7412.         tst.l    d0
  7413.         blt    ACommFail
  7414.         move.b    d0,LeftyMouse
  7415.         move.l    #LEFTYGAD,d1
  7416.         bsr    SetControlBox
  7417.         bra    ARexxCommDone
  7418.  
  7419. ANoLeftyMouse    move.l    ARexxCommand(pc),a0        ; Enable/Disable ESC-Close ?
  7420.         lea    ESCCloseStr(pc),a1
  7421.         bsr    CheckARexxComm
  7422.         tst.l    d0
  7423.         bne.s    ANoESCClose
  7424.  
  7425.         bsr    CheckABool
  7426.         tst.l    d0
  7427.         blt    ACommFail
  7428.         move.b    d0,ESCClose
  7429.         move.l    #WESCGAD,d1
  7430.         bsr    SetControlBox
  7431.         bra    ARexxCommDone
  7432.  
  7433. ANoESCClose    move.l    ARexxCommand(pc),a0        ; Remake cycle qualifier ?
  7434.         lea    ESCQualStr(pc),a1
  7435.         bsr    CheckARexxComm
  7436.         tst.l    d0
  7437.         bne.s    ANoESCQual
  7438.         move.l    ReadBuffer(pc),a1
  7439.         bsr    StrCpy
  7440.         move.l    ESCQualNum(pc),d7        ; Get old number
  7441.         move.l    ReadBuffer,d1
  7442.         move.l    #ESCQualNum,d2
  7443.         LNKLIB    StrToLong,_DOSBase        ; Get number
  7444.         tst.l    d0
  7445.         blt.s    .Error
  7446.         tst.l    ESCQualNum
  7447.         blt.s    .Error
  7448.         cmp.l    #ESCQUALCNT,ESCQualNum
  7449.         blt.s    .End1
  7450. .Error        move.l    d7,ESCQualNum            ; Remake to old value
  7451. .End1        move.l    #ESCQUALGAD,d0
  7452.         move.l    ESCQualNum(pc),d1
  7453.         lea    ControlGads,a0
  7454.         move.l    WndHandle,a1
  7455.         lea    ESCQualList,a2
  7456.         bsr    SetCycleGad
  7457.         bra    ARexxCommDone
  7458.  
  7459. ANoESCQual    move.l    ARexxCommand(pc),a0        ; Enable/Disable "Map Umlauts ?"
  7460.         lea    UmlautOnStr(pc),a1
  7461.         bsr    CheckARexxComm
  7462.         tst.l    d0
  7463.         bne.s    ANoUmlautOn
  7464.  
  7465.         bsr    CheckABool
  7466.         tst.l    d0
  7467.         blt    ACommFail
  7468.         move.b    d0,MapUmlaut
  7469.         move.l    #UMLAUTGAD,d1
  7470.         bsr    SetControlBox
  7471.         bra    ARexxCommDone
  7472.  
  7473. ANoUmlautOn    move.l    ARexxCommand(pc),a0        ; Enable broker ?
  7474.         lea    EnableStr(pc),a1
  7475.         bsr    CheckARexxComm
  7476.         tst.l    d0
  7477.         bne.s    ANoEnable
  7478.         move.b    #0,Disabled
  7479.         move.b    #1,TimeReset
  7480.         bsr    EnableBroker
  7481.         bra    ARexxCommDone
  7482.  
  7483. ANoEnable    move.l    ARexxCommand(pc),a0        ; Disable broker ?
  7484.         lea    DisableStr(pc),a1
  7485.         bsr    CheckARexxComm
  7486.         tst.l    d0
  7487.         bne.s    ANoDisable
  7488.         bsr    DisableBroker
  7489.         bsr    OnScreen
  7490.         bsr    OnMouse
  7491.         move.b    #1,Disabled
  7492.         bra    ARexxCommDone
  7493.  
  7494. ANoDisable    move.l    ARexxCommand(pc),a0        ; Hide window ?
  7495.         lea    HideStr(pc),a1
  7496.         bsr    CheckARexxComm
  7497.         tst.l    d0
  7498.         bne.s    ANoHide
  7499.         bsr    CloseOurWindow
  7500.         bra    ARexxCommDone
  7501.  
  7502. ANoHide        move.l    ARexxCommand(pc),a0        ; PopUp window ?
  7503.         lea    APopUpStr(pc),a1
  7504.         bsr    CheckARexxComm
  7505.         tst.l    d0
  7506.         bne.s    ANoPopUp
  7507.         bsr    OpenOurWindow
  7508.         bra    ARexxCommDone
  7509.  
  7510. ANoPopUp    move.l    ARexxCommand(pc),a0        ; Return a status ?
  7511.         lea    AStatusStr(pc),a1
  7512.         bsr    CheckARexxComm
  7513.         tst.l    d0
  7514.         bne.s    ANoStatus
  7515.         bsr    ReturnStatus
  7516.         tst.l    d0
  7517.         beq    ACommFail
  7518.         bra    ARexxCommDone
  7519.  
  7520. ANoStatus    move.l    ARexxCommand(pc),a0        ; Do a revision ?
  7521.         lea    AReviseStr(pc),a1
  7522.         bsr    CheckARexxComm
  7523.         tst.l    d0
  7524.         bne    ANoRevise
  7525.         move.l    ReadBuffer(pc),a1
  7526.         bsr    StrCpy
  7527.         move.l    ReadBuffer(pc),a1
  7528.         move.l    a1,a0
  7529. .Loop        tst.b    (a1)                ; Get filename
  7530.         beq    ACommFail
  7531.         cmp.b    #' ',(a1)
  7532.         beq.s    GotFileName
  7533.         cmp.b    #'"',(a1)
  7534.         beq.s    GotFileName
  7535.         cmp.b    #"'",(a1)
  7536.         beq.s    GotFileName
  7537.         addq.l    #1,a1
  7538.         bra    .Loop
  7539. GotFileName    move.b    #0,(a1)+
  7540.         move.l    a1,a4
  7541.         lea    FileName(pc),a1            ; Copy filename
  7542.         bsr    StrCpy
  7543.         move.l    a4,a0
  7544.         bsr    SkipBlanks
  7545.         move.l    a0,a4
  7546.         lea    AReviseCStr(pc),a1        ; C or ASM revision ?
  7547.         bsr    CheckARexxComm
  7548.         tst.l    d0
  7549.         bne    NoCMode
  7550.         move.l    #CHeader,RevHeader        ; Set C strings
  7551.         move.l    #CLineNL,RevLineNL
  7552.         move.l    #CLine,RevLine
  7553.         move.l    #CCopyRight,RevCompany
  7554.         move.l    #CFile,RevFile
  7555.         move.l    #CCreatedOn,RevCreatedOn
  7556.         move.l    #CAuthor,RevAuthor
  7557.         move.l    #CRevision,RevRevision
  7558.         move.l    #CPurpose,RevPurpose
  7559.         move.l    #CLog,RevLog
  7560.         move.l    #CLogInit,RevLogInit
  7561.         move.l    #CEnd,RevEnd
  7562.         move.l    #CRevDefine1,RevDefine
  7563.         bra    GotMode
  7564. NoCMode        move.l    a4,a0
  7565.         lea    AReviseAsmStr(pc),a1
  7566.         bsr    CheckARexxComm
  7567.         tst.l    d0
  7568.         bne    NoAsmMode
  7569.         move.l    #AsmHeader,RevHeader        ; Set ASM strings
  7570.         move.l    #AsmLineNL,RevLineNL
  7571.         move.l    #AsmLine,RevLine
  7572.         move.l    #AsmCopyRight,RevCompany
  7573.         move.l    #AsmFile,RevFile
  7574.         move.l    #AsmCreatedOn,RevCreatedOn
  7575.         move.l    #AsmAuthor,RevAuthor
  7576.         move.l    #AsmRevision,RevRevision
  7577.         move.l    #AsmPurpose,RevPurpose
  7578.         move.l    #AsmLog,RevLog
  7579.         move.l    #AsmLogInit,RevLogInit
  7580.         move.l    #AsmEnd,RevEnd
  7581.         move.l    #AsmRevDefine1,RevDefine
  7582.         bra    GotMode
  7583. NoAsmMode    move.l    a4,a0
  7584.         lea    ARevisePasStr(pc),a1
  7585.         bsr    CheckARexxComm
  7586.         tst.l    d0
  7587.         bne    ACommFail
  7588.         move.l    #PASHeader,RevHeader        ; Set PAS strings
  7589.         move.l    #CLineNL,RevLineNL
  7590.         move.l    #CLine,RevLine
  7591.         move.l    #CCopyRight,RevCompany
  7592.         move.l    #CFile,RevFile
  7593.         move.l    #CCreatedOn,RevCreatedOn
  7594.         move.l    #CAuthor,RevAuthor
  7595.         move.l    #CRevision,RevRevision
  7596.         move.l    #CPurpose,RevPurpose
  7597.         move.l    #CLog,RevLog
  7598.         move.l    #PASLogInit,RevLogInit
  7599.         move.l    #PASEnd,RevEnd
  7600.         move.l    #PASRevDefine1,RevDefine
  7601. GotMode        bsr    DoRevision
  7602.         tst.l    d0
  7603.         beq    ACommFail
  7604.         bra    ARexxCommDone
  7605.  
  7606. ANoRevise    move.l    ARexxCommand,a0            ; Load new prefs ?
  7607.         lea    ALoadPrefsStr,a1
  7608.         bsr    CheckARexxComm
  7609.         tst.l    d0
  7610.         bne.s    ANoLoadPrefs
  7611.         move.l    a0,a4
  7612.         lea    PrefsFileName,a0
  7613.         move.l    ReadBuffer,a1
  7614.         bsr    StrCpy
  7615.         move.l    a4,a0
  7616.         lea    PrefsFileName,a1
  7617.         bsr    StrCpy
  7618.         bsr    LoadPrefs
  7619.         move.l    ReadBuffer,a0
  7620.         lea    PrefsFileName,a1
  7621.         bsr    StrCpy
  7622.         bra    ARexxCommDone
  7623.  
  7624. ANoLoadPrefs    move.l    ARexxCommand,a0            ; Save prefs to file ?
  7625.         lea    ASavePrefsStr,a1
  7626.         bsr    CheckARexxComm
  7627.         tst.l    d0
  7628.         bne.s    ANoSavePrefs
  7629.         move.l    a0,a4
  7630.         lea    PrefsFileName,a0
  7631.         move.l    ReadBuffer,a1
  7632.         bsr    StrCpy
  7633.         move.l    a4,a0
  7634.         lea    PrefsFileName,a1
  7635.         bsr    StrCpy
  7636.         bsr    SavePrefs
  7637.         move.l    ReadBuffer,a0
  7638.         lea    PrefsFileName,a1
  7639.         bsr    StrCpy
  7640.         bra    ARexxCommDone
  7641.  
  7642. ANoSavePrefs    move.l    ARexxCommand(pc),a0        ; Change Bill HotKey ?
  7643.         lea    BillKeyStr(pc),a1
  7644.         bsr    CheckARexxComm
  7645.         tst.l    d0
  7646.         bne.s    ANoBillKey
  7647.  
  7648.         move.l    ReadBuffer,a1
  7649.         bsr    StrCpy
  7650.         move.l    #BILLKEYGAD,d7
  7651.         move.l    BillHandle,a0
  7652.         lea    BillTitle,a1
  7653.         move.l    BillFilter,a4
  7654.         lea    BillHotKey,a5
  7655.         bsr    RemakeHotKey
  7656.         bra    ARexxCommDone
  7657.  
  7658. ANoBillKey    move.l    ARexxCommand(pc),a0        ; Change Prefs HotKey ?
  7659.         lea    PrefsKeyStr(pc),a1
  7660.         bsr    CheckARexxComm
  7661.         tst.l    d0
  7662.         bne.s    ANoPrefsKey
  7663.  
  7664.         move.l    ReadBuffer,a1
  7665.         bsr    StrCpy
  7666.         move.l    #PREFSKEYGAD,d7
  7667.         move.l    PrefsHandle,a0
  7668.         lea    PrefsTitle,a1
  7669.         move.l    PrefsFilter,a4
  7670.         lea    PrefsHotKey,a5
  7671.         bsr    RemakeHotKey
  7672.         bra    ARexxCommDone
  7673.  
  7674. ANoPrefsKey    move.l    ARexxCommand(pc),a0        ; Change HotKeys HotKey ?
  7675.         lea    HotKeyStr(pc),a1
  7676.         bsr    CheckARexxComm
  7677.         tst.l    d0
  7678.         bne.s    ANoHotKey
  7679.  
  7680.         move.l    ReadBuffer,a1
  7681.         bsr    StrCpy
  7682.         move.l    #HOTKEYGAD,d7
  7683.         move.l    HotKeyHandle,a0
  7684.         lea    HotWinTitle,a1
  7685.         move.l    HotKeyFilter,a4
  7686.         lea    HotWinHotKey,a5
  7687.         bsr    RemakeHotKey
  7688.         bra    ARexxCommDone
  7689.  
  7690. ANoHotKey    move.l    ARexxCommand(pc),a0        ; Change Shell HotKey ?
  7691.         lea    ShellKeyStr(pc),a1
  7692.         bsr    CheckARexxComm
  7693.         tst.l    d0
  7694.         bne.s    ANoShellKey
  7695.  
  7696.         move.l    ReadBuffer,a1
  7697.         bsr    StrCpy
  7698.         move.l    #SHELLGAD,d7
  7699.         sub.l    a0,a0
  7700.         sub.l    a1,a1
  7701.         move.l    ShellFilter,a4
  7702.         lea    ShellHotKey,a5
  7703.         bsr    RemakeHotKey
  7704.         bra    ARexxCommDone
  7705.  
  7706. ANoShellKey    move.l    ARexxCommand(pc),a0        ; Change Umlaut HotKey ?
  7707.         lea    UmlautKeyStr(pc),a1
  7708.         bsr    CheckARexxComm
  7709.         tst.l    d0
  7710.         bne.s    ANoUmlautKey
  7711.  
  7712.         move.l    ReadBuffer,a1
  7713.         bsr    StrCpy
  7714.         move.l    #UMLAUTKEYGAD,d7
  7715.         sub.l    a0,a0
  7716.         sub.l    a1,a1
  7717.         move.l    UmlautFilter,a4
  7718.         lea    UmlautHotKey,a5
  7719.         bsr    RemakeHotKey
  7720.         bra.s    ARexxCommDone
  7721.  
  7722. ANoUmlautKey    move.l    ARexxCommand(pc),a0        ; Change Shell command ?
  7723.         lea    ShellCommStr(pc),a1
  7724.         bsr    CheckARexxComm
  7725.         tst.l    d0
  7726.         bne.s    ANoShellComm
  7727.  
  7728.         lea    SystemParam,a1
  7729.         bsr    StrCpy
  7730.         move.l    #USERSHELLGAD,d0
  7731.         lea    ControlGads,a0
  7732.         move.l    WndHandle,a1
  7733.         move.l    #64,d1
  7734.         lea    SystemParam,a2
  7735.         bsr    SetStringGad
  7736.         bra.s    ARexxCommDone
  7737.  
  7738. ANoShellComm    bra.s    ARexxCommDone
  7739.  
  7740. ACommFail    move.l    #RC_FAIL,AResult1        ; Command failed
  7741.         move.l    #0,AResult2
  7742. ARexxCommDone    move.l    MyARexxMsg(pc),a1
  7743.         move.l    AResult1(pc),rm_Result1(a1)
  7744.         move.l    AResult2(pc),rm_Result2(a1)
  7745.         CALLSYS    ReplyMsg
  7746.         bra    DoAllARexx
  7747. AllARexxDone    bsr    EnableBroker
  7748.         rts
  7749.  
  7750.  
  7751.  
  7752. **********************************************************************
  7753. *            Return a status value to the calling program            *
  7754. **********************************************************************
  7755. ReturnStatus    move.l    ARexxAction(pc),d0        ; Result expected ?
  7756.         and.l    #RXFF_RESULT,d0
  7757.         beq    StatError            ; Nope -> go on
  7758.         move.l    ReadBuffer(pc),a1
  7759.         bsr    StrCpy
  7760.         move.l    ReadBuffer,d1
  7761.         move.l    #StatusNum,d2
  7762.         LNKLIB    StrToLong,_DOSBase        ; Convert statusnumber to long
  7763.         tst.l    d0
  7764.         ble    StatError
  7765.         move.l    StatusNum(pc),d0        ; Check if status num is ok
  7766.         cmp.l    #StatusCount,d0
  7767.         bgt    StatError
  7768.         subq.l    #1,d0
  7769.         asl.l    #3,d0
  7770.         lea    ARexxStatus(pc),a0
  7771.         lea    0(a0,d0),a2            ; Get address for stat info
  7772.  
  7773.         cmp.l    #RESULTCLOCKPOS,(a2)        ; Give position of clockwindow ?
  7774.         bne.s    NoClockStatus
  7775.         lea    ClockWinDef(pc),a0
  7776.         move.w    nw_LeftEdge(a0),ResultWinData    ; Store position
  7777.         move.w    nw_TopEdge(a0),ResultWinData+2
  7778.         lea    ResultWinFormat(pc),a0
  7779.         lea    ResultWinData(pc),a1
  7780.         bra    MakeResultStr
  7781.  
  7782. NoClockStatus    cmp.l    #RESULTTIME,(a2)        ; Return alarm time ?
  7783.         bne.s    NoTimeStatus
  7784.         lea    AlarmStartVal(pc),a0
  7785.         move.l    ReadBuffer(pc),a1
  7786.         bsr    StrCpy
  7787.         bra    ResultStrDone
  7788.  
  7789. NoTimeStatus    cmp.l    #RESULTPOP,(a2)            ; Return if poped up ?
  7790.         bne.s    NoPopedUpStatus
  7791.         tst.l    WndHandle
  7792.         beq.s    .False
  7793.         lea    TrueStr(pc),a0
  7794.         bra.s    .DoPop
  7795. .False        lea    FalseStr(pc),a0
  7796. .DoPop        move.l    ReadBuffer(pc),a1
  7797.         bsr    StrCpy
  7798.         bra    ResultStrDone
  7799.  
  7800. NoPopedUpStatus    cmp.l    #RESULTBILLPOS,(a2)        ; Give position of billwindow ?
  7801.         bne.s    NoBillStatus
  7802.         lea    BillWinDef(pc),a0
  7803.         move.w    nw_LeftEdge(a0),ResultWinData    ; Store position
  7804.         move.w    nw_TopEdge(a0),ResultWinData+2
  7805.         lea    ResultWinFormat(pc),a0
  7806.         lea    ResultWinData(pc),a1
  7807.         bra.s    MakeResultStr
  7808.  
  7809. NoBillStatus    cmp.l    #RESULTPREFSPOS,(a2)        ; Give position of prefswindow ?
  7810.         bne.s    NoPrefsStatus
  7811.         lea    PrefsWinDef(pc),a0
  7812.         move.w    nw_LeftEdge(a0),ResultWinData    ; Store position
  7813.         move.w    nw_TopEdge(a0),ResultWinData+2
  7814.         lea    ResultWinFormat(pc),a0
  7815.         lea    ResultWinData(pc),a1
  7816.         bra.s    MakeResultStr
  7817.  
  7818. NoPrefsStatus    moveq    #0,d0
  7819.         move.l    4(a2),a3
  7820.         lea    ResultFormat(pc),a0
  7821.         lea    ResultData(pc),a1
  7822.         cmp.l    #RESULTBYTE,(a2)        ; Is stored as byte ?
  7823.         bne.s    NoByteResult
  7824.         move.b    (a3),d0
  7825.         move.l    d0,ResultData
  7826.         bra.s    MakeResultStr
  7827.  
  7828. NoByteResult    cmp.l    #RESULTWORD,(a2)        ; ... as word ?
  7829.         bne.s    NoWordResult
  7830.         move.w    (a3),d0
  7831.         move.l    d0,ResultData
  7832.         bra.s    MakeResultStr
  7833.  
  7834. NoWordResult    cmp.l    #RESULTLONG,(a2)        ; ... as long ?
  7835.         bne.s    NoLongResult
  7836.         move.l    (a3),d0
  7837.         move.l    d0,ResultData
  7838.         bra.s    MakeResultStr
  7839.  
  7840. NoLongResult    cmp.l    #RESULTSTRING,(a2)        ; Return a string ?
  7841.         bne.s    StatError
  7842.         move.l    a3,a0
  7843.         move.l    ReadBuffer(pc),a1
  7844.         bsr    StrCpy
  7845.         bra.s    ResultStrDone
  7846.  
  7847. MakeResultStr    lea    PutChProc(pc),a2        ; Convert string
  7848.         move.l    ReadBuffer(pc),a3
  7849.         CALLSYS    RawDoFmt
  7850.  
  7851. ResultStrDone    move.l    ReadBuffer(pc),a0
  7852.         bsr    StrLen
  7853.         LNKLIB    CreateArgstring,_RexxSysBase    ; Create argstring and store it
  7854.         tst.l    d0                ; If an error occured indicate it
  7855.         beq.s    StatError
  7856.         move.l    d0,AResult2
  7857. EndStatus    moveq    #1,d0
  7858.         rts
  7859. StatError    moveq    #0,d0
  7860.         rts
  7861.  
  7862.  
  7863.  
  7864. **********************************************************************
  7865. *                Checks, if we know the ARexx command                *
  7866. **********************************************************************
  7867. CheckARexxComm    moveq    #0,d0
  7868.         moveq    #0,d1
  7869. .Loop        move.b    (a0)+,d0            ; Get chars from buffer
  7870.         move.b    (a1)+,d1
  7871.         or.b    #$20,d0                ; Make it case in-sensitive
  7872.         or.b    #$20,d1
  7873.         cmp.b    #$20,d0                ; Argstring end ?
  7874.         beq.s    .StringOk
  7875.         cmp.b    d0,d1
  7876.         beq.s    .Loop
  7877. .StringFalse    moveq    #1,d0                ; Error flag
  7878.         rts
  7879. .StringOk    cmp.b    #$20,d1                ; Our string also ending ?
  7880.         bne    .StringFalse            ; Nope -> go on
  7881.         bsr    SkipBlanks
  7882.         moveq    #0,d0                ; Command OK
  7883.         rts
  7884.  
  7885.  
  7886. **********************************************************************
  7887. *             Checks for flags (0/1) in an ARexx-Command             *
  7888. **********************************************************************
  7889. CheckABool    cmp.b    #'0',(a0)
  7890.         beq.s    .False
  7891.         cmp.b    #'1',(a0)
  7892.         beq.s    .True
  7893.         moveq    #-1,d0
  7894.         rts
  7895. .False        moveq    #0,d0
  7896.         rts
  7897. .True        moveq    #1,d0
  7898.         rts
  7899.  
  7900.  
  7901. **********************************************************************
  7902. *              Enter a log message and revise the text               *
  7903. **********************************************************************
  7904. DoRevision    move.l    WndHandle,a0
  7905.         bsr    SetBusy
  7906.         move.l    PrefsHandle,a0
  7907.         bsr    SetBusy
  7908.  
  7909.         move.l    #0,OurLock
  7910.  
  7911.         lea    FileName(pc),a0
  7912. .LoopDev    cmp.b    #':',(a0)            ; Find out whether filename
  7913.         beq.s    .GotDev                ; is given with complete path
  7914.         tst.b    (a0)
  7915.         beq.s    .NoDev
  7916.         addq.l    #1,a0
  7917.         bra.s    .LoopDev
  7918.  
  7919. .NoDev        move.l    MyARexxMsg(pc),a0        ; Lock to current Dir of
  7920.         move.l    MN_REPLYPORT(a0),a0        ; ARexx. Normaly the workdirectory
  7921.         move.l    MP_SIGTASK(a0),a0        ; your editor is running on.
  7922.         move.l    pr_CurrentDir(a0),d1        ; If a path is specified
  7923.         move.l    #0,EasyArg            ; for this version skip description
  7924.         LNKLIB    DupLock,_DOSBase
  7925.         move.l    d0,OurLock
  7926.         tst.l    d0
  7927.         beq    NoRevision
  7928.         move.l    d0,d1
  7929.         DOLIB    CurrentDir
  7930.         move.l    d0,PastLock
  7931.         tst.l    d0
  7932.         beq    NoRevision
  7933.  
  7934. .GotDev        bsr    CheckRevision            ; Check if Revision already there
  7935.         tst.l    d7
  7936.         blt    NoRevision
  7937.  
  7938.         link    a5,#-4
  7939.         bsr    LockScreen
  7940.         tst.l    d0
  7941.         beq    .LogWinErr
  7942.  
  7943.         move.l    -4(a5),a0            ; Get visual info for screen
  7944.         sub.l    a1,a1
  7945.         LNKLIB    GetVisualInfoA,_GadToolsBase
  7946.         move.l    d0,LogVisInfo
  7947.         tst.l    d0
  7948.         beq    .LogWinErr
  7949.         lea    DummyNewGadget(pc),a0        ; Store visual info in newgadget
  7950.         move.l    d0,gng_VisualInfo(a0)
  7951.  
  7952.         move.l    -4(a5),a0            ; Pop Up WBench screen
  7953.         LNKLIB    ScreenToFront,_IntuitionBase
  7954.  
  7955.         lea    LogWinDef(pc),a0        ; Try to open window
  7956.         move.l    #LOGWINWIDTH,WinWidth
  7957.         move.l    #LOGWINHEIGHT,WinHeight
  7958.         move.l    #LOGWINIDCMP,WinIDCMP
  7959.         move.l    #LOGWINFLAGS,WinFlags
  7960.         move.l    #0,DoMenuHelp
  7961.         lea    WindowTags(pc),a1
  7962.         DOLIB    OpenWindowTagList
  7963.         move.l    d0,LogHandle
  7964.         tst.l    d0
  7965.         beq    .LogWinErr
  7966.         bsr    UnlockScreen
  7967.  
  7968.         lea    LogMenuDef,a0            ; Create menu strip
  7969.         sub.l    a1,a1                ; No tags
  7970.         LNKLIB    CreateMenusA,_GadToolsBase
  7971.         move.l    d0,LogMenu
  7972.         tst.l    d0
  7973.         beq    .LogWinErr
  7974.  
  7975.         move.l    LogMenu(pc),a0            ; Do the layout on window
  7976.         move.l    LogVisInfo(pc),a1
  7977.         sub.l    a2,a2
  7978.         DOLIB    LayoutMenusA
  7979.         tst.l    d0
  7980.         beq    .LogWinErr
  7981.  
  7982.         lea    LogGadget(pc),a0        ; Create context gadget
  7983.         LNKLIB    CreateContext,_GadToolsBase
  7984.         move.l    d0,ThisGadget
  7985.         tst.l    d0
  7986.         beq    .LogWinErr
  7987.  
  7988.         move.l    LogHandle(pc),a0
  7989.         moveq    #0,d5
  7990.         move.b    wd_BorderTop(a0),d5        ; Get height of border of window
  7991.  
  7992.         move.w    #1,GadNum            ; Reset gadget ID
  7993.  
  7994.         move.l    #0,StringConts
  7995.         move.l    #75,StrMax
  7996.         moveq    #5,d7                ; Start height
  7997.         moveq    #4,d6
  7998.         lea    LogGads,a4
  7999. .Loop        lea    DummyNewGadget(pc),a1
  8000.         move.w    #LOGSGADWIDTH,gng_Width(a1)
  8001.         move.w    #INTERWIDTH,gng_LeftEdge(a1)
  8002.         move.l    d5,d1
  8003.         add.w    d7,d1                ; Make Top Edge of gadget
  8004.         move.w    d1,gng_TopEdge(a1)
  8005.         move.l    #0,gng_Flags(a1)
  8006.         move.l    #STRING_KIND,d0            ; Create string gadgets
  8007.         move.l    ThisGadget(pc),a0
  8008.         lea    StringTags(pc),a2
  8009.         DOLIB    CreateGadgetA
  8010.         tst.l    d0
  8011.         beq    .LogWinErr
  8012.         move.l    d0,(a4)+
  8013.         move.l    d0,ThisGadget
  8014.         addq.w    #1,GadNum
  8015.         add.l    #13,d7
  8016.         dbf    d6,.Loop
  8017.  
  8018.         lea    DummyNewGadget(pc),a1        ; Create OK gadget
  8019.         move.w    #GADWIDTH,gng_Width(a1)
  8020.         move.w    #INTERWIDTH,gng_LeftEdge(a1)
  8021.         move.l    d5,d1
  8022.         add.w    d7,d1
  8023.         move.w    d1,gng_TopEdge(a1)
  8024.         move.l    #LogOkText,gng_GadgetText(a1)
  8025.         move.l    #PLACETEXT_IN,gng_Flags(a1)
  8026.         move.l    #BUTTON_KIND,d0
  8027.         move.l    ThisGadget(pc),a0
  8028.         lea    ButtonTags(pc),a2
  8029.         DOLIB    CreateGadgetA
  8030.         tst.l    d0
  8031.         beq    .LogWinErr
  8032.         move.l    d0,(a4)+
  8033.         move.l    d0,ThisGadget
  8034.         addq.w    #1,GadNum
  8035.  
  8036.         lea    DummyNewGadget(pc),a1        ; Create CANCEL gadget
  8037.         move.w    #(LOGWINWIDTH-GADWIDTH-INTERWIDTH+6),gng_LeftEdge(a1)
  8038.         move.l    #LogCancelText,gng_GadgetText(a1)
  8039.         move.l    #BUTTON_KIND,d0
  8040.         move.l    ThisGadget(pc),a0
  8041.         lea    ButtonTags(pc),a2
  8042.         DOLIB    CreateGadgetA
  8043.         tst.l    d0
  8044.         beq    .LogWinErr
  8045.         move.l    d0,(a4)+
  8046.         move.l    d0,ThisGadget
  8047.         addq.w    #1,GadNum
  8048.  
  8049.         move.l    #0,IntConts            ; Create major revision
  8050.         move.l    #2,IntMax
  8051.         lea    DummyNewGadget(pc),a1
  8052.         move.w    #275,gng_LeftEdge(a1)
  8053.         move.w    #LOGINTWIDTH,gng_Width(a1)
  8054.         move.l    #LogRevText,gng_GadgetText(a1)
  8055.         move.l    #PLACETEXT_LEFT,gng_Flags(a1)
  8056.         move.l    #INTEGER_KIND,d0
  8057.         move.l    ThisGadget(pc),a0
  8058.         lea    IntegerTags(pc),a2
  8059.         DOLIB    CreateGadgetA
  8060.         tst.l    d0
  8061.         beq    .LogWinErr
  8062.         move.l    d0,(a4)+
  8063.         move.l    d0,ThisGadget
  8064.         addq.w    #1,GadNum
  8065.  
  8066.         lea    DummyNewGadget(pc),a1        ; Create minor revision
  8067.         move.w    #330,gng_LeftEdge(a1)
  8068.         move.l    #LogPointText,gng_GadgetText(a1)
  8069.         move.l    #PLACETEXT_LEFT,gng_Flags(a1)
  8070.         move.l    #INTEGER_KIND,d0
  8071.         move.l    ThisGadget(pc),a0
  8072.         lea    IntegerTags(pc),a2
  8073.         DOLIB    CreateGadgetA
  8074.         tst.l    d0
  8075.         beq.s    .LogWinErr
  8076.         move.l    d0,(a4)+
  8077.         move.l    d0,ThisGadget
  8078.  
  8079.         move.l    LogHandle(pc),a0        ; Add gadgets to list
  8080.         move.l    LogGadget(pc),a1
  8081.         move.l    #-1,d0
  8082.         move.l    #-1,d1
  8083.         sub.l    a2,a2
  8084.         LNKLIB    AddGList,_IntuitionBase
  8085.  
  8086.         move.l    LogGadget(pc),a0        ; Let`s display em
  8087.         move.l    LogHandle(pc),a1
  8088.         sub.l    a2,a2
  8089.         moveq    #-1,d0
  8090.         DOLIB    RefreshGList
  8091.  
  8092.         move.l    LogHandle(pc),a0        ; Append menu to window
  8093.         move.l    LogMenu(pc),a1
  8094.         LNKLIB    SetMenuStrip,_IntuitionBase
  8095.  
  8096.         bsr    UnlockScreen
  8097.         unlk    a5
  8098.         bra.s    .GotLogWin
  8099. .LogWinErr    bsr    UnlockScreen
  8100.         unlk    a5
  8101.         bra    NoLogWin
  8102.  
  8103. .GotLogWin    lea    PurposeMsg(pc),a0        ; Clear old purpose
  8104.         lea    LogMsg(pc),a1            ; and log messages
  8105.         move.w    #(77*5)-1,d7
  8106. .Loop1        move.b    #0,(a0)+
  8107.         move.b    #0,(a1)+
  8108.         dbf    d7,.Loop1
  8109.  
  8110.         tst.b    OnlyLog                ; Enter a new LogMessage ?
  8111.         bne.s    DoOnlyLog
  8112.         move.l    LogHandle(pc),a0        ; Set window title for purpose
  8113.         lea    PurposeWinTitle(pc),a1
  8114.         move.l    #-1,a2
  8115.         DOLIB    SetWindowTitles
  8116.         bsr    CheckRevInput
  8117.         cmp.b    #2,LogInputEnd
  8118.         beq    NoErrorFound
  8119.         lea    PurposeMsg(pc),a3
  8120.         bsr    CopyMessage            ; Copy entered message
  8121.         bra.s    PurpDone
  8122.  
  8123. DoOnlyLog    move.l    LogHandle(pc),a0        ; Change to log title
  8124.         lea    LogWinTitle(pc),a1
  8125.         move.l    #-1,a2
  8126.         DOLIB    SetWindowTitles
  8127.         bsr    CheckRevInput
  8128.         cmp.b    #2,LogInputEnd
  8129.         beq    NoErrorFound
  8130.         lea    LogMsg(pc),a3
  8131.         bsr    CopyMessage            ; Copy entered message
  8132.  
  8133. PurpDone    bsr    CloseLogWin            ; Close input-window
  8134.  
  8135.         move.l    #Author,RevAuthorDat        ; Set strings to defaults
  8136.         move.l    #Company,RevCompanyDat
  8137.  
  8138.         move.l    #AuthorString,d1        ; Try to get Author env
  8139.         move.l    #Author,d2
  8140.         move.l    #128,d3
  8141.         move.l    #GVF_GLOBAL_ONLY,d4
  8142.         LNKLIB    GetVar,_DOSBase
  8143.         tst.l    d0
  8144.         bgt.s    GotAuthor
  8145.         move.l    #DefaultName,RevAuthorDat
  8146.  
  8147. GotAuthor    move.l    #CompanyString,d1        ; Try to get company env
  8148.         move.l    #Company,d2
  8149.         move.l    #128,d3
  8150.         move.l    #GVF_GLOBAL_ONLY,d4
  8151.         LNKLIB    GetVar,_DOSBase
  8152.         tst.l    d0
  8153.         bgt.s    GotCompany
  8154.         move.l    #DefaultName,RevCompanyDat
  8155.  
  8156. GotCompany    move.l    #8,d0
  8157.         lea    LogGads,a0
  8158.         bsr    GetGadgetPtr
  8159.         move.l    gg_SpecialInfo(a0),a0
  8160.         move.l    si_LongInt(a0),d0
  8161.         move.w    d0,RevRevisionDat
  8162.  
  8163.         move.l    #9,d0
  8164.         lea    LogGads,a0
  8165.         bsr    GetGadgetPtr
  8166.         move.l    gg_SpecialInfo(a0),a0
  8167.         move.l    si_LongInt(a0),d0
  8168.         move.w    d0,RevRevisionDat+2
  8169.  
  8170.         move.l    #FileName,d1            ; Open File
  8171.         move.l    d1,EasyArg
  8172.         move.l    #MODE_OLDFILE,d2
  8173.         LNKLIB    Open,_DOSBase
  8174.         move.l    d0,FileHand
  8175.         tst.l    d0
  8176.         beq    NoRevision
  8177.  
  8178.         move.l    #TempName,d1
  8179.         move.l    #MODE_NEWFILE,d2        ; Open temporaryfile
  8180.         DOLIB    Open
  8181.         move.l    d0,TempHand
  8182.         tst.l    d0
  8183.         beq    NoRevision
  8184.  
  8185.         tst.b    OnlyLog                ; Enter new LogMessage ?
  8186.         beq    WriteHeader
  8187.  
  8188. .Loop        move.l    FileHand(pc),d1            ; Seek for our header within
  8189.         move.l    ReadBuffer,d2            ; first 15 lines
  8190.         move.l    #READBUFFSIZE,d3
  8191.         DOLIB    FGets
  8192.         tst.l    d0
  8193.         ble    NoRevision
  8194.         move.l    TempHand(pc),d1            ; Store data unequal to header
  8195.         move.l    ReadBuffer,d2
  8196.         DOLIB    FPuts
  8197.         tst.l    d0
  8198.         blt    NoRevision
  8199.         move.l    RevHeader(pc),a0
  8200.         move.l    ReadBuffer(pc),a1
  8201.         moveq    #-1,d7
  8202.         bsr    StrCmp
  8203.         tst.l    d0
  8204.         beq.s    GotHeader
  8205.         bra    .Loop
  8206.  
  8207. GotHeader    moveq    #5,d7                ; Skip comming 6 lines
  8208.         bsr    RSkipLines
  8209.         tst.l    d0
  8210.         beq    NoRevision
  8211.         move.l    FileHand(pc),d1            ; Get line of current revision
  8212.         move.l    ReadBuffer,d2
  8213.         move.l    #READBUFFSIZE,d3
  8214.         DOLIB    FGets
  8215.         tst.l    d0
  8216.         ble    NoRevision
  8217.         tst.w    RevRevisionDat
  8218.         bne.s    UserRev
  8219.         tst.w    RevRevisionDat+2
  8220.         bne.s    UserRev
  8221.         move.l    ReadBuffer(pc),a4        ; Get address of major version value
  8222.         lea    23(a4),a4
  8223.         move.l    a4,a0
  8224. .Find        cmp.b    #'.',(a0)+            ; Find . separating major and minor revision
  8225.         beq.s    .GotIt
  8226.         bra    .Find
  8227. .GotIt        move.b    #0,-1(a0)
  8228.         move.l    a0,d1                ; Convert value to long
  8229.         move.l    ReadBuffer,d2
  8230.         addq.l    #4,d2
  8231.         DOLIB    StrToLong
  8232.         move.l    a4,d1
  8233.         move.l    ReadBuffer,d2
  8234.         DOLIB    StrToLong
  8235.         move.l    ReadBuffer(pc),a0
  8236.         move.l    (a0),d0
  8237.         move.l    4(a0),d1
  8238.         addq.l    #1,d1
  8239.         cmp.l    #100,d1                ; Over 100 ?
  8240.         bne.s    GotNewRev
  8241.         move.l    #0,d1
  8242.         addq.l    #1,d0
  8243. GotNewRev    move.w    d0,RevRevisionDat        ; Store major version value
  8244.         move.w    d1,RevRevisionDat+2        ; Store minor value
  8245. UserRev        move.l    RevRevision(pc),a0        ; Convert to new string
  8246.         lea    RevRevisionDat(pc),a1
  8247.         bsr    PrintF
  8248.         move.l    TempHand(pc),d1            ; Write new string
  8249.         move.l    ReadBuffer,d2
  8250.         DOLIB    FPuts
  8251.         tst.l    d0
  8252.         blt    NoRevision
  8253.         moveq    #3,d7                ; Skip the next 4 lines
  8254.         bsr    RSkipLines
  8255.         tst.l    d0
  8256.         blt    NoRevision
  8257. .Loop        move.l    FileHand(pc),d1            ; Skip purpose description
  8258.         move.l    ReadBuffer,d2
  8259.         move.l    #READBUFFSIZE,d3
  8260.         DOLIB    FGets
  8261.         tst.l    d0
  8262.         ble    NoRevision
  8263.         move.l    ReadBuffer(pc),a0
  8264.         bsr    StrLen
  8265.         cmp.l    #3,d0
  8266.         beq.s    .GotIt
  8267.         move.l    TempHand(pc),d1
  8268.         move.l    ReadBuffer,d2
  8269.         DOLIB    FPuts
  8270.         tst.l    d0
  8271.         blt    NoRevision
  8272.         bra    .Loop
  8273. .GotIt        move.l    RevLog(pc),a0            ; generate new log entry
  8274.         lea    RevRevisionDat(pc),a1
  8275.         bsr    PrintF
  8276.         move.l    TempHand(pc),d1
  8277.         move.l    ReadBuffer,d2
  8278.         DOLIB    FPuts
  8279.         tst.l    d0
  8280.         blt    NoRevision
  8281.         lea    LogMsg(pc),a4
  8282.         bsr    RWriteMessage            ; Write new logmessage
  8283.         tst.l    d0
  8284.         blt    NoRevision
  8285.         move.l    TempHand(pc),d1
  8286.         move.l    RevLineNL(pc),d2
  8287.         DOLIB    FPuts
  8288.         tst.l    d0
  8289.         blt    NoRevision
  8290.  
  8291. .LoopHeader    move.l    FileHand(pc),d1            ; Search for end of header
  8292.         move.l    ReadBuffer,d2
  8293.         move.l    #READBUFFSIZE,d3
  8294.         DOLIB    FGets
  8295.         tst.l    d0
  8296.         ble    NoRevision
  8297.         move.l    TempHand(pc),d1
  8298.         move.l    ReadBuffer,d2
  8299.         DOLIB    FPuts
  8300.         tst.l    d0
  8301.         blt    NoRevision
  8302.         move.l    RevEnd(pc),a0
  8303.         move.l    ReadBuffer(pc),a1
  8304.         moveq    #-1,d7
  8305.         bsr    StrCmp
  8306.         tst.l    d0
  8307.         beq.s    GotHeaderEnd
  8308.         bra    .LoopHeader
  8309. GotHeaderEnd    move.l    FileHand(pc),d1            ; Read next line,
  8310.         move.l    ReadBuffer,d2            ; following header
  8311.         move.l    #READBUFFSIZE,d3
  8312.         DOLIB    FGets
  8313.         tst.l    d0
  8314.         ble    NoRevision
  8315.         move.l    ReadBuffer(pc),a0
  8316.         bsr    StrLen
  8317.         move.l    FileHand(pc),d1            ; Reset filepointer to last read
  8318.         move.l    d0,d2                ; position
  8319.         neg.l    d2
  8320.         move.l    #OFFSET_CURRENT,d3
  8321.         DOLIB    Seek
  8322.         move.l    ReadBuffer(pc),a0        ; Did we read in a define ?
  8323.         move.l    RevDefine(pc),a1
  8324.         move.l    #12,d7
  8325.         bsr    StrCmp
  8326.         tst.l    d0
  8327.         bne    WriteRest            ; Nope -> go on
  8328. RemakeDefs    move.w    RevRevisionDat(pc),d0
  8329.         move.w    RevRevisionDat+2(pc),d1
  8330.         move.w    d0,RevDefineDat
  8331.         move.w    d1,RevDefineDat+2
  8332.         move.l    RevDefine(pc),a0        ; Write new define
  8333.         lea    RevDefineDat(pc),a1
  8334.         bsr    PrintF
  8335.         move.l    TempHand(pc),d1
  8336.         move.l    ReadBuffer,d2
  8337.         DOLIB    FPuts
  8338.         tst.l    d0
  8339.         blt    NoRevision
  8340.         moveq    #1,d7                ; Skip lines
  8341.         cmp.l    #AsmRevDefine1,RevDefine    ; Revise Asm source
  8342.         bne.s    NoAsmSkip
  8343.         add.l    #4,d7                ; skip one more line
  8344.         bra.s    DoSkip
  8345. NoAsmSkip    cmp.l    #PASRevDefine1,RevDefine
  8346.         bne.s    DoSkip
  8347.         addq.l    #1,d7
  8348. DoSkip        move.l    FileHand(pc),d1
  8349.         move.l    ReadBuffer,d2
  8350.         move.l    #READBUFFSIZE,d3
  8351.         DOLIB    FGets
  8352.         tst.l    d0
  8353.         ble    NoRevision
  8354.         dbf    d7,DoSkip
  8355.  
  8356.         bra    WriteRest            ; Append rest of file
  8357.  
  8358. WriteHeader    cmp.w    #0,RevRevisionDat
  8359.         bne.s    .UserDat
  8360.         cmp.w    #0,RevRevisionDat+2
  8361.         bne.s    .UserDat
  8362.         moveq    #1,d0
  8363.         moveq    #0,d1
  8364.         move.w    d0,RevRevisionDat
  8365.         move.w    d1,RevRevisionDat+2
  8366.  
  8367. .UserDat    move.l    TempHand(pc),d1            ; Write Header
  8368.         move.l    RevHeader(pc),d2
  8369.         DOLIB    FPuts
  8370.         tst.l    d0
  8371.         blt    NoRevision
  8372.         move.l    RevCompany(pc),a0        ; Convert company string
  8373.         lea    RevCompanyDat(pc),a1
  8374.         bsr    PrintF
  8375.         move.l    TempHand(pc),d1
  8376.         move.l    ReadBuffer,d2
  8377.         DOLIB    FPuts
  8378.         tst.l    d0
  8379.         blt    NoRevision
  8380.         move.l    RevFile(pc),a0            ; convert and write filename
  8381.         lea    RevFileDat(pc),a1
  8382.         bsr    PrintF
  8383.         move.l    TempHand(pc),d1
  8384.         move.l    ReadBuffer,d2
  8385.         DOLIB    FPuts
  8386.         tst.l    d0
  8387.         blt    NoRevision
  8388.         move.l    RevCreatedOn(pc),a0        ; do creation date
  8389.         lea    RevCreatedOnDat(pc),a1
  8390.         bsr    PrintF
  8391.         move.l    TempHand(pc),d1
  8392.         move.l    ReadBuffer,d2
  8393.         DOLIB    FPuts
  8394.         tst.l    d0
  8395.         blt    NoRevision
  8396.         move.l    RevAuthor(pc),a0        ; do author
  8397.         lea    RevAuthorDat(pc),a1
  8398.         bsr    PrintF
  8399.         move.l    TempHand(pc),d1
  8400.         move.l    ReadBuffer,d2
  8401.         DOLIB    FPuts
  8402.         tst.l    d0
  8403.         blt    NoRevision
  8404.         move.l    RevRevision(pc),a0        ; Do initial revision
  8405.         lea    RevRevisionDat(pc),a1
  8406.         bsr    PrintF
  8407.         move.l    TempHand(pc),d1
  8408.         move.l    ReadBuffer,d2
  8409.         DOLIB    FPuts
  8410.         tst.l    d0
  8411.         blt    NoRevision
  8412.         move.l    TempHand(pc),d1            ; Write purpose header
  8413.         move.l    RevPurpose(pc),d2
  8414.         DOLIB    FPuts
  8415.         tst.l    d0
  8416.         blt    NoRevision
  8417.         lea    PurposeMsg(pc),a4        ; Write purpose message
  8418.         bsr    RWriteMessage
  8419.         tst.l    d0
  8420.         blt    NoRevision
  8421.         move.l    RevLogInit(pc),a0
  8422.         lea    RevRevisionDat(pc),a1
  8423.         bsr    PrintF
  8424.         move.l    TempHand(pc),d1            ; Write initial log message
  8425.         move.l    ReadBuffer,d2
  8426.         DOLIB    FPuts
  8427.         tst.l    d0
  8428.         blt    NoRevision
  8429.         move.w    RevRevisionDat(pc),d0
  8430.         move.w    RevRevisionDat+2(pc),d1
  8431.         move.w    d0,RevDefineDat
  8432.         move.w    d1,RevDefineDat+2
  8433.         move.l    RevDefine(pc),a0        ; Write initial define
  8434.         lea    RevDefineDat(pc),a1
  8435.         bsr    PrintF
  8436.         move.l    TempHand(pc),d1
  8437.         move.l    ReadBuffer,d2
  8438.         DOLIB    FPuts
  8439.         tst.l    d0
  8440.         blt    NoRevision
  8441.  
  8442. WriteRest    move.l    TempHand(pc),d1            ; Write the remaining part of file
  8443.         DOLIB    Flush
  8444.         move.l    FileHand(pc),d1
  8445.         DOLIB    Flush
  8446. .Loop        move.l    FileHand(pc),d1            ; Read a maximum of 4096 bytes
  8447.         move.l    ReadBuffer,d2
  8448.         move.l    #READBUFFSIZE,d3
  8449.         DOLIB    Read
  8450.         tst.l    d0
  8451.         beq.s    RestWritten            ; End of file -> go on
  8452.         blt    NoRevision            ; Error -> quit
  8453.         move.l    d0,d3
  8454.         move.l    TempHand(pc),d1            ; Write buffer to temp file
  8455.         move.l    ReadBuffer,d2
  8456.         DOLIB    Write
  8457.         tst.l    d0
  8458.         ble    NoRevision
  8459.         bra    .Loop
  8460.  
  8461. RestWritten    move.l    TempHand(pc),d1            ; Close files
  8462.         LNKLIB    Close,_DOSBase
  8463.         move.l    FileHand(pc),d1
  8464.         DOLIB    Close
  8465.  
  8466.         move.l    #0,TempHand
  8467.         move.l    #0,FileHand
  8468.  
  8469.         move.l    #FileName,d1            ; Copy file back
  8470.         move.l    d1,EasyArg
  8471.         move.l    #MODE_NEWFILE,d2
  8472.         DOLIB    Open
  8473.         move.l    d0,FileHand
  8474.         tst.l    d0
  8475.         beq.s    NoRevision
  8476.  
  8477.         move.l    #TempName,d1
  8478.         move.l    d1,EasyArg
  8479.         move.l    #MODE_OLDFILE,d2
  8480.         DOLIB    Open
  8481.         move.l    d0,TempHand
  8482.         tst.l    d0
  8483.         beq.s    NoRevision
  8484.  
  8485. .Loop        move.l    TempHand(pc),d1            ; Read in 4096 bytes
  8486.         move.l    ReadBuffer,d2
  8487.         move.l    #READBUFFSIZE,d3
  8488.         DOLIB    Read
  8489.         tst.l    d0                ; 0 read -> end it
  8490.         beq.s    NoErrorFound
  8491.         blt.s    NoRevision
  8492.         move.l    d0,d3                ; Store read bytes to new file
  8493.         move.l    FileHand(pc),d1
  8494.         move.l    ReadBuffer,d2
  8495.         DOLIB    Write
  8496.         tst.l    d0
  8497.         blt.s    NoRevision
  8498.         bra    .Loop
  8499.  
  8500. NoRevision    LNKLIB    IoErr,_DOSBase            ; Get error number
  8501.         tst.l    d0
  8502.         beq.s    NoErrorFound
  8503.         move.l    d0,ErrorNum
  8504.         bsr    DisplayError            ; Display error
  8505.  
  8506.         moveq    #0,d7
  8507.         bra.s    GotError
  8508. NoErrorFound    moveq    #1,d7
  8509. GotError    move.l    #TempName,d1            ; Delete file, if possible
  8510.         LNKLIB    DeleteFile,_DOSBase
  8511.         tst.l    TempHand            ; Close files
  8512.         beq.s    NoTempFile
  8513.         move.l    TempHand(pc),d1
  8514.         DOLIB    Close
  8515.         move.l    #TempName,d1            ; Delete file, if possible
  8516.         DOLIB    DeleteFile
  8517. NoTempFile    tst.l    FileHand            ; Close input handle
  8518.         beq.s    NoLogWin
  8519.         move.l    FileHand(pc),d1
  8520.         DOLIB    Close
  8521. NoLogWin    tst.l    OurLock
  8522.         beq.s    .NoLock
  8523.         move.l    PastLock(pc),d1
  8524.         LNKLIB    CurrentDir,_DOSBase
  8525.         move.l    OurLock(pc),d1
  8526.         DOLIB    UnLock
  8527. .NoLock        move.l    #0,FileHand
  8528.         move.l    #0,TempHand
  8529.         bsr    CloseLogWin            ; Close our window (AGAIN ???)
  8530.  
  8531. .NoPort        move.l    ARexxAction(pc),d1
  8532.         and.l    #RXFF_RESULT,d1
  8533.         beq.s    .End
  8534.         cmp.b    #2,LogInputEnd
  8535.         bne.s    .NoCancel
  8536.         lea    FalseStr(pc),a0            ; Create BOOL for error
  8537.         bsr    StrLen
  8538.         LNKLIB    CreateArgstring,_RexxSysBase
  8539.         tst.l    d0
  8540.         beq.s    .End
  8541.         move.l    d0,AResult2
  8542.         bra.s    .End
  8543. .NoCancel    lea    TrueStr(pc),a0            ; Create BOOL for ok
  8544.         bsr    StrLen
  8545.         LNKLIB    CreateArgstring,_RexxSysBase
  8546.         tst.l    d0
  8547.         beq.s    .End
  8548.         move.l    d0,AResult2
  8549.  
  8550. .End        move.l    d7,d0
  8551.         move.l    d0,-(sp)
  8552.         move.l    WndHandle,a0
  8553.         bsr    UnBusy
  8554.         move.l    PrefsHandle(pc),a0
  8555.         bsr    UnBusy
  8556. .Loop        move.l    TimerPort(pc),a0        ; All outstanding messages
  8557.         CALLSYS    GetMsg                ; on timer-port removed
  8558.         tst.l    d0
  8559.         beq.s    .Final
  8560.         bra.s    .Loop
  8561. .Final        move.l    (sp)+,d0
  8562.         move.b    #1,TimeReset
  8563.         rts
  8564.  
  8565.  
  8566.  
  8567. **********************************************************************
  8568. *           Checks for inputs from Purpose/Log msg window            *
  8569. **********************************************************************
  8570. CheckRevInput    move.b    #0,LogInputEnd            ; Set end flag for quit
  8571. LoopLog        tst.b    LogInputEnd            ; Are we to quit
  8572.         bne    LogInputOver
  8573.         move.l    LogHandle(pc),a0        ; Wait for a message
  8574.         move.l    wd_UserPort(a0),a0
  8575.         CALLSYS    WaitPort
  8576. LoopLogMsg    move.l    LogHandle(pc),a0        ; get it
  8577.         move.l    wd_UserPort(a0),a0
  8578.         CALLSYS    GetMsg
  8579.         tst.l    d0
  8580.         beq.s    LoopLog
  8581.         move.l    d0,a1
  8582.         move.l    im_Class(a1),d6
  8583.         move.l    im_IAddress(a1),a4
  8584.         move.w    gg_GadgetID(a4),d7
  8585.         move.w    im_Code(a1),d5
  8586.         cmp.w    #'a',d5
  8587.         blt.s    .End
  8588.         and.w    #~$20,d5
  8589. .End        DOLIB    ReplyMsg
  8590.  
  8591.         cmp.l    #IDCMP_ACTIVEWINDOW,d6        ; Window activated ?
  8592.         bne.s    LogWinInAct
  8593.         move.l    LogGadget(pc),a0        ; Activate first str gadget
  8594.         move.l    gg_NextGadget(a0),a0
  8595.         move.l    LogHandle(pc),a1
  8596.         sub.l    a2,a2
  8597.         LNKLIB    ActivateGadget,_IntuitionBase
  8598.         bra    LoopLogMsg
  8599.  
  8600. LogWinInAct    cmp.l    #IDCMP_GADGETUP,d6        ; Gadget released
  8601.         bne.s    LogNoGadUp
  8602.         cmp.w    #6,d7                ; Ok gadget ?
  8603.         bne.s    LogNoOk
  8604.         move.b    #1,LogInputEnd            ; Yep -> quit input
  8605.         bra.s    LoopLogMsg
  8606. LogNoOk        cmp.w    #7,d7                ; Cancel gadget ?
  8607.         bne.s    LoopLogMsg
  8608.         move.b    #2,LogInputEnd
  8609.         bra    LoopLogMsg
  8610.  
  8611. LogNoGadUp    cmp.l    #IDCMP_VANILLAKEY,d6        ; Keypress ?
  8612.         bne.s    LogNoVKey
  8613.         cmp.w    #OKKEY,d5            ; o pressed ?
  8614.         bne.s    LogNoOkKey
  8615. LogOK        move.b    #1,LogInputEnd            ; quit
  8616.         move.l    #6,d0
  8617.         bra.s    LogFeedBack
  8618. LogNoOkKey    cmp.w    #ESCKEY,d5            ; Cancel ?
  8619.         beq.s    LogCancel
  8620.         cmp.w    #CANCELKEY,d5            ; c pressed ?
  8621.         bne    LoopLogMsg
  8622. LogCancel    move.b    #2,LogInputEnd
  8623.         moveq    #7,d0
  8624. LogFeedBack    tst.l    d0
  8625.         beq    LoopLogMsg
  8626.         lea    LogGads,a0
  8627.         move.l    LogHandle,a5
  8628.         bsr    ButtonCheck
  8629.         bra    LoopLogMsg
  8630.  
  8631. LogNoVKey    cmp.l    #IDCMP_MENUPICK,d6        ; Picked a menu ?
  8632.         bne.s    NoLogMenu
  8633.         cmp.w    #-1,d5
  8634.         beq.s    EndLogMenu
  8635.         move.w    d5,d2
  8636.         and.w    #$1f,d2                ; Get menunumber
  8637.         move.w    d5,d1
  8638.         asr.w    #5,d1
  8639.         and.w    #$3f,d1                ; Get itemnumber
  8640.         move.l    LogMenu,a1
  8641.         bsr    GetMenuPtr
  8642.         GTMENUITEM_USERDATA a2,a0
  8643.         cmp.l    #0,a0
  8644.         beq.s    EndLogMenu
  8645.         jmp    (a0)
  8646. EndLogMenu    bra    LoopLogMsg
  8647.  
  8648. NoLogMenu    cmp.l    #IDCMP_CHANGEWINDOW,d6        ; Window moved ?
  8649.         bne    LoopLogMsg
  8650.         move.l    LogHandle(pc),a0        ; Store new position
  8651.         lea    LogWinDef(pc),a1
  8652.         bsr    StoreWinPos
  8653.         bra    LoopLogMsg
  8654. LogInputOver    rts
  8655.  
  8656.  
  8657.  
  8658.  
  8659.  
  8660. **********************************************************************
  8661. *                    Checks for existing revision                    *
  8662. **********************************************************************
  8663. CheckRevision    move.l    #FileName,d1            ; Try to open file
  8664.         move.l    #MODE_OLDFILE,d2
  8665.         move.l    d1,EasyArg
  8666.         LNKLIB    Open,_DOSBase
  8667.         move.l    d0,FileHand
  8668.         tst.l    d0
  8669.         beq.s    FileNotFound
  8670.  
  8671.         moveq    #14,d7
  8672. CheckLines    move.l    FileHand(pc),d1            ; Search for our header
  8673.         move.l    ReadBuffer,d2            ; within the first 15 lines
  8674.         move.l    #READBUFFSIZE,d3
  8675.         DOLIB    FGets
  8676.         tst.l    d0
  8677.         beq.s    FileError
  8678.         blt.s    FileNotFound
  8679.         move.l    RevHeader(pc),a0
  8680.         move.l    ReadBuffer(pc),a1
  8681.         moveq    #-1,d7
  8682.         bsr    StrCmp                ; current line our header ?
  8683.         tst.l    d0
  8684.         beq.s    IsMine                ; Yep -> go on
  8685.         dbf    d7,CheckLines            ; Loop
  8686. FileError    moveq    #0,d7                ; Nothing found
  8687.         bra.s    EndCheckRev
  8688. IsMine        moveq    #1,d7                ; Got it
  8689.         bra.s    EndCheckRev
  8690. FileNotFound    moveq    #-1,d7
  8691. EndCheckRev    move.b    d7,OnlyLog            ; store flag
  8692.         tst.l    FileHand            ; Close file again
  8693.         beq.s    .End
  8694.         move.l    FileHand(pc),d1
  8695.         DOLIB    Close
  8696.         move.l    #0,FileHand
  8697. .End        rts
  8698.  
  8699.  
  8700.  
  8701.  
  8702. **********************************************************************
  8703. *                      Skip the following bytes                      *
  8704. **********************************************************************
  8705. RSkipLines    move.l    FileHand(pc),d1            ; Read line
  8706.         move.l    ReadBuffer,d2
  8707.         move.l    #READBUFFSIZE,d3
  8708.         DOLIB    FGets
  8709.         tst.l    d0
  8710.         ble.s    .Error
  8711.         move.l    TempHand(pc),d1            ; Store line
  8712.         move.l    ReadBuffer,d2
  8713.         DOLIB    FPuts
  8714.         tst.l    d0
  8715.         blt.s    .Error
  8716.         dbf    d7,RSkipLines            ; Loop
  8717.         moveq    #1,d0
  8718.         rts
  8719. .Error        moveq    #0,d0
  8720.         rts
  8721.  
  8722.  
  8723.  
  8724.  
  8725.  
  8726. **********************************************************************
  8727. *                 Writes Log/Purpose message to file                 *
  8728. **********************************************************************
  8729. RWriteMessage    moveq    #4,d7                ; Now loop for message lines
  8730. .LoopPurp    tst.b    (a4)                ; line ok ?
  8731.         beq.s    .EndPurp
  8732.         move.l    TempHand(pc),d1            ; Write initial chars
  8733.         move.l    RevLine(pc),d2
  8734.         DOLIB    FPuts
  8735.         tst.l    d0
  8736.         blt.s    .Error
  8737.         move.l    a4,a0
  8738.         bsr    StrLen
  8739.         move.b    #$0a,0(a0,d0)
  8740.         move.l    TempHand(pc),d1
  8741.         move.l    a4,d2
  8742.         DOLIB    FPuts
  8743.         tst.l    d0
  8744.         blt.s    .Error
  8745. .EndPurp    lea    77(a4),a4            ; Loop
  8746.         dbf    d7,.LoopPurp
  8747. .Error        rts
  8748.  
  8749.  
  8750.  
  8751.  
  8752. **********************************************************************
  8753. *              Copy message eneterd to desired location              *
  8754. **********************************************************************
  8755. CopyMessage    move.l    LogGadget(pc),a2        ; Copy contents of string gads
  8756.         move.l    gg_NextGadget(a2),a2
  8757.         moveq    #4,d7                ; Loop for 5 gadgets
  8758. .Loop        move.l    gg_SpecialInfo(a2),a0
  8759.         move.l    si_Buffer(a0),a0
  8760.         move.l    a0,a4
  8761.         move.l    a3,a1
  8762.         bsr    StrCpy                ; Copy string to buffer
  8763.         move.l    gg_NextGadget(a2),a2
  8764.         lea    77(a3),a3            ; Next buffer
  8765.         move.b    #0,(a4)                ; Clear string
  8766.         dbf    d7,.Loop
  8767.         move.l    LogGadget(pc),a0        ; Redisplay str gadgets
  8768.         move.l    LogHandle(pc),a1        ; with empty boxes
  8769.         sub.l    a2,a2
  8770.         moveq    #-1,d0
  8771.         LNKLIB    RefreshGList,_IntuitionBase
  8772.         rts
  8773.  
  8774.  
  8775.  
  8776.  
  8777. **********************************************************************
  8778. *                 Deletes our environment variables                  *
  8779. **********************************************************************
  8780. DeleteEnvs    move.l    #EnvDayString,d1
  8781.         move.l    #GVF_GLOBAL_ONLY,d2
  8782.         LNKLIB    DeleteVar,_DOSBase
  8783.         move.l    #EnvDateString,d1
  8784.         move.l    #GVF_GLOBAL_ONLY,d2
  8785.         DOLIB    DeleteVar
  8786.         move.l    #EnvTimeString,d1
  8787.         move.l    #GVF_GLOBAL_ONLY,d2
  8788.         DOLIB    DeleteVar
  8789.         rts
  8790.  
  8791.  
  8792.  
  8793.  
  8794.  
  8795. **********************************************************************
  8796. *           Display Msg that only to be run under Kick2.x            *
  8797. **********************************************************************
  8798. OnlyKick20    tst.l    _ArgC                ; Did we come from WB ?
  8799.         beq.s    .FromWB                ; Yep -> display requester
  8800.  
  8801.         move.l    _stdout(pc),d1            ; Get Consolehandle
  8802.         move.l    #Only20Txt,d2
  8803.         move.l    #Only20TxtEnd-Only20Txt,d3
  8804.         LNKLIB    Write,_DOSBase            ; Write msg
  8805.         rts
  8806. .FromWB        lea    IntName(pc),a1            ; try to open IntBase
  8807.         moveq    #0,d0
  8808.         CALLSYS    OpenLibrary
  8809.         tst.l    d0
  8810.         beq.s    OnlyKick20Ret
  8811.         move.l    d0,_IntuitionBase
  8812.  
  8813.         sub.l    a0,a0                ; Display requester
  8814.         lea    Only20ITxt(pc),a1
  8815.         lea    OkITxt(pc),a2
  8816.         move.l    a2,a3
  8817.         move.l    #0,d0
  8818.         move.l    #0,d1
  8819.         move.l    #300,d2
  8820.         move.l    #60,d3
  8821.         LNKLIB    AutoRequest,_IntuitionBase
  8822. OnlyKick20Ret    rts
  8823.  
  8824.  
  8825.  
  8826.  
  8827. **********************************************************************
  8828. *                          Display an error                          *
  8829. **********************************************************************
  8830. DisplayError    tst.l    ErrorNum
  8831.         bge.s    .GoOn
  8832.         rts
  8833. .GoOn        move.l    ErrorNum(pc),d0            ; Get error num
  8834.         cmp.l    #2,d0                ; Is it the broker set up error ?
  8835.         bne.s    NoDoubleMean            ; Nope -> go on
  8836.         tst.l    DoublePort            ; Did we already had a port ?
  8837.         beq.s    NoDoubleMean            ; Nope -> go on
  8838.         rts
  8839. NoDoubleMean    cmp.l    #200,d0                ; Display DOS error ?
  8840.         blt.s    .OurError            ; Nope -> go on
  8841.         sub.l    #200,d0
  8842.         asl.l    #2,d0
  8843.         lea    DosErrors(pc),a0
  8844.         move.l    0(a0,d0),a0            ; Get dos error
  8845.         bra.s    .DosError
  8846.  
  8847. .OurError    lea    EasyTexts(pc),a0
  8848.         asl.l    #2,d0
  8849.         move.l    0(a0,d0),a0            ; get adr of error-txt
  8850. .DosError    lea    MyEasyRequest(pc),a1        ; Display Easy-Requester
  8851.         move.l    #EasyTitle,es_Title(a1)
  8852.         move.l    a0,es_TextFormat(a1)
  8853.         move.l    #EasyGadget,es_GadgetFormat(a1)
  8854.         sub.l    a0,a0
  8855.         sub.l    a2,a2
  8856.         lea    EasyArg(pc),a3
  8857.         LNKLIB    EasyRequestArgs,_IntuitionBase
  8858.         move.l    #-1,ErrorNum
  8859.         move.l    #0,EasyArg
  8860.         rts
  8861.  
  8862.  
  8863. **********************************************************************
  8864. *                        Compare two strings                         *
  8865. **********************************************************************
  8866. StrCmp        moveq    #0,d0
  8867.         moveq    #0,d1
  8868.         movem.l    a0/a1,-(sp)            ; Store pointers
  8869. .Loop        move.b    (a0)+,d0            ; get chars
  8870.         move.b    (a1)+,d1
  8871.         tst.b    d0                ; Source string ended ?
  8872.         beq.s    .EndSrc                ; yep -> final check
  8873.         cmp.b    #$0a,d0                ; a newline ?
  8874.         beq.s    .EndSrc                ; yep -> final check
  8875.         or.b    #$20,d0                ; make case-insensitive
  8876.         or.b    #$20,d1
  8877.         cmp.b    d0,d1                ; equal ?
  8878.         bne.s    .Invalid
  8879.         dbf    d7,.Loop
  8880.         movem.l    (sp)+,a0/a1
  8881.         moveq    #0,d0
  8882.         rts
  8883. .Invalid    moveq    #1,d0                ; Error flag
  8884.         movem.l    (sp)+,a0/a1
  8885.         rts
  8886. .EndSrc        cmp.b    d0,d1                ; last chars equal ?
  8887.         bne.s    .Invalid            ; Nope -> error
  8888.         moveq    #0,d0                ; a ok
  8889.         movem.l    (sp)+,a0/a1
  8890.         rts
  8891.  
  8892.  
  8893.  
  8894. **********************************************************************
  8895. *                           Copy a string                            *
  8896. **********************************************************************
  8897. StrCpy        move.b    (a0)+,d0
  8898.         move.b    d0,(a1)+
  8899.         tst.b    d0
  8900.         beq.s    .End
  8901.         bra.s    StrCpy
  8902. .End        rts
  8903.  
  8904.  
  8905.  
  8906.  
  8907. **********************************************************************
  8908. *                          Concat 2 string                           *
  8909. **********************************************************************
  8910. StrCat        tst.b    (a1)+
  8911.         beq.s    .Loop
  8912.         bra    StrCat
  8913. .Loop        subq.l    #1,a1
  8914.         bra    StrCpy
  8915.  
  8916.  
  8917.  
  8918.  
  8919. **********************************************************************
  8920. *            Copy a string up to x chars or end of string            *
  8921. **********************************************************************
  8922. StrNCpy        move.b    (a0)+,d0
  8923.         move.b    d0,(a1)+
  8924.         tst.b    d0
  8925.         beq.s    .End
  8926.         dbf    d7,StrNCpy
  8927. .End        rts
  8928.  
  8929.  
  8930.  
  8931. **********************************************************************
  8932. *                      Calc length of a string                       *
  8933. **********************************************************************
  8934. StrLen        move.l    a0,-(sp)
  8935.         moveq    #0,d0
  8936. .Loop        tst.b    (a0)+
  8937.         beq.s    .End
  8938.         addq.w    #1,d0
  8939.         bne.s    .Loop
  8940. .End        move.l    (sp)+,a0
  8941.         rts
  8942.  
  8943.  
  8944.  
  8945. **********************************************************************
  8946. *                  Just skip the blanks in a string                  *
  8947. **********************************************************************
  8948. SkipBlanks    cmp.b    #' ',(a0)            ; Loop while there are spaces
  8949.         beq.s    .NoEnd                ; and tabs
  8950.         cmp.b    #$09,(a0)
  8951.         beq.s    .NoEnd
  8952.         cmp.b    #'"',(a0)
  8953.         beq.s    .NoEnd
  8954.         cmp.b    #"'",(a0)
  8955.         beq.s    .NoEnd
  8956.         tst.b    (a0)
  8957.         beq.s    .GotEnd
  8958.         bra.s    .GotEnd
  8959. .NoEnd        addq.l    #1,a0
  8960.         bra.s    SkipBlanks
  8961. .GotEnd        rts
  8962.  
  8963.  
  8964.  
  8965. **********************************************************************
  8966. *                           Just a printf                            *
  8967. **********************************************************************
  8968. PrintF        movem.l    RegsAll,-(sp)
  8969.         lea    PutChProc(pc),a2
  8970.         move.l    ReadBuffer(pc),a3
  8971.         CALLSYS    RawDoFmt
  8972.         movem.l    (sp)+,RegsAll
  8973.         rts
  8974.  
  8975.  
  8976. **********************************************************************
  8977. *                      Small dummy for RawDoFmt                      *
  8978. **********************************************************************
  8979. PutChProc    move.b    d0,(a3)+
  8980.         rts
  8981.  
  8982.  
  8983. **********************************************************************
  8984. *                         Enable the broker                          *
  8985. **********************************************************************
  8986. EnableBroker    movem.l    RegsAll,-(sp)
  8987.         tst.b    Disabled            ; Don`t enable when disabled
  8988.         bne.s    .End
  8989.         move.l    MyBroker(pc),a0
  8990.         moveq    #1,d0
  8991.         LNKLIB    ActivateCxObj,_CxBase
  8992.         bsr    OnScreen
  8993.         bsr    OnMouse
  8994. .End        movem.l    (sp)+,RegsAll
  8995.         rts
  8996.  
  8997.  
  8998.  
  8999. **********************************************************************
  9000. *                        Disable broker again                        *
  9001. **********************************************************************
  9002. DisableBroker    movem.l    RegsAll,-(sp)
  9003.         tst.b    Disabled
  9004.         bne.s    .End
  9005.         move.l    MyBroker(pc),a0
  9006.         moveq    #0,d0
  9007.         LNKLIB    ActivateCxObj,_CxBase
  9008.         bsr    OnScreen
  9009.         bsr    OnMouse
  9010. .End        movem.l    (sp)+,RegsAll
  9011.         rts
  9012.  
  9013.  
  9014.  
  9015. **********************************************************************
  9016. *                      Set new window positions                      *
  9017. **********************************************************************
  9018. GetWinPos    move.l    ReadBuffer(pc),a4
  9019.         move.l    a4,a5
  9020. .FindSlash    tst.b    (a5)                ; If there was no / in pos -> quit
  9021.         beq.s    .NoWinPos
  9022.         cmp.b    #'/',(a5)+
  9023.         beq.s    .GotSlash
  9024.         bra    .FindSlash
  9025. .GotSlash    move.b    #0,-1(a5)            ; Remove slash with 0
  9026.         move.l    a4,d1                ; a4 = String XPos / a5 = YPos
  9027.         move.l    #WinLeftEdge,d2            ; Get offset
  9028.         LNKLIB    StrToLong,_DOSBase
  9029.         tst.l    d1
  9030.         blt.s    .LError
  9031.         tst.l    d0                ; If coord is > 0 -> go on
  9032.         bge.s    .WinSLOk
  9033. .LError        move.l    #0,WinLeftEdge            ; Set to 0
  9034. .WinSLOk    move.l    a5,d1
  9035.         move.l    #WinTopEdge,d2            ; Get Y offset
  9036.         DOLIB    StrToLong,_DOSBase
  9037.         tst.l    d1
  9038.         blt.s    .TError
  9039.         tst.l    d0
  9040.         bge.s    .WinSTOk
  9041. .TError        move.l    #0,WinTopEdge            ; Set to 0 if specified < 0
  9042. .WinSTOk    moveq    #1,d0
  9043.         rts
  9044. .NoWinPos    moveq    #0,d0
  9045.         rts
  9046.  
  9047.  
  9048.  
  9049.  
  9050.  
  9051. **********************************************************************
  9052. *      Adjusts the window so that it will reside within screen       *
  9053. **********************************************************************
  9054. AdjustWinPos    move.w    nw_LeftEdge(a0),d0        ; Get position where window might "end"
  9055.         move.w    nw_TopEdge(a0),d1
  9056.         add.w    nw_Width(a0),d0
  9057.         add.w    nw_Height(a0),d1
  9058.  
  9059.         move.w    sc_Width(a1),d2
  9060.         move.w    sc_Height(a1),d3
  9061.         cmp.w    d0,d2
  9062.         bge.s    .LOk
  9063.         sub.w    nw_Width(a0),d2            ; readjust left edge
  9064.         move.w    d2,nw_LeftEdge(a0)
  9065. .LOk        cmp.w    d1,d3
  9066.         bge.s    .ROk
  9067.         sub.w    nw_Height(a0),d3        ; readjust top edge
  9068.         move.w    d3,nw_TopEdge(a0)
  9069. .ROk        rts
  9070.  
  9071.  
  9072.  
  9073.  
  9074.  
  9075.  
  9076. **********************************************************************
  9077. *           Store new position of window within NewWindow            *
  9078. **********************************************************************
  9079. StoreWinPos    move.w    wd_LeftEdge(a0),nw_LeftEdge(a1)
  9080.         move.w    wd_TopEdge(a0),nw_TopEdge(a1)
  9081.         rts
  9082.  
  9083.  
  9084.  
  9085. **********************************************************************
  9086. *       Remake the CheckBox ticks if the main window is open         *
  9087. **********************************************************************
  9088. RemakeGadgets    move.b    DoActivate(pc),d0        ; Set checkbox-ticks
  9089.         move.l    #ACTIGAD,d1            ; according to modes
  9090.         bsr    SetControlBox
  9091.         move.b    MouseMode(pc),d0
  9092.         move.l    #MODEGAD,d1
  9093.         bsr    SetControlBox
  9094.         move.b    ShowClock(pc),d0
  9095.         move.l    #DISPLAYGAD,d1
  9096.         bsr    SetControlBox
  9097.         move.b    ClockWin(pc),d0
  9098.         move.l    #WINDOWGAD,d1
  9099.         bsr    SetControlBox
  9100.         move.b    ShowSecs(pc),d0
  9101.         move.l    #SECSGAD,d1
  9102.         bsr    SetControlBox
  9103.         move.b    AmiDate(pc),d0
  9104.         move.l    #AMIGAD,d1
  9105.         bsr    SetControlBox
  9106.         move.b    ShowDay(pc),d0
  9107.         move.l    #DAYGAD,d1
  9108.         bsr    SetControlBox
  9109.         move.b    ShowDate(pc),d0
  9110.         move.l    #DATEGAD,d1
  9111.         bsr    SetControlBox
  9112.         move.b    ShortDay(pc),d0
  9113.         move.l    #SHORTGAD,d1
  9114.         bsr    SetControlBox
  9115.         move.b    DoAlarm(pc),d0
  9116.         move.l    #ALARMMODEGAD,d1
  9117.         bsr    SetControlBox
  9118.         move.b    SetEnv(pc),d0
  9119.         move.l    #ENVGAD,d1
  9120.         bsr    SetControlBox
  9121.         move.b    CycleWin(pc),d0
  9122.         move.l    #CYCLEGAD,d1
  9123.         bsr    SetControlBox
  9124.         move.b    KeyClick(pc),d0
  9125.         move.l    #CLICKGAD,d1
  9126.         bsr    SetControlBox
  9127.         move.b    WBFront(pc),d0
  9128.         move.l    #WBFRONTGAD,d1
  9129.         bsr.s    SetControlBox
  9130.         move.b    LeftyMouse(pc),d0
  9131.         move.l    #LEFTYGAD,d1
  9132.         bsr.s    SetControlBox
  9133.         move.b    ESCClose(pc),d0
  9134.         move.l    #WESCGAD,d1
  9135.         bsr.s    SetControlBox
  9136.         move.b    MapUmlaut(pc),d0
  9137.         move.l    #UMLAUTGAD,d1
  9138.         bsr.s    SetControlBox
  9139.         rts
  9140.  
  9141.  
  9142.  
  9143.  
  9144.  
  9145. **********************************************************************
  9146. *               Give visual feedback for button press                *
  9147. * D0 = Number of gadget                                              *
  9148. * A0 = Pointer to first gadget                                       *
  9149. * A5 = Pointer to window                                             *
  9150. **********************************************************************
  9151. ButtonCheck    movem.l    RegsAll,-(sp)
  9152.         cmp.l    #0,a5
  9153.         beq.s    .End
  9154.         bsr    GetGadgetPtr
  9155.         move.l    a0,a4
  9156.         or.w    #GFLG_SELECTED,gg_Flags(a4)
  9157.         move.l    a4,a0
  9158.         move.l    a5,a1
  9159.         sub.l    a2,a2
  9160.         moveq    #1,d0
  9161.         LNKLIB    RefreshGList,_IntuitionBase
  9162.         moveq    #5,d1
  9163.         LNKLIB    Delay,_DOSBase
  9164.         and.w    #~GFLG_SELECTED,gg_Flags(a4)
  9165.         move.l    a4,a0
  9166.         move.l    a5,a1
  9167.         sub.l    a2,a2
  9168.         moveq    #1,d0
  9169.         LNKLIB    RefreshGList,_IntuitionBase
  9170. .End        movem.l    (sp)+,RegsAll
  9171.         rts
  9172.  
  9173.  
  9174.  
  9175.  
  9176.  
  9177. **********************************************************************
  9178. *     Only a small dummy for shorter access to ControlCheckGads      *
  9179. * D0 = CheckBox mode                                                 *
  9180. * D1 = Number of gadget                                              *
  9181. **********************************************************************
  9182. SetControlBox    movem.l    d0-d1,-(sp)
  9183.         lea    ControlGads,a0
  9184.         move.l    WndHandle,a1
  9185.         bsr.s    SetCheckBox
  9186.         movem.l    (sp)+,d0-d1
  9187.         subq.l    #1,d1
  9188.         moveq    #1,d2
  9189.         bra.s    SetControlMenu
  9190.  
  9191.  
  9192. **********************************************************************
  9193. *                 Set a checkbox to specified value                  *
  9194. * D0 = Mode                                                          *
  9195. * D1 = Number of gadget                                              *
  9196. * A0 = Address of GadgetList                                         *
  9197. * A1 = Address of window                                             *
  9198. **********************************************************************
  9199. SetCheckBox    movem.l    RegsAll,-(sp)
  9200.         cmp.l    #0,a1
  9201.         beq.s    .End
  9202.         and.l    #$000000ff,d0
  9203.         move.l    d0,SelectMode            ; Set tag state
  9204.         move.l    d1,d0
  9205.         bsr    GetGadgetPtr
  9206.         sub.l    a2,a2
  9207.         lea    CheckBoxTags(pc),a3        ; Set new gadget attributes
  9208.         LNKLIB    GT_SetGadgetAttrsA,_GadToolsBase
  9209. .End        movem.l    (sp)+,RegsAll
  9210.         rts
  9211.  
  9212.  
  9213.  
  9214. **********************************************************************
  9215. *                    Get a pointer to a menuitem                     *
  9216. * A1 = Pointer to menustrip                                          *
  9217. * D1 = ItemNumber                                                    *
  9218. * D2 = MenuNumber                                                    *
  9219. **********************************************************************
  9220. GetMenuPtr    ext.l    d1
  9221.         ext.l    d2
  9222.         move.l    a1,a2
  9223. .GetMenu    tst.l    d2
  9224.         beq.s    .GotMenu
  9225.         move.l    mu_NextMenu(a2),a2
  9226.         subq.l    #1,d2
  9227.         bra.s    .GetMenu
  9228. .GotMenu    move.l    mu_FirstItem(a2),a2
  9229. .GetItem    tst.l    d1
  9230.         beq.s    .GotItem
  9231.         move.l    mi_NextItem(a2),a2
  9232.         subq.l    #1,d1
  9233.         bra.s    .GetItem
  9234. .GotItem    rts
  9235.  
  9236.  
  9237.  
  9238. **********************************************************************
  9239. *            Set a control toogle menu to specified value            *
  9240. * D0 = Mode                                                          *
  9241. * D1 = ItemNumber                                                    *
  9242. * D2 = MenuNumber                                                    *
  9243. **********************************************************************
  9244. SetControlMenu    move.l    MainMenu,a1
  9245.         move.l    WndHandle,a0
  9246.         bra.s    SetToggleMenu
  9247.  
  9248.  
  9249. **********************************************************************
  9250. *                Set a toggle menu to specified value                *
  9251. * D0 = Mode                                                          *
  9252. * D1 = ItemNumber                                                    *
  9253. * D2 = MenuNumber                                                    *
  9254. * A0 = Window                                                        *
  9255. * A1 = Menu                                                          *
  9256. **********************************************************************
  9257. SetToggleMenu    cmp.l    #0,a0
  9258.         beq.s    .End
  9259.         bsr    GetMenuPtr
  9260.         move.w    mi_Flags(a2),d1            ; Get Flags for menu
  9261.         tst.b    d0
  9262.         beq.s    .ClearFlag
  9263.         or.w    #CHECKED,d1
  9264.         bra.s    .FlagAltered
  9265. .ClearFlag    and.w    #~CHECKED,d1
  9266. .FlagAltered    move.w    d1,mi_Flags(a2)
  9267.         move.l    a0,a4
  9268.         LNKLIB    ResetMenuStrip,_IntuitionBase
  9269.         move.l    a4,a0
  9270.         sub.l    a1,a1
  9271.         LNKLIB    GT_RefreshWindow,_GadToolsBase
  9272. .End        rts
  9273.  
  9274.  
  9275.  
  9276. **********************************************************************
  9277. *                  Set MX Gadget to specified value                  *
  9278. * D0 = Number of button active                                       *
  9279. * D1 = Number of gadget                                              *
  9280. * A0 = Address of GadgetList                                         *
  9281. * A1 = Address of window                                             *
  9282. * A2 = Address of labels                                             *
  9283. **********************************************************************
  9284. SetMXGad    movem.l    RegsAll,-(sp)
  9285.         cmp.l    #0,a1
  9286.         beq.s    .End
  9287.         and.l    #$000000ff,d0
  9288.         move.l    d0,MxActive
  9289.         move.l    a2,MxLabels
  9290.         move.l    d1,d0
  9291.         bsr    GetGadgetPtr
  9292.         sub.l    a2,a2
  9293.         lea    MxTags(pc),a3
  9294.         LNKLIB    GT_SetGadgetAttrsA,_GadToolsBase
  9295. .End        movem.l    (sp)+,RegsAll
  9296.         rts
  9297.  
  9298.  
  9299.  
  9300.  
  9301. **********************************************************************
  9302. *              Set a cycle gadget to a specified value               *
  9303. * D0 = Number of gadget                                              *
  9304. * A0 = Address of GadgetList                                         *
  9305. * A1 = Pointer to window                                             *
  9306. * A2 = Pointer to labels                                             *
  9307. * D1 = Number of setting                                             *
  9308. **********************************************************************
  9309. SetCycleGad    movem.l    RegsAll,-(sp)
  9310.         cmp.l    #0,a1
  9311.         beq.s    .End
  9312.         move.l    d1,CycActive
  9313.         move.l    a2,CycLabels
  9314.         bsr    GetGadgetPtr
  9315.         sub.l    a2,a2
  9316.         lea    CycleTags,a3
  9317.         LNKLIB    GT_SetGadgetAttrsA,_GadToolsBase
  9318. .End        movem.l    (sp)+,RegsAll
  9319.         rts
  9320.  
  9321.  
  9322.  
  9323.  
  9324. **********************************************************************
  9325. *                Set the contents of a string gadget                 *
  9326. * D0 = Number of gadget                                              *
  9327. * A0 = Address of GadgetList                                         *
  9328. * A1 = Pointer to window                                             *
  9329. * D1 = Maximum of chars                                              *
  9330. * A2 = Pointer to new string                                         *
  9331. **********************************************************************
  9332. SetStringGad    movem.l    RegsAll,-(sp)
  9333.         cmp.l    #0,a1
  9334.         beq.s    .End
  9335.         bsr.s    GetGadgetPtr
  9336.         move.l    d1,StrMax
  9337.         move.l    a2,StringConts
  9338.         sub.l    a2,a2
  9339.         lea    StringTags,a3
  9340.         LNKLIB    GT_SetGadgetAttrsA,_GadToolsBase
  9341. .End        movem.l    (sp)+,RegsAll
  9342.         rts
  9343.  
  9344.  
  9345.  
  9346.  
  9347.  
  9348. **********************************************************************
  9349. *                Set the contents of a string gadget                 *
  9350. * D0 = Number of gadget                                              *
  9351. * A0 = Address of GadgetList                                         *
  9352. * A1 = Pointer to window                                             *
  9353. * D1 = Maximum of chars                                              *
  9354. * D2 = New value                                                     *
  9355. **********************************************************************
  9356. SetIntegerGad    movem.l    RegsAll,-(sp)
  9357.         cmp.l    #0,a1
  9358.         beq.s    .End
  9359.         move.l    d1,IntMax
  9360.         move.l    d2,IntConts
  9361.         bsr.s    GetGadgetPtr
  9362.         sub.l    a2,a2
  9363.         lea    IntegerTags,a3
  9364.         LNKLIB    GT_SetGadgetAttrsA,_GadToolsBase
  9365. .End        movem.l    (sp)+,RegsAll
  9366.         rts
  9367.  
  9368.  
  9369.  
  9370.  
  9371. **********************************************************************
  9372. *                      Activate a string gadget                      *
  9373. * D0 = Number of gadget                                              *
  9374. * A0 = Pointer to GadgetList                                         *
  9375. * A1 = Pointer to Window                                             *
  9376. **********************************************************************
  9377. ActStringGad    movem.l    RegsAll,-(sp)
  9378.         bsr.s    GetGadgetPtr
  9379.         sub.l    a2,a2
  9380.         LNKLIB    ActivateGadget,_IntuitionBase
  9381.         movem.l    (sp)+,RegsAll
  9382.         rts
  9383.  
  9384.  
  9385.  
  9386.  
  9387. **********************************************************************
  9388. *                      Get Address of a gadget                       *
  9389. * D0 = Number of gadget                                              *
  9390. * A0 = Pointer to first gadget                                       *
  9391. **********************************************************************
  9392. GetGadgetPtr    subq.l    #1,d0
  9393.         asl.l    #2,d0
  9394.         move.l    0(a0,d0),a0
  9395.         rts
  9396.  
  9397.  
  9398.  
  9399.  
  9400. **********************************************************************
  9401. *                   Changes a HotKey for a Filter                    *
  9402. * D7 = Number of gadget to change                                    *
  9403. * A0 = Pointer to window                                             *
  9404. * A1 = Pointer to string                                             *
  9405. * A4 = Pointer to filter                                             *
  9406. * A5 = Pointer to filterdescription                                  *
  9407. * ReadBuffer + 0 = Copy of new filterdescription                     *
  9408. **********************************************************************
  9409. RemakeHotKey    movem.l    RegsAll,-(sp)
  9410.  
  9411.         movem.l    a0/a1,-(sp)
  9412.         bsr    DisableBroker            ; Disable the broker
  9413.  
  9414.         move.l    a5,a0                ; Copy old hotkey
  9415.         move.l    ReadBuffer(pc),a1
  9416.         lea    2048(a1),a1
  9417.         bsr    StrCpy
  9418.  
  9419.         move.l    ReadBuffer(pc),a0
  9420.         move.l    a5,a1
  9421.         bsr    StrCpy
  9422.  
  9423.         move.l    a4,a0                ; Try to set new filter
  9424.         move.l    a5,a1
  9425.         LNKLIB    SetFilter,_CxBase
  9426.         move.l    a4,a0                ; Error occured ?
  9427.         DOLIB    CxObjError
  9428.         tst.l    d0
  9429.         beq.s    GotNewChangeHK            ; Nope -> go on
  9430.  
  9431.         move.l    ReadBuffer(pc),a0        ; Remake hotkey
  9432.         lea    2048(a0),a0
  9433.         move.l    a5,a1
  9434.         bsr    StrCpy
  9435.  
  9436.         move.l    a4,a0                ; Reset old hotkey
  9437.         move.l    a5,a1
  9438.         DOLIB    SetFilter
  9439.  
  9440. GotNewChangeHK    movem.l    (sp)+,a0/a1
  9441.         cmp.l    #0,a0
  9442.         beq.s    .NoNewTitle
  9443.         move.l    #-1,a2
  9444.         LNKLIB    SetWindowTitles,_IntuitionBase
  9445. .NoNewTitle    move.l    d7,d0
  9446.         lea    HotKeyGads,a0
  9447.         move.l    HotKeyHandle(pc),a1
  9448.         move.l    #30,d1
  9449.         move.l    a5,a2
  9450.         bsr    SetStringGad
  9451.         bsr    EnableBroker
  9452.         movem.l    (sp)+,RegsAll
  9453.         rts
  9454.  
  9455.  
  9456.  
  9457.  
  9458.  
  9459. **********************************************************************
  9460. *         Set busy for a window and disable all it`s gadgets         *
  9461. * A0 = Pointer to window                                             *
  9462. **********************************************************************
  9463. SetBusy        movem.l    RegsAll,-(sp)
  9464.         cmp.l    #0,a0
  9465.         beq.s    .End
  9466.         move.l    a0,a4                ; Set pointer
  9467.         lea    BusyPtr,a1
  9468.         move.l    #16,d0
  9469.         move.l    #16,d1
  9470.         move.l    #-6,d2
  9471.         move.l    #0,d3
  9472.         LNKLIB    SetPointer,_IntuitionBase
  9473.         move.l    #1,GadDisable
  9474.         move.l    wd_FirstGadget(a4),a5
  9475. .Loop        cmp.l    #0,a5                ; Disable all gadgets
  9476.         beq.s    .End
  9477.         move.l    a5,a0
  9478.         move.l    a4,a1
  9479.         sub.l    a2,a2
  9480.         lea    DisableTag(pc),a3
  9481.         LNKLIB    GT_SetGadgetAttrsA,_GadToolsBase
  9482.         move.l    gg_NextGadget(a5),a5
  9483.         bra.s    .Loop
  9484. .End        movem.l    (sp)+,RegsAll
  9485.         rts
  9486.  
  9487.  
  9488.  
  9489.  
  9490. **********************************************************************
  9491. *          Un-Busy a window and reenable all gadgets again           *
  9492. * A0 = Pointer to window to be re-enabled                            *
  9493. **********************************************************************
  9494. UnBusy        movem.l    RegsAll,-(sp)
  9495.         cmp.l    #0,a0
  9496.         beq.s    .End
  9497.         move.l    a0,a4                ; Clear pointer
  9498.         LNKLIB    ClearPointer,_IntuitionBase
  9499.         move.l    #0,GadDisable
  9500.         move.l    wd_FirstGadget(a4),a5        ; Enable all gadgets
  9501. .Loop        cmp.l    #0,a5
  9502.         beq.s    .End
  9503.         move.l    a5,a0
  9504.         move.l    a4,a1
  9505.         sub.l    a2,a2
  9506.         lea    DisableTag(pc),a3
  9507.         LNKLIB    GT_SetGadgetAttrsA,_GadToolsBase
  9508.         move.l    gg_NextGadget(a5),a5
  9509.         bra.s    .Loop
  9510. .End        movem.l    (sp)+,RegsAll
  9511.         rts
  9512.  
  9513.  
  9514.  
  9515.  
  9516. **********************************************************************
  9517. *                     Lock the Workbench-Screen                      *
  9518. **********************************************************************
  9519. LockScreen    sub.l    a0,a0
  9520.         LNKLIB    LockPubScreen,_IntuitionBase
  9521.         move.l    d0,-4(a5)
  9522.         rts
  9523.  
  9524.  
  9525.  
  9526.  
  9527. **********************************************************************
  9528. *                      Unlock the locked screen                      *
  9529. **********************************************************************
  9530. UnlockScreen    tst.l    -4(a5)
  9531.         beq.s    .End
  9532.         sub.l    a0,a0
  9533.         move.l    -4(a5),a1
  9534.         LNKLIB    UnlockPubScreen,_IntuitionBase
  9535. .End        rts
  9536.  
  9537.  
  9538.  
  9539.  
  9540. **********************************************************************
  9541. *           Display Online-Help text for given Menu-Entry            *
  9542. * D0 = Windownumber (1 = Control, 2 = Prefs, 3 = Bill, 4 = HotKey    *
  9543. **********************************************************************
  9544. OnlineHelp    tst.b    HelpPage
  9545.         bne.s    OtherHelp
  9546.         cmp.w    #-1,d5
  9547.         beq    NoHelp
  9548.         move.w    d5,d2
  9549.         and.w    #$1f,d2                ; Get menunumber
  9550.         move.w    d5,d1
  9551.         asr.w    #5,d1
  9552.         and.w    #$3f,d1                ; Get itemnumber
  9553.         ext.l    d2
  9554.         ext.l    d1
  9555.         mulu    #1000,d0            ; Make unique FileName
  9556.         mulu    #100,d2
  9557.         add.l    d0,d1
  9558.         add.l    d2,d1
  9559.         move.l    d1,HelpNum
  9560.         lea    LIntFormat,a0            ; Convert to string
  9561.         lea    HelpNum,a1
  9562.         lea    PutChProc,a2
  9563.         lea    HelpName,a3
  9564.         CALLSYS    RawDoFmt
  9565.  
  9566. OtherHelp    move.l    #HelpFile,d1            ; Try to open Help file
  9567.         move.l    #MODE_OLDFILE,d2
  9568.         LNKLIB    Open,_DOSBase
  9569.         tst.l    d0
  9570.         beq    NoHelp
  9571.         move.l    ReadBuffer,a0
  9572.         move.l    #(1024/4)-1,d7
  9573. .ClearBuffer    move.l    #0,(a0)+
  9574.         dbf    d7,.ClearBuffer
  9575.         move.l    d0,d7
  9576.         move.l    d0,d1
  9577.         move.l    ReadBuffer,d2            ; Read in text
  9578.         move.l    #$ffffff,d3
  9579.         DOLIB    Read
  9580.         move.l    d0,d6
  9581.         move.l    d7,d1
  9582.         DOLIB    Close                ; Close file
  9583.         tst.l    d6
  9584.         blt    NoHelp
  9585.  
  9586.         move.l    ReadBuffer(pc),a0        ; Copy header of help text
  9587.         lea    HelpDescr(pc),a1
  9588. .CopyHeader    move.b    (a0)+,d0
  9589.         cmp.b    #$0a,d0
  9590.         beq.s    .HeaderDone
  9591.         move.b    d0,(a1)+
  9592.         bra.s    .CopyHeader
  9593. .HeaderDone    move.b    #0,(a1)
  9594.         move.l    a0,HelpText
  9595.         moveq    #0,d0                ; Calc number of lines of
  9596. .CalcLines    tst.b    (a0)                ; Help text
  9597.         beq.s    .GotLines
  9598.         cmp.b    #$0a,(a0)
  9599.         bne.s    .NoLine
  9600.         addq.l    #1,d0
  9601. .NoLine        addq.l    #1,a0
  9602.         bra.s    .CalcLines
  9603. .GotLines    move.l    d0,ScrollTotal            ; Write new settings
  9604.         move.l    #0,ScrollTop
  9605.         move.l    #9,ScrollVis
  9606.  
  9607.         link    a5,#-4                ; Lock screen
  9608.         bsr    LockScreen
  9609.         tst.l    d0
  9610.         beq    HelpWinError
  9611.  
  9612.         move.l    -4(a5),a0            ; Get visual info
  9613.         sub.l    a1,a1
  9614.         LNKLIB    GetVisualInfoA,_GadToolsBase
  9615.         move.l    d0,HelpVisInfo
  9616.         tst.l    d0
  9617.         beq    HelpWinError
  9618.         lea    DummyNewGadget(pc),a0
  9619.         move.l    d0,gng_VisualInfo(a0)
  9620.         move.l    d0,BevelVisInfo
  9621.  
  9622.         move.l    #HELPWINWIDTH,WinWidth
  9623.         move.l    #HELPWINHEIGHT,WinHeight
  9624.         move.l    #HELPWINIDCMP,WinIDCMP
  9625.         move.l    #HELPWINFLAGS,WinFlags
  9626.  
  9627.         lea    HelpWinDef(pc),a0        ; Open window
  9628.         move.l    -4(a5),a1
  9629.         bsr    AdjustWinPos
  9630.         lea    WindowTags(pc),a1
  9631.         LNKLIB    OpenWindowTagList,_IntuitionBase
  9632.         move.l    d0,HelpHandle
  9633.         tst.l    d0
  9634.         beq    HelpWinError
  9635.  
  9636.         lea    HelpMenuDef,a0            ; Create menu strip
  9637.         sub.l    a1,a1                ; No tags
  9638.         LNKLIB    CreateMenusA,_GadToolsBase
  9639.         move.l    d0,HelpMenu
  9640.         tst.l    d0
  9641.         beq    HelpWinError
  9642.  
  9643.         move.l    HelpMenu(pc),a0            ; Do the layout on window
  9644.         move.l    HelpVisInfo(pc),a1
  9645.         sub.l    a2,a2
  9646.         DOLIB    LayoutMenusA
  9647.         tst.l    d0
  9648.         beq    HelpWinError
  9649.  
  9650.         move.l    HelpHandle(pc),a0
  9651.         move.l    wd_RPort(a0),HelpRPort
  9652.         moveq    #0,d7
  9653.         move.b    wd_BorderTop(a0),d7
  9654.  
  9655.         move.l    HelpRPort(pc),a0        ; Draw text-box
  9656.         move.l    #INTERWIDTH,d0
  9657.         move.l    #INTERHEIGHT,d1
  9658.         add.l    d7,d1
  9659.         move.l    #HELPWINWIDTH-30,d2
  9660.         move.l    #HELPWINHEIGHT-(INTERHEIGHT*2),d3
  9661.         lea    BevelTag(pc),a1
  9662.         LNKLIB    DrawBevelBoxA,_GadToolsBase
  9663.  
  9664.         lea    HelpGadget(pc),a0        ; Create Context-Gadget
  9665.         LNKLIB    CreateContext,_GadToolsBase
  9666.         tst.l    d0
  9667.         beq    HelpWinError
  9668.         move.l    d0,ThisGadget
  9669.  
  9670.         move.w    #1,GadNum
  9671.  
  9672.         lea    DummyNewGadget(pc),a1        ; Create scroller gadget
  9673.         move.w    #INTERHEIGHT,d0
  9674.         add.w    d7,d0
  9675.         move.w    d0,gng_TopEdge(a1)
  9676.         move.w    #HELPWINWIDTH-20,gng_LeftEdge(a1)
  9677.         move.w    #20,gng_Width(a1)
  9678.         move.w    #HELPWINHEIGHT-(INTERHEIGHT*2),d0
  9679.         move.w    d0,gng_Height(a1)
  9680.         move.l    #0,gng_GadgetText(a1)
  9681.         move.l    #0,gng_Flags(a1)
  9682.         move.l    #SCROLLER_KIND,d0
  9683.         move.l    ThisGadget,a0
  9684.         lea    ScrollerTags,a2
  9685.         DOLIB    CreateGadgetA
  9686.         tst.l    d0
  9687.         beq    HelpWinError
  9688.         move.l    d0,HelpScroll
  9689.  
  9690.         lea    GadgetTxtAttr(pc),a0        ; Set font for window
  9691.         LNKLIB    OpenFont,_GfxBase
  9692.         move.l    d0,HelpFont
  9693.         tst.l    d0
  9694.         beq    HelpWinError
  9695.         move.l    HelpRPort(pc),a1
  9696.         move.l    d0,a0
  9697.         DOLIB    SetFont
  9698.  
  9699.         move.l    HelpHandle(pc),a0        ; Add gadgets to window
  9700.         move.l    HelpGadget(pc),a1
  9701.         move.l    #-1,d0
  9702.         move.l    #-1,d1
  9703.         sub.l    a2,a2
  9704.         LNKLIB    AddGList,_IntuitionBase
  9705.  
  9706.         move.l    HelpGadget(pc),a0        ; Make them appear
  9707.         move.l    HelpHandle(pc),a1
  9708.         sub.l    a2,a2
  9709.         move.l    #-1,d0
  9710.         DOLIB    RefreshGList
  9711.  
  9712.         move.l    HelpHandle,a0
  9713.         move.l    HelpMenu,a1
  9714.         DOLIB    SetMenuStrip
  9715.  
  9716.         move.l    HelpHandle,a0            ; Redisplay gadget
  9717.         sub.l    a1,a1
  9718.         LNKLIB    GT_RefreshWindow,_GadToolsBase
  9719.  
  9720.         move.l    WndHandle,a0            ; Make all gadgets busy
  9721.         bsr    SetBusy
  9722.         move.l    PrefsHandle,a0
  9723.         bsr    SetBusy
  9724.         move.l    HotKeyHandle,a0
  9725.         bsr    SetBusy
  9726.  
  9727.         bsr    PrintHelp            ; Print first help page
  9728.  
  9729. HelpWinLoop    move.l    HelpHandle(pc),a0        ; Wait for message
  9730.         move.l    wd_UserPort(a0),a0
  9731.         CALLSYS    WaitPort
  9732. HelpMsgLoop    move.l    HelpHandle(pc),a0
  9733.         move.l    wd_UserPort(a0),a0
  9734.         LNKLIB    GT_GetIMsg,_GadToolsBase
  9735.         tst.l    d0
  9736.         beq    HelpWinLoop
  9737.  
  9738.         move.l    d0,a1                ; Get important data
  9739.         move.l    im_Class(a1),d6
  9740.         move.w    im_Code(a1),d5
  9741.         move.w    im_Qualifier(a1),d7
  9742.  
  9743.         DOLIB    GT_ReplyIMsg
  9744.  
  9745.         cmp.l    #IDCMP_CLOSEWINDOW,d6        ; Closed Help window ?
  9746.         beq    HelpWinEnd
  9747.  
  9748.         cmp.l    #IDCMP_GADGETUP,d6        ; Gadget released ?
  9749.         bne.s    NoHelpGadUp
  9750.         move.b    #0,Scrolling            ; No moving-scroll
  9751.         ext.l    d5                ; Display new page
  9752.         cmp.l    ScrollTop,d5
  9753.         beq.s    NoHelpGadUp
  9754.         move.l    d5,ScrollTop
  9755.         movem.l    d5-d7,-(sp)
  9756.         bsr    PrintHelp
  9757.         movem.l    (sp)+,d5-d7
  9758. NoHelpGadUp    cmp.l    #IDCMP_GADGETDOWN,d6        ; Gadget pressed ?
  9759.         bne.s    NoHelpGadDown
  9760.         move.b    #1,Scrolling
  9761. NoHelpGadDown    cmp.l    #IDCMP_GADGETDOWN,d6
  9762.         beq.s    .DoScroll
  9763.         cmp.l    #IDCMP_MOUSEMOVE,d6        ; Mouse moved
  9764.         bne.s    .NoScroll
  9765.         tst.b    Scrolling            ; and scrolling enabled ?
  9766.         beq.s    .NoScroll
  9767.         cmp.l    #9,ScrollTotal            ; Display new area
  9768.         ble.s    .NoScroll
  9769. .DoScroll    ext.l    d5
  9770.         move.l    d5,ScrollTop
  9771.         movem.l    d5-d7,-(sp)
  9772.         bsr    PrintHelp
  9773.         movem.l    (sp)+,d5-d7
  9774. .NoScroll    cmp.l    #IDCMP_RAWKEY,d6
  9775.         bne    NoHelpRKey
  9776.  
  9777.         cmp.w    #$45,d5                ; On ESC -> quit Help
  9778.         beq    HelpWinEnd
  9779.  
  9780.         and.w    #(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT),d7
  9781.         bne.s    PageMove
  9782.         cmp.w    #CURSORUP,d5            ; Unshifted CURSOR keys move
  9783.         bne.s    NoRowUp
  9784. HelpRowUp    tst.l    ScrollTop
  9785.         beq    HelpMsgLoop
  9786.         subq.l    #1,ScrollTop            ; up one line
  9787.         bra    DoKeyMove
  9788. NoRowUp        cmp.w    #CURSORDOWN,d5
  9789.         bne.s    NoRowDown
  9790. HelpRowDown    cmp.l    #9,ScrollTotal
  9791.         ble    HelpMsgLoop
  9792.         move.l    ScrollTotal(pc),d0
  9793.         sub.l    #9,d0
  9794.         cmp.l    ScrollTop,d0
  9795.         beq    HelpMsgLoop
  9796.         addq.l    #1,ScrollTop            ; down one line
  9797.         bra.s    DoKeyMove
  9798. NoRowDown    bra    HelpMsgLoop
  9799. PageMove    cmp.w    #CURSORUP,d5
  9800.         bne.s    NoPageUp
  9801. HelpPageUp    cmp.l    #8,ScrollTop
  9802.         bge.s    .UpFull
  9803.         move.l    #0,ScrollTop
  9804.         bra.s    .UpPage
  9805. .UpFull        subq.l    #8,ScrollTop            ; up one page
  9806. .UpPage        bra.s    DoKeyMove
  9807. NoPageUp    cmp.w    #CURSORDOWN,d5
  9808.         bne.s    NoPageDown
  9809. HelpPageDown    cmp.l    #9,ScrollTotal
  9810.         ble    HelpMsgLoop
  9811.         move.l    ScrollTop(pc),d0
  9812.         add.l    #8,d0                ; down one page
  9813.         move.l    ScrollTotal(pc),d1
  9814.         sub.l    #8,d1
  9815.         cmp.l    d1,d0
  9816.         blt.s    .DownFull
  9817.         move.l    d1,d0
  9818. .DownFull    move.l    d0,ScrollTop
  9819.         bra.s    DoKeyMove
  9820. NoPageDown    bra    HelpMsgLoop
  9821. DoKeyMove    bsr    PrintHelp            ; Print new area
  9822.         move.l    HelpScroll,a0            ; Remake scroll gadget
  9823.         move.l    HelpHandle,a1
  9824.         sub.l    a2,a2
  9825.         lea    ScrollerTags,a3
  9826.         LNKLIB    GT_SetGadgetAttrsA,_GadToolsBase
  9827.         bra    HelpMsgLoop
  9828.  
  9829. NoHelpRKey    cmp.l    #IDCMP_MENUPICK,d6        ; Menu picked ?
  9830.         bne.s    NoHelpMenu
  9831.         cmp.w    #-1,d5
  9832.         beq.s    EndHelpMenu
  9833.         move.w    d5,d2
  9834.         and.w    #$1f,d2                ; Get menunumber
  9835.         move.w    d5,d1
  9836.         asr.w    #5,d1
  9837.         and.w    #$3f,d1                ; Get itemnumber
  9838.         move.w    d1,d5
  9839.         move.l    HelpMenu,a1
  9840.         bsr    GetMenuPtr
  9841.         GTMENUITEM_USERDATA a2,a0
  9842.         cmp.l    #0,a0
  9843.         beq.s    EndHelpMenu
  9844.         jmp    (a0)                ; execute menu function
  9845. EndHelpMenu    bra    HelpMsgLoop
  9846.  
  9847. NoHelpMenu    cmp.l    #IDCMP_CHANGEWINDOW,d6        ; Window moved ?
  9848.         bne.s    NoHelpMoved
  9849.         move.l    HelpHandle,a0
  9850.         lea    HelpWinDef,a1
  9851.         bsr    StoreWinPos
  9852.         bra    HelpMsgLoop
  9853. NoHelpMoved    bra    HelpMsgLoop
  9854.  
  9855.  
  9856. HelpWinEnd    move.l    WndHandle,a0            ; Unbusy windows
  9857.         bsr    UnBusy
  9858.         move.l    PrefsHandle,a0
  9859.         bsr    UnBusy
  9860.         move.l    HotKeyHandle,a0
  9861.         bsr    UnBusy
  9862. HelpWinError    bsr    UnlockScreen            ; Unlock screen
  9863.         unlk    a5
  9864.         tst.l    HelpFont
  9865.         beq.s    .NoFont
  9866.         move.l    HelpFont,a1            ; Close font
  9867.         LNKLIB    CloseFont,_GfxBase
  9868. .NoFont        tst.l    HelpHandle
  9869.         beq.s    .NoWin
  9870.         move.l    HelpHandle,a0
  9871.         LNKLIB    CloseWindow,_IntuitionBase    ; Close window
  9872. .NoWin        tst.l    HelpGadget
  9873.         beq.s    .NoGad
  9874.         move.l    HelpGadget,a0
  9875.         LNKLIB    FreeGadgets,_GadToolsBase    ; Free gadget
  9876. .NoGad        tst.l    HelpMenu
  9877.         beq.s    .NoMenu
  9878.         move.l    HelpMenu,a0
  9879.         LNKLIB    FreeMenus,_GadToolsBase        ; Free menues
  9880. .NoMenu        tst.l    HelpVisInfo
  9881.         beq.s    .NoVisInfo
  9882.         move.l    HelpVisInfo,a0
  9883.         LNKLIB    FreeVisualInfo,_GadToolsBase    ; Free VisInfo
  9884. .NoVisInfo    move.l    #0,HelpHandle
  9885.         move.l    #0,HelpGadget
  9886.         move.l    #0,HelpVisInfo
  9887.         move.l    #0,HelpFont
  9888.         move.l    #0,HelpMenu
  9889. NoHelp        move.b    #0,HelpPage
  9890.         rts
  9891.  
  9892.  
  9893.  
  9894. **********************************************************************
  9895. *                   Print out 9 lines of a helptext                  *
  9896. **********************************************************************
  9897. PrintHelp    move.l    HelpHandle(pc),a0
  9898.         moveq    #0,d7
  9899.         move.b    wd_BorderTop(a0),d7
  9900.         move.l    HelpRPort(pc),a1
  9901.         moveq    #0,d0
  9902.         LNKLIB    SetAPen,_GfxBase
  9903.         move.l    HelpRPort(pc),a1
  9904.         move.l    #INTERWIDTH+2,d0
  9905.         move.l    #INTERHEIGHT+1,d1
  9906.         add.l    d7,d1
  9907.         move.l    #HELPWINWIDTH-28,d2
  9908.         move.l    #HELPWINHEIGHT-(INTERHEIGHT*2)+13,d3
  9909.         DOLIB    RectFill
  9910.         move.l    HelpRPort(pc),a1
  9911.         moveq    #1,d0
  9912.         DOLIB    SetAPen
  9913.         add.l    #INTERHEIGHT*3+2,d7
  9914.         addq.l    #2,d7
  9915.         move.l    HelpText(pc),a4
  9916.         moveq    #8,d6
  9917.         move.l    ScrollTop(pc),d0
  9918. .FindFirst    tst.l    d0
  9919.         beq.s    .GotFirst
  9920. .FindNext    cmp.b    #$0a,(a4)+
  9921.         bne    .FindNext
  9922.         subq.l    #1,d0
  9923.         bra.s    .FindFirst
  9924. .GotFirst    tst.b    (a4)
  9925.         beq.s    .HelpDone
  9926.         move.l    HelpRPort(pc),a1
  9927.         move.l    #INTERWIDTH+4,d0
  9928.         move.l    d7,d1
  9929.         LNKLIB    Move,_GfxBase
  9930.         move.l    HelpRPort(pc),a1
  9931.         move.l    a4,a0
  9932.         moveq    #0,d0
  9933. .GetLength    cmp.b    #$0a,(a4)+
  9934.         beq.s    .GotLength
  9935.         addq.l    #1,d0
  9936.         bra.s    .GetLength
  9937. .GotLength    DOLIB    Text
  9938.         add.l    #9,d7
  9939.         dbf    d6,.GotFirst
  9940. .HelpDone    rts
  9941.  
  9942.  
  9943.  
  9944. **********************************************************************
  9945. *                Edit Hook for String/Integer gadgets                *
  9946. * A0 = Pointer to Hook itself                                        *
  9947. * A1 = Pointer to parameter                                          *
  9948. * A2 = Pointer to SGWork-Structure                                   *
  9949. *                       Provided editing is :                        *
  9950. * Activating the next gadget on RETURN press                         *
  9951. * Actuvating the previous gadget on SHIFTED RETURN press             *
  9952. * Simulating HELP-Exit of gadget on ESC-Press                        *
  9953. * Accessing menus via Key-Stroke RIGHT AMIGA - ShortCut              *
  9954. * Using CURSOR UP/DOWN for entering previous/next gadget             *
  9955. * Using CONTROL CURSOR LEFT/RIGHT to get to the prev/next word       *
  9956. **********************************************************************
  9957. StrEditFunc    movem.l    RegsAll,-(sp)
  9958.         cmp.l    #SGH_KEY,0(a1)            ; Key pressed ?
  9959.         bne    .End
  9960.         move.l    sgw_Actions(a2),d0
  9961.         move.l    d0,d1
  9962.         and.l    #SGA_END,d0            ; Gadget released ?
  9963.         beq.s    .NoReturn            ; Nope -> go on
  9964.         cmp.w    #HELPKEY,sgw_Code(a2)        ; HELP used to escape ?
  9965.         beq.s    .NoReturn            ; Yep -> go on
  9966.         move.l    sgw_IEvent(a2),a3
  9967.         move.w    ie_Qualifier(a3),d2
  9968.         and.w    #(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT),d2
  9969.         beq.s    .NextGadget
  9970.         or.l    #SGA_PREVACTIVE,d1
  9971.         bra.s    .ActGadget
  9972. .NextGadget    or.l    #SGA_NEXTACTIVE,d1
  9973. .ActGadget    move.l    d1,sgw_Actions(a2)
  9974.         bra    .End
  9975.  
  9976. .NoReturn    move.l    sgw_IEvent(a2),a3        ; User pressed ESC ?
  9977.         cmp.w    #$45,ie_Code(a3)
  9978.         bne.s    .NoEsc
  9979.         move.l    #SGA_END,sgw_Actions(a2)    ; Simulate release of gadget
  9980.         move.w    #HELPKEY,sgw_Code(a2)
  9981.         bra    .End
  9982. .NoEsc        cmp.w    #$4c,ie_Code(a3)        ; Cursor UP ?
  9983.         bne.s    .NoUp
  9984.         move.l    #SGA_END|SGA_PREVACTIVE,sgw_Actions(a2)
  9985.         move.w    #$44,sgw_Code(a2)
  9986.         bra    .End
  9987. .NoUp        cmp.w    #$4d,ie_Code(a3)        ; Cursor DOWN ?
  9988.         bne.s    .NoDown
  9989.         move.l    #SGA_END|SGA_NEXTACTIVE,sgw_Actions(a2)
  9990.         move.w    #$44,sgw_Code(a2)
  9991.         bra    .End
  9992. .NoDown        move.w    ie_Qualifier(a3),d0
  9993.         and.w    #IEQUALIFIER_CONTROL,d0        ; CONTROL pressed ?
  9994.         beq    .NoWordJump
  9995.         move.l    sgw_WorkBuffer(a2),a1        ; Get pointer to buffer
  9996.         move.w    sgw_BufferPos(a2),d0        ; Get cursor position
  9997.         cmp.w    #$4f,ie_Code(a3)        ; Jump to left word ?
  9998.         beq.s    .JumpLeft
  9999.         cmp.w    #$4e,ie_Code(a3)        ; Jump to right word ?
  10000.         beq.s    .JumpRight
  10001.         bra    .NoWordJump
  10002. .JumpLeft    tst.w    d0                ; Already at beginning ?
  10003.         beq    .End
  10004.         moveq    #-1,d1                ; Set new position
  10005. .LeftLoop1    tst.w    d0                ; All done ?
  10006.         blt.s    .FirstLeft            ; Yep -> first loop donw
  10007.         cmp.b    #' ',0(a1,d0.w)            ; Got a space ?
  10008.         beq.s    .NoCharLeft            ; Yep -> loop
  10009.         move.w    d0,d1                ; Nope -> Store new position
  10010.         bra.s    .FirstLeft
  10011. .NoCharLeft    subq.w    #1,d0                ; Next char to the left
  10012.         bra.s    .LeftLoop1
  10013. .FirstLeft    cmp.w    #-1,d1                ; Got new position ?
  10014.         bne.s    .NoNegLeft
  10015.         moveq    #0,d1                ; Nope -> clear position
  10016. .NoNegLeft    tst.w    d1                ; New position marked ?
  10017.         beq.s    .JumpedLeft            ; Nope -> jump to first char
  10018.         move.w    d1,d0                ; Copy new position
  10019.         moveq    #-1,d1                ; Clear position
  10020. .LeftLoop2    tst.w    d0                ; Already at first char ?
  10021.         blt.s    .JumpedLeft            ; Yep -> position cursor
  10022.         cmp.b    #' ',0(a1,d0.w)            ; Now skip chars different to space
  10023.         bne.s    .NoSpaceLeft
  10024.         move.w    d0,d1                ; Store first pos of char after space
  10025.         addq.w    #1,d1
  10026.         bra.s    .JumpedLeft            ; DONE
  10027. .NoSpaceLeft    subq.w    #1,d0                ; Loop for chars
  10028.         bra    .LeftLoop2
  10029. .JumpedLeft    tst.w    d1                ; Do we have a new position ?
  10030.         bge.s    .GotLeft            ; Yep -> Repos
  10031.         move.w    #0,sgw_BufferPos(a2)        ; Set cursor to first char
  10032.         bra.s    .LeftDone
  10033. .GotLeft    move.w    d1,sgw_BufferPos(a2)        ; Set cursor to new position
  10034. .LeftDone    move.w    #EO_MOVECURSOR,sgw_EditOp(a2)
  10035.         bra    .End
  10036.  
  10037. .JumpRight    cmp.w    sgw_NumChars(a2),d0        ; Already at end of string ?
  10038.         beq    .End                ; Yep -> no movement
  10039.         moveq    #-1,d1
  10040. .RightLoop    cmp.w    sgw_NumChars(a2),d0        ; All chars checked ?
  10041.         beq.s    .JumpedRight            ; Yep -> end of movement
  10042.         cmp.b    #' ',0(a1,d0.w)            ; Space encountered ?
  10043.         bne.s    .NoSpaceRight            ; Nope -> go on
  10044. .RightSpaceLoop    cmp.w    sgw_NumChars(a2),d0        ; All chars checked ?
  10045.         beq.s    .JumpedRight            ; Yep -> end of movement
  10046.         cmp.b    #' ',0(a1,d0.w)            ; Still a space ?
  10047.         beq.s    .NoRightChar            ; Yep -> loop for spaces
  10048.         move.w    d0,d1                ; Got new word
  10049.         bra.s    .JumpedRight            ; -> Do movement
  10050. .NoRightChar    addq.w    #1,d0                ; Next char (SPACE)
  10051.         bra    .RightSpaceLoop            ; Loop for spaces
  10052. .NoSpaceRight    addq.w    #1,d0                ; Loop for normal chars
  10053.         bra    .RightLoop
  10054. .JumpedRight    tst.w    d1                ; Got new position ?
  10055.         bge.s    .GotRight            ; Yep -> do so
  10056.         move.w    sgw_NumChars(a2),sgw_BufferPos(a2)
  10057.         bra.s    .RightDone
  10058. .GotRight    move.w    d1,sgw_BufferPos(a2)        ; Store new position
  10059. .RightDone    move.w    #EO_MOVECURSOR,sgw_EditOp(a2)
  10060.         bra.s    .End
  10061.  
  10062. .NoWordJump    move.l    sgw_IEvent(a2),a3
  10063.         move.w    ie_Qualifier(a3),d0        ; Right Amiga pressed ?
  10064.         and.w    #IEQUALIFIER_RCOMMAND,d0
  10065.         beq.s    .NoAmiga
  10066.         cmp.w    #96,ie_Code(a3)            ; Char entered ?
  10067.         bge.s    .NoAmiga
  10068.         move.w    ie_Qualifier(a3),d0        ; Any shift pressed ?
  10069.         and.w    #(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT),d0
  10070.         bne.s    .DoMenu
  10071.         cmp.w    #$32,ie_Code(a3)        ; Magic X
  10072.         beq.s    .NoAmiga
  10073.         cmp.w    #$10,ie_Code(a3)        ; or Q pressed ?
  10074.         beq.s    .NoAmiga
  10075. .DoMenu        move.l    sgw_Actions(a2),d0        ; Ok -> Then use the menues
  10076.         or.l    #(SGA_END|SGA_REUSE),d0
  10077.         and.l    #~(SGA_USE|SGA_BEEP),d0
  10078.         move.l    d0,sgw_Actions(a2)
  10079.         move.l    sgw_GadgetInfo(a2),a0
  10080.         move.l    ggi_Window(a0),DoActWindow    ; Tell menu owner to reactivate
  10081.         move.l    sgw_Gadget(a2),DoActGadget    ; gadget
  10082.         bra.s    .End
  10083. .NoAmiga
  10084. .End        movem.l    (sp)+,RegsAll
  10085.         rts
  10086.  
  10087.  
  10088.  
  10089. **********************************************************************
  10090. *             A large multiplication routine LONG * LONG             *
  10091. **********************************************************************
  10092. _mulu        move.w    d1,d2
  10093.         mulu.w    d0,d2
  10094.         move.l    d1,d3
  10095.         swap    d3
  10096.         mulu.w    d0,d3
  10097.         swap    d3
  10098.         clr.w    d3
  10099.         add.l    d3,d2
  10100.         swap    d0
  10101.         mulu.w    d1,d0
  10102.         swap    d0
  10103.         clr.w    d0
  10104.         add.l    d2,d0
  10105.         rts
  10106.  
  10107.  
  10108. **********************************************************************
  10109. *                A large division routine LONG / LONG                *
  10110. **********************************************************************
  10111. _divu        move.l    d1,-(a7)
  10112.         bsr.s    .l1
  10113.         move.l    (a7)+,d1
  10114.         tst.l    d0
  10115.         rts
  10116. .l1        swap    d1
  10117.         tst.w    d1
  10118.         bne.s    .l2
  10119.         swap    d1
  10120.         move.w    d1,-(a7)
  10121.         move.w    d0,-(a7)
  10122.         clr.w    d0
  10123.         swap    d0
  10124.         divu.w    d1,d0
  10125.         move.l    d0,d1
  10126.         swap    d0
  10127.         move.w    (a7)+,d1
  10128.         divu.w    (a7)+,d1
  10129.         move.w    d1,d0
  10130.         clr.w    d1
  10131.         swap    d1
  10132.         rts
  10133. .l2        swap    d1
  10134.         move.w    d2,-(a7)
  10135.         move.l    d3,-(a7)
  10136.         move.l    d1,d3
  10137.         move.l    d0,d1
  10138.         clr.w    d1
  10139.         swap    d1
  10140.         swap    d0
  10141.         clr.w    d0
  10142.         move.w    #$f,d2
  10143. .l4        add.l    d0,d0
  10144.         addx.l    d1,d1
  10145.         cmp.l    d1,d3
  10146.         bhi.s    .l3
  10147.         sub.l    d3,d1
  10148.         addq.w    #1,d0
  10149. .l3        dbf    d2,.l4
  10150.         move.l    (a7)+,d3
  10151.         move.w    (a7)+,d2
  10152.         rts
  10153.  
  10154.  
  10155.  
  10156. **********************************************************************
  10157. *                  Versionstring for C:Version-Prg                   *
  10158. **********************************************************************
  10159. VersionString    dc.b    0,"$VER: KCommodity V"
  10160.         REVISION
  10161.         dc.b    " ("
  10162.         REVDATE
  10163.         dc.b    ")",0
  10164.         EVEN
  10165.  
  10166.  
  10167.  
  10168. **********************************************************************
  10169. *                          Template for CLI                          *
  10170. **********************************************************************
  10171. Template    BOLDON
  10172.         SETFRONTPEN 2
  10173.         dc.b    "KCommodity V"
  10174.         REVISION
  10175.         dc.b    " ("
  10176.         REVDATE
  10177.         dc.b    ") "
  10178.         STYLENORMAL
  10179.         SETFRONTPEN 1
  10180.         dc.b "by Kai Iske. SHAREWARE",$0a
  10181.         dc.b    "USAGE : KCommodity",$0a
  10182.         dc.b    "        ToolType :             Description :              Default :",$0a
  10183.         dc.b    "        -------------------------------------------------------------------",$0a
  10184.         dc.b    "        [CX_PRIORITY=n]        Priority of Broker         5",$0a
  10185.         dc.b    "        [CX_POPKEY=s]          PopUpKey for Window        LCOMMAND HELP",$0a
  10186.         dc.b    "        [CX_POPUP=YES|NO]      PopUp on startup           YES",$0a
  10187.         dc.b    "        [PORTNAME=s]           Set name for ARexx-Port    KComm.1",$0a
  10188.         dc.b    "        [TOOLPRI=n]            Priority of Program        21 (Must be > 21)",$0a
  10189.         dc.b    "        [NOICON]               Don`t display AppIcon      ---",$0a
  10190. TemplateEnd    EVEN
  10191. PressKey    SETFRONTPEN 2
  10192.         dc.b    "Press any key to continue....",13
  10193.         SETFRONTPEN 1
  10194. PressKeyLen    EQU    *-PressKey
  10195. ClearStr    dc.b    $9B,$30,$20,$70
  10196. ClearStrLen    EQU    *-ClearStr
  10197. EndAnyStr    dc.b    $9B,$20,$70,$9b,$4b,$9B,"0;39;49m",0
  10198. EndAnyStrLen    EQU    *-EndAnyStr
  10199.  
  10200.  
  10201.  
  10202.  
  10203. **********************************************************************
  10204. *                             Variables                              *
  10205. **********************************************************************
  10206. IntName        dc.b    "intuition.library",0
  10207. ComName        dc.b    "commodities.library",0
  10208. LayerName    dc.b    "layers.library",0,0
  10209. GadName        dc.b    "gadtools.library",0,0
  10210. GfxName        dc.b    "graphics.library",0,0
  10211. DiskFontName    dc.b    "diskfont.library",0,0
  10212. RexxSysName    dc.b    "rexxsyslib.library",0,0
  10213. WBName        dc.b    "workbench.library",0
  10214. AslName        dc.b    "asl.library",0
  10215. TimerName    dc.b    "timer.device",0,0
  10216. AudioName    dc.b    "audio.device",0,0
  10217. ConsoleName    dc.b    "console.device",0,0
  10218. PortName    dc.b    "KComm-Port",0
  10219. TimerPortName    dc.b    "KComm-Timer-Port",0
  10220. AudioPortName    dc.b    "KComm-Audio-Port",0
  10221. ARexxPortName    dc.b    "KComm.1",0
  10222.         ds.b    32
  10223. AppPortName    dc.b    "KComm-App-Port",0
  10224.         EVEN
  10225. TempName    dc.b    "T:KCX.TEMPFILE",0,0
  10226. ConWinDef    dc.b    "RAW:0/0//150/Telefone log info",0
  10227.         EVEN
  10228. CheckerName    dc.b    "KCOMM.TIME-PROCESS",0
  10229.         EVEN
  10230. PrtName        dc.b    "PRT:",0
  10231.         EVEN
  10232. _IntuitionBase    dc.l    0
  10233. _CxBase        dc.l    0
  10234. _LayersBase    dc.l    0
  10235. _GadToolsBase    dc.l    0
  10236. _GfxBase    dc.l    0
  10237. _DiskFontBase    dc.l    0
  10238. _RexxSysBase    dc.l    0
  10239. _AslBase    dc.l    0
  10240. _ConsoleBase    dc.l    0
  10241. _WorkBenchBase    dc.l    0
  10242. BrokerPort    dc.l    0
  10243. TimerPort    dc.l    0
  10244. AudioPort    dc.l    0
  10245. ARexxPort    dc.l    0
  10246. DoublePort    dc.l    0
  10247. AppPort        dc.l    0
  10248. CheckerProc    dc.l    0
  10249. CheckerProcSig    dc.l    0
  10250. MyBroker    dc.l    0
  10251. MsgType        dc.l    0
  10252. MsgID        dc.l    0
  10253. EventFilter    dc.l    0
  10254. PopUpFilter    dc.l    0
  10255. PageFilter    dc.l    0
  10256. PrefsFilter    dc.l    0
  10257. BillFilter    dc.l    0
  10258. HotKeyFilter    dc.l    0
  10259. ShellFilter    dc.l    0
  10260. UmlautFilter    dc.l    0
  10261. BrokerSigFlag    dc.l    0
  10262. TimerSigFlag    dc.l    0
  10263. ARexxSigFlag    dc.l    0
  10264. AlarmSigFlag    dc.l    0
  10265. HelpSigFlag    dc.l    0
  10266. AppSigFlag    dc.l    0
  10267. AlarmSigBit    dc.l    0
  10268. HelpSigBit    dc.l    0
  10269. ThisSig        dc.l    0
  10270. WindowSigFlag    dc.l    0
  10271. ClockSigFlag    dc.l    0
  10272. MyILock        dc.l    0
  10273. MouseX        dc.l    0
  10274. MouseY        dc.l    0
  10275. ActWindow    dc.l    0
  10276. WndHandle    dc.l    0
  10277. FirstGadget    dc.l    0
  10278. VisInfo        dc.l    0
  10279. MainMenu    dc.l    0
  10280. ClockHandle    dc.l    0
  10281. LogHandle    dc.l    0
  10282. LogGadget    dc.l    0
  10283. LogVisInfo    dc.l    0
  10284. LogMenu        dc.l    0
  10285. BillHandle    dc.l    0
  10286. BillRPort    dc.l    0
  10287. BillSigFlag    dc.l    0
  10288. BillGadget    dc.l    0
  10289. BillVisInfo    dc.l    0
  10290. BillMenu    dc.l    0
  10291. PrefsHandle    dc.l    0
  10292. PrefsSigFlag    dc.l    0
  10293. PrefsGadget    dc.l    0
  10294. PrefsVisInfo    dc.l    0
  10295. PrefsMenu    dc.l    0
  10296. HotKeyHandle    dc.l    0
  10297. HotKeySigFlag    dc.l    0
  10298. HotKeyGadget    dc.l    0
  10299. HotKeyVisInfo    dc.l    0
  10300. HotKeyMenu    dc.l    0
  10301. HelpNum        dc.l    0
  10302. HelpText    dc.l    0
  10303. HelpHandle    dc.l    0
  10304. HelpRPort    dc.l    0
  10305. HelpFont    dc.l    0
  10306. HelpGadget    dc.l    0
  10307. HelpVisInfo    dc.l    0
  10308. HelpMenu    dc.l    0
  10309. HelpScroll    dc.l    0
  10310. HelpItem    dc.w    0
  10311. ThisGadget    dc.l    0
  10312. BlankHandle    dc.l    0
  10313. FileHand    dc.l    0
  10314. TempHand    dc.l    0
  10315. OurLock        dc.l    0
  10316. PastLock    dc.l    0
  10317. QuitBroker    dc.w    0
  10318. ToolPri        dc.l    21
  10319. CXPri        dc.l    5
  10320. ClockWidth    dc.w    0
  10321. WinLeftEdge    dc.l    0
  10322. WinTopEdge    dc.l    0
  10323. ErrorNum    dc.l    -1
  10324. MyBitMap    dc.l    0
  10325. MyRastPort    dc.l    0
  10326. MyFont        dc.l    0
  10327. BitMapWidth    dc.w    0
  10328. BitMapHeight    dc.w    0
  10329. BitMapDepth    dc.w    0
  10330. BitMapSize    dc.l    0
  10331. LeftEdge    dc.l    0
  10332. BlitWidth    dc.l    0
  10333. MyARexxMsg    dc.l    0
  10334. ARexxCommand    dc.l    0
  10335. ARexxAction    dc.l    0
  10336. AResult1    dc.l    0
  10337. AResult2    dc.l    0
  10338. IEClass        dc.w    0
  10339. IEvent        dc.l    0
  10340. ScreenOff    dc.l    0
  10341. MouseOff    dc.l    0
  10342. PageNum        dc.l    0
  10343. EWidth        dc.l    0
  10344. FWidth        dc.l    0
  10345. MyAslRequest    dc.l    0
  10346. AllocKey    dc.w    0
  10347. KCXAppIcon    dc.l    0
  10348. DoActWindow    dc.l    0
  10349. DoActGadget    dc.l    0
  10350. OldSprite    dc.w    -1,-1
  10351. ToolPriStr    dc.b    "TOOLPRI",0
  10352. PriStr        dc.b    "CX_PRIORITY",0
  10353. KeyStr        dc.b    "CX_POPKEY",0
  10354. PopUpStr    dc.b    "CX_POPUP",0,0
  10355. PortNameStr    dc.b    "PORTNAME",0,0
  10356. ActivateStr    dc.b    "ACTIVATE",0,0
  10357. MouseStr    dc.b    "MOUSEMODE",0
  10358. ShowCStr    dc.b    "SHOWCLOCK",0
  10359. ClockWStr    dc.b    "CLOCKWIN",0,0
  10360. ClockPosStr    dc.b    "CLOCKWINPOS",0
  10361. ShowDateStr    dc.b    "SHOWDATE",0,0
  10362. ShowDayStr    dc.b    "SHOWDAY",0
  10363. ShortDayStr    dc.b    "SHORTDAY",0,0
  10364. ShowSecsStr    dc.b    "SHOWSECS",0,0
  10365. AmiDateStr    dc.b    "AMIDATE",0
  10366. PageStr        dc.b    "PAGEKEY",0
  10367. PageNumStr    dc.b    "PAGENUM",0
  10368. AlarmStr    dc.b    "ALARM",0
  10369. AlarmTimeStr    dc.b    "ALARMTIME",0
  10370. SetEnvStr    dc.b    "SETENV",0,0
  10371. ScreenTStr    dc.b    "SCREENTIME",0,0
  10372. MouseTStr    dc.b    "MOUSETIME",0
  10373. CycleWStr    dc.b    "CYCLEWIN",0,0
  10374. CycleStr    dc.b    "CYCLEKEY",0,0
  10375. ClickStr    dc.b    "CLICK",0
  10376. ClickVStr    dc.b    "CLICKVOL",0,0
  10377. BillPosStr    dc.b    "BILLWINPOS",0,0
  10378. BillWinStr    dc.b    "BILLPOPUP",0
  10379. PrefsPosStr    dc.b    "PREFSWINPOS",0
  10380. LogCallStr    dc.b    "LOGCALLS",0,0
  10381. WBFrontStr    dc.b    "WBFRONT",0
  10382. LeftyStr    dc.b    "LEFTYMOUSE",0,0
  10383. ESCCloseStr    dc.b    "ESCCLOSE",0,0
  10384. ESCQualStr    dc.b    "ESCKEY",0,0
  10385. UmlautOnStr    dc.b    "MAPUMLAUT",0
  10386. BillKeyStr    dc.b    "BILLKEY",0
  10387. PrefsKeyStr    dc.b    "PREFSKEY",0,0
  10388. HotKeyStr    dc.b    "HOTWINKEY",0
  10389. ShellKeyStr    dc.b    "SHELLKEY",0,0
  10390. UmlautKeyStr    dc.b    "UMLAUTKEY",0
  10391. ShellCommStr    dc.b    "SHELLCOMM",0
  10392. IconStr        dc.b    "NOICON",0,0
  10393. EnableStr    dc.b    "ENABLE",0,0
  10394. DisableStr    dc.b    "DISABLE",0
  10395. HideStr        dc.b    "HIDE",0,0
  10396. AClearLogStr    dc.b    "CLEARLOG",0,0
  10397. APopUpStr    dc.b    "POPUP",0
  10398. AStatusStr    dc.b    "STATUS",0,0
  10399. AReviseStr    dc.b    "REVISE",0,0
  10400. AReviseAsmStr    dc.b    "ASM",0
  10401. AReviseCStr    dc.b    "C",0
  10402. ARevisePasStr    dc.b    "PAS",0
  10403. ALoadPrefsStr    dc.b    "LOADPREFS",0
  10404. ASavePrefsStr    dc.b    "SAVEPREFS",0
  10405. OnString    dc.b    "ON",0,0
  10406. OffString    dc.b    "OFF",0
  10407. YesString    dc.b    "YES",0
  10408. NoString    dc.b    "NO",0,0
  10409. AskString    dc.b    "?",0
  10410. EnvDayString    dc.b    "DAY",0
  10411. EnvDateString    dc.b    "DATE",0,0
  10412. EnvTimeString    dc.b    "TIME",0,0
  10413. AuthorString    dc.b    "AUTHOR",0,0
  10414. CompanyString    dc.b    "COMPANY",0
  10415. FalseStr    dc.b    "0",0
  10416. TrueStr        dc.b    "1",0
  10417. FileName    ds.b    128
  10418.         EVEN
  10419.  
  10420.  
  10421.  
  10422.  
  10423.  
  10424.  
  10425. **********************************************************************
  10426. *                           Some booleans                            *
  10427. **********************************************************************
  10428. DoActivate    dc.b    1
  10429. MouseMode    dc.b    0
  10430. ShowClock    dc.b    1
  10431. ClockWin    dc.b    0
  10432. ShowSecs    dc.b    1
  10433. AmiDate        dc.b    0
  10434. ShowDay        dc.b    0
  10435. ShowDate    dc.b    0
  10436. ShortDay    dc.b    0
  10437. DoAlarm        dc.b    0
  10438. SetEnv        dc.b    0
  10439. CycleWin    dc.b    1
  10440. KeyClick    dc.b    1
  10441. BillPopUp    dc.b    1
  10442. LogCalls    dc.b    1
  10443. WBFront        dc.b    1
  10444. LeftyMouse    dc.b    0
  10445. ESCClose    dc.b    1
  10446. MapUmlaut    dc.b    0
  10447. FLAGSET        EQU    *-DoActivate
  10448.  
  10449. NoBillPopDown    dc.b    0
  10450. MouseTimeOut    dc.b    0
  10451. ScrTimeOut    dc.b    0
  10452. SprOff        dc.b    0
  10453. OnlyLog        dc.b    0
  10454. LogInputEnd    dc.b    0
  10455. Disabled    dc.b    0
  10456. DoPopUp        dc.b    1
  10457. TimeReset    dc.b    1
  10458. Online        dc.b    0
  10459. CheapMode    dc.b    0
  10460. DoRemakeCosts    dc.b    0
  10461. DispAppIcon    dc.b    1
  10462. Scrolling    dc.b    0
  10463. HelpPage    dc.b    0
  10464.         EVEN
  10465. ScreenTime    dc.l    60
  10466. MouseTime    dc.l    10
  10467. ClickVol    dc.l    32
  10468. PopQualNum    dc.l    0
  10469. ESCQualNum    dc.l    4
  10470. LONGQUAL    EQU    *-ScreenTime
  10471.  
  10472.  
  10473.  
  10474. **********************************************************************
  10475. *                    Pointers to Device-Requests                     *
  10476. **********************************************************************
  10477. TimerReq    dc.l    0
  10478. AudioReq    dc.l    0
  10479. ConsoleReq    dc.l    0
  10480.  
  10481.  
  10482.  
  10483. **********************************************************************
  10484. *                            Audio-Stuff                             *
  10485. **********************************************************************
  10486. LEFTCH0        EQU    1
  10487. RIGHTCH0    EQU    2
  10488. LEFTCH1        EQU    8
  10489. RIGHTCH1    EQU    4
  10490. AnyChannel    dc.b    LEFTCH0|RIGHTCH0
  10491.         dc.b    LEFTCH0|RIGHTCH1
  10492.         dc.b    LEFTCH1|RIGHTCH0
  10493.         dc.b    LEFTCH1|RIGHTCH1
  10494.         dc.b    LEFTCH0
  10495.         dc.b    LEFTCH1
  10496.         dc.b    RIGHTCH0
  10497.         dc.b    RIGHTCH1
  10498.  
  10499.  
  10500. **********************************************************************
  10501. *                Tags for new process of timer events                *
  10502. **********************************************************************
  10503. CheckerTags    dc.l    NP_Entry            ; We only supply an entry point
  10504.         dc.l    TimeChecker
  10505.         dc.l    NP_Name                ; Name of process
  10506.         dc.l    CheckerName
  10507.         dc.l    NP_Priority            ; We run at a higher proirity
  10508.         dc.l    3                ; so that we`re quite fast
  10509.         dc.l    NP_StackSize            ; Stack-Size to be used
  10510.         dc.l    4096
  10511.         dc.l    TAG_DONE
  10512.         dc.l    0
  10513.  
  10514.  
  10515. **********************************************************************
  10516. *              ARexx-Status pointers and their numbers               *
  10517. **********************************************************************
  10518. RESULTBYTE    EQU    1
  10519. RESULTWORD    EQU    2
  10520. RESULTLONG    EQU    3
  10521. RESULTSTRING    EQU    4
  10522. RESULTCLOCKPOS    EQU    5
  10523. RESULTTIME    EQU    6
  10524. RESULTPOP    EQU    7
  10525. RESULTBILLPOS    EQU    8
  10526. RESULTPREFSPOS    EQU    9
  10527. ARexxStatus    dc.l    RESULTLONG,ToolPri
  10528.         dc.l    RESULTLONG,CXPri
  10529.         dc.l    RESULTSTRING,PopUpKey
  10530.         dc.l    RESULTBYTE,DoPopUp
  10531.         dc.l    RESULTBYTE,DoActivate
  10532.         dc.l    RESULTBYTE,MouseMode
  10533.         dc.l    RESULTBYTE,ShowClock
  10534.         dc.l    RESULTBYTE,ClockWin
  10535.         dc.l    RESULTCLOCKPOS,0        ; This is for the ClockWinPos
  10536.         dc.l    RESULTBYTE,ShowDate
  10537.         dc.l    RESULTBYTE,ShowDay
  10538.         dc.l    RESULTBYTE,ShowSecs
  10539.         dc.l    RESULTBYTE,AmiDate
  10540.         dc.l    RESULTSTRING,PageHotKey
  10541.         dc.l    RESULTLONG,PageNum
  10542.         dc.l    RESULTBYTE,DoAlarm
  10543.         dc.l    RESULTTIME,0            ; This is for alarmtime
  10544.         dc.l    RESULTBYTE,Disabled
  10545.         dc.l    RESULTPOP,0            ; This is for poped up mode
  10546.         dc.l    RESULTBYTE,SetEnv
  10547.         dc.l    RESULTBYTE,ShortDay
  10548.         dc.l    RESULTLONG,ScreenTime
  10549.         dc.l    RESULTLONG,MouseTime
  10550.         dc.l    RESULTBYTE,CycleWin
  10551.         dc.l    RESULTLONG,PopQualNum
  10552.         dc.l    RESULTBYTE,KeyClick
  10553.         dc.l    RESULTLONG,ClickVol
  10554.         dc.l    RESULTBYTE,LogCalls
  10555.         dc.l    RESULTBILLPOS,0            ; BillWinPos
  10556.         dc.l    RESULTBYTE,BillPopUp
  10557.         dc.l    RESULTPREFSPOS,0        ; PrefsWinPos
  10558.         dc.l    RESULTBYTE,WBFront
  10559.         dc.l    RESULTBYTE,LeftyMouse
  10560.         dc.l    RESULTBYTE,ESCClose
  10561.         dc.l    RESULTLONG,ESCQualNum
  10562.         dc.l    RESULTSTRING,BillHotKey
  10563.         dc.l    RESULTSTRING,PrefsHotKey
  10564.         dc.l    RESULTSTRING,HotWinHotKey
  10565.         dc.l    RESULTSTRING,ShellHotKey
  10566.         dc.l    RESULTSTRING,UmlautHotKey
  10567.         dc.l    RESULTSTRING,SystemParam
  10568.         dc.l    RESULTBYTE,MapUmlaut
  10569. StatusCount    EQU    (*-ARexxStatus)/8
  10570. StatusNum    dc.l    0
  10571. ResultData    dc.l    0
  10572. ResultWinData    dc.w    0
  10573.         dc.w    0
  10574.  
  10575.  
  10576.  
  10577.  
  10578.  
  10579. **********************************************************************
  10580. *          Formats and data for C/ASM/PAS Revision Headers           *
  10581. **********************************************************************
  10582. CHeader        dc.b    "/* $Revision Header built by KCommodity by Kai Iske *** (do not edit) ************",$0a
  10583.         dc.b    "**",$0a,0
  10584.         EVEN
  10585. CLineNL        dc.b    "**",$0a,0
  10586. CLine        dc.b    "**     ",0,0
  10587. CCopyRight    dc.b    "** © Copyright by %s",$0a
  10588.         dc.b    "**",$0a,0
  10589.         EVEN
  10590. CFile        dc.b    "** File             : %s",$0a,0
  10591.         EVEN
  10592. CCreatedOn    dc.b    "** Created on       : %s, %s %s",$0a,0
  10593.         EVEN
  10594. CAuthor        dc.b    "** Created by       : %s",$0a,0
  10595.         EVEN
  10596. CRevision    dc.b    "** Current revision : V%d.%02.2d",$0a,0
  10597.         EVEN
  10598. CPurpose    dc.b    "**",$0a
  10599.         dc.b    "**",$0a
  10600.         dc.b    "** Purpose",$0a
  10601.         dc.b    "** -------",$0a,0
  10602.         EVEN
  10603. CLog        dc.b    "**",$0a
  10604.         dc.b    "** Revision V%d.%02.2d",$0a
  10605.         dc.b    "** --------------",$0a
  10606.         dc.b    "** changed on %s, %s %s  by  %s.   LogMessage :",$0a,0
  10607.         EVEN
  10608. CLogInit    dc.b    "**",$0a
  10609.         dc.b    "** Revision V%d.%02.2d",$0a
  10610.         dc.b    "** --------------",$0a
  10611.         dc.b    "**     --- Initial release ---",$0a
  10612.         dc.b    "**",$0a
  10613. CEnd        dc.b    "*********************************************************************************/",$0a,0
  10614.         EVEN
  10615. CRevDefine1    dc.b    '#define REVISION "%d.%02.2d"',$09,$09,"/* This is the revision number */",$0a
  10616.         dc.b    '#define REVDATE  "%s"',$09,$09,"/* This is the revision date */",$0a
  10617.         EVEN
  10618.  
  10619.  
  10620.  
  10621. AsmHeader    dc.b    ";* $Revision Header built by KCommodity by Kai Iske *** (do not edit) ************",$0a
  10622.         dc.b    ";*",$0a,0
  10623.         EVEN
  10624. AsmLineNL    dc.b    ";*",$0a,0
  10625. AsmLine        dc.b    ";*     ",0,0
  10626. AsmCopyRight    dc.b    ";* © Copyright by %s",$0a
  10627.         dc.b    ";*",$0a,0
  10628.         EVEN
  10629. AsmFile        dc.b    ";* File             : %s",$0a,0
  10630.         EVEN
  10631. AsmCreatedOn    dc.b    ";* Created on       : %s, %s %s",$0a,0
  10632.         EVEN
  10633. AsmAuthor    dc.b    ";* Created by       : %s",$0a,0
  10634.         EVEN
  10635. AsmRevision    dc.b    ";* Current revision : V%d.%02.2d",$0a,0
  10636.         EVEN
  10637. AsmPurpose    dc.b    ";*",$0a
  10638.         dc.b    ";*",$0a
  10639.         dc.b    ";* Purpose",$0a
  10640.         dc.b    ";* -------",$0a,0
  10641.         EVEN
  10642. AsmLog        dc.b    ";*",$0a
  10643.         dc.b    ";* Revision V%d.%02.2d",$0a
  10644.         dc.b    ";* --------------",$0a
  10645.         dc.b    ";* changed on %s, %s %s  by  %s.   LogMessage :",$0a,0
  10646.         EVEN
  10647. AsmLogInit    dc.b    ";*",$0a
  10648.         dc.b    ";* Revision V%d.%02.2d",$0a
  10649.         dc.b    ";* --------------",$0a
  10650.         dc.b    ";*     --- Initial release ---",$0a
  10651.         dc.b    ";*",$0a
  10652. AsmEnd        dc.b    ";*********************************************************************************",$0a,0
  10653.         EVEN
  10654. AsmRevDefine1    dc.b    "REVISION  MACRO        ; This is the macro for the revision number",$0a
  10655.         dc.b    '          dc.b "%d.%02.2d"',$0a
  10656.         dc.b    "          ENDM",$0a
  10657.         dc.b    "REVDATE   MACRO        ; This is the macro for the revision date",$0a
  10658.         dc.b    '          dc.b "%s"',$0a
  10659.         dc.b    "          ENDM",$0a,0
  10660.         EVEN
  10661.  
  10662.  
  10663. PASHeader    dc.b    "(* $Revision Header built by KCommodity by Kai Iske *** (do not edit) ************",$0a
  10664.         dc.b    "**",$0a,0
  10665.         EVEN
  10666. PASLogInit    dc.b    "**",$0a
  10667.         dc.b    "** Revision V%d.%02.2d",$0a
  10668.         dc.b    "** --------------",$0a
  10669.         dc.b    "**     --- Initial release ---",$0a
  10670.         dc.b    "**",$0a
  10671. PASEnd        dc.b    "*********************************************************************************)",$0a,0
  10672.         EVEN
  10673. PASRevDefine1    dc.b    "CONST (* Place all your constants beneith these ones *)",$0a
  10674.         dc.b    '        REVISION = "%d.%02.2d"        (* This is the revision number *)',$0a
  10675.         dc.b    '         REVDATE = "%s"    (* This is the revision date *)',$0a,0
  10676.         EVEN
  10677.  
  10678. RevHeader    dc.l    0
  10679. RevLineNL    dc.l    0
  10680. RevLine        dc.l    0
  10681. RevCompany    dc.l    0
  10682. RevFile        dc.l    0
  10683. RevCreatedOn    dc.l    0
  10684. RevAuthor    dc.l    0
  10685. RevRevision    dc.l    0
  10686. RevPurpose    dc.l    0
  10687. RevLog        dc.l    0
  10688. RevLogInit    dc.l    0
  10689. RevEnd        dc.l    0
  10690. RevDefine    dc.l    0
  10691. RevCompanyDat    dc.l    Company
  10692. RevFileDat    dc.l    FileName
  10693. RevRevisionDat    dc.w    0
  10694.         dc.w    0
  10695. RevCreatedOnDat    dc.l    RevDayString
  10696.         dc.l    RevDateString
  10697.         dc.l    RevTimeString
  10698. RevAuthorDat    dc.l    Author
  10699. RevDefineDat    dc.w    0
  10700.         dc.w    0
  10701.         dc.l    RevDateString
  10702. PurposeMsg    ds.b    77*5
  10703. LogMsg        ds.b    77*5
  10704. Author        ds.b    130
  10705. Company        ds.b    130
  10706. ReadBuffer    dc.l    0
  10707. DefaultName    dc.b    "--- Unknown ---",0
  10708.         EVEN
  10709.  
  10710.  
  10711.  
  10712. **********************************************************************
  10713. *                       This is our datetime                         *
  10714. **********************************************************************
  10715. MyDateTime    ds.b    dat_SIZEOF
  10716. DayString    ds.b    LEN_DATSTRING
  10717. DateString    ds.b    LEN_DATSTRING
  10718. TimeString    ds.b    LEN_DATSTRING
  10719. OnlineString    ds.b    LEN_DATSTRING
  10720. AllDayString    ds.b    LEN_DATSTRING
  10721. AllDateString    ds.b    LEN_DATSTRING
  10722. AllTimeString    ds.b    LEN_DATSTRING
  10723. RevDayString    ds.b    LEN_DATSTRING
  10724. RevDateString    ds.b    LEN_DATSTRING
  10725. RevTimeString    ds.b    LEN_DATSTRING
  10726. CopyTime    ds.b    LEN_DATSTRING
  10727. **********************************************************************
  10728. *                   Formats for displaying the day                   *
  10729. **********************************************************************
  10730. FormatData    dc.l    DayString
  10731.         dc.l    DateString
  10732.         dc.l    TimeString
  10733. FinalString    ds.b    ((LEN_DATSTRING*3)+10)
  10734. OnlineFormStr    dc.b    "Online ",0
  10735.         EVEN
  10736. EString        dc.b    "E",0
  10737.         EVEN
  10738. FString        dc.b    "F",0
  10739.         EVEN
  10740.  
  10741.  
  10742. **********************************************************************
  10743. *               The main structure of all...The Broker               *
  10744. **********************************************************************
  10745.         CNOP    0,4
  10746. MyBrokerDef    dc.b    NB_VERSION            ; Commodities-Version (NEEDED)
  10747.         dc.b    0
  10748.         dc.l    BrokerName            ; Name of broker (For Exchange-Prg)
  10749.         dc.l    BrokerTitle            ; Title   (For Exchange-Prg)
  10750.         dc.l    BrokerDesc            ; Broker-Description (For Exchange-Prg)
  10751.         dc.w    NBU_NOTIFY!NBU_UNIQUE        ; Notify broker, we are unique
  10752.         dc.w    COF_SHOW_HIDE            ; We can be hidden/shown
  10753.         dc.w    0                ; Pri of broker plus an alignment byte
  10754.         dc.l    0                ; Port-Pointer
  10755.         dc.w    0                ; Dummy
  10756. BrokerName    dc.b    "KCommodity",0
  10757.         EVEN
  10758. BrokerTitle    dc.b    "KCommodity V"
  10759.         REVISION
  10760.         dc.b    " ("
  10761.         REVDATE
  10762.         dc.b    ")"
  10763.         dc.b    ", Kai Iske",0
  10764.         EVEN
  10765. BrokerDesc    dc.b    "Multifunction commodity. SHAREWARE",0
  10766.         EVEN
  10767.  
  10768.  
  10769.  
  10770. **********************************************************************
  10771. *                     Definition of Input-Filter                     *
  10772. **********************************************************************
  10773.         CNOP    0,4
  10774. MyCustomIXDef    dc.b    IX_VERSION            ; Version of filter (NEEDED)
  10775.         dc.b    0                ; Filter Event-Class (that we want)
  10776.         dc.w    0                ; Codes (Bits)
  10777.         dc.w    0                ; Codes-Mask for filtering the Codes
  10778.         dc.w    0                ; Qualifier
  10779.         dc.w    0                ; Qualifier-Mask
  10780.         dc.w    0                ; Qualifier-Synonyms
  10781.  
  10782.  
  10783.  
  10784. **********************************************************************
  10785. *                         AutoRequester-Texts                        *
  10786. **********************************************************************
  10787. Only20ITxt    dc.b    0,1
  10788.         dc.b    RP_JAM1
  10789.         dc.b    0
  10790.         dc.w    10,10
  10791.         dc.l    0
  10792.         dc.l    Only20Txt
  10793.         dc.l    0
  10794. Only20Txt    dc.b    "This only runs under OS 2.x !",0,$0a
  10795. Only20TxtEnd
  10796.         EVEN
  10797. OkITxt        dc.b    2,1
  10798.         dc.b    RP_JAM1
  10799.         dc.b    0
  10800.         dc.w    6,3
  10801.         dc.l    0
  10802.         dc.l    OkTxt
  10803.         dc.l    0
  10804. OkTxt        dc.b    "OK",0
  10805.         EVEN
  10806.  
  10807.  
  10808. **********************************************************************
  10809. *                            Error-Texts                             *
  10810. **********************************************************************
  10811. EasyTitle    dc.b    "KCommodity V"
  10812.         REVISION
  10813. EasyTitleEnd
  10814.         EVEN
  10815. EasyTexts    dc.l    NoLibErr,NoMsgPErr,NoBrokerErr,NoCFilterErr
  10816.         dc.l    CFilterErr,BrokerErr,NoTimerPortErr,NoPlanesErr
  10817.         dc.l    NoFontErr,DefPopUpKey,DefPageKey,NoARexxPortErr
  10818.         dc.l    OutOfMemory,NoBitMap,NoRastPort,NoAudioPortErr
  10819.         dc.l    NoChannelsErr,NoPlayingErr,NoTempBuff
  10820.         dc.l    NoTimerBuff,NoAudioBuff,NoConsoleBuff,DefPrefsKeyUse
  10821.         dc.l    DefBillKeyUse,DefHotWinKeyUse,DefShellKeyUse,NoHotKeyErr
  10822.         dc.l    DefUmlautKeyUse
  10823. NoLibErr    dc.b    "%s could not be opened.",0
  10824.         EVEN
  10825. NoMsgPErr    dc.b    "Broker-Port could not be created.",0
  10826.         EVEN
  10827. NoBrokerErr    dc.b    "Broker could not be set up.",0
  10828.         EVEN
  10829. NoCFilterErr    dc.b    "Filter for CUSTOM handler could not be set up.",0
  10830.         EVEN
  10831. CFilterErr    dc.b    "Definition of CUSTOM handler failed.",0
  10832.         EVEN
  10833. BrokerErr    dc.b    "Broker could not be set up correctly.",0
  10834.         EVEN
  10835. NoTimerPortErr    dc.b    "Could not generate Timer-Port.",0
  10836.         EVEN
  10837. NoPlanesErr    dc.b    "Could not allocate memory for BitPlanes.",0
  10838.         EVEN
  10839. NoFontErr    dc.b    "Could not set appropriate font.",0
  10840.         EVEN
  10841. DefPopUpKey    dc.b    "User PopUp-HotKey",$0a,$0a
  10842.         dc.b    "%s",$0a,$0a
  10843.         dc.b    "could not be installed.",$0a,$0a
  10844.         dc.b    "Now using default : LCOMMAND HELP",0
  10845.         EVEN
  10846. DefPageKey    dc.b    "User Page-HotKey",$0a,$0a
  10847.         dc.b    "%s",$0a,$0a
  10848.         dc.b    "could not be installed.",$0a,$0a
  10849.         dc.b    "Now using default : RALT HELP",0
  10850.         EVEN
  10851. NoARexxPortErr    dc.b    "Could not set up ARexx-Port.",0
  10852.         EVEN
  10853. OutOfMemory    dc.b    "Sorry out of memory.",0
  10854.         EVEN
  10855. NoBitMap    dc.b    "Sorry, could not generate BitMap.",0
  10856.         EVEN
  10857. NoRastPort    dc.b    "Sorry, could not generate RastPort.",0
  10858.         EVEN
  10859. NoAudioPortErr    dc.b    "Audio-Port could not be set up.",0
  10860.         EVEN
  10861. NoChannelsErr    dc.b    "Channel for click could not be allocated.",0
  10862.         EVEN
  10863. NoPlayingErr    dc.b    "Click-Sound can not be played.",0
  10864.         EVEN
  10865. NoTempBuff    dc.b    "Could not allocate memory for Temp-Buffer.",0
  10866.         EVEN
  10867. NoTimerBuff    dc.b    "Could not allocate memory for Timer-Request.",0
  10868.         EVEN
  10869. NoAudioBuff    dc.b    "Could not allocate memory for Audio-Request.",0
  10870.         EVEN
  10871. NoConsoleBuff    dc.b    "Could not allocate memory for Console-Request.",0
  10872.         EVEN
  10873. DefPrefsKeyUse    dc.b    "User Preferences-HotKey",$0a,$0a
  10874.         dc.b    "%s",$0a,$0a
  10875.         dc.b    "could not be installed.",$0a,$0a
  10876.         dc.b    "Now using default : ALT SHIFT P",0
  10877.         EVEN
  10878. DefBillKeyUse    dc.b    "User BillWindow-HotKey",$0a,$0a
  10879.         dc.b    "%s",$0a,$0a
  10880.         dc.b    "could not be installed.",$0a,$0a
  10881.         dc.b    "Now using default : ALT SHIFT B",0
  10882.         EVEN
  10883. DefHotWinKeyUse    dc.b    "User HotKeyWindow-HotKey",$0a,$0a
  10884.         dc.b    "%s",$0a,$0a
  10885.         dc.b    "could not be installed.",$0a,$0a
  10886.         dc.b    "Now using default : ALT SHIFT H",0
  10887.         EVEN
  10888. DefShellKeyUse    dc.b    "User Shell-HotKey",$0a,$0a
  10889.         dc.b    "%s",$0a,$0a
  10890.         dc.b    "could not be installed.",$0a,$0a
  10891.         dc.b    "Now using default : ALT SHIFT S",0
  10892.         EVEN
  10893. NoHotKeyErr    dc.b    "Default HotKey",$0a,$0a
  10894.         dc.b    "%s",$0a,$0a
  10895.         dc.b    "could not be set up. Aborting",0
  10896.         EVEN
  10897. DefUmlautKeyUse    dc.b    "User Umlaut-HotKey",$0a,$0a
  10898.         dc.b    "%s",$0a,$0a
  10899.         dc.b    "could not be installed.",$0a,$0a
  10900.         dc.b    "Now using default : ALT SHIFT U",0
  10901.         EVEN
  10902.  
  10903.  
  10904. **********************************************************************
  10905. *                          About requester                           *
  10906. **********************************************************************
  10907. AboutText    dc.b    "KCommodity V"
  10908.         REVISION
  10909.         dc.b    $0a
  10910.         dc.b    "last changed : "
  10911.         REVDATE
  10912.         dc.b    $0a
  10913.         dc.b    "written by Kai Iske",$0a
  10914.         dc.b    "© 1992 Kai Iske, ShareWare 20 DM, $20",$0a,0
  10915.         EVEN
  10916. AboutGadgets    dc.b    "OK|REGISTER",0
  10917.         EVEN
  10918.  
  10919.  
  10920.  
  10921. **********************************************************************
  10922. *                 Include the text for registration                  *
  10923. **********************************************************************
  10924. RegisterTxt    INCBIN    "Register.TXT"
  10925.         dc.b    0,0
  10926.         EVEN
  10927. REGISTERLEN    EQU    *-RegisterTxt
  10928.  
  10929.  
  10930. **********************************************************************
  10931. *                 These are the important dos errors                 *
  10932. **********************************************************************
  10933. DosErrors    dc.l    0,0,Error202,0,Error204,Error205,0,0,0,0,0,0,0
  10934.         dc.l    Error213,Error214,0,0,0,Error218,0,0,Error221
  10935.         dc.l    Error222,Error223,Error224,Error225,Error226
  10936.         dc.l    0,0,0,0,0,0,0
  10937. Error202    dc.b    "Can`t open %s.",$0a
  10938.         dc.b    "Object in use.",0
  10939.         EVEN
  10940. Error204    dc.b    "Can`t open %s.",$0a
  10941.         dc.b    "Directory not found.",0
  10942.         EVEN
  10943. Error205    dc.b    "Can`t open %s.",$0a
  10944.         dc.b    "Object not found.",0
  10945.         EVEN
  10946. Error213    dc.b    "Disk not validated.",0
  10947.         EVEN
  10948. Error214    dc.b    "Disk is write-protected.",0
  10949.         EVEN
  10950. Error218    dc.b    "Device/Volume not mounted.",0
  10951.         EVEN
  10952. Error221    dc.b    "Disk is full.",0
  10953.         EVEN
  10954. Error222    dc.b    "Can`t delete %s.",$0a
  10955.         dc.b    "Object is protected from deletion.",0
  10956.         EVEN
  10957. Error223    dc.b    "Can`t write to %s.",$0a
  10958.         dc.b    "File is write-protected.",0
  10959.         EVEN
  10960. Error224    dc.b    "Can`t read %s",$0a
  10961.         dc.b    "File is read protected",0
  10962.         EVEN
  10963. Error225    dc.b    "Not a valid DOS disk",0
  10964.         EVEN
  10965. Error226    dc.b    "No disk in drive",0
  10966.         EVEN
  10967. EasyGadget    dc.b    "OK",0
  10968. EasyArg        dc.l    0
  10969.         EVEN
  10970.  
  10971.  
  10972. **********************************************************************
  10973. *                       Easy-Requeststructure                        *
  10974. **********************************************************************
  10975. MyEasyRequest    dc.l    es_SIZEOF
  10976.         dc.l    0
  10977.         dc.l    0
  10978.         dc.l    0
  10979.         dc.l    0
  10980.  
  10981.  
  10982. **********************************************************************
  10983. *                 Definition for the blanked screen                  *
  10984. **********************************************************************
  10985. BlankScreenDef    dc.w    0,0
  10986.         dc.w    64,-1
  10987.         dc.w    1
  10988.         dc.b    -1,-1
  10989.         dc.w    0
  10990.         dc.w    CUSTOMSCREEN|SCREENQUIET
  10991.         dc.l    0
  10992.         dc.l    0
  10993.         dc.l    0
  10994.         dc.l    0
  10995.  
  10996.  
  10997. **********************************************************************
  10998. *                 Some defines fo easy customization                 *
  10999. **********************************************************************
  11000. WINWIDTH    EQU    620
  11001. WINHEIGHT    EQU    155
  11002. WINIDCMP    EQU    CYCLEIDCMP|STRINGIDCMP|CHECKBOXIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_ACTIVEWINDOW|IDCMP_MENUPICK|IDCMP_CHANGEWINDOW|IDCMP_MENUHELP|IDCMP_RAWKEY
  11003. WINFLAGS    EQU    WFLG_DRAGBAR|WFLG_CLOSEGADGET|WFLG_DEPTHGADGET|WFLG_ACTIVATE
  11004. LOGWINWIDTH    EQU    630
  11005. LOGWINHEIGHT    EQU    86
  11006. LOGWINIDCMP    EQU    IDCMP_CLOSEWINDOW|STRINGIDCMP|BUTTONIDCMP|IDCMP_ACTIVEWINDOW|IDCMP_VANILLAKEY|IDCMP_CHANGEWINDOW
  11007. LOGWINFLAGS    EQU    WFLG_DEPTHGADGET|WFLG_DRAGBAR|WFLG_CLOSEGADGET|WFLG_ACTIVATE|WFLG_RMBTRAP
  11008. BILLWINWIDTH    EQU    240
  11009. BILLWINHEIGHT    EQU    80
  11010. BILLWINIDCMP    EQU    MXIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_CHANGEWINDOW|IDCMP_MENUPICK|IDCMP_RAWKEY|IDCMP_MENUHELP
  11011. BILLWINFLAGS    EQU    WFLG_DEPTHGADGET|WFLG_DRAGBAR|WFLG_CLOSEGADGET
  11012. PREFSWINWIDTH    EQU    422
  11013. PREFSWINHEIGHT    EQU    136
  11014. PREFSWINIDCMP    EQU    BUTTONIDCMP|STRINGIDCMP|LISTVIEWIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_RAWKEY|IDCMP_CHANGEWINDOW|IDCMP_MENUHELP|IDCMP_MENUPICK|IDCMP_ACTIVEWINDOW
  11015. PREFSWINFLAGS    EQU    WFLG_DEPTHGADGET|WFLG_DRAGBAR|WFLG_CLOSEGADGET|WFLG_ACTIVATE
  11016. CLOCKWIDTH    EQU    1
  11017. CLOCKHEIGHT    EQU    1
  11018. CLOCKIDCMP    EQU    IDCMP_CHANGEWINDOW|IDCMP_CLOSEWINDOW
  11019. CLOCKFLAGS    EQU    WFLG_CLOSEGADGET|WFLG_DEPTHGADGET|WFLG_DRAGBAR|WFLG_RMBTRAP
  11020. KEYWINWIDTH    EQU    400
  11021. KEYWINHEIGHT    EQU    98
  11022. KEYWINIDCMP    EQU    STRINGIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_CHANGEWINDOW|IDCMP_MENUPICK|IDCMP_ACTIVEWINDOW|IDCMP_RAWKEY|IDCMP_MENUHELP
  11023. KEYWINFLAGS    EQU    WFLG_CLOSEGADGET|WFLG_DEPTHGADGET|WFLG_DRAGBAR|WFLG_ACTIVATE
  11024. HELPWINWIDTH    EQU    600
  11025. HELPWINHEIGHT    EQU    100
  11026. HELPWINIDCMP    EQU    SLIDERIDCMP|IDCMP_MOUSEMOVE|ARROWIDCMP|IDCMP_CLOSEWINDOW|IDCMP_RAWKEY|IDCMP_CHANGEWINDOW|IDCMP_MENUPICK
  11027. HELPWINFLAGS    EQU    WFLG_CLOSEGADGET|WFLG_DEPTHGADGET|WFLG_DRAGBAR|WFLG_ACTIVATE
  11028. BEVELWIDTH    EQU    64+INTERWIDTH
  11029. BEVELHEIGHT    EQU    13
  11030. **********************************************************************
  11031. *                    Some defines for the gadgets                    *
  11032. **********************************************************************
  11033. GADWIDTH    EQU    90
  11034. GADHEIGHT    EQU    12
  11035. STRGADWIDTH    EQU    260
  11036. INTGADWIDTH    EQU    45
  11037. LOGSGADWIDTH    EQU    620
  11038. LOGINTWIDTH    EQU    36
  11039. PREFINTGADWIDTH    EQU    54
  11040. CYCLEWIDTH    EQU    120
  11041. **********************************************************************
  11042. *                    This is our Windowstructure                     *
  11043. **********************************************************************
  11044. MyWindowDef    dc.w    0,0
  11045.         dc.w    0,0
  11046.         dc.b    0,1
  11047.         dc.l    0
  11048.         dc.l    0
  11049.         dc.l    0
  11050.         dc.l    0
  11051.         dc.l    ControlTitle
  11052.         dc.l    0
  11053.         dc.l    0
  11054.         dc.w    0,0,0,0
  11055.         dc.w    WBENCHSCREEN
  11056. ControlTitle    dc.b    "KCommodity : HotKey="
  11057. PopUpKey    ds.b    80
  11058. DefaultPopUpKey    dc.b    "LCOMMAND HELP",0
  11059.         EVEN
  11060. WindowScrTitle    dc.b    "KCommodity V"
  11061.         REVISION
  11062.         dc.b    " ("
  11063.         REVDATE
  11064.         dc.b    ") "
  11065.         dc.b    "by Kai Iske. SHAREWARE"
  11066.  
  11067.  
  11068.  
  11069. **********************************************************************
  11070. *                     Definition for Clockwindow                     *
  11071. **********************************************************************
  11072. ClockWinDef    dc.w    0,0
  11073.         dc.w    0,0
  11074.         dc.b    0,1
  11075.         dc.l    0
  11076.         dc.l    0
  11077.         dc.l    0
  11078.         dc.l    0
  11079.         dc.l    0
  11080.         dc.l    0
  11081.         dc.l    0
  11082.         dc.w    0,0,0,0
  11083.         dc.w    WBENCHSCREEN
  11084.  
  11085.  
  11086. **********************************************************************
  11087. *                  Definition of Log/Purpose window                  *
  11088. **********************************************************************
  11089. LogWinDef    dc.w    0,0
  11090.         dc.w    0,0
  11091.         dc.b    0,1
  11092.         dc.l    0
  11093.         dc.l    0
  11094.         dc.l    0
  11095.         dc.l    0
  11096.         dc.l    0
  11097.         dc.l    0
  11098.         dc.l    0
  11099.         dc.w    0,0,0,0
  11100.         dc.w    WBENCHSCREEN
  11101. LogWinTitle    dc.b    "You can now enter a 5 lines (75 chars per line) Log Message",0
  11102.         EVEN
  11103. PurposeWinTitle    dc.b    "You can now enter a 5 lines (75 chars per line) Purpos Message",0
  11104.         EVEN
  11105.  
  11106.  
  11107.  
  11108. **********************************************************************
  11109. *                        Telefon cost window                         *
  11110. **********************************************************************
  11111. BillWinDef    dc.w    400,11
  11112.         dc.w    BILLWINWIDTH,BILLWINHEIGHT
  11113.         dc.b    0,1
  11114.         dc.l    0
  11115.         dc.l    0
  11116.         dc.l    0
  11117.         dc.l    0
  11118.         dc.l    BillTitle
  11119.         dc.l    0
  11120.         dc.l    0
  11121.         dc.w    0,0,0,0
  11122.         dc.w    WBENCHSCREEN
  11123. BillTitle    dc.b    "Bill  HotKey="
  11124. BillHotKey    ds.b    80
  11125. DefBillHotKey    dc.b    "ALT SHIFT B",0
  11126.         EVEN
  11127.  
  11128.  
  11129.  
  11130. **********************************************************************
  11131. *                 Bill-Preferences window definition                 *
  11132. **********************************************************************
  11133. PrefsWinDef    dc.w    0,0
  11134.         dc.w    PREFSWINWIDTH,PREFSWINHEIGHT
  11135.         dc.b    0,1
  11136.         dc.l    0
  11137.         dc.l    0
  11138.         dc.l    0
  11139.         dc.l    0
  11140.         dc.l    PrefsTitle
  11141.         dc.l    0
  11142.         dc.l    0
  11143.         dc.w    0,0,0,0
  11144.         dc.w    WBENCHSCREEN
  11145. PrefsTitle    dc.b    "Telefone preferences  HotKey="
  11146. PrefsHotKey    ds.b    80
  11147. DefPrefsHotKey    dc.b    "ALT SHIFT P",0
  11148.         EVEN
  11149.  
  11150.  
  11151.  
  11152. **********************************************************************
  11153. *                    Definition for HotKey window                    *
  11154. **********************************************************************
  11155. HotKeyWinDef    dc.w    0,0
  11156.         dc.w    KEYWINWIDTH,KEYWINHEIGHT
  11157.         dc.b    0,1
  11158.         dc.l    0
  11159.         dc.l    0
  11160.         dc.l    0
  11161.         dc.l    0
  11162.         dc.l    HotWinTitle
  11163.         dc.l    0
  11164.         dc.l    0
  11165.         dc.w    0,0,0,0
  11166.         dc.w    WBENCHSCREEN
  11167. HotWinTitle    dc.b    "HotKeys  HotKey="
  11168. HotWinHotKey    ds.b    80
  11169. DefHotWinHotKey    dc.b    "ALT SHIFT H",0
  11170.         EVEN
  11171.  
  11172.  
  11173. **********************************************************************
  11174. *                     Definition of Help-Window                      *
  11175. **********************************************************************
  11176. HelpWinDef    dc.w    0,0
  11177.         dc.w    HELPWINWIDTH,HELPWINHEIGHT
  11178.         dc.b    0,1
  11179.         dc.l    0
  11180.         dc.l    0
  11181.         dc.l    0
  11182.         dc.l    0
  11183.         dc.l    HelpTitle
  11184.         dc.l    0
  11185.         dc.l    0
  11186.         dc.w    0,0,0,0
  11187.         dc.w    WBENCHSCREEN
  11188. HelpTitle    dc.b    "KCommodity Help for : "
  11189. HelpDescr    ds.b    40
  11190. HelpFile    dc.b    "ENV:KCX/"
  11191. HelpName    ds.b    128
  11192.         EVEN
  11193. MainHelpFile    dc.b    "MainHelp",0
  11194.         EVEN
  11195. PrefsHelpFile    dc.b    "PrefsHelp",0
  11196.         EVEN
  11197. BillHelpFile    dc.b    "BillHelp",0
  11198.         EVEN
  11199. HotKeyHelpFile    dc.b    "HotKeyHelp",0
  11200.         EVEN
  11201.  
  11202.  
  11203. **********************************************************************
  11204. *                      Our tags for the window                       *
  11205. **********************************************************************
  11206. WindowTags    dc.l    WA_AutoAdjust
  11207.         dc.l    1
  11208.         dc.l    WA_InnerWidth
  11209. WinWidth    dc.l    0
  11210.         dc.l    WA_InnerHeight
  11211. WinHeight    dc.l    0
  11212.         dc.l    WA_ScreenTitle
  11213.         dc.l    WindowScrTitle
  11214.         dc.l    WA_IDCMP
  11215. WinIDCMP    dc.l    0
  11216.         dc.l    WA_Flags
  11217. WinFlags    dc.l    0
  11218.         dc.l    WA_MenuHelp
  11219. DoMenuHelp    dc.l    1
  11220.         dc.l    TAG_DONE
  11221.         dc.l    0
  11222.  
  11223.  
  11224.  
  11225. **********************************************************************
  11226. *             And here comes a plain NewGadget-Structure             *
  11227. **********************************************************************
  11228. DummyNewGadget    dc.w    10,0                ; Left and top edge
  11229.         dc.w    GADWIDTH,GADHEIGHT        ; Width and height
  11230.         dc.l    0                ; Text pointer
  11231.         dc.l    GadgetTxtAttr            ; TextAttr
  11232. GadNum        dc.w    1                ; Gadget ID
  11233.         dc.l    0                ; Gadget Flags
  11234.         dc.l    0                ; For use by GetVisualInfo()
  11235.         dc.l    0                ; User Data
  11236.  
  11237.  
  11238.  
  11239. **********************************************************************
  11240. *               These are the tags for the new gadgets               *
  11241. **********************************************************************
  11242. ButtonTags    dc.l    GT_Underscore
  11243.         dc.b    0,0,0,'_'
  11244.         dc.l    TAG_DONE
  11245.         dc.l    0
  11246.  
  11247.  
  11248.  
  11249. **********************************************************************
  11250. *      Thanks to Olaf 'Olsen' Barthels great TERM I was able to      *
  11251. *        add a String-Edit Hook, since this function was not         *
  11252. *                   really documented. Thanx Olaf                    *
  11253. **********************************************************************
  11254.         IFND    GTST_EditHook
  11255. GTST_EditHook    EQU    GT_TagBase+55
  11256.         ENDC
  11257.  
  11258. **********************************************************************
  11259. *             These are the tags for the string-gadgets              *
  11260. **********************************************************************
  11261. StringTags    dc.l    GT_Underscore
  11262.         dc.b    0,0,0,'_'
  11263.         dc.l    GTST_String
  11264. StringConts    dc.l    0
  11265.         dc.l    GTST_MaxChars
  11266. StrMax        dc.l    0
  11267.         dc.l    GA_TabCycle
  11268.         dc.l    1
  11269.         dc.l    STRINGA_ExitHelp
  11270.         dc.l    1
  11271.         dc.l    GTST_EditHook
  11272.         dc.l    StrEditHook
  11273.         dc.l    TAG_DONE
  11274.         dc.l    0
  11275.  
  11276. **********************************************************************
  11277. *                      Tags for integer gadgets                      *
  11278. **********************************************************************
  11279. IntegerTags    dc.l    GT_Underscore
  11280.         dc.b    0,0,0,'_'
  11281.         dc.l    GTIN_Number
  11282. IntConts    dc.l    0
  11283.         dc.l    GTIN_MaxChars
  11284. IntMax        dc.l    3
  11285.         dc.l    STRINGA_ExitHelp
  11286.         dc.l    1
  11287.         dc.l    GA_TabCycle
  11288.         dc.l    1
  11289.         dc.l    GTST_EditHook
  11290.         dc.l    StrEditHook
  11291.         dc.l    TAG_DONE
  11292.         dc.l    0
  11293.  
  11294. **********************************************************************
  11295. *       This is the hook for the String/Integer-Gadget editing       *
  11296. **********************************************************************
  11297. StrEditHook    ds.b    h_SIZEOF
  11298.  
  11299. **********************************************************************
  11300. *                       Tags for cycle gadget                        *
  11301. **********************************************************************
  11302. CycleTags    dc.l    GT_Underscore
  11303.         dc.b    0,0,0,'_'
  11304.         dc.l    GTCY_Labels
  11305. CycLabels    dc.l    0
  11306.         dc.l    GTCY_Active
  11307. CycActive    dc.l    0
  11308.         dc.l    TAG_DONE
  11309.         dc.l    0
  11310.  
  11311.  
  11312. **********************************************************************
  11313. *                   Tags for MutualXclude gadgets                    *
  11314. **********************************************************************
  11315. MxTags        dc.l    GT_Underscore
  11316.         dc.b    0,0,0,'_'
  11317.         dc.l    GTMX_Labels
  11318. MxLabels    dc.l    0
  11319.         dc.l    GTMX_Active
  11320. MxActive    dc.l    0
  11321.         dc.l    GTMX_Spacing
  11322.         dc.l    4
  11323.         dc.l    TAG_DONE
  11324.         dc.l    0
  11325.  
  11326.  
  11327. **********************************************************************
  11328. *       This is just a tag for changing the defaults for gads        *
  11329. **********************************************************************
  11330. CheckBoxTags    dc.l    GT_Underscore
  11331.         dc.b    0,0,0,'_'
  11332.         dc.l    GTCB_Checked
  11333. SelectMode    dc.l    1
  11334.         dc.l    TAG_DONE
  11335.         dc.l    0
  11336.  
  11337.  
  11338. **********************************************************************
  11339. *                 This is a tag for ScrollerGadgets                  *
  11340. **********************************************************************
  11341. ScrollerTags    dc.l    GTSC_Top
  11342. ScrollTop    dc.l    0
  11343.         dc.l    GTSC_Total
  11344. ScrollTotal    dc.l    0
  11345.         dc.l    GTSC_Visible
  11346. ScrollVis    dc.l    9
  11347.         dc.l    GTSC_Arrows
  11348.         dc.l    10
  11349.         dc.l    PGA_Freedom
  11350.         dc.l    LORIENT_VERT
  11351.         dc.l    GA_Immediate
  11352.         dc.l    1
  11353.         dc.l    GA_RelVerify
  11354.         dc.l    1
  11355.         dc.l    TAG_DONE
  11356.         dc.l    0
  11357.  
  11358.  
  11359. **********************************************************************
  11360. *               This is the tag for disabling gadgets                *
  11361. **********************************************************************
  11362. DisableTag    dc.l    GA_Disabled
  11363. GadDisable    dc.l    0
  11364.         dc.l    TAG_DONE
  11365.         dc.l    0
  11366.  
  11367.  
  11368. **********************************************************************
  11369. *                        Tags for a BevelBox                         *
  11370. **********************************************************************
  11371. BevelTag    dc.l    GTBB_Recessed
  11372.         dc.l    1
  11373.         dc.l    GT_VisualInfo
  11374. BevelVisInfo    dc.l    0
  11375.         dc.l    TAG_DONE
  11376.         dc.l    0
  11377.  
  11378.  
  11379.  
  11380.  
  11381. **********************************************************************
  11382. *                         FileRequester tags                         *
  11383. **********************************************************************
  11384. AslFileTags    dc.l    ASL_Hail
  11385. FileReqHeader    dc.l    0
  11386.         dc.l    ASL_Window
  11387. FileReqWin    dc.l    0
  11388.         dc.l    ASL_LeftEdge
  11389. FileReqLeft    dc.l    0
  11390.         dc.l    ASL_TopEdge
  11391. FileReqTop    dc.l    0
  11392.         dc.l    ASL_Width
  11393. FileReqWidth    dc.l    320
  11394.         dc.l    ASL_Height
  11395. FileReqHeight    dc.l    140
  11396.         dc.l    ASL_File
  11397. FileReqFile    dc.l    0
  11398.         dc.l    ASL_Dir
  11399. FileReqDir    dc.l    0
  11400.         dc.l    TAG_DONE
  11401.         dc.l    0
  11402.  
  11403.  
  11404. **********************************************************************
  11405. *                         HotKey definitions                         *
  11406. **********************************************************************
  11407. PageHotKey    ds.b    80
  11408. DefPageHotKey    dc.b    "RALT HELP",0
  11409.         EVEN
  11410. ShellHotKey    ds.b    80
  11411. DefShellHotKey    dc.b    "ALT SHIFT S",0
  11412.         EVEN
  11413. UmlautHotKey    ds.b    80
  11414. DefUmlautHK    dc.b    "ALT SHIFT U",0
  11415.         EVEN
  11416. POPUPKEYID    EQU    1                ; Definitions for IDs
  11417. PAGEKEYID    EQU    2
  11418. PREFSKEYID    EQU    3
  11419. BILLKEYID    EQU    4
  11420. HOTWINKEYID    EQU    5
  11421. SHELLKEYID    EQU    6
  11422. RAWEVENTID    EQU    7
  11423. UMLAUTKEYID    EQU    8
  11424.  
  11425.  
  11426.  
  11427. **********************************************************************
  11428. *                  Tags for use to open a new shell                  *
  11429. **********************************************************************
  11430. SystemTags    dc.l    SYS_Input
  11431. SysInput    dc.l    0
  11432.         dc.l    SYS_Output
  11433. SysOutput    dc.l    0
  11434.         dc.l    SYS_Asynch
  11435.         dc.l    1
  11436.         dc.l    SYS_UserShell
  11437.         dc.l    1
  11438.         dc.l    NP_Path
  11439. SysPath        dc.l    0
  11440.         dc.l    TAG_DONE
  11441.         dc.l    0
  11442. SystemComm    dc.b    "NewSHELL "
  11443. SystemParam    dc.b    "CON:0/11//200/KCX-Shell/CLOSE",0
  11444.         ds.b    25
  11445.         EVEN
  11446. SystemInOut    dc.b    "NIL:",0
  11447.         EVEN
  11448. WBPName        dc.b    "Workbench",0            ; Names of processes we want
  11449.         EVEN                    ; to clone path-lists from :-)
  11450. NCLIName    dc.b    "New CLI",0
  11451.         EVEN
  11452. ICLIName    dc.b    "Initial CLI",0
  11453.         EVEN
  11454. AShellName    dc.b    "AmigaShell",0
  11455.         EVEN
  11456. BCLIName    dc.b    "Background CLI",0
  11457.         EVEN
  11458.  
  11459.  
  11460.  
  11461. **********************************************************************
  11462. *                      Texts for control window                      *
  11463. **********************************************************************
  11464. HotKeyGadTxt    dc.b    "HotKeys... (_9)",0
  11465.         EVEN
  11466. AlarmGadTxt    dc.b    "Alarm time (_5)",0
  11467.         EVEN
  11468. ShellGadTxt    dc.b    "_User Shell",0
  11469.         EVEN
  11470. AlarmStartVal    dc.b    "00:00:00",0
  11471.         EVEN
  11472. AlarmText    dc.b    "Hey guy,",$0a,"It`s time for you to wake up !",0
  11473.         EVEN
  11474. ScrBTxt        dc.b    "Screen time (_6)",0
  11475.         EVEN
  11476. MouseBTxt    dc.b    "Mouse time (_7)",0
  11477.         EVEN
  11478. ClickVolTxt    dc.b    "Click vol (_8)",0
  11479.         EVEN
  11480. FrontGadTxt    dc.b    "Win Qualifier (_X)",0
  11481.         EVEN
  11482. ESCGadTxt    dc.b    "ESC Qualifier (_J)",0
  11483.         EVEN
  11484. PopQualList    dc.l    AltKeyDef
  11485.         dc.l    AmiKeyDef
  11486.         dc.l    ShiftKeyDef
  11487.         dc.l    ControlKeyDef
  11488.         dc.l    0
  11489. POPQUALCNT    EQU    4
  11490. ESCQualList    dc.l    AltKeyDef
  11491.         dc.l    AmiKeyDef
  11492.         dc.l    ShiftKeyDef
  11493.         dc.l    ControlKeyDef
  11494.         dc.l    NoneKeyDef
  11495.         dc.l    0
  11496. ESCQUALCNT    EQU    5
  11497. NoneKeyDef    dc.b    "None",0
  11498.         EVEN
  11499. AltKeyDef    dc.b    "Any Alt",0
  11500.         EVEN
  11501. AmiKeyDef    dc.b    "Any Command",0
  11502.         EVEN
  11503. ShiftKeyDef    dc.b    "Any Shift",0
  11504.         EVEN
  11505. ControlKeyDef    dc.b    "Control",0
  11506.         EVEN
  11507. PopQualFlags    dc.w    IEQUALIFIER_RALT
  11508.         dc.w    IEQUALIFIER_LALT
  11509.         dc.w    IEQUALIFIER_RCOMMAND
  11510.         dc.w    IEQUALIFIER_LCOMMAND
  11511.         dc.w    IEQUALIFIER_RSHIFT
  11512.         dc.w    IEQUALIFIER_LSHIFT
  11513.         dc.w    IEQUALIFIER_CONTROL
  11514.         dc.w    IEQUALIFIER_CONTROL
  11515.         dc.w    -1,-1
  11516.  
  11517. UmlautTab    dc.w    $2a,$20,$12
  11518.         dc.w    $2a,$20,$12
  11519.         dc.w    $29,$18,$12
  11520.         dc.w    $29,$18,$12
  11521.         dc.w    $1a,$16,$12
  11522.         dc.w    $1a,$16,$12
  11523.         dc.w    $0b,$21,$21
  11524.         dc.w    0,0,0
  11525.  
  11526. TeleBillTxt    dc.b    "Telefone _bill...",0
  11527.         EVEN
  11528. TelePrefsTxt    dc.b    "Bill _preferences...",0
  11529.         EVEN
  11530. AlarmHour    dc.l    0
  11531. AlarmMins    dc.l    0
  11532. AlarmSecs    dc.l    0
  11533. ThisHour    dc.l    0
  11534. ThisMins    dc.l    0
  11535. ThisSecs    dc.l    0
  11536.  
  11537.  
  11538. **********************************************************************
  11539. *                    Control window menu entries                     *
  11540. **********************************************************************
  11541. MainMenuDef    dc.b    NM_TITLE,0
  11542.         dc.l    ProjectName,0
  11543.         dc.w    0
  11544.         dc.l    0,0
  11545.  
  11546.         dc.b    NM_ITEM,0
  11547.         dc.l    .LoadPrefs,.LoadKey
  11548.         dc.w    0
  11549.         dc.l    0,DoLoadPrefs
  11550.  
  11551.         dc.b    NM_ITEM,0
  11552.         dc.l    .SavePrefs,.SaveKey
  11553.         dc.w    0
  11554.         dc.l    0,ReSavePrefs
  11555.  
  11556.         dc.b    NM_ITEM,0
  11557.         dc.l    .SaveAsPrefs,.SaveAsKey
  11558.         dc.w    0
  11559.         dc.l    0,DoSaveAsPrefs
  11560.  
  11561.         dc.b    NM_ITEM,0
  11562.         dc.l    NM_BARLABEL,0
  11563.         dc.w    0
  11564.         dc.l    0,0
  11565.  
  11566.         dc.b    NM_ITEM,0
  11567.         dc.l    .Enable,.EnableKey
  11568.         dc.w    0
  11569.         dc.l    0,EnableKey
  11570.  
  11571.         dc.b    NM_ITEM,0
  11572.         dc.l    .Disable,.DisableKey
  11573.         dc.w    0
  11574.         dc.l    0,DisableKey
  11575.  
  11576.         dc.b    NM_ITEM,0
  11577.         dc.l    HideItem,HideItemKey
  11578.         dc.w    0
  11579.         dc.l    0,HideKey
  11580.  
  11581.         dc.b    NM_ITEM,0
  11582.         dc.l    NM_BARLABEL,0
  11583.         dc.w    0
  11584.         dc.l    0,0
  11585.  
  11586.         dc.b    NM_ITEM,0
  11587.         dc.l    .AboutName,0
  11588.         dc.w    0
  11589.         dc.l    0,DisplayAbout
  11590.  
  11591.         dc.b    NM_ITEM,0
  11592.         dc.l    NM_BARLABEL,0
  11593.         dc.w    0
  11594.         dc.l    0,0
  11595.  
  11596.         dc.b    NM_ITEM,0
  11597.         dc.l    .QuitName,.QuitKey
  11598.         dc.w    0
  11599.         dc.l    0,QuitKey
  11600.  
  11601.  
  11602.  
  11603.         dc.b    NM_TITLE,0
  11604.         dc.l    .EnableDisable,0
  11605.         dc.w    0
  11606.         dc.l    0,0
  11607.  
  11608.         dc.b    NM_ITEM,0
  11609.         dc.l    .ActivateWin,.ActivateKey
  11610.         dc.w    CHECKIT!MENUTOGGLE
  11611.         dc.l    0,ActiKey
  11612.  
  11613.         dc.b    NM_ITEM,0
  11614.         dc.l    .MouseMode,.MouseModeKey
  11615.         dc.w    CHECKIT!MENUTOGGLE
  11616.         dc.l    0,ModeKey
  11617.  
  11618.         dc.b    NM_ITEM,0
  11619.         dc.l    .DisplayClock,.DispClockKey
  11620.         dc.w    CHECKIT!MENUTOGGLE
  11621.         dc.l    0,DisplayKey
  11622.  
  11623.         dc.b    NM_ITEM,0
  11624.         dc.l    .DispClockWin,.DispWinKey
  11625.         dc.w    CHECKIT!MENUTOGGLE
  11626.         dc.l    0,WindowKey
  11627.  
  11628.         dc.b    NM_ITEM,0
  11629.         dc.l    .ShowSecs,.ShowSecsKey
  11630.         dc.w    CHECKIT!MENUTOGGLE
  11631.         dc.l    0,SecsKey
  11632.  
  11633.         dc.b    NM_ITEM,0
  11634.         dc.l    .ShowDate,.ShowDateKey
  11635.         dc.w    CHECKIT!MENUTOGGLE
  11636.         dc.l    0,DateKey
  11637.  
  11638.         dc.b    NM_ITEM,0
  11639.         dc.l    .AmiDate,.AmiDateKey
  11640.         dc.w    CHECKIT!MENUTOGGLE
  11641.         dc.l    0,AmiKey
  11642.  
  11643.         dc.b    NM_ITEM,0
  11644.         dc.l    .ShowDay,.ShowDayKey
  11645.         dc.w    CHECKIT!MENUTOGGLE
  11646.         dc.l    0,DayKey
  11647.  
  11648.         dc.b    NM_ITEM,0
  11649.         dc.l    .ShortDayStr,.ShortDayStr
  11650.         dc.w    CHECKIT!MENUTOGGLE
  11651.         dc.l    0,ShortKey
  11652.  
  11653.         dc.b    NM_ITEM,0
  11654.         dc.l    .AlarmOn,.AlarmOnKey
  11655.         dc.w    CHECKIT!MENUTOGGLE
  11656.         dc.l    0,AlarmModeKey
  11657.  
  11658.         dc.b    NM_ITEM,0
  11659.         dc.l    .KeyClick,.KeyClickKey
  11660.         dc.w    CHECKIT!MENUTOGGLE
  11661.         dc.l    0,ClickKey
  11662.  
  11663.         dc.b    NM_ITEM,0
  11664.         dc.l    .WriteEnv,.WriteEnvKey
  11665.         dc.w    CHECKIT!MENUTOGGLE
  11666.         dc.l    0,EnvKey
  11667.  
  11668.         dc.b    NM_ITEM,0
  11669.         dc.l    .WindowCycle,.WindowCycKey
  11670.         dc.w    CHECKIT!MENUTOGGLE
  11671.         dc.l    0,CycleKey
  11672.  
  11673.         dc.b    NM_ITEM,0
  11674.         dc.l    .WBFront,.WBFrontKey
  11675.         dc.w    CHECKIT!MENUTOGGLE
  11676.         dc.l    0,WBFrontKey
  11677.  
  11678.         dc.b    NM_ITEM,0
  11679.         dc.l    .LeftyMouse,.LeftyMouseKey
  11680.         dc.w    CHECKIT!MENUTOGGLE
  11681.         dc.l    0,LeftyKey
  11682.  
  11683.         dc.b    NM_ITEM,0
  11684.         dc.l    .ESCClose,.ESCCloseKey
  11685.         dc.w    CHECKIT!MENUTOGGLE
  11686.         dc.l    0,WESCKey
  11687.  
  11688.         dc.b    NM_ITEM,0
  11689.         dc.l    .MapUmlaut,.UmlautKey
  11690.         dc.w    CHECKIT!MENUTOGGLE
  11691.         dc.l    0,UmlautKey
  11692.  
  11693.  
  11694.         dc.b    NM_TITLE,0
  11695.         dc.l    .Settings,0
  11696.         dc.w    0
  11697.         dc.l    0,0
  11698.  
  11699.         dc.b    NM_ITEM,0
  11700.         dc.l    .NextPopQual,.NextPopKey
  11701.         dc.w    0
  11702.         dc.l    0,FrontKey
  11703.  
  11704.         dc.b    NM_ITEM,0
  11705.         dc.l    .NextESCQual,.NextESCKey
  11706.         dc.w    0
  11707.         dc.l    0,ESCKey
  11708.  
  11709.         dc.b    NM_ITEM,0
  11710.         dc.l    NM_BARLABEL,0
  11711.         dc.w    0
  11712.         dc.l    0,0
  11713.  
  11714.         dc.b    NM_ITEM,0
  11715.         dc.l    .ChangeAlarm,.SetAlarmKey
  11716.         dc.w    0
  11717.         dc.l    0,SetAlarmKey
  11718.  
  11719.         dc.b    NM_ITEM,0
  11720.         dc.l    .UserShell,.UserShellKey
  11721.         dc.w    0
  11722.         dc.l    0,UserShellKey
  11723.  
  11724.         dc.b    NM_ITEM,0
  11725.         dc.l    NM_BARLABEL,0
  11726.         dc.w    0
  11727.         dc.l    0,0
  11728.  
  11729.         dc.b    NM_ITEM,0
  11730.         dc.l    .ScreenTime,.ScreenKey
  11731.         dc.w    0
  11732.         dc.l    0,ScreenKey
  11733.  
  11734.         dc.b    NM_ITEM,0
  11735.         dc.l    .MouseTime,.MouseKey
  11736.         dc.w    0
  11737.         dc.l    0,MouseKey
  11738.  
  11739.         dc.b    NM_ITEM,0
  11740.         dc.l    .ClickVol,.VolKey
  11741.         dc.w    0
  11742.         dc.l    0,VolKey
  11743.  
  11744.  
  11745.         dc.b    NM_TITLE,0
  11746.         dc.l    .Windows,0
  11747.         dc.w    0
  11748.         dc.l    0,0
  11749.  
  11750.         dc.b    NM_ITEM,0
  11751.         dc.l    .BillWin,.BillKey
  11752.         dc.w    0
  11753.         dc.l    0,BillKey
  11754.  
  11755.         dc.b    NM_ITEM,0
  11756.         dc.l    .PrefsWin,.PrefsKey
  11757.         dc.w    0
  11758.         dc.l    0,PrefsKey
  11759.  
  11760.         dc.b    NM_ITEM,0
  11761.         dc.l    .HotKeyWin,.HotWinKey
  11762.         dc.w    0
  11763.         dc.l    0,HotWinKey
  11764.  
  11765.         dc.b    NM_END,0
  11766.         dc.l    0,0
  11767.         dc.w    0
  11768.         dc.l    0,0
  11769.  
  11770. .LoadPrefs    dc.b    "Load Preferences...",0
  11771.         EVEN
  11772. .LoadKey    dc.b    LOADKEY,0
  11773. .SavePrefs    dc.b    "Save Preferences",0
  11774.         EVEN
  11775. .SaveKey    dc.b    "S",0
  11776. .SaveAsPrefs    dc.b    "Save Preferences as...",0
  11777.         EVEN
  11778. .SaveAsKey    dc.b    SAVEKEY,0
  11779. .Enable        dc.b    "Enable",0
  11780.         EVEN
  11781. .EnableKey    dc.b    ENABLEKEY,0
  11782. .Disable    dc.b    "Disable",0
  11783.         EVEN
  11784. .DisableKey    dc.b    DISABLEKEY,0
  11785. .AboutName    dc.b    "About...",0
  11786.         EVEN
  11787. .QuitName    dc.b    "Quit",0
  11788.         EVEN
  11789. .QuitKey    dc.b    QUITKEY,0
  11790.  
  11791.  
  11792. .EnableDisable    dc.b    "Enable/Disable",0
  11793.         EVEN
  11794. .ActivateWin    dc.b    "Window activate",0
  11795.         EVEN
  11796. .ActivateKey    dc.b    ACTIKEY,0
  11797. .MouseMode    dc.b    "MouseMode",0
  11798.         EVEN
  11799. .MouseModeKey    dc.b    MODEKEY,0
  11800. .DisplayClock    dc.b    "Display Clock",0
  11801.         EVEN
  11802. .DispClockKey    dc.b    DISPLAYKEY,0
  11803. .DispClockWin    dc.b    "Display in window",0
  11804.         EVEN
  11805. .DispWinKey    dc.b    WINDOWKEY,0
  11806. .ShowSecs    dc.b    "Show secondz",0
  11807.         EVEN
  11808. .ShowSecsKey    dc.b    SECSKEY,0
  11809. .ShowDate    dc.b    "Show date",0
  11810.         EVEN
  11811. .ShowDateKey    dc.b    DATEKEY,0
  11812. .AmiDate    dc.b    "American date",0
  11813.         EVEN
  11814. .AmiDateKey    dc.b    AMIKEY,0
  11815. .ShowDay    dc.b    "Show day",0
  11816.         EVEN
  11817. .ShowDayKey    dc.b    DAYKEY,0
  11818. .ShortDayStr    dc.b    "Short day string",0
  11819.         EVEN
  11820. .ShortStrKey    dc.b    SHORTKEY,0
  11821. .AlarmOn    dc.b    "Alarm on",0
  11822.         EVEN
  11823. .AlarmOnKey    dc.b    ALARMMODEKEY,0
  11824. .KeyClick    dc.b    "Key-Click",0
  11825.         EVEN
  11826. .KeyClickKey    dc.b    CLICKKEY,0
  11827. .WriteEnv    dc.b    "Write environment",0
  11828.         EVEN
  11829. .WriteEnvKey    dc.b    ENVKEY,0
  11830. .WindowCycle    dc.b    "Window cycling",0
  11831.         EVEN
  11832. .WindowCycKey    dc.b    CYCLEKEY,0
  11833. .WBFront    dc.b    "WB to front",0
  11834.         EVEN
  11835. .WBFrontKey    dc.b    WBFRONTKEY,0
  11836. .LeftyMouse    dc.b    "LeftyMouse",0
  11837.         EVEN
  11838. .LeftyMouseKey    dc.b    LEFTYKEY,0
  11839. .ESCClose    dc.b    "ESC WindowClose",0
  11840.         EVEN
  11841. .ESCCloseKey    dc.b    WESCKEY,0
  11842. .MapUmlaut    dc.b    'Map "Umlauts"',0
  11843.         EVEN
  11844. .UmlautKey    dc.b    UMLAUTKEY,0
  11845.  
  11846. .Settings    dc.b    "Other settings",0
  11847.         EVEN
  11848. .NextPopQual    dc.b    "Win Qualifier",0
  11849.         EVEN
  11850. .NextPopKey    dc.b    FRONTKEY,0
  11851. .NextESCQual    dc.b    "ESC Qualifier",0
  11852.         EVEN
  11853. .NextESCKey    dc.b    ESCQUALKEY,0
  11854. .ChangeAlarm    dc.b    "Alarm time",0
  11855.         EVEN
  11856. .SetAlarmKey    dc.b    SETALARMKEY,0
  11857. .UserShell    dc.b    "User shell",0
  11858.         EVEN
  11859. .UserShellKey    dc.b    USERSHELLKEY,0
  11860. .ScreenTime    dc.b    "Screen time",0
  11861.         EVEN
  11862. .ScreenKey    dc.b    SCREENKEY,0
  11863. .MouseTime    dc.b    "Mouse time",0
  11864.         EVEN
  11865. .MouseKey    dc.b    MOUSEKEY,0
  11866. .ClickVol    dc.b    "Click vol",0
  11867.         EVEN
  11868. .VolKey        dc.b    VOLKEY,0
  11869.  
  11870. .Windows    dc.b    "Windows",0
  11871.         EVEN
  11872. .BillWin    dc.b    "Telefone bill...",0
  11873.         EVEN
  11874. .BillKey    dc.b    BILLKEY,0
  11875. .PrefsWin    dc.b    "Telefone preferences...",0
  11876.         EVEN
  11877. .PrefsKey    dc.b    PREFSKEY,0
  11878. .HotKeyWin    dc.b    "HotKeys...",0
  11879.         EVEN
  11880. .HotWinKey    dc.b    HOTWINKEY,0
  11881.  
  11882.  
  11883. ProjectName    dc.b    "Project",0
  11884.         EVEN
  11885. HideItem    dc.b    "Hide",0
  11886.         EVEN
  11887. HideItemKey    dc.b    HIDEKEY,0
  11888.  
  11889.  
  11890. **********************************************************************
  11891. *                    Texts for Log/Purpose-Window                    *
  11892. **********************************************************************
  11893. LogOkText    dc.b    "_OK",0
  11894.         EVEN
  11895. LogCancelText    dc.b    "_CANCEL",0
  11896.         EVEN
  11897. LogRevText    dc.b    "Revision",0
  11898.         EVEN
  11899. LogPointText    dc.b    ".",0
  11900.         EVEN
  11901.  
  11902. OKKEY        EQU    'O'
  11903. CANCELKEY    EQU    'C'
  11904.  
  11905.  
  11906. **********************************************************************
  11907. *                  Log/Purpose-Window menu-entries                   *
  11908. **********************************************************************
  11909. LogMenuDef    dc.b    NM_TITLE,0
  11910.         dc.l    ProjectName,0
  11911.         dc.w    0
  11912.         dc.l    0,0
  11913.  
  11914.         dc.b    NM_ITEM,0
  11915.         dc.l    .Ok,.OkKey
  11916.         dc.w    0
  11917.         dc.l    0,LogOK
  11918.  
  11919.         dc.b    NM_ITEM,0
  11920.         dc.l    .Cancel,.CancelKey
  11921.         dc.w    0
  11922.         dc.l    0,LogCancel
  11923.  
  11924.         dc.b    NM_END,0
  11925.         dc.l    0,0
  11926.         dc.w    0
  11927.         dc.l    0,0
  11928.  
  11929. .Ok        dc.b    "OK",0
  11930.         EVEN
  11931. .OkKey        dc.b    OKKEY,0
  11932. .Cancel        dc.b    "CANCEL",0
  11933.         EVEN
  11934. .CancelKey    dc.b    CANCELKEY,0
  11935.  
  11936.  
  11937. **********************************************************************
  11938. *                         Bill window ITexts                         *
  11939. **********************************************************************
  11940. BillITxts    dc.b    1,0
  11941.         dc.b    RP_JAM2
  11942.         dc.b    0
  11943.         dc.w    INTERWIDTH+INTERWIDTH/2+16
  11944.         dc.w    2
  11945.         dc.l    GadgetTxtAttr
  11946.         dc.l    .Str1
  11947.         dc.l    .ITxt2
  11948. .Str1        dc.b    "Time",0
  11949.         EVEN
  11950.  
  11951. .ITxt2        dc.b    1,0
  11952.         dc.b    RP_JAM2
  11953.         dc.b    0
  11954.         dc.w    INTERWIDTH+BEVELWIDTH+INTERWIDTH+INTERWIDTH/2+8
  11955.         dc.w    2
  11956.         dc.l    GadgetTxtAttr
  11957.         dc.l    .Str2
  11958.         dc.l    .ITxt3
  11959. .Str2        dc.b    "Online",0
  11960.         EVEN
  11961.  
  11962. .ITxt3        dc.b    1,0
  11963.         dc.b    RP_JAM2
  11964.         dc.b    0
  11965.         dc.w    INTERWIDTH+((BEVELWIDTH+INTERWIDTH)*2)+INTERWIDTH/2+16
  11966.         dc.w    2
  11967.         dc.l    GadgetTxtAttr
  11968.         dc.l    .Str3
  11969.         dc.l    BillVarStrings
  11970. .Str3        dc.b    "Cost",0
  11971.         EVEN
  11972.  
  11973. BillVarStrings    dc.b    1,0
  11974.         dc.b    RP_JAM2
  11975.         dc.b    0
  11976.         dc.w    INTERWIDTH+INTERWIDTH/2
  11977.         dc.w    2+BEVELHEIGHT
  11978.         dc.l    GadgetTxtAttr
  11979.         dc.l    TimeString
  11980.         dc.l    .ITxt2
  11981. .ITxt2        dc.b    1,0
  11982.         dc.b    RP_JAM2
  11983.         dc.b    0
  11984.         dc.w    INTERWIDTH+BEVELWIDTH+INTERWIDTH+INTERWIDTH/2
  11985.         dc.w    2+BEVELHEIGHT
  11986.         dc.l    GadgetTxtAttr
  11987.         dc.l    OnlineString
  11988.         dc.l    .ITxt3
  11989. .ITxt3        dc.b    1,0
  11990.         dc.b    RP_JAM2
  11991.         dc.b    0
  11992.         dc.w    INTERWIDTH+((BEVELWIDTH+INTERWIDTH)*2)+INTERWIDTH/2
  11993.         dc.w    2+BEVELHEIGHT
  11994.         dc.l    GadgetTxtAttr
  11995.         dc.l    CostString
  11996.         dc.l    .ITxt4
  11997. .ITxt4        dc.b    1,0
  11998.         dc.b    RP_JAM2
  11999.         dc.b    0
  12000.         dc.w    INTERWIDTH+4
  12001.         dc.w    BEVELHEIGHT*4+12
  12002.         dc.l    GadgetTxtAttr
  12003.         dc.l    PerHourStr
  12004.         dc.l    0
  12005. PerHourStr    dc.b    "Costs per hour : "
  12006. PerHourBuff    ds.b    9
  12007.         EVEN
  12008. CostString    dc.b    "    0.00",0
  12009.         EVEN
  12010. TimeZoneLabels    dc.l    TimeZone1Str
  12011.         dc.l    TimeZone2Str
  12012.         dc.l    TimeZone3Str
  12013.         dc.l    0
  12014. TimeZone1Str    dc.b    "Time _1",0
  12015.         EVEN
  12016. TimeZone2Str    dc.b    "Time _2",0
  12017.         EVEN
  12018. TimeZone3Str    dc.b    "Time _3",0
  12019.         EVEN
  12020. CostUnitTxt    dc.b    "Cost/_Unit",0
  12021.         EVEN
  12022.  
  12023. CheapLabels    dc.l    CheapTxt
  12024.         dc.l    NormalTxt
  12025.         dc.l    0
  12026. CheapTxt    dc.b    "_Normal",0
  12027.         EVEN
  12028. NormalTxt    dc.b    "_Cheap",0
  12029.         EVEN
  12030. TotalCost    dc.l    0
  12031. LogInDate    ds.b    LEN_DATSTRING
  12032. LogInTime    ds.b    LEN_DATSTRING
  12033.  
  12034.  
  12035. **********************************************************************
  12036. *                   Defines for BillWindow-Gadgets                   *
  12037. **********************************************************************
  12038. TIMEZONEGAD    EQU    1
  12039. CHEAPMODEGAD    EQU    2
  12040. TIME1KEY    EQU    '1'
  12041. TIME2KEY    EQU    '2'
  12042. TIME3KEY    EQU    '3'
  12043. NORMALKEY    EQU    'N'
  12044. CHEAPKEY    EQU    'C'
  12045.  
  12046.  
  12047. **********************************************************************
  12048. *                Defines for BillWindow menu-entries                 *
  12049. **********************************************************************
  12050. BillMenuDef    dc.b    NM_TITLE,0
  12051.         dc.l    ProjectName,0
  12052.         dc.w    0
  12053.         dc.l    0,0
  12054.  
  12055.         dc.b    NM_ITEM,0
  12056.         dc.l    .Time1,.Time1Key
  12057.         dc.w    0
  12058.         dc.l    0,BTime
  12059.  
  12060.         dc.b    NM_ITEM,0
  12061.         dc.l    .Time2,.Time2Key
  12062.         dc.w    0
  12063.         dc.l    0,BTime
  12064.  
  12065.         dc.b    NM_ITEM,0
  12066.         dc.l    .Time3,.Time3Key
  12067.         dc.w    0
  12068.         dc.l    0,BTime
  12069.  
  12070.         dc.b    NM_ITEM,0
  12071.         dc.l    NM_BARLABEL,0
  12072.         dc.w    0
  12073.         dc.l    0,0
  12074.  
  12075.         dc.b    NM_ITEM,0
  12076.         dc.l    .CostNormal,.CostNormalKey
  12077.         dc.w    0
  12078.         dc.l    0,NormalKey
  12079.  
  12080.         dc.b    NM_ITEM,0
  12081.         dc.l    .CostCheap,.CostCheapKey
  12082.         dc.w    0
  12083.         dc.l    0,CheapKey
  12084.  
  12085.         dc.b    NM_ITEM,0
  12086.         dc.l    NM_BARLABEL,0
  12087.         dc.w    0
  12088.         dc.l    0,0
  12089.  
  12090.         dc.b    NM_ITEM,0
  12091.         dc.l    HideItem,HideItemKey
  12092.         dc.w    0
  12093.         dc.l    0,BEscKey
  12094.  
  12095.         dc.b    NM_END,0
  12096.         dc.l    0,0
  12097.         dc.w    0
  12098.         dc.l    0,0
  12099.  
  12100. .Time1        dc.b    "Time 1",0
  12101.         EVEN
  12102. .Time1Key    dc.b    TIME1KEY
  12103. .Time2        dc.b    "Time 2",0
  12104.         EVEN
  12105. .Time2Key    dc.b    TIME2KEY
  12106. .Time3        dc.b    "Time 3",0
  12107.         EVEN
  12108. .Time3Key    dc.b    TIME3KEY
  12109. .CostNormal    dc.b    "Normal",0
  12110.         EVEN
  12111. .CostNormalKey    dc.b    NORMALKEY
  12112. .CostCheap    dc.b    "Cheap",0
  12113.         EVEN
  12114. .CostCheapKey    dc.b    CHEAPKEY
  12115. .Hide        dc.b    "Hide",0
  12116.         EVEN
  12117. .HideKey    dc.b    HIDEKEY
  12118.  
  12119. **********************************************************************
  12120. *                Structures for the costs-calculating                *
  12121. **********************************************************************
  12122.         RSRESET
  12123. cu_Normal    rs.l    1
  12124. cu_Cheap    rs.l    1
  12125.  
  12126. CostUnit1    dc.l    360
  12127.         dc.l    720
  12128. CostUnit2    dc.l    60
  12129.         dc.l    120
  12130. CostUnit3    dc.l    21
  12131.         dc.l    42
  12132. CostUnit    dc.l    23
  12133. CostBuffer    dc.l    ReadBuffer
  12134.  
  12135.  
  12136.  
  12137. **********************************************************************
  12138. *         Gadget/Window text defines for Preferences window          *
  12139. **********************************************************************
  12140. PrefsGadTxts    dc.l    .Txt1,.Txt2,.Txt3,.Txt4,.Txt5,.Txt6,.Txt7,.Txt8,.Txt9
  12141.         dc.l    .Txt10,.Txt11,.Txt12
  12142. .Txt1        dc.b    "_Normal Time/Unit 1",0
  12143.         EVEN
  12144. .Txt2        dc.b    "Cheap Time/Unit 1",0
  12145.         EVEN
  12146. .Txt3        dc.b    "Normal Time/Unit 2",0
  12147.         EVEN
  12148. .Txt4        dc.b    "Cheap Time/Unit 2",0
  12149.         EVEN
  12150. .Txt5        dc.b    "Normal Time/Unit 3",0
  12151.         EVEN
  12152. .Txt6        dc.b    "Cheap Time/Unit 3",0
  12153.         EVEN
  12154. .Txt7        dc.b    "Costs per unit",0
  12155.         EVEN
  12156. .Txt8        dc.b    "_PopUp Bill window",0
  12157.         EVEN
  12158. .Txt9        dc.b    "_Log calls",0
  12159.         EVEN
  12160. .Txt10        dc.b    "_Clear log",0
  12161.         EVEN
  12162. .Txt11        dc.b    "_Save Log to...",0
  12163.         EVEN
  12164. .Txt12        dc.b    "_Total sum...",0
  12165.         EVEN
  12166.  
  12167. PrefsTimeLabels    dc.l    .Txt1
  12168.         dc.l    .Txt2
  12169.         dc.l    .Txt3
  12170.         dc.l    0
  12171. .Txt1        dc.b    "Time _1       (to use on startup)",0
  12172.         EVEN
  12173. .Txt2        dc.b    "Time _2",0
  12174.         EVEN
  12175. .Txt3        dc.b    "Time _3",0
  12176.         EVEN
  12177.  
  12178. PrefsModeLabels    dc.l    .Txt1
  12179.         dc.l    .Txt2
  12180.         dc.l    0
  12181. .Txt1        dc.b    "Normal _4",0
  12182.         EVEN
  12183. .Txt2        dc.b    "Cheap  _5",0
  12184.         EVEN
  12185. PTimeZone    dc.l    0
  12186. PTariff        dc.l    0
  12187.  
  12188.  
  12189. LogPath        dc.b    "S:",0
  12190.         ds.b    256
  12191.         EVEN
  12192. LogFile        dc.b    "KCXLOGFILE",0
  12193.         ds.b    30
  12194.         EVEN
  12195. LogFileName    dc.b    "S:KCXLOGFILE",0
  12196.         ds.b    280
  12197.         EVEN
  12198. LogFileHeader    dc.b    "Select new preferences file",0
  12199.         EVEN
  12200. PrefsPath    dc.b    "ENV:",0
  12201.         ds.b    256
  12202.         EVEN
  12203. PrefsFile    dc.b    "KCXPREFFILE",0
  12204.         ds.b    30
  12205.         EVEN
  12206. PrefsFileName    dc.b    "ENV:KCXPREFFILE",0
  12207.         ds.b    280
  12208.         EVEN
  12209. PrefsLoadHeader    dc.b    "Load preferences",0
  12210.         EVEN
  12211. PrefsSaveHeader    dc.b    "Save pereferences",0
  12212.         EVEN
  12213.  
  12214.  
  12215.  
  12216. **********************************************************************
  12217. *                        Prefs-Gadget defines                        *
  12218. **********************************************************************
  12219. NORMAL1GAD    EQU    1
  12220. CHEAP1GAD    EQU    2
  12221. NORMAL2GAD    EQU    3
  12222. CHEAP2GAD    EQU    4
  12223. NORMAL3GAD    EQU    5
  12224. CHEAP3GAD    EQU    6
  12225. COSTGAD        EQU    7
  12226. PTIMEGAD    EQU    8
  12227. PMODEGAD    EQU    9
  12228. BILLPOPGAD    EQU    10
  12229. LOGCALLGAD    EQU    11
  12230. CLEARLOGGAD    EQU    12
  12231. SAVETOGAD    EQU    13
  12232. LOGFILEGAD    EQU    14
  12233. TOTALSUMGAD    EQU    15
  12234. NORMAL1KEY    EQU    'N'
  12235. SAVETOKEY    EQU    'S'
  12236. TOTALSUMKEY    EQU    'T'
  12237. BILLPOPKEY    EQU    'P'
  12238. LOGCALLKEY    EQU    'L'
  12239. CLEARLOGKEY    EQU    'C'
  12240. PNORMALKEY    EQU    '4'
  12241. PCHEAPKEY    EQU    '5'
  12242.  
  12243.  
  12244.  
  12245. **********************************************************************
  12246. *                  Preferences window menu-entries                   *
  12247. **********************************************************************
  12248. PrefsMenuDef    dc.b    NM_TITLE,0
  12249.         dc.l    ProjectName,0
  12250.         dc.w    0
  12251.         dc.l    0,0
  12252.  
  12253.         dc.b    NM_ITEM,0
  12254.         dc.l    .TimeUnits,.TimeUnitsKey
  12255.         dc.w    0
  12256.         dc.l    0,Normal1Key
  12257.  
  12258.         dc.b    NM_ITEM,0
  12259.         dc.l    NM_BARLABEL,0
  12260.         dc.w    0
  12261.         dc.l    0,0
  12262.  
  12263.         dc.b    NM_ITEM,0
  12264.         dc.l    .Time1,.Time1Key
  12265.         dc.w    0
  12266.         dc.l    0,Time123Key
  12267.  
  12268.         dc.b    NM_ITEM,0
  12269.         dc.l    .Time2,.Time2Key
  12270.         dc.w    0
  12271.         dc.l    0,Time123Key
  12272.  
  12273.         dc.b    NM_ITEM,0
  12274.         dc.l    .Time3,.Time3Key
  12275.         dc.w    0
  12276.         dc.l    0,Time123Key
  12277.  
  12278.         dc.b    NM_ITEM,0
  12279.         dc.l    NM_BARLABEL,0
  12280.         dc.w    0
  12281.         dc.l    0,0
  12282.  
  12283.         dc.b    NM_ITEM,0
  12284.         dc.l    .TariffN,.TariffNKey
  12285.         dc.w    0
  12286.         dc.l    0,Tariff45Key
  12287.  
  12288.         dc.b    NM_ITEM,0
  12289.         dc.l    .TariffC,.TariffCKey
  12290.         dc.w    0
  12291.         dc.l    0,Tariff45Key
  12292.  
  12293.         dc.b    NM_ITEM,0
  12294.         dc.l    NM_BARLABEL,0
  12295.         dc.w    0
  12296.         dc.l    0,0
  12297.  
  12298.         dc.b    NM_ITEM,0
  12299.         dc.l    HideItem,HideItemKey
  12300.         dc.w    0
  12301.         dc.l    0,PEscKey
  12302.  
  12303.         dc.b    NM_TITLE,0
  12304.         dc.l    .OtherStuff,0
  12305.         dc.w    0
  12306.         dc.l    0,0
  12307.  
  12308.         dc.b    NM_ITEM,0
  12309.         dc.l    .PopUpBill,.PopUpBillKey
  12310.         dc.w    CHECKIT!MENUTOGGLE
  12311.         dc.l    0,BillPopKey
  12312.  
  12313.         dc.b    NM_ITEM,0
  12314.         dc.l    .LogCalls,.LogCallsKey
  12315.         dc.w    CHECKIT!MENUTOGGLE
  12316.         dc.l    0,LogCallKey
  12317.  
  12318.         dc.b    NM_ITEM,0
  12319.         dc.l    NM_BARLABEL,0
  12320.         dc.w    0
  12321.         dc.l    0,0
  12322.  
  12323.         dc.b    NM_ITEM,0
  12324.         dc.l    .ClearLog,.ClearLogKey
  12325.         dc.w    0
  12326.         dc.l    0,ClearLogKey
  12327.  
  12328.         dc.b    NM_ITEM,0
  12329.         dc.l    NM_BARLABEL,0
  12330.         dc.w    0
  12331.         dc.l    0,0
  12332.  
  12333.         dc.b    NM_ITEM,0
  12334.         dc.l    .SaveTo,.SaveToKey
  12335.         dc.w    0
  12336.         dc.l    0,SaveToKey
  12337.  
  12338.         dc.b    NM_ITEM,0
  12339.         dc.l    .LogName,.LogNameKey
  12340.         dc.w    0
  12341.         dc.l    0,ChangeLogName
  12342.  
  12343.         dc.b    NM_ITEM,0
  12344.         dc.l    .TotalCost,.TotalCostKey
  12345.         dc.w    0
  12346.         dc.l    0,TotalSumKey
  12347.  
  12348.  
  12349.         dc.b    NM_END,0
  12350.         dc.l    0,0
  12351.         dc.w    0
  12352.         dc.l    0,0
  12353.  
  12354.  
  12355. .TimeUnits    dc.b    "Normal Time/Unit 1",0
  12356.         EVEN
  12357. .TimeUnitsKey    dc.b    NORMAL1KEY,0
  12358. .Time1        dc.b    "Time 1",0
  12359.         EVEN
  12360. .Time1Key    dc.b    TIME1KEY,0
  12361. .Time2        dc.b    "Time 2",0
  12362.         EVEN
  12363. .Time2Key    dc.b    TIME2KEY,0
  12364. .Time3        dc.b    "Time 3",0
  12365.         EVEN
  12366. .Time3Key    dc.b    TIME3KEY,0
  12367. .TariffN    dc.b    "Normal",0
  12368.         EVEN
  12369. .TariffNKey    dc.b    PNORMALKEY,0
  12370. .TariffC    dc.b    "Cheap",0
  12371.         EVEN
  12372. .TariffCKey    dc.b    PCHEAPKEY,0
  12373.  
  12374. .OtherStuff    dc.b    "Other actions",0
  12375.         EVEN
  12376. .PopUpBill    dc.b    "PopUp Bill window",0
  12377.         EVEN
  12378. .PopUpBillKey    dc.b    BILLPOPKEY,0
  12379. .LogCalls    dc.b    "Log calls",0
  12380.         EVEN
  12381. .LogCallsKey    dc.b    LOGCALLKEY,0
  12382. .ClearLog    dc.b    "Clear log",0
  12383.         EVEN
  12384. .ClearLogKey    dc.b    CLEARLOGKEY,0
  12385. .SaveTo        dc.b    "Save Log to...",0
  12386.         EVEN
  12387. .SaveToKey    dc.b    SAVETOKEY,0
  12388. .LogName    dc.b    "Change Log name",0
  12389.         EVEN
  12390. .LogNameKey    dc.b    "F",0
  12391. .TotalCost    dc.b    "Total sum...",0
  12392.         EVEN
  12393. .TotalCostKey    dc.b    TOTALSUMKEY,0
  12394.  
  12395.  
  12396.  
  12397.  
  12398. **********************************************************************
  12399. *                     Defines for HotKey-Window                      *
  12400. **********************************************************************
  12401. HotKeyGadStat    dc.l    PopUpKey,PageHotKey,BillHotKey,PrefsHotKey,HotWinHotKey
  12402.         dc.l    ShellHotKey,UmlautHotKey
  12403. HotKeyGadTxts    dc.l    .Txt1,.Txt2,.Txt3,.Txt4,.Txt5,.Txt6,.Txt7
  12404. .Txt1        dc.b    "_Control",0
  12405.         EVEN
  12406. .Txt2        dc.b    "_Page-Key",0
  12407.         EVEN
  12408. .Txt3        dc.b    "_Bill",0
  12409.         EVEN
  12410. .Txt4        dc.b    "P_references",0
  12411.         EVEN
  12412. .Txt5        dc.b    "_HotKeys",0
  12413.         EVEN
  12414. .Txt6        dc.b    "_Open Shell",0
  12415.         EVEN
  12416. .Txt7        dc.b    '_Map "Umlauts"',0
  12417.         EVEN
  12418.  
  12419. POPUPGAD    EQU    1
  12420. PAGEGAD        EQU    2
  12421. BILLKEYGAD    EQU    3
  12422. PREFSKEYGAD    EQU    4
  12423. HOTKEYGAD    EQU    5
  12424. SHELLGAD    EQU    6
  12425. UMLAUTKEYGAD    EQU    7
  12426.  
  12427. POPUPKEY    EQU    'C'
  12428. PAGEKEY        EQU    'P'
  12429. BILLKEYKEY    EQU    'B'
  12430. PREFSKEYKEY    EQU    'R'
  12431. HOTKEYKEY    EQU    'H'
  12432. SHELLKEY    EQU    'O'
  12433. UMLAUTKEYKEY    EQU    'M'
  12434.  
  12435.  
  12436. **********************************************************************
  12437. *                     HotKey-Window menu-entries                     *
  12438. **********************************************************************
  12439. HotKeyMenuDef    dc.b    NM_TITLE,0
  12440.         dc.l    ProjectName,0
  12441.         dc.w    0
  12442.         dc.l    0,0
  12443.  
  12444.         dc.b    NM_ITEM,0
  12445.         dc.l    .Control,.ControlKey
  12446.         dc.w    0
  12447.         dc.l    0,HPopUpKey
  12448.  
  12449.         dc.b    NM_ITEM,0
  12450.         dc.l    .Page,.PageKey
  12451.         dc.w    0
  12452.         dc.l    0,HPageKey
  12453.  
  12454.         dc.b    NM_ITEM,0
  12455.         dc.l    .Bill,.BillKey
  12456.         dc.w    0
  12457.         dc.l    0,HBillKey
  12458.  
  12459.         dc.b    NM_ITEM,0
  12460.         dc.l    .Prefs,.PrefsKey
  12461.         dc.w    0
  12462.         dc.l    0,HPrefsKey
  12463.  
  12464.         dc.b    NM_ITEM,0
  12465.         dc.l    .Hot,.HotKey
  12466.         dc.w    0
  12467.         dc.l    0,HHotKey
  12468.  
  12469.         dc.b    NM_ITEM,0
  12470.         dc.l    .Shell,.ShellKey
  12471.         dc.w    0
  12472.         dc.l    0,HShellKey
  12473.  
  12474.         dc.b    NM_ITEM,0
  12475.         dc.l    .Umlaut,.UmlautKey
  12476.         dc.w    0
  12477.         dc.l    0,HUmlautKey
  12478.  
  12479.         dc.b    NM_ITEM,0
  12480.         dc.l    NM_BARLABEL,0
  12481.         dc.w    0
  12482.         dc.l    0,0
  12483.  
  12484.         dc.b    NM_ITEM,0
  12485.         dc.l    .Hide,.HideKey
  12486.         dc.w    0
  12487.         dc.l    0,HEscKey
  12488.  
  12489.         dc.b    NM_END,0
  12490.         dc.l    0,0
  12491.         dc.w    0
  12492.         dc.l    0,0
  12493.  
  12494. .Control    dc.b    "Control",0
  12495.         EVEN
  12496. .ControlKey    dc.b    POPUPKEY,0
  12497. .Page        dc.b    "Page-Key",0
  12498.         EVEN
  12499. .PageKey    dc.b    PAGEKEY,0
  12500. .Bill        dc.b    "Bill",0
  12501.         EVEN
  12502. .BillKey    dc.b    BILLKEYKEY,0
  12503. .Prefs        dc.b    "Preferences",0
  12504.         EVEN
  12505. .PrefsKey    dc.b    PREFSKEYKEY,0
  12506. .Hot        dc.b    "HotKeys",0
  12507.         EVEN
  12508. .HotKey        dc.b    HOTKEYKEY,0
  12509. .Shell        dc.b    "Open Shell",0
  12510.         EVEN
  12511. .ShellKey    dc.b    SHELLKEY,0
  12512. .Umlaut        dc.b    'Map "Umlauts"',0
  12513.         EVEN
  12514. .UmlautKey    dc.b    UMLAUTKEYKEY,0
  12515. .Hide        dc.b    "Hide",0
  12516.         EVEN
  12517. .HideKey    dc.b    "Q",0
  12518.  
  12519.  
  12520.  
  12521. **********************************************************************
  12522. *                Definition of Menus for Help-Window                 *
  12523. **********************************************************************
  12524. HelpMenuDef    dc.b    NM_TITLE,0
  12525.         dc.l    ProjectName,0
  12526.         dc.w    0
  12527.         dc.l    0,0
  12528.  
  12529.         dc.b    NM_ITEM,0
  12530.         dc.l    .RowUp,0
  12531.         dc.w    0
  12532.         dc.l    0,HelpRowUp
  12533.  
  12534.         dc.b    NM_ITEM,0
  12535.         dc.l    .RowDown,0
  12536.         dc.w    0
  12537.         dc.l    0,HelpRowDown
  12538.  
  12539.         dc.b    NM_ITEM,0
  12540.         dc.l    .PageUp,0
  12541.         dc.w    0
  12542.         dc.l    0,HelpPageUp
  12543.  
  12544.         dc.b    NM_ITEM,0
  12545.         dc.l    .PageDown,0
  12546.         dc.w    0
  12547.         dc.l    0,HelpPageDown
  12548.  
  12549.         dc.b    NM_ITEM,0
  12550.         dc.l    NM_BARLABEL,0
  12551.         dc.w    0
  12552.         dc.l    0,0
  12553.  
  12554.         dc.b    NM_ITEM,0
  12555.         dc.l    .Close,.CloseKey
  12556.         dc.w    0
  12557.         dc.l    0,HelpWinEnd
  12558.  
  12559.         dc.b    NM_END,0
  12560.         dc.l    0,0
  12561.         dc.w    0
  12562.         dc.l    0,0
  12563.  
  12564. .RowUp        dc.b    "One row up (CURSOR UP)",0
  12565.         EVEN
  12566. .RowDown    dc.b    "One row down (CURSOR DOWN)",0
  12567.         EVEN
  12568. .PageUp        dc.b    "One page up (SHIFT CURSOR UP)",0
  12569.         EVEN
  12570. .PageDown    dc.b    "One page down (SHIFT CURSOR DOWN)",0
  12571.         EVEN
  12572. .Close        dc.b    "Close help",0
  12573.         EVEN
  12574. .CloseKey    dc.b    "C",0
  12575.  
  12576.  
  12577.  
  12578. **********************************************************************
  12579. *  Text atribute for gadgets. We are stubborn. Let`s take topaz :-)  *
  12580. **********************************************************************
  12581. GadgetTxtAttr    dc.l    FontName
  12582.         dc.w    8
  12583.         dc.b    FS_NORMAL
  12584.         dc.b    FPF_ROMFONT
  12585. FontName    dc.b    "topaz.font",0
  12586.         EVEN
  12587.  
  12588.  
  12589.  
  12590. **********************************************************************
  12591. *                 Text attr for the text in titlebar                 *
  12592. **********************************************************************
  12593. TxtAttr        dc.l    0
  12594.         dc.w    0
  12595.         dc.b    FS_NORMAL
  12596.         dc.b    0
  12597.  
  12598.  
  12599.  
  12600. **********************************************************************
  12601. *                     Formatstrings for RawDoFmt                     *
  12602. **********************************************************************
  12603. TimeFormats    dc.l    FormLSec,FormLNSec,FormSSec,FormSNSec
  12604. FormLSec    dc.b    "%s %s %s",0
  12605.         EVEN
  12606. FormLNSec    dc.b    "%s %s %.5s",0
  12607.         EVEN
  12608. FormSSec    dc.b    "%.3s %s %s",0
  12609.         EVEN
  12610. FormSNSec    dc.b    "%.3s %s %.5s",0
  12611.         EVEN
  12612. ResultFormat    dc.b    "%-ld",0
  12613.         EVEN
  12614. ResultWinFormat    dc.b    "%d/%d",0
  12615.         EVEN
  12616. CostFormString    dc.b    "%5ld.%02ld",0
  12617.         EVEN
  12618. PerHourForm    dc.b    "%4ld.%02ld",0
  12619.         EVEN
  12620. LIntFormat    dc.b    "%ld",0
  12621.         EVEN
  12622. FormAlarmSStr    dc.b    "%02ld:%02ld:%02ld",0
  12623.         EVEN
  12624. FormAlarmNSStr    dc.b    "%02ld:%02ld",0
  12625.         EVEN
  12626. FormMemString    dc.b    "C: %7ld   F: %8ld",0
  12627.         EVEN
  12628. FormTMemString    dc.b    "Total Memory : %8ld",0
  12629.         EVEN
  12630. LogEntryFormat    dc.b    "%8.8s : %8.8s - %8.8s / Zone %ld Tariff %c / Time %02ld:%02ld:%02ld / Cost %ld.%02ld",$0a,0
  12631.         EVEN
  12632. FinalCostForm    dc.b    "                                                                  -----------",$0a
  12633.         dc.b    "                                                Total Sum              %ld.%02ld",$0a,0
  12634.         EVEN
  12635. DayCostForm    dc.b    "                                                                  -----------",$0a
  12636.         dc.b    "                                         Sum for %s               %ld.%02ld",$0a,$0a,0
  12637.         EVEN
  12638. ChipMem        dc.l    0
  12639. FastMem        dc.l    0
  12640. TotalMem    dc.l    0
  12641. MaxMem        dc.l    0
  12642. NextUnit    dc.l    0
  12643. UnitsDone    dc.l    0
  12644. LogEntryDat    dc.l    LogInDate
  12645.         dc.l    LogInTime
  12646.         dc.l    TimeString
  12647. TimeZone    dc.l    0
  12648. LogEntryTariff    dc.w    0
  12649. OnlineHour    dc.l    0
  12650. OnlineMinute    dc.l    0
  12651. OnlineSeconds    dc.l    0
  12652. CostMajor    dc.l    0
  12653. CostMinor    dc.l    0
  12654. BillTotalCost    dc.l    0
  12655. BillDayCost    dc.l    0
  12656. BillDayPtr    dc.l    BillDayStr
  12657. BillMajor    dc.l    0
  12658. BillMinor    dc.l    0
  12659. BillDayStr    ds.b    10
  12660.  
  12661.  
  12662.  
  12663.  
  12664.  
  12665. **********************************************************************
  12666. *                Defines for better access to gadgets                *
  12667. **********************************************************************
  12668. ACTIGAD        EQU    1
  12669. MODEGAD        EQU    2
  12670. DISPLAYGAD    EQU    3
  12671. WINDOWGAD    EQU    4
  12672. SECSGAD        EQU    5
  12673. DATEGAD        EQU    6
  12674. AMIGAD        EQU    7
  12675. DAYGAD        EQU    8
  12676. SHORTGAD    EQU    9
  12677. ALARMMODEGAD    EQU    10
  12678. CLICKGAD    EQU    11
  12679. ENVGAD        EQU    12
  12680. CYCLEGAD    EQU    13
  12681. WBFRONTGAD    EQU    14
  12682. LEFTYGAD    EQU    15
  12683. WESCGAD        EQU    16
  12684. UMLAUTGAD    EQU    17
  12685. LOADGAD        EQU    18
  12686. SAVEGAD        EQU    19
  12687. ENABLEGAD    EQU    20
  12688. DISABLEGAD    EQU    21
  12689. HIDEGAD        EQU    22
  12690. QUITGAD        EQU    23
  12691. SETALARMGAD    EQU    24
  12692. USERSHELLGAD    EQU    25
  12693. SCREENGAD    EQU    26
  12694. MOUSEGAD    EQU    27
  12695. VOLGAD        EQU    28
  12696. FRONTGAD    EQU    29
  12697. BILLGAD        EQU    30
  12698. PREFSGAD    EQU    31
  12699. ESCQUALGAD    EQU    32
  12700. HOTWINGAD    EQU    33
  12701.  
  12702.  
  12703. ACTIKEY        EQU    'W'
  12704. MODEKEY        EQU    'M'
  12705. DISPLAYKEY    EQU    'C'
  12706. WINDOWKEY    EQU    'I'
  12707. SECSKEY        EQU    'Z'
  12708. DATEKEY        EQU    'T'
  12709. AMIKEY        EQU    'N'
  12710. DAYKEY        EQU    'Y'
  12711. SHORTKEY    EQU    'G'
  12712. ALARMMODEKEY    EQU    'L'
  12713. CLICKKEY    EQU    'K'
  12714. ENVKEY        EQU    'R'
  12715. CYCLEKEY    EQU    '1'
  12716. WBFRONTKEY    EQU    '2'
  12717. LEFTYKEY    EQU    '3'
  12718. WESCKEY        EQU    '4'
  12719. FRONTKEY    EQU    'X'
  12720. ESCQUALKEY    EQU    'J'
  12721. UMLAUTKEY    EQU    '!'
  12722. SETALARMKEY    EQU    '5'
  12723. SCREENKEY    EQU    '6'
  12724. MOUSEKEY    EQU    '7'
  12725. VOLKEY        EQU    '8'
  12726. USERSHELLKEY    EQU    'U'
  12727. HOTWINKEY    EQU    '9'
  12728. BILLKEY        EQU    'B'
  12729. PREFSKEY    EQU    'P'
  12730. LOADKEY        EQU    'O'
  12731. SAVEKEY        EQU    'A'
  12732. ENABLEKEY    EQU    'E'
  12733. DISABLEKEY    EQU    'D'
  12734. HIDEKEY        EQU    'H'
  12735. QUITKEY        EQU    'Q'
  12736.  
  12737.  
  12738. ControlGads    ds.l    33+1
  12739. PrefsGads    ds.l    15+1
  12740. BillGads    ds.l    2+1
  12741. LogGads        ds.l    9+1
  12742. HotKeyGads    ds.l    6+1
  12743. GadgetAttrs    dc.l    Gadget1Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12744.         dc.w    INTERWIDTH,5
  12745.         dc.l    Gadget2Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12746.         dc.w    INTERWIDTH,18
  12747.         dc.l    Gadget3Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12748.         dc.w    INTERWIDTH,31
  12749.         dc.l    Gadget4Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12750.         dc.w    INTERWIDTH,44
  12751.         dc.l    Gadget5Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12752.         dc.w    INTERWIDTH,57
  12753.         dc.l    Gadget6Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12754.         dc.w    INTERWIDTH,70
  12755.         dc.l    Gadget7Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12756.         dc.w    WINWIDTH-GADWIDTH-310,5
  12757.         dc.l    Gadget8Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12758.         dc.w    WINWIDTH-GADWIDTH-310,18
  12759.         dc.l    Gadget9Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12760.         dc.w    WINWIDTH-GADWIDTH-310,31
  12761.         dc.l    Gadget10Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12762.         dc.w    WINWIDTH-GADWIDTH-310,44
  12763.         dc.l    Gadget11Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12764.         dc.w    WINWIDTH-GADWIDTH-310,57
  12765.         dc.l    Gadget12Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12766.         dc.w    WINWIDTH-GADWIDTH-310,70
  12767.         dc.l    Gadget13Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12768.         dc.w    WINWIDTH-GADWIDTH-94,5
  12769.         dc.l    Gadget14Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12770.         dc.w    WINWIDTH-GADWIDTH-94,18
  12771.         dc.l    Gadget15Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12772.         dc.w    WINWIDTH-GADWIDTH-94,31
  12773.         dc.l    Gadget16Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12774.         dc.w    WINWIDTH-GADWIDTH-94,44
  12775.         dc.l    Gadget17Txt,PLACETEXT_RIGHT,CHECKBOX_KIND
  12776.         dc.w    WINWIDTH-GADWIDTH-94,57
  12777.         dc.l    Gadget18Txt,PLACETEXT_IN,BUTTON_KIND
  12778.         dc.w    INTERWIDTH+5,WINHEIGHT-GADHEIGHT-INTERHEIGHT
  12779.         dc.l    Gadget19Txt,PLACETEXT_IN,BUTTON_KIND
  12780.         dc.w    INTERWIDTH+5+GADWIDTH+INTERWIDTH,WINHEIGHT-GADHEIGHT-INTERHEIGHT
  12781.         dc.l    Gadget20Txt,PLACETEXT_IN,BUTTON_KIND
  12782.         dc.w    INTERWIDTH+5+(GADWIDTH+INTERWIDTH)*2,WINHEIGHT-GADHEIGHT-INTERHEIGHT
  12783.         dc.l    Gadget21Txt,PLACETEXT_IN,BUTTON_KIND
  12784.         dc.w    INTERWIDTH+5+(GADWIDTH+INTERWIDTH)*3,WINHEIGHT-GADHEIGHT-INTERHEIGHT
  12785.         dc.l    Gadget22Txt,PLACETEXT_IN,BUTTON_KIND
  12786.         dc.w    INTERWIDTH+5+(GADWIDTH+INTERWIDTH)*4,WINHEIGHT-GADHEIGHT-INTERHEIGHT
  12787.         dc.l    Gadget23Txt,PLACETEXT_IN,BUTTON_KIND
  12788.         dc.w    INTERWIDTH+5+(GADWIDTH+INTERWIDTH)*5,WINHEIGHT-GADHEIGHT-INTERHEIGHT
  12789.         dc.l    0
  12790. Gadget1Txt    dc.b    "_Window activate",0
  12791.         EVEN
  12792. Gadget2Txt    dc.b    "_MouseMode",0
  12793.         EVEN
  12794. Gadget3Txt    dc.b    "Display _clock/mem",0
  12795.         EVEN
  12796. Gadget4Txt    dc.b    "D_isplay in window",0
  12797.         EVEN
  12798. Gadget5Txt    dc.b    "Show second_z",0
  12799.         EVEN
  12800. Gadget6Txt    dc.b    "Show da_te",0
  12801.         EVEN
  12802. Gadget7Txt    dc.b    "America_n date",0
  12803.         EVEN
  12804. Gadget8Txt    dc.b    "Show da_y",0
  12805.         EVEN
  12806. Gadget9Txt    dc.b    "Short day strin_g",0
  12807.         EVEN
  12808. Gadget10Txt    dc.b    "A_larm on",0
  12809.         EVEN
  12810. Gadget11Txt    dc.b    "_Key-Click",0
  12811.         EVEN
  12812. Gadget12Txt    dc.b    "W_rite environment",0
  12813.         EVEN
  12814. Gadget13Txt    dc.b    "Window cycling (_1)",0
  12815.         EVEN
  12816. Gadget14Txt    dc.b    "WB to front (_2)",0
  12817.         EVEN
  12818. Gadget15Txt    dc.b    "LeftyMouse (_3)",0
  12819.         EVEN
  12820. Gadget16Txt    dc.b    "ESC WindowClose (_4)",0
  12821.         EVEN
  12822. Gadget17Txt    dc.b    'Map "Umlauts" (_!)',0
  12823.         EVEN
  12824. Gadget18Txt    dc.b    "L_oad Prefs",0
  12825.         EVEN
  12826. Gadget19Txt    dc.b    "S_ave Prefs",0
  12827.         EVEN
  12828. Gadget20Txt    dc.b    "_Enable",0
  12829.         EVEN
  12830. Gadget21Txt    dc.b    "_Disable",0
  12831.         EVEN
  12832. Gadget22Txt    dc.b    "_Hide",0
  12833.         EVEN
  12834. Gadget23Txt    dc.b    "_Quit",0
  12835.         EVEN
  12836.  
  12837.  
  12838.  
  12839.  
  12840.  
  12841. **********************************************************************
  12842. *                          The AppIcon-Icon                          *
  12843. **********************************************************************
  12844. KCXAppIconDef    dc.w    0,0
  12845.  
  12846.         dc.l    0                ; Gadget structure
  12847.         dc.w    0,0
  12848.         dc.w    49,20
  12849.         dc.w    0,0,0
  12850.         dc.l    AppIconImg
  12851.         dc.l    0,0,0,0
  12852.         dc.w    0
  12853.         dc.l    0
  12854.  
  12855.         dc.b    0,0
  12856.         dc.l    0
  12857.         dc.l    0
  12858.         dc.l    NO_ICON_POSITION        ; Position of icon
  12859.         dc.l    NO_ICON_POSITION
  12860.         dc.l    0
  12861.         dc.l    0
  12862.         dc.l    0
  12863.  
  12864. AppIconImg    dc.w    0,0                ; Image structure
  12865.         dc.w    49,19
  12866.         dc.w    2
  12867.         dc.l    AppIconPic
  12868.         dc.b    3,0
  12869.         dc.l    0
  12870.  
  12871. AppIconText    dc.b    "KCommodity",0
  12872.         EVEN
  12873.  
  12874.  
  12875.  
  12876.  
  12877. **********************************************************************
  12878. *                 Structures for the Tools-MenuItems                 *
  12879. **********************************************************************
  12880. AppItemID    dc.l    MAINITEM
  12881. AppItemTxt    dc.l    .Txt1
  12882. APPITEMNUM    EQU    (*-AppItemTxt)/4
  12883. .Txt1        dc.b    "KCX Main-Window",0
  12884.         EVEN
  12885. AppItemPtr    ds.l    APPITEMNUM
  12886. MAINITEM    EQU    1
  12887. HOTKEYITEM    EQU    2
  12888. BILLITEM    EQU    3
  12889. PREFSITEM    EQU    4
  12890.  
  12891.  
  12892.  
  12893.         SECTION    Sound,DATA_C
  12894.  
  12895. ClickData    DC.L    $F7011C12,$FEFA0710
  12896.         DC.L    $F7EA3026,$FC0007F3
  12897.         DC.L    $EA0E12F5,$C1CD0513
  12898.         DC.L    $F6FEE1,$2F11DD
  12899.         DC.L    $F2260DE4,$FF160A00
  12900.         DC.L    $E6E31723,$F4D7FB26
  12901.         DC.L    $14F1E7F2,$FE0202E6
  12902.         DC.L    $DD060FEC,$E0EFF8F2
  12903.         DC.L    $F8FCF2ED,$F1FDFEF2
  12904.         DC.L    $F1FDFB00,$8F5F207
  12905.         DC.L    $6FC030C,$FE0E0E
  12906.         DC.L    $C1F1B07,$5111920
  12907.         DC.L    $2F1D0507
  12908.  
  12909.  
  12910. NoSpriteDat    dc.w    0,0
  12911.         dc.w    0,0
  12912.         dc.w    0,0
  12913.  
  12914. BusyPtr        DC.W    $0000,$0000,$0400,$07C0,$0000,$07C0
  12915.         DC.W    $0100,$0380,$0000,$07E0,$07C0,$1FF8
  12916.         DC.W    $1FF0,$3FEC,$3FF8,$7FDE,$3FF8,$7FBE
  12917.         DC.W    $7FFC,$FF7F,$7EFC,$FFFF,$7FFC,$FFFF
  12918.         DC.W    $3FF8,$7FFE,$3FF8,$7FFE,$1FF0,$3FFC
  12919.         DC.W    $07C0,$1FF8,$0000,$07E0,$0000,$0000
  12920.  
  12921. AppIconPic    dc.w $0,$0,$1,$8000,$0,$0,$1,$8000
  12922.         dc.w $ff,$ffff,$fe01,$8000,$3aa,$aaaa,$ab81,$8000
  12923.         dc.w $2ff,$feaa,$aa81,$8000,$6be,$eeaa,$aac1,$8000
  12924.         dc.w $6be,$ebfa,$aac1,$8000,$6ba,$eafa,$aac1,$8000
  12925.         dc.w $6be,$eaee,$aac1,$8000,$6be,$eeff,$2ac1,$8000
  12926.         dc.w $6ff,$ffff,$cac1,$8000,$6aa,$aaab,$f2c1,$8000
  12927.         dc.w $6aa,$aaab,$fec1,$8000,$6aa,$aaab,$eac1,$8000
  12928.         dc.w $2aa,$aaab,$f281,$8000,$3aa,$aaaa,$fb81,$8000
  12929.         dc.w $ff,$ffff,$fc01,$8000,$0,$0,$601,$8000
  12930.         dc.w $7fff,$ffff,$ffff,$8000,$ffff,$ffff,$fffe,$0
  12931.         dc.w $d555,$5555,$5554,$0,$d500,$0,$154,$0
  12932.         dc.w $d4ff,$ffff,$fe54,$0,$d580,$81ff,$ff54,$0
  12933.         dc.w $d3c9,$19ff,$ff94,$0,$d3c3,$3e07,$ff94,$0
  12934.         dc.w $d3c7,$3f0f,$ff94,$0,$d3c3,$3f97,$ff94,$0
  12935.         dc.w $d3c9,$190b,$ff94,$0,$d380,$8203,$ff94,$0
  12936.         dc.w $d3ff,$fffd,$ff94,$0,$d3ff,$fffd,$ff94,$0
  12937.         dc.w $d3ff,$fffe,$ff94,$0,$d5ff,$fffe,$df54,$0
  12938.         dc.w $d4ff,$ffff,$6e54,$0,$d500,$0,$4754,$0
  12939.         dc.w $d555,$5555,$5354,$0,$8000,$0,$0,$0
  12940.         END
  12941.