home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / Information / CHACK7.TXT3.SFX / chack7.txt3 next >
Encoding:
Text File  |  1990-02-12  |  40.0 KB  |  898 lines

  1.  
  2. will contain information; the rest of the fields should be ignored.
  3.  
  4. Each subsequent call to this routine will return the next directory
  5. entry in the directory.  All of the "dirent" fields will be valid for
  6. these.
  7.  
  8. Then, after all directory entries have been read through, the last call
  9. will return a directory entry with a null (zero-length) name.  This
  10. corresponds to the "blocks free" line in a Commodore disk directory
  11. listing.  The "aceDirentBytes" field for this last entry will be set to
  12. the number of bytes available for storage on the disk.  On a Commodore
  13. disk drive, this will be the number of blocks free multiplied by 254.
  14. After reading this last entry, you should close the directory.
  15.  
  16. At any time, if something bizarre happens to the listing from the disk
  17. that is not considered an error (I don't actually know if this is
  18. possible or not), then the .Z flag will be set, indicating the abrupt
  19. ending of the directory listing.
  20.  
  21. NAME   :  isdir
  22. PURPOSE:  determine whether the given pathname is for a file or a directory
  23. ARGS   :  (zp) = pathname
  24. RETURNS:  .A   = device identifier
  25.           .X   = is a disk device flag
  26.           .Y   = is a directory flag
  27.           .CS  = error occurred flag
  28. ALTERS :  errno
  29.  
  30. Given a properly formatted directoryname or filename, this routine will
  31. return whether the name is for a file or a directory, whether the device
  32. of the file or directory is a disk or character device, and the system
  33. identifier for the device.  The two flags return $FF for true and $00
  34. for false.  The device identifier is superfluous for now, but a
  35. "devinfo" call may be added later. Note that this file does not indicate
  36. whether the file/directory actually exists or not.
  37.  
  38. NAME   :  chdir
  39. PURPOSE:  change the current working directory
  40. ARGS   :  (zp) = new directory pathname
  41. RETURNS:  .CS  = error occurred flag
  42. ALTERS :  .A, .X, .Y, errno
  43.  
  44. Changes the current working directory to the named directory.  Too bad
  45. the Commodore Kernal doesn't have a similar call.  Unlike the "cd" shell
  46. command, the argument has to be a properly formatted directory name.
  47. Note that only directories in native partitions on CMD devices are
  48. supported by this command; the 1581's crummy idea of partitions is not
  49. supported.
  50.  
  51. NAME   :  cdhome
  52. PURPOSE:  change the current working directory back to the "home" directory
  53. ARGS   :  <none>
  54. RETURNS:  .CS  = error occurred flag
  55. ALTERS :  .A, .X, .Y, errno
  56.  
  57. Changes the current working directory back to the "home" directory that
  58. is defined in the "config.sys" file as the initial directory.
  59.  
  60. NAME   :  mkdir
  61. PURPOSE:  create a new directory
  62. ARGS   :  (zp) = pathname of new directory
  63. RETURNS:  .CS  = error occurred flag
  64. ALTERS :  .A, .X, .Y, errno
  65.  
  66. Creates a new directory.  I'm not sure, but I think that the current
  67. directory has to be the parent directory of the directory you want to
  68. create.  This may be required by CMD devices, which will be the lowest
  69. common denominator for directory support.  [Note: this call is not
  70. implemented in Release #9].
  71.  
  72. NAME   :  rmdir
  73. PURPOSE:  delete an empty existing directory
  74. ARGS   :  (zp) = pathname of empty directory to remove
  75. RETURNS:  .CS  = error occurred flag
  76. ALTERS :  .A, .X, .Y, errno
  77.  
  78. Deletes an existing directory.  The directory must be empty (have no
  79. directory entries) in order for this command to succeed.  Again, I am
  80. pretty sure that you have to be "in" the parent directory of the one to
  81. be deleted, since this is probably required by CMD devices.  [Note: this
  82. call is not implemented in Release #9].
  83.  
  84. 2.3. MEMORY CALLS
  85.  
  86. The calls given in this section are to be used for accessing "far"
  87. memory in ACE, which includes all REU, RAMLink, RAM1 and above, and
  88. sections of RAM0 that are not in the application program area.
  89. Applications are not allowed to access "far" memory directly, because
  90. the practice of bypassing the operating system would undoubtedly lead to
  91. problems (can you say "MS-DOS"?).
  92.  
  93. All of these calls use a 32-bit pointer that is stored in the zero-page
  94. argument field "mp" (memory pointer).  This field is to be interpreted
  95. as consisting of low and high words.  The low word, which of course come
  96. first, is the offset into the memory "bank" that is contained in the
  97. high word. Users may assume that offsets within a bank are continuous,
  98. so operations like addition may be performed without fear on offsets, to
  99. access subfields of a structure, for example.  You may not, however,
  100. make any interpretation of the bank word.  An application should only
  101. access far memory that it has allocated for itself via the "pagealloc"
  102. call.
  103.  
  104. NAME   :  zpload
  105. ARGS   :  [mp] = source far memory pointer
  106.           .X   = destination zero-page address
  107.           .Y   = transfer length
  108. RETURNS:  .CS  = error occurred flag
  109. ALTERS :  .A, .X, .Y, errno
  110.  
  111. Load zero-page locations with the contents of far memory.  "mp", of
  112. course, gives the address of the first byte of far memory to be
  113. retrieved.  The X register is loaded with the first address of the
  114. storage space for the data on zero page.  It must be in the application
  115. zero-page space.  The Y register holds the number of bytes to be
  116. transferred, which, considering that transfers must be to the
  117. application zero-page storage, must be 126 bytes or less.  This routine
  118. will return a "reference through null pointer" if [mp] contains a null
  119. pointer.
  120.  
  121. NAME   :  zpstore
  122. ARGS   :  .X   = source zero-page address
  123.           [mp] = destination far memory pointer
  124.           .Y   = transfer length
  125. RETURNS:  .CS  = error occurred flag
  126. ALTERS :  .A, .X, .Y, errno
  127.  
  128. This routine is the complement of "zpload"; this transfers data from
  129. zero page to far memory.  The arguments and restrictions are the same as
  130. "zpload".
  131.  
  132. NAME   :  fetch
  133. ARGS   :  [mp] = source far memory pointer
  134.           (zp) = destination RAM0 pointer
  135.           .AY  = transfer length
  136. RETURNS:  .CS  = error occurred flag
  137. ALTERS :  .A, .X, .Y, errno
  138.  
  139. This routine will fetch up to 64K of data from far memory into RAM0
  140. memory where it can be accessed directly by the processor.  The
  141. arguments should mostly speak for themselves.  You should not fetch into
  142. RAM0 memory that is not specifically allocated to the application.  You
  143. will get an error if you try to use a null far pointer.
  144.  
  145. NAME   :  stash
  146. ARGS   :  (zp) = source RAM0 pointer
  147.           [mp] = destination far memory pointer
  148.           .AY  = transfer length
  149. RETURNS:  .CS  = error occurred flag
  150. ALTERS :  .A, .X, .Y, errno
  151.  
  152. This is the complement of "fetch" and operates analogously, except that
  153. it transfers data from RAM0 to far memory.
  154.  
  155. NAME   :  pagealloc
  156. ARGS   :  .A   = requested number of pages to be allocated
  157.           .X   = starting "type" of memory to search
  158.           .Y   = ending "type" of memory to search, inclusive
  159. RETURNS:  [mp] = far memory pointer to start of allocated memory
  160.           .CS  = error occurred flag
  161. ALTERS :  .A, .X, .Y, errno
  162.  
  163. This routine allocates a given number of contiguous far-memory pages for
  164. use by the application, and returns a pointer to the first byte of the
  165. first page. On calling, the accumulator contains the number of pages to
  166. allocate (a page is 256 contiguous bytes aligned on a 256-byte address
  167. (i.e., the low byte of a page address is all zeros)).
  168.  
  169. The X and Y registers contain the start and end "types" of far memory to
  170. search for the required allocation.  The possible types are mentioned in
  171. the System Constants section.  The numeric values for the "aceMem"
  172. constants are arranged in order of accessing speed.  So, if your
  173. application has speed requirements that dictate, for example, that
  174. RAMLink memory should not be used, then you would call "pagealloc" with
  175. a search range of .X=0 to .Y=aceMemInternal.  If you wanted to say you
  176. are willing to accept any memory the system can give to you, you would
  177. specify .X=0 to .Y=255.  The values of 0 and 255 will be converted to
  178. the fastest and slowest memory available.  ACE will give you the fastest
  179. type of memory, from what you specify as acceptable, that it can.  If
  180. you had an application that you didn't want to waste the high-speed
  181. memory on, you could first call "pagealloc" asking for slow memory, such
  182. as .X=aceMemRLREU to .Y=255, and if there is none of that type of memory
  183. left, make another call with .X=0 to .Y=aceMemRLREU-1.
  184.  
  185. This routine will then search its available free memory for a chunk
  186. fitting your specifications.  If it cannot find one, the routine will
  187. return a "insufficient memory" error and a null pointer.  Note that this
  188. error may occur if there is actually the correct amount of memory free
  189. but just not in a big enough contiguous chunk.  If successful, this
  190. routine will return in "mp" a pointer to the first byte of the first
  191. page of the allocated memory.
  192.  
  193. If you call a subprogram with the "exec" call while the current program
  194. is holding far memory, that far memory will be kept allocated to your
  195. program and will be safe while the child program is executing.  If you
  196. don't deallocate the memory with "pagefree" before exiting back to your
  197. parent program, then the system will automatically deallocate all memory
  198. allocated to you.  So, have no fear about calling "exit" if you are in
  199. the middle of complicated far memory manipulation when a fatal error
  200. condition is discovered and you don't feel like figuring out what memory
  201. your program owns and deallocating it.
  202.  
  203. Some applications will want to have the most amount of memory to work
  204. with, and if there is free space in the application program area that
  205. the program is not using directly, then you may want to use that as
  206. "far" memory.  To do this, you will need to write your own stub routines
  207. that manage page allocation and deallocation requests to the near
  208. memory, and calls the "pagealloc" and "pagefree" routines to manage the
  209. far memory.  The "sort" program distributed with ACE does this.  Please
  210. note that you CANNOT simply free the unused memory of the application
  211. program area and expect the system to manage it.  Bad stuff would
  212. happen.
  213.  
  214. Some applications will want to have a byte-oriented memory allocation
  215. service rather than a page-oriented service.  You can build a
  216. byte-oriented service on top of the page-oriented service in your
  217. application programs that manage memory for the application and ask the
  218. system for pages whenever more memory is required by the application.
  219. Note that this still means that allocated memory will be freed
  220. automatically when an application exits.  The "sort" program implements
  221. this byte-oriented service, so you can check its source code to see how
  222. this is done (or to simply cut and paste the code into your own
  223. program).
  224.  
  225. NAME   :  pagefree
  226. ARGS   :  [mp] = far memory pointer to start of memory to be freed
  227.           .A   = number of pages to be freed
  228. RETURNS:  .CS  = error occurred flag
  229. ALTERS :  .A, .X, .Y, errno
  230.  
  231. This deallocates memory that was allocated to a process by using the
  232. "pagealloc" system call.  You will get an error return if you try to
  233. deallocate memory that you don't own.
  234.  
  235. 2.4. SCREEN CONTROL CALLS
  236.  
  237. This section describes the system calls that are available to
  238. application programmers for full-screen applications.  These calls are
  239. intended to be general enough to handle different screen hardware (the
  240. VIC and VDC chips and a VIC soft-80-column bitmap screen, and possibly
  241. others).  These calls are also designed to be efficient as possible, to
  242. discourage progammers from attempting to bypass using them.  Bypassing
  243. these calls would be a bad thing.
  244.  
  245. The calls are designed around the C-128/PET concept of a window.  There
  246. is only one active window on the display at a time, which may be is
  247. large as the entire screen or as small as 1x1 character cells.  This
  248. window is very cheap to setup and tear down.  An application can have
  249. multiple windows on the screen by switching the active window around.
  250.  
  251. In the calls below, all mention of "sw" in the arguments and return
  252. values refer to the "syswork" array.  For many calls, there is a
  253. "char/color/ high-attribute" argument.  This argument determines which
  254. parts of a screen location will be modified.  There are three components
  255. to each screen location: the character code, the color code, and the
  256. high-attributes.  The character code is exactly the same as the PETSCII
  257. code for the character that you want to display (unlike the screen-code
  258. arrangement that Commodore chose). There are 128 individual characters
  259. in the normal PETSCII positions, and 128 reversed images of the
  260. characters in the most sensible other positions.  The codes are as
  261. follows:
  262.  
  263. CODES (hex)   DESCRIPTION
  264. -----------   -----------
  265. $00-$1f       reverse lowercase letters
  266. $20-$3f       digits and punctuation
  267. $40-$5f       lowercase letters
  268. $60-$7f       reverse graphics characters
  269. $80-$9f       reverse uppercase letters
  270. $a0-$bf       graphics characters
  271. $c0-$df       uppercase letters
  272. $e0-$ef       reverse digits and punctuation
  273.  
  274. There are sixteen color codes, occupying the lower four bits of the color
  275. value.  These are RGBI codes, as follows:
  276.  
  277. CODE(dec)   (hex)   (bin)   DESCRIPTION
  278. ---------   -----   -rgbi   -----------
  279.         0      $0   %0000   black
  280.         1      $1   %0001   dark grey
  281.         2      $2   %0010   blue
  282.         3      $3   %0011   light blue
  283.         4      $4   %0100   green
  284.         5      $5   %0101   light green
  285.         6      $6   %0110   dark cyan on VDC, medium grey on VIC-II
  286.         7      $7   %0111   cyan
  287.         8      $8   %1000   red
  288.         9      $9   %1001   light red
  289.        10      $a   %1010   purple
  290.        11      $b   %1011   light purple on VDC, orange on VIC-II
  291.        12      $c   %1100   brown
  292.        13      $d   %1101   yellow
  293.        14      $e   %1110   light grey
  294.        15      $f   %1111   white
  295.  
  296. Finally, there are the high-attribute bits.  These occupy the four most
  297. significant bits of the color value.  Depending on the type of display
  298. (VIC text, VDC text, or VIC/VDC bitmap), these bits have one of three
  299. meanings: character attributes, background character color, or no
  300. effect.  Thus, care must be taken in using these bits; they will have
  301. different effects on different displays.  The background character codes
  302. are the same as the foreground character codes listed above.  The
  303. character attributes have the following meanings:
  304.  
  305. BIT VALUE   (dec)   (hex)   DESCRIPTION
  306. -avub----   -----   -----   -----------
  307. %10000000     128     $80   alternate characterset (italic)
  308. %01000000      64     $40   reverse character
  309. %00100000      32     $20   underline
  310. %00010000      16     $10   blink
  311.  
  312. These values are additive (or, should I say, "or-ative"); you can use
  313. any combination of them at one time.  Normally, you may wish to leave
  314. the high-attribute bits alone, unless you take the values to give them
  315. from the color palettes (next section).  To specify which of you wish to
  316. have changed, set bits in the "char/color/high-attribute" argument to
  317. system calls.  The flags have the following values.  They are or-ative
  318. as well:
  319.  
  320. BIT VALUE   (dec)   (hex)   DESCRIPTION
  321. -cah-----   -----   -----   -----------
  322. %10000000     128     $80   modify character
  323. %01000000      64     $40   modify color
  324. %00100000      32     $20   modify high-attribute bits
  325.  
  326. The screen calls that deal with placing characters on the screen refer
  327. to screen locations using absolute addresses of locations in screen
  328. memory.  This scheme is used for increased efficiency.  You can obtain
  329. information about the absolute screen address of the top left-hand
  330. corner of the current window and the number of screen addresses between
  331. successive rows, to figure out screen addresses for your applications.
  332. For added convenience, there is a call which will accept row and column
  333. numbers and return the corresponding absolute screen address.
  334.  
  335. The screen-control system calls are as follows:
  336.  
  337. NAME   :  winmax
  338. ARGS   :  <none>
  339. RETURNS:  <none>
  340. ALTERS :  .A, .X, .Y
  341.  
  342. Sets the current window to cover the entire screen.
  343.  
  344. NAME   :  winclear
  345. ARGS   :  .A   = char/color/high-attribute modification flags
  346.           .X   = character fill value
  347.           .Y   = color fill value
  348. RETURNS:  <none>
  349. ALTERS :  .A, .X, .Y
  350.  
  351. This call "clears" the current window by filling it with the
  352. character/color you specify.  You can use the char/color/hi-attr to
  353. limit what gets cleared. [Note: The arguments for this call are slightly
  354. different in Release #9].
  355.  
  356. NAME   :  winset
  357. ARGS   :  .A   = number of rows in window
  358.           .X   = number of columns in window
  359.           sw+0 = absolute screen row of top left corner of window
  360.           sw+1 = absolute screen column of top left corner of window
  361. RETURNS:  .CS  = error occurred flag
  362. ALTERS :  .A, .X, .Y, errno
  363.  
  364. Sets the current window to the size you specify.  You will get an error
  365. return if the window will not fit on the screen or of it does not
  366. contain at least one character. [Note: This call is not implemented in
  367. Release #9].
  368.  
  369. NAME   :  winsize
  370. ARGS   :  <none>
  371. RETURNS:  .A   = number of rows in window
  372.           .X   = number of columns in window
  373.           sw+0 = absolute screen row of top left corner of window
  374.           sw+1 = absolute screen column of top left corner of window
  375.          (sw+2)= screen address of top left corner
  376.          (sw+4)= screen address increment between successive rows on screen
  377. ALTERS :  <none>
  378.  
  379. Returns information about the current window. [Note: the arguments are
  380. slightly different in Release #9].
  381.  
  382. NAME   :  winput
  383. ARGS   : (sw+0)= absolute screen address to start putting data at
  384.          (sw+2)= character string pointer
  385.           .X   = length of character string
  386.           .Y   = color
  387.           .A   = char/color/high-attribute modification flags
  388.           sw+4 = fill character
  389.           sw+5 = total field length
  390. RETURNS:  <none>
  391. ALTERS :  .A, .X, .Y
  392.  
  393. Puts text onto the screen.  The output region is given by the absolute
  394. starting screen address and the total field length.  This region must be
  395. contained on one line of the current window, or bad things will happen.
  396. A pointer to the characters to be printed is given, as well as the
  397. length of the character array.  Control characters in this string are
  398. ignored; they are poked literally onto the screen, including the null
  399. character.  The length of the character string must be less than or
  400. equal to the total length of the field.  Remaining spaces in the field
  401. will be filled in with the "fill character".
  402.  
  403. The color of the total field length will be filled in with "color".  You
  404. can use the "char/color/hi-attr" modification flags to specify what is
  405. to be changed.  If you were to, for example, specify that the colors of
  406. the field are not to be changed, then the call would execute faster.
  407.  
  408. NAME   :  wincolor
  409. ARGS   :  .X   = new RGBI screen color
  410.           .Y   = new RGBI border color
  411.           .A   = which colors to change ($80=screen + $40=border)
  412. RETURNS:  .X   = resulting RGBI screen color
  413.           .Y   = resulting RGBI border color
  414. ALTERS :  .A
  415.  
  416. Sets the color of the screen and border.  You may optionally set one,
  417. the other, both, or neither.  The resulting colors for colors changed,
  418. and the existing colors for colors unchaned will be returned.  Note that
  419. not all screens have an adjustable color, so the border argument may be
  420. ignored.
  421.  
  422. NAME   :  winpos
  423. ARGS   :  .A   = row
  424.           .X   = column
  425. RETURNS: (sw+0)= screen memory address of position
  426. ALTERS :  .A, .X, .Y
  427.  
  428. Given a row and column in the current window, returns the corresponding
  429. absolute screen memory location for use with other calls.  No errors are
  430. returned, so garbage in, garbage out.
  431.  
  432. NAME   :  wincursor
  433. ARGS   : (sw+0)= screen address to place cursor
  434.           .A   = enable flag ($ff=cursor-on / $00=cursor-off)
  435.           .Y   = color to show cursor in
  436. RETURNS:  <none>
  437. ALTERS :  .A, .X, .Y
  438.  
  439. Displays or undisplays the cursor at the given screen address.  This
  440. call returns immediately in either case.  No errors are returned.  Do
  441. not display anything in or scroll the window while the cursor is being
  442. displayed, do not display the cursor twice, and do not undisplay the
  443. cursor twice in a row or bad things will happen.  Also, make sure you
  444. give the same address when undisplaying the cursor as you did when
  445. displaying the cursor.  When the system starts, the cursor will be in
  446. its undisplayed state (duh!).  You also get to specify the color you
  447. want the cursor to be shown in.  The high-attribute bits of this color
  448. are ignored.
  449.  
  450. NAME   :  winscroll
  451. ARGS   :  .A   = flags: char/color/hi-attr + $08=up + $04=down
  452.           .X   = number of rows to scroll up/down
  453.           sw+4 = fill character
  454.           .Y   = fill color
  455. RETURNS:  <none>
  456. ALTERS :  .A, .X, .Y
  457.  
  458. Scrolls the contents of the current window up or down.  You can scroll
  459. any number of rows at a time.  After scrolling, the bottom (or top) rows
  460. will be filled with the fill character and color.  You can limit whether
  461. the characters and/or colors are to be scrolled by using the "flags"
  462. byte in the usual way.  Scrolling only the characters, for example, will
  463. be twice as fast as scrolling both characters and attributes.  Whether
  464. to scroll up or down is specified also using bits in the "flags" field,
  465. as indicated in the input arguments above.  You can specify scrolling in
  466. more than one way, and the result will be to scroll in each specified
  467. direction in turn, in the order up, then down.  In the future, scrolling
  468. left and right may be added to this call. [Note: The arguments and
  469. semantics of this call are a little different in Release #9].
  470.  
  471. 2.5. CONSOLE CALLS
  472.  
  473. The calls in this section refer to the system "console", which includes
  474. the screen and keyboard.  The screen-related calls are at a higher level
  475. than the calls in the previous section.
  476.  
  477. NAME   :  stopkey
  478. ARGS   :  <none>
  479. RETURNS:  .CS  = stop key pressed
  480. ALTERS :  .A, .X, .Y, errno
  481.  
  482. Indicates whether the STOP (RUN/STOP) key is currently being held down
  483. by the user.  If so, carry flag is set on return (and clear if not).  If
  484. the stop key is discovered to be pressed by this call, then the keyboard
  485. buffer will also be cleared.
  486.  
  487. NAME   :  getkey
  488. ARGS   :  <none>
  489. RETURNS:  .A   = keyboard character
  490. ALTERS :  .X, .Y
  491.  
  492. Waits for the user to type a key (or takes a previous keystroke from the
  493. keyboard buffer).  Regular characters are returned in their regular
  494. PETSCII codes, but there are many special control keystrokes.  They are
  495. not listed here (yet) because I haven't figured out what all of the
  496. special codes should be, but all 256 possible character values will be
  497. covered.  Special codes like "page up", etc. should help in
  498. standardizing control keystrokes for applications.  The key code is
  499. returned in the accumulator.  No errors are possible.
  500.  
  501. NAME   :  concolor
  502. ARGS   :  .A   = which colors to modify: $02=character + $01=cursor 
  503.                  + $80=modify high-attributes of colors
  504.           .X   = new RGBI character color
  505.           .Y   = new RGBI cursor color
  506. RETURNS:  .X   = resulting character color
  507.           .Y   = resulting cursor color
  508. ALTERS :  .A
  509.  
  510. Sets the character and cursor colors to be used by the console for the
  511. "read" and "write" system calls that refer to files opened to the
  512. console device. You can use the flags argument to limit what gets
  513. changed. [Note: flags argument is slightly different in Release #9].
  514.  
  515. NAME   :  conpalette
  516. ARGS   :  <none>
  517. RETURNS:  sw+0 = main character color
  518.           sw+1 = cursor color
  519.           sw+2 = status character color
  520.           sw+3 = separator character color
  521.           sw+4 = highlight character color
  522.           sw+5 = alert character color
  523.           sw+6 = screen border color
  524.           sw+7 = screen background color
  525. ALTERS :  .A, .X, .Y
  526.  
  527. Returns the palette of colors that are recommended to be used in
  528. applications. These colors are chosen by the user in the system
  529. configuration, so they can be interpreted as being what the user wants
  530. and expects applications to use. A different selection is made by the
  531. user for each different screen type, and the palette returned will be
  532. for the screen type currently in use.  The high-attribute bits of these
  533. colors are valid.  Eight colors are included in the palette, and you may
  534. interpret their meaning according to the application. The suggested
  535. usages are given in the return arguments listed above.
  536.  
  537. NAME   :  conscreen
  538. ARGS   :  .A   = number of text rows required, minimum
  539.           .X   = number of text columns required, minimum
  540. RETURNS:  .A   = number of text rows you get
  541.           .X   = number of text columns you get
  542.           .CS  = error occurred flag (requested size cannot be given)
  543. ALTERS :  .Y, errno
  544.  
  545. This call selects an appropriate display device, screen, and layout for
  546. displaying text.  You ask for the minimum number of rows and columns you
  547. require on the screen, and the call returns to you what you receive.  If
  548. the system cannot match your minimum requirements, an error will be
  549. returned, and the current screen will be unchanged.  The clock speed of
  550. the processor will be changed to match the screen selected, if
  551. appropriate.
  552.  
  553. NAME   :  conpos
  554. ARGS   :  .A   = row
  555.           .X   = column
  556. RETURNS:  .CS  = error encountered flag
  557. ALTERS :  .A, .X, .Y
  558.  
  559. This call will set the screen location that the next console "read" or
  560. "write" system call will operate from.  If the "cursor" position is
  561. outside the boundaries of the current window on the screen, an error
  562. will be returned. [Note: this function is not implemented in Release
  563. #9].
  564.  
  565. 2.6. PROCESS CONTROL CALLS
  566.  
  567. This section describes calls that are used to control the execution of
  568. processes (active programs).  From within one program, you can call for
  569. the execution of another program, have it execute, and then return to
  570. the calling program.  Since only one program is allowed in memory at a
  571. time, some special problems arise.  Also, only rudimentary versions of
  572. these system calls are implemented in Release #9 and I haven't decided
  573. completely how they should work.  So, this section is a bit tentative.
  574.  
  575. NAME   :  exec
  576. PURPOSE:  execute external program as a child process
  577. ARGS   :  (zp) = program name of executable
  578.           (zw) = start address of argument vector
  579.           .AY  = number of arguments
  580.           [mp] = pointer to far memory volatile storage
  581. RETURNS:  .A   = exit code
  582.           .X   = number of bytes in "aceExitData" used
  583.           [mp] = pointer to far memory volatile storage
  584.           .CS  = error occurred flag
  585. ALTERS :  .Y, errno
  586.  
  587. Calling this routine will cause a new "frame" to be set up on the
  588. "system stack" (lowering the available application area memory a
  589. little), the specified program to be loaded into memory over top of the
  590. current one, the new program to be executed, the old program to be
  591. reloaded from whatever disk unit it came from originally upon exit of
  592. the new program, and control to be returned to the old process with the
  593. return values from the executed program. This is a complicated procedure
  594. and many things can go wrong.
  595.  
  596. The first thing that a process that wants to call another program must
  597. do is set up the arguments to be passed in.  All arguments must be
  598. null-terminated strings.  These arguments are to be put into high
  599. memory, starting from one less than the location pointed to by
  600. "aceMemTop" and working downward.  It does not matter in which order the
  601. strings are placed, as long as they are all grouped together.  Then,
  602. immediately below the strings comes the vector of two-byte RAM0 pointers
  603. that point to the strings.  This array must be in order, with the lowest
  604. entry pointing to the first (zero subscript) string, etc., the second
  605. highest entry pointing to the last string, and the highest entry
  606. containing the value $0000.  An asciigram follows:
  607.  
  608.   HIGHER ADDRESSES
  609. |           |
  610. |           | <--(aceMemTop)
  611. +-----------+
  612. |           |
  613. | string    |
  614. |           |         : collection of null-terminated strings
  615. |  contents |
  616. |           |
  617. |           |
  618. +-----------+
  619. |   $0000   |         : argv[N] : null argument pointer
  620. +-----------+
  621. | strptrN-1 |         : argv[N-1]
  622. +-----------+
  623. | strptrN-2 |         : argv[N-2]
  624. +-----------+
  625. .           .
  626. .           .
  627. +-----------+
  628. | strptr 1  |         : argv[1] : first actual argument
  629. +-----------+
  630. | strptr 0  | <--(zw) : argv[0] : filename of program to be executed
  631. +-----------+
  632. |           |
  633.   LOWER ADDRESSES
  634.  
  635. The first entry should indicate the filename or command name of the
  636. program being executed, and the subsequent arguments are the actual
  637. input arguments to the program being called.  The address of the first
  638. argument vector table entry is loaded into (zw), and the number of
  639. arguments is loaded into .AY. Note that this value also includes the
  640. command name, so if, for example, you were to call program "wc" to count
  641. two filenames "hello" and "goodbye", then you would pass an argument
  642. count of 3.  The name pointed to by "argv[0]" does not actually have to
  643. be the literal command name, but the one pointed to by (zp) does.  If a
  644. relative executable name is given in (zp), then the search path will be
  645. used to locate the executable.  Oh, don't screw up the organization of
  646. the arguments or bad things will happen; there is no structure checking.
  647.  
  648. After setting up the arguments, you'll want to set up any redirections
  649. of stdin, stdout, or stderr you'll be needing.  Because there is only
  650. one open file table in the whole uni-tasking system, you'll have to
  651. manipulate existing entries using the "fdswap" system call described
  652. earlier.  The open file table is inherited by the child process.  Note
  653. that if it closes any of the open files it inherited, then they are also
  654. closed to your use also.  If the child accidentally leaves open any
  655. files it opened, they will be closed by the system before you are
  656. reactivated.
  657.  
  658. Finally, before the call is made, you have to save any volatile local
  659. information into "far" memory.  All application zeropage and application
  660. area memory will be modified by the called program, so you must save
  661. whatever you will need to continue after the return to be able to
  662. continue.  As mentioned earlier, all of the "far" memory that a parent
  663. program owns will be safe, so you can save your volatile information
  664. there, in any format you wish.  All you have to do is save the pointer
  665. to the far memory into the [mp] pointer.  Upon return of the child
  666. process, the value you put into [mp] will be restored, and you can then
  667. restore your volatile information out of far storage.  If you wish to
  668. save no volatile information, then you can just leave garbage in the
  669. [mp] value, since it will not be interpreted by the system.
  670.  
  671. Alright, so now you call the "exec" primitive, the child program is
  672. loaded, executed, and it returns.
  673.  
  674. At this time, the parent program (that's you) is reloaded from wherever
  675. it was loaded originally and you are returned to the instruction
  676. immediately following the "jsr exec", with your processor stack intact
  677. but the rest of your volatile storage invalid.  Even if there is an
  678. error return (carry flag set), your volatile storage will still need to
  679. be restored, since the application area may have been overwritten before
  680. the error was discovered.  In the case of an error return, the child
  681. process will not have been executed.  If the system is unable to reload
  682. the parent program (you), then an error return is given to your parent,
  683. and so on, as far back as necessary.  (This is a minor exception to the
  684. rule that an error return indicates that a child didn't execute; in this
  685. case, the child didn't complete).
  686.  
  687. You are also returned an "exit code", which will have
  688. application-specific meaning, although standard programs (e.g., shell
  689. script) interpret the value as: 0==normal exit, anything else==error
  690. exit.  The X register is also set to indicate the amount of
  691. "aceExitData" that is used, to allow for more complicated return values.
  692.  
  693. [Note: This call is different in Release #9].
  694.  
  695. NAME   :  execsub
  696. PURPOSE:  execute internal subroutine as a separate process
  697. ARGS   :  (zp) = address of subroutine
  698.           (zw) = address of argument vector
  699. RETURNS:  .A   = exit code
  700.           .X   = number of bytes in "aceExitData" used
  701.           .CS  = error occurred flag
  702. ALTERS :  .Y, errno
  703.  
  704. This call is very similar to "exec", except that it calls an internal
  705. subroutine rather than an external program.  Thus, you don't have to
  706. save or restore your volatile storage, or worry about loading the child
  707. or reloading the parent.  You do, however, set up the arguments and file
  708. redirections as you would for a full "exec".  [Note: this call is
  709. different in Release #9].
  710.  
  711. NAME   :  exit
  712. PURPOSE:  exit current program, return to parent
  713. ARGS   :  .A   = exit code
  714.           .X   = number of bytes in "aceExitData" used
  715. RETURNS:  <there is no return, brah-ha-ha-ha-ha-ha!!!>
  716. ALTERS :  <don't bloody well matter>
  717.  
  718. This call causes the current program to exit back to its parent. A
  719. program that exits simply by returning to its environment will give back
  720. an exit code of 0, which should be interpreted as a normal return.  If
  721. you wish to indicate a special return, you should use some exit code
  722. other than zero.  Many utilities will interpret non-zero error codes as
  723. actual errors and may abort further operations because of this.
  724.  
  725. You may set up a return data in "aceExitData", up to 255 bytes worth,
  726. and load the number of bytes used into .X if you wish.  It is
  727. recommended that the first field of this data be a special identifier
  728. code so programs that cannot interpret your data will not try.  You
  729. cannot give any far pointers in your return data, since all far memory
  730. allocated to you will be freed by the system before returning to your
  731. parent.
  732.  
  733. NAME   :  memstat
  734. PURPOSE:  get "far" memory status plus process id
  735. ARGS   :  <none>
  736. RETURNS:  .A   = current process id
  737.          [sw+0]= amount of "far" memory free
  738.          [sw+4]= total amount of "far" memory
  739. ALTERS :  .X, .Y
  740.  
  741. This call returns the current process id, the number of bytes of far
  742. memory currently free, and the total amount of far memory.
  743.  
  744. 2.7. MISCELLANEOUS CALLS
  745.  
  746. NAME   :  utoa
  747. PURPOSE:  convert unsigned 32-bit number to a decimal PETSCII string
  748. ARGS   :  .A   = minimum length for return string
  749.           .X   = zero-page address of 32-bit number
  750.          (sw+0)= pointer to string buffer to store string
  751. RETURNS:  .Y   = length of string
  752. ALTERS :  .A, .X
  753.  
  754. This is a utility call in the kernel.  It is really not necessary for it
  755. to be in the kernel, but so many programs make use of it that it makes
  756. sense for it to be factored out.  You give a pointer to a 32-bit
  757. unsigned value in zero page memory, a pointer to a buffer to store that
  758. string that is at least as long as necessary to store the value plus the
  759. null-character terminator that will be put on the end of the string, and
  760. a minimum length value for the string.  If the number requires fewer
  761. digits than the minimum length, the string will be padded with spaces on
  762. the left.  Since a 32-bit quantity can only contain an maximum of ten
  763. decimal digits, the string buffer will only need to be a maximum of
  764. eleven bytes in size.
  765.  
  766. NAME   :  getdate
  767. PURPOSE:  get the current date and time
  768. ARGS   : (.AY) = address of buffer to put BCD-format date into
  769. RETURNS:  <none>
  770. ALTERS :  .A, .X, .Y
  771.  
  772. Returns the current date and time in the BCD format described in the
  773. paragraph on "aceDirentDate".  It puts it into the at-least-eight-byte
  774. storage area pointed to by (.AY).
  775.  
  776. NAME   :  setdate
  777. PURPOSE:  set the current date and time
  778. ARGS   : (.AY) = address of date in BCD format
  779. RETURNS:  <none>
  780. ALTERS :  .A, .X, .Y
  781.  
  782. Sets the current date and time in the system.  (.AY) points to the BCD
  783. date string whose format is discussed in the paragraph on
  784. "aceDirentDate".  No validity checking is performed on the date given.
  785.  
  786. NAME   :  cmdopen
  787. PURPOSE:  open command channel to Commodore disk drives
  788. ARGS   :  (zp) = device name
  789. RETURNS:  .A   = file descriptor number
  790.           .CS  = error occurred flag
  791. ALTERS :  .X, .Y, errno
  792.  
  793. This "cmd" set of system calls really should not be present, but they
  794. will be needed until the full complement of disk-utility system calls
  795. are implemented. It is really not recommended that any application
  796. program rely on these calls being around very long.  This call opens the
  797. command channel on the named device (standard ACE device name string)
  798. and returns the file descriptor number to use thereafter.
  799.  
  800. NAME   :  cmdclose
  801. PURPOSE:  close command channel to Commodore disk drives
  802. ARGS   :  .A   = file descriptor number
  803. RETURNS:  .CS  = error occurred flag
  804. ALTERS :  .A, .X, .Y, errno
  805.  
  806. This closes an opened command channel to a disk drive.  Closing the
  807. status will NOT affect any other open files on the disk unit at the
  808. time.
  809.  
  810. NAME   :  cmdsend
  811. PURPOSE:  send command over command channel to Commodore disk drives
  812. ARGS   :  .X   = file descriptor number
  813.          (.AY) = pointer to null-terminated command string
  814. RETURNS:  .CS  = error occurred flag
  815. ALTERS :  .A, .X, .Y, errno
  816.  
  817. This sends a command string to a disk drive.  Since a null-terminated
  818. string representation is used, not all Commodore/CMD-DOS commands can be
  819. sent, but the important ones can be.
  820.  
  821. NAME   :  cmdstatus
  822. PURPOSE:  receive current status from command channel of Commodore disk drives
  823. ARGS   :  .X   = file descriptor number
  824.          (.AY) = pointer to buffer for null-terminated status string
  825. RETURNS:  .A   = status code in binary
  826.           .CS  = error occurred
  827. ALTERS :  .X, .Y, errno
  828.  
  829. This returns the status of a disk drive in a string as well as the
  830. binary disk status number in the accumulator.  The given status buffer
  831. must be at least 50 or so characters long (whatever is the longest
  832. possible disk status string).
  833.  
  834. 3. USER PROGRAM ORGANIZATION
  835.  
  836. The ACE system itself is written using the Buddy-128 assembler, so it is
  837. recommended that applications be written in this also.  User programs
  838. for ACE have a very simple structure.  Here is the standard "hello,
  839. world" example program written in Buddy assembler for ACE:
  840.  
  841. -----=-----
  842. .seq acehead.s
  843. .org aceAppAddress
  844. .obj "@0:hello"
  845.  
  846. jmp main
  847. .byte aceID1,aceID2,aceID3
  848.  
  849. main = *
  850.    lda #<helloMsg
  851.    ldy #>helloMsg
  852.    sta zp+0
  853.    sty zp+1
  854.    lda #<helloMsgEnd-helloMsg
  855.    ldy #>helloMsgEnd-helloMsg
  856.    ldx #stdout
  857.    jsr write
  858.    rts
  859.  
  860. helloMsg = *
  861.    .asc "Hello, cruel world."
  862.    .byte 13
  863. helloMsgEnd = *
  864. -----=-----
  865.  
  866. This would normally be put into a file called "hello.s".  The ".s"
  867. extension means that this is an assembler file (a la Unix).  The first
  868. thing this program does is include the "acehead.s" file.  This is the
  869. Buddy assembler file that contains the header information declarations
  870. required to access the ACE system interface.  The next line gives the
  871. start address to start assembling to; it must be "aceAppAddress", which
  872. is the address that ACE will load the program at.  The next line is a
  873. directive to the assembler to write the executable code to a
  874. Commodore-DOS "PRG" file named "hello".  This will be the command to
  875. enter at the ACE shell prompt.
  876.  
  877. The next six bytes of object code (which are the first six bytes of a
  878. program) describe the header required by ACE programs.  The first three
  879. bytes must be a JMP to the main routine of the program.  The next three
  880. bytes must have the values "aceID1", "aceID2", and "aceID3",
  881. respectively.  And that's all there is to it.  The rest of the program
  882. can be organized however you want it to be.
  883.  
  884. In this example, we set up the arguments for the "write" system call to
  885. print the string "Hello, cruel world." plus a carriage return to
  886. standard output.  Note that this string does not need a terminating null
  887. ($00) character since the write call takes a buffer length.  The program
  888. then returns to its calling environment via an RTS.  This will cause an
  889. implied "exit(0)" to be performed by the system, returning to the parent
  890. program.
  891.  
  892. Although this program does not take advantage of this, an application
  893. program may use zero-page locations $0002 through $007f for storage
  894. without fear of having the storage trodden upon by the system.  Also,
  895. the processor stack may be used from the point it was at upon entry to
  896. your program all the way down to the bottom.  I will be doing something
  897. about ensuring there is always enough processor space for an application
  898. to use in the future, but for now, all applications have to share the
  899.