?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. ;==============================================================================
  2. ;### SYSTEM-LIBRARY-ROUTINES ##################################################
  3. ;==============================================================================
  4.  
  5. SyDesktop_WINOPN
  6. ;******************************************************************************
  7. ;*** Name           Window_Open_Command
  8. ;*** Input          A  = Window data record ram bank (0-15)
  9. ;***                DE = Window data record address (#C000-#FFFF)
  10. ;*** Output         A  = Window ID (only, if CF=0)
  11. ;***                CF = Success status
  12. ;***                     0 = OK
  13. ;***                     1 = window couldn't be opened, as the maximum number
  14. ;***                         of windows (32) has been reached
  15. ;*** Destroyed      BC,DE,HL,IX,IY
  16. ;*** Description    Opens a new window. Its data record must be placed in the
  17. ;***                transfer ram area (between #c000 and #ffff).
  18. ;***                For more information about the window data record see the
  19. ;***                chapter "desktop manager data records".
  20. ;***                For more information about the transfer ram memory types see
  21. ;***                the "applications" chapter.
  22. ;******************************************************************************
  23.         ld b,a
  24.         db #dd:ld l,e
  25.         db #dd:ld h,d
  26.         ld a,(AppPrzN)      ;register window for the application process
  27.         ld (ix+3),a
  28.         ld a,b
  29.         ld c,MSC_DSK_WINOPN
  30.         call SyDesktop_SendMessage
  31. SyWOpn1 call SyDesktop_WaitMessage
  32.         cp MSR_DSK_WOPNER
  33.         scf
  34.         ret z               ;return with set carry flag, if window couldn't be opened
  35.         cp MSR_DSK_WOPNOK
  36.         jr nz,SyWOpn1       ;different message than "open ok" -> continue waiting
  37.         ld a,(iy+4)         ;get window ID and return with cleared carry flag
  38.         ret
  39.  
  40. SyDesktop_WINCLS
  41. ;******************************************************************************
  42. ;*** Name           Window_Close_Command
  43. ;*** Input          A  = Window ID
  44. ;*** Output         -
  45. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  46. ;*** Limitation     works always
  47. ;*** Description    Closes the window. The desktop manager will remove it from the
  48. ;***                screen.
  49. ;******************************************************************************
  50.         ld c,MSC_DSK_WINCLS
  51.         jp SyDesktop_SendMessage
  52.  
  53. SyDesktop_WINDIN
  54. ;******************************************************************************
  55. ;*** Name           Window_Redraw_ContentExtended_Command
  56. ;*** Input          A  = Window ID
  57. ;***                E  = -1, control ID or negative number of controls
  58. ;***                     000 - 239 -> the control with the specified ID will be
  59. ;***                                  redrawed.
  60. ;***                     240 - 254 -> redraws -P2 controls, starting from
  61. ;***                                  control P3. As an example, if P2 is -3
  62. ;***                                  (253) and P3 is 5, the controls 5, 6 and 7
  63. ;***                                  will be redrawed.
  64. ;***                     255       -> redraws all controls inside the window
  65. ;***                                  content.
  66. ;***                - if E is between 240 and 254:
  67. ;***                D = ID of the first control, which should be redrawed.
  68. ;*** Output         -
  69. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  70. ;*** Limitation     works always
  71. ;*** Description    Redraws one, all or a specified number of controls inside the
  72. ;***                window content. This command is identical with MSC_DSK_WININH
  73. ;***                with the exception, that it always works but with less speed.
  74. ;***                For more information see MSC_DSK_WININH.
  75. ;******************************************************************************
  76.         ld c,MSC_DSK_WINDIN
  77.         jp SyDesktop_SendMessage
  78.  
  79. SyDesktop_WINTIT
  80. ;******************************************************************************
  81. ;*** Name           Window_Redraw_Title_Command
  82. ;*** Input          A  = Window ID
  83. ;*** Output         -
  84. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  85. ;*** Limitation     works only, if window has focus
  86. ;*** Description    Redraws the title bar of a window. Use this command to update
  87. ;***                the screen display, if you changed the text of the window
  88. ;***                title.
  89. ;******************************************************************************
  90.         ld c,MSC_DSK_WINTIT
  91.         jp SyDesktop_SendMessage
  92.  
  93. SyDesktop_WINSTA
  94. ;******************************************************************************
  95. ;*** Name           Window_Redraw_Statusbar_Command
  96. ;*** Input          A  = Window ID
  97. ;*** Output         -
  98. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  99. ;*** Limitation     works only, if window has focus
  100. ;*** Description    Redraws the status bar of a window. Use this command to update
  101. ;***                the screen display, if you changed the text of the status bar.
  102. ;******************************************************************************
  103.         ld c,MSC_DSK_WINSTA
  104.         jp SyDesktop_SendMessage
  105.  
  106. SyDesktop_WINMAX
  107. ;******************************************************************************
  108. ;*** Name           Window_Size_Maximize_Command
  109. ;*** Input          A  = Window ID
  110. ;*** Output         -
  111. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  112. ;*** Limitation     works only, if the window is minimized or restored
  113. ;*** Description    Maximizes a window. A maximized window has a special status,
  114. ;***                where it can't be moved to another screen position.
  115. ;******************************************************************************
  116.         ld c,MSC_DSK_WINMAX
  117.         jp SyDesktop_SendMessage
  118.  
  119. SyDesktop_WINMID
  120. ;******************************************************************************
  121. ;*** Name           Window_Size_Restore_Command
  122. ;*** Input          A  = Window ID
  123. ;*** Output         -
  124. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  125. ;*** Limitation     works only, if the window is maximized or minimized
  126. ;*** Description    Restores the window or the size of the window, if it was
  127. ;***                minimized or maximized before.
  128. ;******************************************************************************
  129.         ld c,MSC_DSK_WINMID
  130.         jp SyDesktop_SendMessage
  131.  
  132. SyDesktop_SendMessage
  133. ;******************************************************************************
  134. ;*** Input          C  = Command
  135. ;***                A  = Window ID
  136. ;***                DE,HL = additional parameters
  137. ;*** Output         -
  138. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  139. ;*** Description    Sends a message to the desktop manager, which includes the
  140. ;***                window ID and additional parameters
  141. ;******************************************************************************
  142.         ld iy,AppMsgB
  143.         ld (iy+0),c
  144.         ld (iy+1),a
  145.         ld (iy+2),e
  146.         ld (iy+3),d
  147.         ld (iy+4),l
  148.         ld (iy+5),h
  149.         db #dd:ld h,2       ;2 is the number of the desktop manager process
  150.         ld a,(AppPrzN)
  151.         db #dd:ld l,a
  152.         rst #10
  153.         ret
  154. EndLib
  155.  
  156. SyDesktop_WaitMessage
  157. ;******************************************************************************
  158. ;*** Input          -
  159. ;*** Output         IY = message buffer
  160. ;***                A  = first byte in the Message buffer (IY+0)
  161. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  162. ;*** Description    Sends a message to the desktop manager, which includes the
  163. ;***                window ID and additional parameters
  164. ;******************************************************************************
  165.         ld iy,AppMsgB
  166. SyDWMs1 db #dd:ld h,2       ;2 is the number of the desktop manager process
  167.         ld a,(AppPrzN)
  168.         db #dd:ld l,a
  169.         rst #08             ;wait for a desktop manager message
  170.         db #dd:dec l
  171.         jr nz,SyDWMs1
  172.         ld a,(iy+0)
  173.         ret
  174.  
  175. SySystem_PRGRUN
  176. ;******************************************************************************
  177. ;*** Name           Program_Run_Command
  178. ;*** Input          HL = File path and name address
  179. ;***                A  = [Bit0-3] File path and name ram bank (0-15)
  180. ;***                     [Bit7  ] Flag, if system error message should be
  181. ;***                              suppressed
  182. ;*** Output         A  = Success status
  183. ;***                     0 = OK
  184. ;***                     1 = File does not exist
  185. ;***                     2 = File is not an executable and its type is not
  186. ;***                         associated with an application
  187. ;***                     3 = Error while loading (see P8 for error code)
  188. ;***                     4 = Memory full
  189. ;***                - If success status is 0:
  190. ;***                L  = Application ID
  191. ;***                H  = Process ID (the applications main process)
  192. ;***                - If success status is 3:
  193. ;***                L  = File manager error code
  194. ;*** Destroyed      F,BC,DE,IX,IY
  195. ;*** Description    Loads and starts an application or opens a document with a
  196. ;***                known type by loading the associated application first.
  197. ;***                If Bit7 of A is not set, the system will open a message box,
  198. ;***                if an error occurs during the loading process.
  199. ;***                If the operation was successful, you will find the
  200. ;***                application ID and the process ID in L and H. If it failed
  201. ;***                because of loading problems L contains the file manager
  202. ;***                error code.
  203. ;******************************************************************************
  204.         ld c,MSC_SYS_PRGRUN
  205.         call SySystem_SendMessage
  206. SySPRn1 call SySystem_WaitMessage
  207.         cp MSR_SYS_PRGRUN
  208.         jr nz,SySPRn1
  209.         ld a,(AppMsgB+1)
  210.         ld hl,(AppMsgB+8)
  211.         ret
  212.  
  213. SySystem_PRGEND
  214. ;******************************************************************************
  215. ;*** Name           Program_End_Command
  216. ;*** Input          L  = Application ID
  217. ;*** Output         -
  218. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  219. ;*** Description    Stops an application and releases all its used system
  220. ;***                resources. This command first stops all processes of the
  221. ;***                application. After this all open windows will be closed and the
  222. ;***                reserved memory will be released.
  223. ;***                Please note, that this command can't release memory, stop
  224. ;***                processes and timers or close windows, which are not
  225. ;***                registered for the application. Such resources first have
  226. ;***                to be released by the application itself.
  227. ;******************************************************************************
  228.         ld c,MSC_SYS_PRGEND
  229.         jp SySystem_SendMessage
  230.  
  231. SySystem_SYSWRN
  232. ;******************************************************************************
  233. ;*** Name           Dialogue_Infobox_Command
  234. ;*** Input          HL = Content data address (#C000-#FFFF)
  235. ;***                A  = Content data ram bank (0-15)
  236. ;***                B  = [Bit0-2] Number of buttons (1-3)
  237. ;***                              1 = "OK" button
  238. ;***                              2 = "Yes", "No" buttons
  239. ;***                              3 = "Yes", "No", "Cancel" buttons
  240. ;***                     [Bit3-5] Titletext
  241. ;***                              0 = default (bit7=[0]"Error!"/[1]"Info")
  242. ;***                              1 = "Error!"
  243. ;***                              2 = "Info"
  244. ;***                              3 = "Warning"
  245. ;***                              4 = "Confirmation"
  246. ;***                     [Bit6  ] Flag, if window should be modal
  247. ;***                     [Bit7  ] Box type
  248. ;***                              0 = default (warning [!] symbol)
  249. ;***                              1 = info (own symbol will be used)
  250. ;***                DE = Data record of the caller window; the dialogue window
  251. ;***                     will be the modal window of it, during its open)
  252. ;*** Content data   00  1W  Address of text line 1
  253. ;***                02  1W  4 * [text line 1 pen] + 2
  254. ;***                04  1W  Address of text line 2
  255. ;***                06  1W  4 * [text line 2 pen] + 2
  256. ;***                08  1W  Address of text line 3
  257. ;***                10  1W  4 * [text line 3 pen] + 2
  258. ;***                - if E[bit7] is 1:
  259. ;***                12  1W  Address of symbol (24x24 pixel SymbOS graphic format)
  260. ;*** Output         A  = Result status
  261. ;***                     0 -> The infobox is currently used by another
  262. ;***                          application. It can only be opened once at the
  263. ;***                          same time, if it's not a pure info message (one
  264. ;***                          button, not modal). The user should close the other
  265. ;***                          infobox first before it can be opened again by the
  266. ;***                          application.
  267. ;***                     2 -> The user clicked "OK".
  268. ;***                     3 -> The user clicked "Yes".
  269. ;***                     4 -> The user clicked "No".
  270. ;***                     5 -> The user clicked "Cancel" or the close button.
  271. ;*** Destroyed      F,BC,DE,HL,IX,IY
  272. ;*** Description    Opens an info, warning or confirm box and displays three line
  273. ;***                of text and up to three click buttons.
  274. ;***                If Bit7 of B is set to 1, you can specify an own symbol, which
  275. ;***                will be showed left to the text. If this bit is not set, a "!"-
  276. ;***                warning symbol will be displayed.
  277. ;***                If Bit6 of B is set to 1, the window will be opened as a modal
  278. ;***                window, and you will receive a message with its window number
  279. ;***                (see MSR_SYS_SYSWRN).
  280. ;***                Please note, that the content data must always be placed in the
  281. ;***                transfer ram area (#C000-#FFFF). The texts itself and the
  282. ;***                optional graphic must always be placed inside a 16K (data ram
  283. ;***                area).
  284. ;***                As the text line pen, you should choose 1, so 6 would be the
  285. ;***                correct value.
  286. ;***                For more information about the mentioned memory types (data,
  287. ;***                transfer) see the "applications" chapter.
  288. ;***                For more information about the SymbOS graphic format see the
  289. ;***                "desktop manager data records" chapter.
  290. ;******************************************************************************
  291.         ld (SySWrnW),de
  292.         ld e,b
  293.         ld c,MSC_SYS_SYSWRN
  294.         push bc
  295.         call SySystem_SendMessage
  296.         pop af
  297.         and 7+64
  298.         dec a
  299.         ret z
  300. SySWrn1 call SySystem_WaitMessage
  301.         cp MSR_SYS_SYSWRN
  302.         jr nz,SySWrn1
  303.         ld ix,(SySSOpW)
  304.         ld (ix+51),0
  305.         ld a,(iy+1)
  306.         cp 1
  307.         ret nz
  308.         ld a,(iy+2)
  309.         ld (ix+51),a
  310.         jr SySWrn1
  311. SySWrnW dw 0
  312.  
  313. SySystem_SELOPN
  314. ;******************************************************************************
  315. ;*** Name           Dialogue_FileSelector_Command
  316. ;*** Input          HL = File mask, path and name address (#C000-#FFFF)
  317. ;***                     00  3B  File extension filter (e.g. "*  ")
  318. ;***                     03  1B  0
  319. ;***                     04 256B path and filename
  320. ;***                A  = [Bit0-3] File mask, path and name ram bank (0-15)
  321. ;***                     [Bit6  ] Flag, if "open" (0) or "save" (1) dialogue
  322. ;***                     [Bit7  ] Flag, if file (0) or directory (1) selection
  323. ;***                C  = Attribute filter
  324. ;***                     Bit0 = 1 -> don't show read only files
  325. ;***                     Bit1 = 1 -> don't show hidden files
  326. ;***                     Bit2 = 1 -> don't show system files
  327. ;***                     Bit3 = 1 -> don't show volume ID entries
  328. ;***                     Bit4 = 1 -> don't show directories
  329. ;***                     Bit5 = 1 -> don't show archive files
  330. ;***                IX = Maximum number of directory entries
  331. ;***                IY = Maximum size of directory data buffer
  332. ;***                DE = Data record of the caller window; the file selector
  333. ;***                     window will be a modal window of it, during its open)
  334. ;*** Output         A  = Success status
  335. ;***                     0 -> The user choosed a file and closed the dialogue
  336. ;***                          with "OK". The complete file path and name can be
  337. ;***                          found in the filepath buffer of the application.
  338. ;***                     1 -> The user aborted the file selection. The content
  339. ;***                          of the applications filepath buffer is unchanged.
  340. ;***                     2 -> The file selection dialogue is currently used by
  341. ;***                          another application. It can only be opened once
  342. ;***                          at the same time. The user should close the
  343. ;***                          dialogue first before it can be opened again by
  344. ;***                          the application.
  345. ;***                     3 -> Memory full. There was not enough memory
  346. ;***                          available for the directory buffer and/or the
  347. ;***                          list data structure.
  348. ;***                     4 -> No window available. The desktop manager couldn't
  349. ;***                          open a new window for the dialogue, as the
  350. ;***                          maximum number of windows (32) has already been
  351. ;***                          reached.
  352. ;*** Destroyed      F,BC,DE,HL,IX,IY
  353. ;*** Description    Opens the file selection dialogue. In this dialogue the user
  354. ;***                can move through the directory structure, change the drive and
  355. ;***                search and select a file or a directory for opening or saving.
  356. ;***                If you specify a path, the dialogue will start directly in the
  357. ;***                directory. If you append a filename, too, it will be used as
  358. ;***                the preselected file.
  359. ;***                You can filter the entries of the directory by attributes and
  360. ;***                filename extension. We recommend always to set Bit3 of the
  361. ;***                attribute filter byte.
  362. ;***                The File mask/path/name string (260 bytes) must always be
  363. ;***                placed in the transfer ram area (#C000-#FFFF). For more
  364. ;***                information about this memory types see the "applications"
  365. ;***                chapter.
  366. ;***                Please note, that the system will reserve memory to store the
  367. ;***                listed directory entries and the data structure of the list.
  368. ;***                With IX and IY you can choose, how much memory should be used.
  369. ;***                We recommend to set the number of entries between 100 and 200
  370. ;***                (Amsdos supports a maximum amount of 64 entries) and to set the
  371. ;***                data buffer between 5000 and 10000.
  372. ;******************************************************************************
  373.         ld (SySSOpW),de
  374.         push iy
  375.         ld iy,AppMsgB
  376.         ld (iy+6),a
  377.         ld (iy+7),c
  378.         ld (iy+8),l
  379.         ld (iy+9),h
  380.         db #dd:ld a,l
  381.         ld (iy+10),a
  382.         db #dd:ld a,h
  383.         ld (iy+11),a
  384.         pop de
  385.         ld (iy+12),e
  386.         ld (iy+13),d
  387.         ld c,MSC_SYS_SELOPN
  388.         call SySystem_SendMessage
  389. SySSOp1 call SySystem_WaitMessage
  390.         cp MSR_SYS_SELOPN
  391.         jr nz,SySSOp1
  392.         ld ix,(SySSOpW)
  393.         ld (ix+51),0
  394.         ld a,(iy+1)
  395.         cp -1
  396.         ret nz
  397.         ld a,(iy+2)
  398.         ld (ix+51),a
  399.         jr SySSOp1
  400. SySSOpW dw 0
  401.  
  402. SySystem_SendMessage
  403. ;******************************************************************************
  404. ;*** Input          C       = Command
  405. ;***                HL,A,DE = additional Parameters
  406. ;*** Output         -
  407. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  408. ;*** Description    Sends a message to the system manager
  409. ;******************************************************************************
  410.         ld iy,AppMsgB
  411.         ld (iy+0),c
  412.         ld (iy+1),l
  413.         ld (iy+2),h
  414.         ld (iy+3),a
  415.         ld (iy+4),e
  416.         ld (iy+5),d
  417.         db #dd:ld h,3       ;3 is the number of the system manager process
  418.         ld a,(AppPrzN)
  419.         db #dd:ld l,a
  420.         rst #10
  421.         ret
  422.  
  423. SySystem_WaitMessage
  424. ;******************************************************************************
  425. ;*** Input          -
  426. ;*** Output         IY = message buffer
  427. ;***                A  = first byte in the Message buffer (IY+0)
  428. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  429. ;*** Description    Sends a message to the desktop manager, which includes the
  430. ;***                window ID and additional parameters
  431. ;******************************************************************************
  432.         ld iy,AppMsgB
  433. SySWMs1 db #dd:ld h,3       ;3 is the number of the system manager process
  434.         ld a,(AppPrzN)
  435.         db #dd:ld l,a
  436.         rst #08             ;wait for a system manager message
  437.         db #dd:dec l
  438.         jr nz,SySWMs1
  439.         ld a,(iy+0)
  440.         ret
  441.  
  442. SySystem_CallFunction
  443. ;******************************************************************************
  444. ;*** Name           System_CallFunction
  445. ;*** Input          ((SP+0)) = System manager command
  446. ;***                ((SP+1)) = Function ID
  447. ;***                AF,BC,DE,HL,IX,IY = Input for the function
  448. ;*** Output         AF,BC,DE,HL,IX,IY = Output from the function
  449. ;*** Destroyed      -
  450. ;*** Description    Calls a function via the system manager. This function is
  451. ;***                needed to have access to the file manager.
  452. ;******************************************************************************
  453.         ld (AppMsgB+04),bc      ;copy registers into the message buffer
  454.         ld (AppMsgB+06),de
  455.         ld (AppMsgB+08),hl
  456.         ld (AppMsgB+10),ix
  457.         ld (AppMsgB+12),iy
  458.         push af
  459.         pop hl
  460.         ld (AppMsgB+02),hl
  461.         pop hl
  462.         ld e,(hl)
  463.         inc hl
  464.         ld d,(hl)
  465.         inc hl
  466.         push hl
  467.         ld (AppMsgB+00),de      ;module und funktion number
  468.         ld a,e
  469.         ld (SyCallN),a
  470.         ld iy,AppMsgB
  471.         ld a,(AppPrzN)
  472.         db #dd:ld l,a
  473.         ld a,3
  474.         db #dd:ld h,a
  475.         rst #10                 ;send message
  476. SyCall1 rst #30
  477.         ld iy,AppMsgB
  478.         ld a,(AppPrzN)
  479.         db #dd:ld l,a
  480.         ld a,3
  481.         db #dd:ld h,a
  482.         rst #18                 ;wait for answer
  483.         db #dd:dec l
  484.         jr nz,SyCall1
  485.         ld a,(AppMsgB)
  486.         sub 128
  487.         ld e,a
  488.         ld a,(SyCallN)
  489.         cp e
  490.         jr nz,SyCall1
  491.         ld hl,(AppMsgB+02)      ;get registers out of the message buffer
  492.         push hl
  493.         pop af
  494.         ld bc,(AppMsgB+04)
  495.         ld de,(AppMsgB+06)
  496.         ld hl,(AppMsgB+08)
  497.         ld ix,(AppMsgB+10)
  498.         ld iy,(AppMsgB+12)
  499.         ret
  500. SyCallN db 0
  501.