?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  2. ;@                                                                            @
  3. ;@                 S Y M B O S   S Y S T E M   L I B R A R Y                  @
  4. ;@                        - SYSTEM MANAGER FUNCTIONS -                        @
  5. ;@                                                                            @
  6. ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  7.  
  8. ;Author     Prodatron / Symbiosis
  9. ;Date       28.03.2015
  10.  
  11. ;The system manager is responsible for starting and stopping applications and
  12. ;it also provides several dialogue services.
  13. ;This library supports you in using the system manager functions.
  14.  
  15. ;The existance of
  16. ;- "App_PrcID" (a byte, where the ID of the applications process is stored)
  17. ;- "App_MsgBuf" (the message buffer, 14 bytes, which are placed in the transfer
  18. ;  ram area)
  19. ;is required.
  20.  
  21.  
  22. ;### SUMMARY ##################################################################
  23.  
  24. ;use_SySystem_PRGRUN     equ 0   ;Starts an application or opens a document
  25. ;use_SySystem_PRGEND     equ 0   ;Stops an application and frees its resources
  26. ;use_SySystem_PRGSRV     equ 0   ;Manages shared services or finds applications
  27. ;use_SySystem_SYSWRN     equ 0   ;Opens an info, warning or confirm box
  28. ;use_SySystem_SELOPN     equ 0   ;Opens the file selection dialogue
  29. ;use_SySystem_HLPOPN     equ 0   ;Opens the help file for this application (##!!## missing doc)
  30.  
  31.  
  32. ;### MAIN FUNCTIONS ###########################################################
  33.  
  34. if use_SySystem_PRGRUN=1
  35. SySystem_PRGRUN
  36. ;******************************************************************************
  37. ;*** Name           Program_Run_Command
  38. ;*** Input          HL = File path and name address
  39. ;***                A  = [Bit0-3] File path and name ram bank (0-15)
  40. ;***                     [Bit7  ] Flag, if system error message should be
  41. ;***                              suppressed
  42. ;*** Output         A  = Success status
  43. ;***                     0 = OK
  44. ;***                     1 = File does not exist
  45. ;***                     2 = File is not an executable and its type is not
  46. ;***                         associated with an application
  47. ;***                     3 = Error while loading (see P8 for error code)
  48. ;***                     4 = Memory full
  49. ;***                - If success status is 0:
  50. ;***                L  = Application ID
  51. ;***                H  = Process ID (the applications main process)
  52. ;***                - If success status is 3:
  53. ;***                L  = File manager error code
  54. ;*** Destroyed      F,BC,DE,IX,IY
  55. ;*** Description    Loads and starts an application or opens a document with a
  56. ;***                known type by loading the associated application first.
  57. ;***                If Bit7 of A is not set, the system will open a message box,
  58. ;***                if an error occurs during the loading process.
  59. ;***                If the operation was successful, you will find the
  60. ;***                application ID and the process ID in L and H. If it failed
  61. ;***                because of loading problems L contains the file manager
  62. ;***                error code.
  63. ;******************************************************************************
  64.         ld c,MSC_SYS_PRGRUN
  65.         call SySystem_SendMessage
  66. SySPRn1 call SySystem_WaitMessage
  67.         cp MSR_SYS_PRGRUN
  68.         jr nz,SySPRn1
  69.         ld a,(App_MsgBuf+1)
  70.         ld hl,(App_MsgBuf+8)
  71.         ret
  72. endif
  73.  
  74. if use_SySystem_PRGEND=1
  75. SySystem_PRGEND
  76. ;******************************************************************************
  77. ;*** Name           Program_End_Command
  78. ;*** Input          L  = Application ID
  79. ;*** Output         -
  80. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  81. ;*** Description    Stops an application and releases all its used system
  82. ;***                resources. This command first stops all processes of the
  83. ;***                application. After this all open windows will be closed and the
  84. ;***                reserved memory will be released.
  85. ;***                Please note, that this command can't release memory, stop
  86. ;***                processes and timers or close windows, which are not
  87. ;***                registered for the application. Such resources first have
  88. ;***                to be released by the application itself.
  89. ;******************************************************************************
  90.         ld c,MSC_SYS_PRGEND
  91.         jp SySystem_SendMessage
  92. endif
  93.  
  94. if use_SySystem_PRGSRV=1
  95. SySystem_PRGSRV
  96. ;******************************************************************************
  97. ;*** Name           Program_SharedService_Command
  98. ;*** Input          E  = Command type
  99. ;***                     0 = search application or shared service
  100. ;***                     1 = search, start and use shared service
  101. ;***                     2 = release shared service
  102. ;***                - if E is 0 or 1:
  103. ;***                HL = Address of the 12byte application ID string
  104. ;***                - if E is 0 or 1:
  105. ;***                A  = Ram bank (0-15) of the 12byte application ID string
  106. ;***                - if E is 2:
  107. ;*** Output         A  = Result status
  108. ;***                     0 = OK
  109. ;***                     5 = application or shared service not found (can only
  110. ;***                         occur on command type 0)
  111. ;***                     1-4=error while starting shared service; same codes
  112. ;***                         like in MSR_SYS_PRGRUN, please read there for a
  113. ;***                         detailed description
  114. ;***                - If command type was 0 or 1, and result status is 0:
  115. ;***                L  = Application ID
  116. ;***                H  = Process ID (the applications main process)
  117. ;***                - If result status is 3:
  118. ;***                L  = File manager error code
  119. ;*** Destroyed      F,BC,DE,IX,IY
  120. ;*** Description    This function can be used to find, start and release shared
  121. ;***                services or to find applications.
  122. ;***                For a detailed description please read chapter "System
  123. ;***                Manager", "Program_SharedService_Command" in the SymbOS
  124. ;***                Developer Documentation.
  125. ;******************************************************************************
  126.         ld c,MSC_SYS_PRGSRV
  127.         call SySystem_SendMessage
  128. SySPSr1 call SySystem_WaitMessage
  129.         cp MSR_SYS_PRGSRV
  130.         jr nz,SySPSr1
  131.         ld a,(App_MsgBuf+1)
  132.         ld hl,(App_MsgBuf+8)
  133.         ret
  134. endif
  135.  
  136. if use_SySystem_SYSWRN=1
  137. SySystem_SYSWRN
  138. ;******************************************************************************
  139. ;*** Name           Dialogue_Infobox_Command
  140. ;*** Input          HL = Content data address (#C000-#FFFF)
  141. ;***                A  = Content data ram bank (0-15)
  142. ;***                B  = [Bit0-2] Number of buttons (1-3)
  143. ;***                              1 = "OK" button
  144. ;***                              2 = "Yes", "No" buttons
  145. ;***                              3 = "Yes", "No", "Cancel" buttons
  146. ;***                     [Bit3-5] Titletext
  147. ;***                              0 = default (bit7=[0]"Error!"/[1]"Info")
  148. ;***                              1 = "Error!"
  149. ;***                              2 = "Info"
  150. ;***                              3 = "Warning"
  151. ;***                              4 = "Confirmation"
  152. ;***                     [Bit6  ] Flag, if window should be modal window
  153. ;***                     [Bit7  ] Box type
  154. ;***                              0 = default (warning [!] symbol)
  155. ;***                              1 = info (own symbol will be used)
  156. ;***                DE = 0 or data record of the caller window; the dialogue
  157. ;***                     window will be a modal window of it, during its open
  158. ;*** Content data   00  1W  Address of text line 1
  159. ;***                02  1W  4 * [text line 1 pen] + 2
  160. ;***                04  1W  Address of text line 2
  161. ;***                06  1W  4 * [text line 2 pen] + 2
  162. ;***                08  1W  Address of text line 3
  163. ;***                10  1W  4 * [text line 3 pen] + 2
  164. ;***                - if E[bit7] is 1:
  165. ;***                12  1W  Address of symbol (24x24 pixel SymbOS graphic format)
  166. ;*** Output         A  = Result status
  167. ;***                     0 -> The infobox is currently used by another
  168. ;***                          application. It can only be opened once at the
  169. ;***                          same time, if it's not a pure info message (one
  170. ;***                          button, not a modal window). The user should
  171. ;***                          close the other infobox first before it can be
  172. ;***                          opened again by the application.
  173. ;***                     2 -> The user clicked "OK".
  174. ;***                     3 -> The user clicked "Yes".
  175. ;***                     4 -> The user clicked "No".
  176. ;***                     5 -> The user clicked "Cancel" or the close button.
  177. ;*** Destroyed      F,BC,DE,HL,IX,IY
  178. ;*** Description    Opens an info, warning or confirm box and displays three line
  179. ;***                of text and up to three click buttons.
  180. ;***                If Bit7 of B is set to 1, you can specify an own symbol, which
  181. ;***                will be showed left to the text. If this bit is not set, a "!"-
  182. ;***                warning symbol will be displayed.
  183. ;***                If Bit6 of B is set to 1, the window will be opened as a modal
  184. ;***                window, and you will receive a message with its window number
  185. ;***                (see MSR_SYS_SYSWRN).
  186. ;***                Please note, that the content data must always be placed in the
  187. ;***                transfer ram area (#C000-#FFFF). The texts itself and the
  188. ;***                optional graphic must always be placed inside a 16K (data ram
  189. ;***                area).
  190. ;***                As the text line pen, you should choose 1, so 6 would be the
  191. ;***                correct value.
  192. ;***                For more information about the mentioned memory types (data,
  193. ;***                transfer) see the "applications" chapter.
  194. ;***                For more information about the SymbOS graphic format see the
  195. ;***                "desktop manager data records" chapter.
  196. ;******************************************************************************
  197.         ld (SySWrnW),de
  198.         ld e,b
  199.         ld c,MSC_SYS_SYSWRN
  200.         push bc
  201.         call SySystem_SendMessage
  202.         pop af
  203.         and 7+64
  204.         dec a
  205.         ret z
  206. SySWrn1 call SySystem_WaitMessage
  207.         cp MSR_SYS_SYSWRN
  208.         jr nz,SySWrn1
  209.         ld ix,(SySWrnW)
  210.         db #dd:ld a,l
  211.         db #dd:or h
  212.         ld c,0
  213.         jr z,SySWrn2
  214.         ld (ix+51),c
  215.         inc c
  216. SySWrn2 ld a,(App_MsgBuf+1)
  217.         cp 1
  218.         ret nz
  219.         dec c
  220.         jr nz,SySWrn1
  221.         ld a,(App_MsgBuf+2)
  222.         ld (ix+51),a
  223.         jr SySWrn1
  224. SySWrnW dw 0
  225. endif
  226.  
  227. if use_SySystem_SELOPN=1
  228. SySystem_SELOPN
  229. ;******************************************************************************
  230. ;*** Name           Dialogue_FileSelector_Command
  231. ;*** Input          HL = File mask, path and name address (#C000-#FFFF)
  232. ;***                     00  3B  File extension filter (e.g. "*  ")
  233. ;***                     03  1B  0
  234. ;***                     04 256B path and filename
  235. ;***                A  = [Bit0-3] File mask, path and name ram bank (0-15)
  236. ;***                     [Bit6  ] Flag, if "open" (0) or "save" (1) dialogue
  237. ;***                     [Bit7  ] Flag, if file (0) or directory (1) selection
  238. ;***                C  = Attribute filter
  239. ;***                     Bit0 = 1 -> don't show read only files
  240. ;***                     Bit1 = 1 -> don't show hidden files
  241. ;***                     Bit2 = 1 -> don't show system files
  242. ;***                     Bit3 = 1 -> don't show volume ID entries
  243. ;***                     Bit4 = 1 -> don't show directories
  244. ;***                     Bit5 = 1 -> don't show archive files
  245. ;***                IX = Maximum number of directory entries
  246. ;***                IY = Maximum size of directory data buffer
  247. ;***                DE = Data record of the caller window; the file selector
  248. ;***                     window will be a modal window of it, during its open)
  249. ;*** Output         A  = Success status
  250. ;***                     0 -> The user choosed a file and closed the dialogue
  251. ;***                          with "OK". The complete file path and name can be
  252. ;***                          found in the filepath buffer of the application.
  253. ;***                     1 -> The user aborted the file selection. The content
  254. ;***                          of the applications filepath buffer is unchanged.
  255. ;***                     2 -> The file selection dialogue is currently used by
  256. ;***                          another application. It can only be opened once
  257. ;***                          at the same time. The user should close the
  258. ;***                          dialogue first before it can be opened again by
  259. ;***                          the application.
  260. ;***                     3 -> Memory full. There was not enough memory
  261. ;***                          available for the directory buffer and/or the
  262. ;***                          list data structure.
  263. ;***                     4 -> No window available. The desktop manager couldn't
  264. ;***                          open a new window for the dialogue, as the
  265. ;***                          maximum number of windows (32) has already been
  266. ;***                          reached.
  267. ;*** Destroyed      F,BC,DE,HL,IX,IY
  268. ;*** Description    Opens the file selection dialogue. In this dialogue the user
  269. ;***                can move through the directory structure, change the drive and
  270. ;***                search and select a file or a directory for opening or saving.
  271. ;***                If you specify a path, the dialogue will start directly in the
  272. ;***                directory. If you append a filename, too, it will be used as
  273. ;***                the preselected file.
  274. ;***                You can filter the entries of the directory by attributes and
  275. ;***                filename extension. We recommend always to set Bit3 of the
  276. ;***                attribute filter byte.
  277. ;***                The File mask/path/name string (260 bytes) must always be
  278. ;***                placed in the transfer ram area (#C000-#FFFF). For more
  279. ;***                information about this memory types see the "applications"
  280. ;***                chapter.
  281. ;***                Please note, that the system will reserve memory to store the
  282. ;***                listed directory entries and the data structure of the list.
  283. ;***                With IX and IY you can choose, how much memory should be used.
  284. ;***                We recommend to set the number of entries between 100 and 200
  285. ;***                (Amsdos supports a maximum amount of 64 entries) and to set the
  286. ;***                data buffer between 5000 and 10000.
  287. ;******************************************************************************
  288.         ld (SySSOpW+2),de
  289.         push iy
  290.         ld iy,App_MsgBuf
  291.         ld (App_MsgBuf+6),a
  292.         ld (iy+7),c
  293.         ld (App_MsgBuf+8),hl
  294.         db #dd:ld a,l
  295.         ld (App_MsgBuf+10),a
  296.         db #dd:ld a,h
  297.         ld (App_MsgBuf+11),a
  298.         pop de
  299.         ld (App_MsgBuf+12),de
  300.         ld c,MSC_SYS_SELOPN
  301.         call SySystem_SendMessage
  302. SySSOp1 call SySystem_WaitMessage
  303.         cp MSR_SYS_SELOPN
  304.         jr nz,SySSOp1
  305. SySSOpW ld ix,0
  306.         ld (ix+51),0
  307.         ld a,(App_MsgBuf+1)
  308.         cp -1
  309.         ret nz
  310.         ld a,(App_MsgBuf+2)
  311.         ld (ix+51),a
  312.         jr SySSOp1
  313. endif
  314.  
  315. if use_SySystem_HLPOPN=1
  316. SySystem_HLPFLG db 0    ;flag, if HLP-path is valid
  317. SySystem_HLPPTH db "%help.exe "
  318. SySystem_HLPPTH1 ds 128
  319. SySHInX db ".HLP",0
  320.  
  321. SySystem_HLPINI
  322.         ld hl,(App_BegCode)
  323.         ld de,App_BegCode
  324.         dec h
  325.         add hl,de                   ;HL = CodeEnd = Command line
  326.         ld de,SySystem_HLPPTH1
  327.         ld bc,0
  328.         db #dd:ld l,128
  329. SySHIn1 ld a,(hl)
  330.         or a
  331.         jr z,SySHIn3
  332.         cp " "
  333.         jr z,SySHIn3
  334.         cp "."
  335.         jr nz,SySHIn2
  336.         ld c,e
  337.         ld b,d
  338. SySHIn2 ld (de),a
  339.         inc hl
  340.         inc de
  341.         db #dd:dec l
  342.         ret z
  343.         jr SySHIn1
  344. SySHIn3 ld a,c
  345.         or b
  346.         ret z
  347.         ld e,c
  348.         ld d,b
  349.         ld hl,SySHInX
  350.         ld bc,5
  351.         ldir
  352.         ld a,1
  353.         ld (SySystem_HLPFLG),a
  354.         ret
  355.  
  356. SySystem_HLPOPN
  357.         ld a,(SySystem_HLPFLG)
  358.         or a
  359.         ret z
  360.         ld hl,SySystem_HLPPTH
  361.         ld a,(App_BnkNum)
  362.         jp SySystem_PRGRUN
  363. endif
  364.  
  365.  
  366. ;### SUB ROUTINES #############################################################
  367.  
  368. SySystem_SendMessage
  369. ;******************************************************************************
  370. ;*** Input          C       = Command
  371. ;***                HL,A,DE = additional Parameters
  372. ;*** Output         -
  373. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  374. ;*** Description    Sends a message to the system manager
  375. ;******************************************************************************
  376.         ld iy,App_MsgBuf
  377.         ld (iy+0),c
  378.         ld (App_MsgBuf+1),hl
  379.         ld (App_MsgBuf+3),a
  380.         ld (App_MsgBuf+4),de
  381.         db #dd:ld h,PRC_ID_SYSTEM
  382.         ld a,(App_PrcID)
  383.         db #dd:ld l,a
  384.         rst #10
  385.         ret
  386.  
  387. SySystem_WaitMessage
  388. ;******************************************************************************
  389. ;*** Input          -
  390. ;*** Output         IY = message buffer
  391. ;***                A  = first byte in the Message buffer (IY+0)
  392. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  393. ;*** Description    Sends a message to the desktop manager, which includes the
  394. ;***                window ID and additional parameters
  395. ;******************************************************************************
  396.         ld iy,App_MsgBuf
  397. SySWMs1 db #dd:ld h,PRC_ID_SYSTEM
  398.         ld a,(App_PrcID)
  399.         db #dd:ld l,a
  400.         rst #08             ;wait for a system manager message
  401.         db #dd:dec l
  402.         jr nz,SySWMs1
  403.         ld a,(App_MsgBuf+0)
  404.         ret
  405.