home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Basic / MAXONB32.DMS / in.adf / docs.lha / Operating_System < prev    next >
Encoding:
Text File  |  1994-10-31  |  99.8 KB  |  3,373 lines

  1. Operating System Support
  2.  
  3.  
  4.  
  5.  
  6. The Amiga header files
  7.  
  8. MaxonBASIC is supplied with a number of .bmap,
  9. .bh and .bc specific to the Amiga which give
  10. access to the machine´s operating system.
  11. Whilst it is outside the scope of this manual
  12. to give a complete description of the system
  13. software, this section does give an overview of
  14. the facilities available and within which
  15. subsystem and files you can find them.
  16. Many of the example programs supplied with
  17. MaxonBASIC 3 make use of these files and as
  18. such, serve as an excellent starting point for
  19. writing your own Amiga programs. For a complete
  20. guide to system you should refer to the Amiga
  21. ROM Kernel Manuals or one of the many books
  22. available on programming the Amiga (see the
  23. Bibliography).
  24. The operating system itself consists of a
  25. hierarchical system of disk loaded and ROM
  26. resident function libraries, device drivers and
  27. shared hardware resources all working under the
  28. management of the system executive, responsible
  29. for the multitasking and message passing
  30. facilities of the machine. We will use the term
  31. library to refer not just to true libraries but
  32. also to devices, datatypes and resources.
  33.  
  34. In order for your program to use the facilities
  35. of a given library, your program must first
  36. inform the compiler which functions the library
  37. contains and the machine register conventions
  38. for each call. This information is stored in
  39. .bmap files. Our standard installation will
  40. have copied these for you into the BMAP:
  41. directory. The LIBRARY DECLARE statement is
  42. used to tell the compiler to read the
  43. appropriate .bmap file.
  44. For example,
  45.  
  46.  
  47.  LIBRARY DECLARE "graphics.library"
  48.  LIBRARY DECLARE "audio.device"
  49.  LIBRARY DECLARE "gadgets/colorwheel.gadget"
  50.  
  51.  
  52. These statements will access the graphics.bmap,
  53. audio.bmap and gadgets/colorwheel.bmap files.
  54. The facilities provided by the operating system
  55. have been expanded over the years considerably
  56. but in a way that you can still write programs
  57. for older systems using the newer .bmap files.
  58. To actually call a library you must first
  59. ´open´ the relevant library. For true libraries
  60. you can use the LIBRARY OPEN statement, for
  61. example:
  62.  
  63.  
  64.  LIBRARY OPEN "graphics.library"
  65.  
  66.  
  67. If you are going to write a program that uses a
  68. facility of the library that wasn´t available
  69. in earlier versions you can specify a minimum
  70. version when you open the library. For example,
  71. if you program will require the LoadRGB32
  72. function that was introduced in version 39 of
  73. the graphics library you can use:
  74.  
  75.  
  76.  LIBRARY OPEN "graphics.library",39
  77.  
  78.  
  79. The versions of the operating system that were
  80. currently in use at the time of writing are:
  81.  
  82. 34  Workbench 1.3 (A500 owners)
  83. 37  Workbench 2.04/2.05(e.g. shipped with
  84. A3000 )
  85. 38  Workbench 2.1 (e.g. A600 owners who have
  86. upgraded)
  87. 39  Workbench 3.0 (e.g. A1200 and A4000
  88. owners)
  89. 40  Workbench 3.1 (e.g. CD32 owners)
  90.  
  91. Note that early A500 may only have version 33
  92. Kickstart (1.2) but they now generally have
  93. Workbench 1.3.
  94. For devices and resources you will need to use
  95. the OpenDevice and OpenResource functions of
  96. exec.library together with the LIBRARY VARPTR
  97. statement.
  98. The library statement is not enough - the .bmap
  99. files make no distinction between functions and
  100. sub-programs, because they are converted from
  101. the C equivalent .fd files. This is because C
  102. makes no real distinction between functions and
  103. sub-programs - if you aren´t interested in the
  104. result of a function you can call it without
  105. doing anything with the result.
  106. We use the DECLARE statement to do indicate
  107. which routines are functions and which are
  108. subroutines after the LIBRARY statement. Here
  109. is an example of the ASL library:
  110.  
  111. LIBRARY DECLARE "asl.library"
  112. DECLARE FUNCTION AllocAslRequest& LIBRARY ´
  113. reqType&, tagList&
  114. DECLARE SUB FreeAslRequest LIBRARY
  115. ´requester&
  116. DECLARE FUNCTION AslRequest& LIBRARY   ´
  117. requester&, tagList&
  118.  
  119. The first DECLARE statement indicates that
  120. AllocAslRequest& is a function and the comment
  121. indicates that it has two parameters, reqType&
  122. and tagList&. On the other hand, FreeAslRequest
  123. is a sub-program, i.e. it doesn´t return a
  124. value. It has one parameter, requester&. Note
  125. that all the operating system functions that
  126. are true functions return a long value and that
  127. all the parameters are passed as long integers
  128. too.
  129. Taglists are the method used by most of the
  130. parts of the operating system that have been
  131. added in Workbench 2 and above. The file
  132. requester has 31 different possible options (at
  133. the time of writing!). The operating system
  134. could have a function call for the File
  135. Requester that has 31 parameters, or an area of
  136. memory containing all those parameters but this
  137. would be unwieldy and would be out of date if
  138. Commodore decided to add one more option in a
  139. later release.
  140. So instead you pass a list of tags (which
  141. indicate the value that you are setting and
  142. values that you are setting the flags to). If
  143. you leave out a tag the operating system will
  144. usually provide a sensible default for you.
  145. Commodore have given the tags names, so that
  146. you don´t have to remember the right numbers
  147. for the tags. We supply those names in include
  148. files with MaxonBASIC 3. These constants are in
  149. the files with extension .bc. Continuing our
  150. ASL File Requester example, there´s a tag
  151. called ASLFR_TitleText& ; this specifies the
  152. string to be placed in the top line of the
  153. requester. Taglists are terminated by a value
  154. of 0 (TAG_DONE& and TAG_END& are the
  155. identifiers that are normally used).
  156.  
  157.  
  158. DIM frtags&(20)
  159. TAGLIST VARPTR(frtags&(0)), _
  160.  ASLFR_TitleText&, "MaxonBASIC File Requester",
  161. _
  162.  TAG_DONE&
  163.  
  164.  
  165. Here the taglist is stored in the array
  166. frtags&(). Notice that we have dimensioned it
  167. with 21 elements (0..20). This is enough for 10
  168. pairs of tags and the terminator. Note that the
  169. address where the tag list is stored is passed,
  170. hence the VARPTR(frtags&(0)). This gives total
  171. flexibility in that you can modify the middle
  172. of a tag list or store it in some memory that
  173. you have allocated yourself. However the
  174. compiler can´t check that you haven´t specified
  175. too many tags. If you specify a string in a tag
  176. list the BASIC will automatically turn it into
  177. a null-terminated C-style string for you and
  178. use the address of the string.
  179. Note that the string values will become invalid
  180. if a garbage collect occurs so you should
  181. ensure that there is sufficient space left on
  182. the heap for any strings you need before
  183. setting up your taglist. Let us assume that you
  184. are setting up a taglist that needs strings
  185. that are x bytes long, you can to this as
  186. follows:
  187.  
  188.  
  189. IF FRE(0)< x*2 THEN junk&=FRE("")
  190.  
  191.  
  192. Library sub-programs and functions are called
  193. in the same way as BASIC sub-programs and
  194. functions. Here is a complete example of
  195. displaying the File Requester and then freeing
  196. it again.
  197.  
  198.  
  199. REM $include asl.bh
  200. LIBRARY OPEN Òasl.libraryÓ
  201.  
  202. CONST TAG_DONE&=0
  203.  
  204. DIM frtags&(20)
  205.  
  206. TAGLIST VARPTR(frtags&(0)), _
  207.  ASLFR_TitleText&,"MaxonBASIC File Requester",
  208. _
  209.  ASLFR_InitialFile&,"", _
  210.  ASLFR_InitialDrawer&, CURDIR$, _
  211.  
  212.  TAG_DONE&
  213.  
  214. fr&=AllocAslRequest&(ASL_FileRequest&,VARPTR(fr
  215. tags&(0)))
  216.  
  217. IF fr& THEN
  218.  IF AslRequest&(fr&,0) THEN
  219.      PRINT "OK!Ó
  220.  ELSE
  221.      PRINT "Cancelled"
  222.  END IF
  223.  
  224.  FreeASlRequest fr&
  225.  
  226. END IF
  227.  
  228.  
  229. The REM $include statement will make the BASIC
  230. read the asl.bh file. This contains the LIBRARY
  231. DECLARE statement for the ASL library and the
  232. appropriate DECLARE statements for all its
  233. functions and libraries. It also includes
  234. asl.bc itself -this contains the constants for
  235. the tags.
  236. There´s an additional constant here that isn´t
  237. a tag, ASL_FileRequest&. It indicates to the
  238. ASL library that a File Requester (rather than
  239. a Font or Screen requester) is required.
  240. Constants like this are in the asl.bc file too.
  241. All these constants are defined as long
  242. integers even if their values would fit easily
  243. into an ordinary 16 bit integer. This is for
  244. consistency; you shouldn´t need to know the
  245. actual values of these constants.
  246. The example above should really include
  247. utility.bc which contains the definition of
  248. TAG_DONE& rather than defining it itself. This
  249. example is all very well but it doesn´t
  250. actually know which file you have selected. To
  251. do this we need to look at the area of memory
  252. pointed to by the value returned by the
  253. AllocAslRequest& function. This is a data
  254. structure which is described in the asl.bc file
  255. like this:
  256.  
  257.  
  258. ´FileRequester fields
  259. CONST fr_Reserved0% = 0
  260. CONST fr_File% = 4
  261. CONST fr_Drawer% = 8
  262. CONST fr_Reserved1% = 12
  263. CONST fr_LeftEdge% = 22
  264. CONST fr_TopEdge% = 24
  265. CONST fr_Width% = 26
  266. CONST fr_Height% = 28
  267. CONST fr_Reserved2% = 30
  268. CONST fr_NumArgs% = 32
  269. CONST fr_ArgList% = 36
  270. CONST fr_UserData% = 40
  271. CONST fr_Reserved3% = 44
  272. CONST fr_Pattern% = 52
  273. CONST FileRequester_sizeof%=56
  274.  
  275.  
  276. This means that the FileRequester structure
  277. takes 56 bytes - but you should use the
  278. FileRequester_sizeof% constant instead if you
  279. needed it in your programs. The first field is
  280. fr_Reserved and this is 4 bytes long we know
  281. this because the next offset is 4 and the
  282. offset for fr_Reserved is 0. Fields that are
  283. called reserved should be left alone by your
  284. programs.
  285. The next field fr_File, is 4 bytes long (8-4)
  286. and is a pointer to the filename that the user
  287. has entered as a C-string. We can print this
  288. out using:
  289.  
  290.  
  291.  PRINT PEEK$(PEEKL(fr&+fr_File%))
  292.  
  293.  
  294. fr&+fr_File% gives the address of the fr_File
  295. field and the PEEKL retrieves the value stored
  296. there. PEEK$ will then convert this into a
  297. BASIC string.
  298. The operating system data structures are listed
  299. in detail in the ROM Kernel Manual: Includes
  300. and Autodocs and are supplied on disk in the
  301. Native Developer Update Kit, available from
  302. Commodore. The newer parts of the operating
  303. system generally don´t require you to modify
  304. system data structures, they provide ways of
  305. setting the fields via tags, however the older
  306. facilities need to be accessed directly.
  307. One data structure that is often used is the
  308. TextAttr. Here is its definition from
  309. graphics.bc:
  310.  
  311.  
  312. ´TextAttr fields
  313. CONST ta_Name% = 0
  314. CONST ta_YSize% = 4
  315. CONST ta_Style% = 6
  316. CONST ta_Flags% = 7
  317. CONST TextAttr_sizeof%=8
  318.  
  319.  
  320. To define a text attr we can use an array of
  321. integers like this:
  322.  
  323.  
  324. DIM ta%(TextAttr_sizeof%\2)
  325.  
  326.  
  327. The division by 2 is needed because the sizes
  328. of structures are specified in bytes and each
  329. element of an integer array uses 2 bytes.
  330. The following sub-program can be used to set up
  331. such an array:
  332.  
  333.  
  334. DEFINT a-z
  335.  
  336. SUB InitTextAttr(T(1),FontName$,BYVAL Height, _
  337.      BYVAL style,BYVAL flags)
  338. POKEL
  339. VARPTR(T(0))+ta_Name%,SADD(FontName$+CHR$(0))
  340. t(ta_YSize\2)=Height
  341. POKEB VARPTR(T(0))+ta_Style,style
  342. POKEB VARPTR(T(0))+ta_Flags,flags
  343. END SUB
  344.  
  345.  
  346. Note that SADD(FontName$+CHR$(0)) is used to
  347. produce a pointer to a C string and POKEL is
  348. used to store this as a long within the integer
  349. array. To store integer elements of arrays you
  350. can use a normal BASIC array assignment but
  351. note again the division by 2 which converts
  352. from a byte offset to an integer array index.
  353. To store the byte members of this structure we
  354. use the POKEB instruction.
  355. When working with the operating system you´ll
  356. save a lot of time if you use pre-tokenised
  357. files for the include files. See the end of
  358. Chapter 4: The Compiler for a description of
  359. this.
  360. In our examples we normally include the .bh
  361. file for a library or device that we are using
  362. but occasionally we will include the .bc file
  363. instead. We use this when we aren´t calling the
  364. library directly but still want to use its
  365. constants or data structures; this saves
  366. opening the library unnecessarily at runtime
  367. and speeds up compilation a little.
  368.  
  369.  
  370. Additional functions
  371.  
  372. As well as the data structure and constant
  373. definitions, the C header files also contain
  374. some C macros. We´ve included versions of the
  375. most useful of these as sub-programs in files
  376. in the Blib drawer within the BH drawer.
  377. As well as the functions that are actually in
  378. the true Amiga libraries, you will also see C
  379. examples using functions from the C linkable
  380. Amiga.lib library. This includes code for
  381. calling devices directly, task and port
  382. creation and BOOPSI support routines. Again we
  383. have also provided these in the Blib drawer.
  384. The Blib drawer also has routines that we hope
  385. you will find useful for things such as busy
  386. pointers and gadtools menus. These have no
  387. equivalents in C.
  388.  
  389.  
  390. Name conflicts
  391.  
  392. In some cases, the conventional names used
  393. operating system routines and record fields
  394. conflict with BASIC reserved words or other
  395. operating system field names.
  396. The following reserved words are prefaced with
  397. an x; this is a hangover from AmigaBASIC and
  398. HiSoft BASIC 1:
  399.  
  400. ABS       CLOSE      EXIT       INPUT
  401. OPEN      OUTPUT     READ       TAN
  402. TRANSLATE WAIT       WRITE      
  403.  
  404. So the DOS library Open routine is named xOpen.
  405. Clashes with other reserved words are resolved
  406. by adding an underscore (_) to the end of a
  407. name. For example the window field of the Layer
  408. data structure in the graphics library is
  409. called window_%.
  410.  Clashes between structure fields and constant
  411. names are resolved by prefixing the structure
  412. name with the name of a structure, hence the
  413. priority field from the Layer data structure in
  414. the graphics library has been renamed
  415. LayerPriority%.
  416. The best way to check the name of a field is to
  417. view the .bc file itself in the editor - you
  418. can also check the size of the field at the
  419. same time; this may not be obvious if you are
  420. converting an example written in C.
  421. We also strongly recommend that you keep your
  422. code that calls the operating system in sub-
  423. programs and use the Variable Checks
  424. (VARCHECKS) option; this way the compiler can
  425. often tell you if you mistype a field or
  426. constant name; if you don´t use this option the
  427. compiler won´t warn you but your program will
  428. either crash or not work quite correctly when
  429. you run it.
  430.  
  431.  
  432.  
  433. Libraries
  434.  
  435. The following documentation gives for each
  436. library, the version of the operating system in
  437. which it first appeared, the corresponding
  438. Commodore C header files and a description of
  439. the library´s function. Note that we only
  440. include here versions of the operating system
  441. that are currently in use.
  442. A general overview of the library is then
  443. given. For a full description, please refer to
  444. the Amiga ROM Kernel Manuals: Libraries and the
  445. Native Developer Update Kit.
  446.  
  447.  
  448. Amigaguide                                2.1
  449.  
  450.  
  451. Headers:     libraries/amigaguide.h
  452. The amigaguide library provides the progammer´s
  453. interface to the AmigaGuide help system. It
  454. lets you add context sensitive help to the
  455. program that you are writing. Typically you
  456. would use the OpenAmigaGuideAsyncA& function to
  457. open AmigaGuide and use the SendAmigaGuideCmdA&
  458. function to send it commands (for example to
  459. give help on a particular topic) and then
  460. CloseAmigaGuide when finished. This library can
  461. also be used to set up nodes that change
  462. dynamically.
  463.  
  464.  
  465. ASL 2.04
  466.  
  467.  
  468.  
  469.  
  470.  
  471. Headers:     libraries/asl.h
  472. From Workbench 2.0, the asl.library contains
  473. File and Font Requesters and Workbench 2.1
  474. added the Screen Mode Requester. Typically you
  475. allocate a requester with AllocAslRequest&,
  476. activate it with AslRequest&, read the values
  477. returned and then call FreeAslRequest.
  478.  
  479.  
  480. Bullet                                    2.1
  481.  
  482.  
  483. Headers:     diskfont/glyph.h,oterrors.h
  484. The Bullet library is the Compugraphic outline
  485. font engine that has been supplied as part of
  486. the operating system from Workench 2.1. You can
  487. use this if you need fine control over the font
  488. rendering for example arbitrary rotation of
  489. characters and access to kerning tables.
  490.  
  491.  
  492. Commodities                              2.04
  493.  
  494.  
  495. Headers:     libraries/commodities.h
  496. The Commodoties library is used if your are
  497. writing your own Commodities like the screen
  498. blanker.
  499.  
  500.  
  501. Datatypes                                 3.0
  502.  
  503.  
  504. Headers:     datatypes/datatypes.h
  505. This library lets you use the data types that
  506. were added as part of Workbench 3.0; you´ll
  507. need this library regardless of which datatype
  508. class you are using and you will need to use
  509. the include file for the particular datatype
  510. classes that are used. These are described
  511. later.
  512.  
  513.  
  514. DiskFont                                  1.3
  515.  
  516.  
  517. Headers:     diskfont/diskfont.h,
  518.              diskfonttag.h
  519. The DiskFont library is a disk-loaded library
  520. responsible for loading new fonts into the
  521. system. Using the OpenDiskFont function rather
  522. than the Graphics library´s OpenFont function
  523. will automatically load a font from the current
  524. FONTS: directory if necessary.
  525. Note that any number of programs may be using
  526. the same font in memory and even once each of
  527. these has called CloseFont, the data may still
  528. remain in memory. However, all unused fonts,
  529. libraries and devices will be flushed from
  530. memory once the system requires the memory for
  531. something else.
  532.  
  533.  
  534. DOS 1.3
  535.  
  536.  
  537.  
  538. Headers:     dos/datetime.h, dos.h, dosasl.h
  539.              dosextens.h, doshunks.h,
  540.              dostags.h, exall.h,
  541.              filehandler.h, notify.h,
  542.              rdargs.h, record.h, var.h,
  543.              stdio.h
  544.  
  545. The DOS library contains functions to examine
  546. and manipulate files as well as some utility
  547. routines and new process handling.
  548. Note that you need to use LIBRARY OPEN
  549. "dos.library" to call the exec functions; C
  550. examples don´t do this.
  551.  
  552.  
  553. Files
  554.  
  555.  
  556. Some of the key routines in the DOS library are
  557. xOpen, xInput and xOutput which return file
  558. handles for subsequent xRead, xWrite and
  559. possible Seek calls. You must xClose any file
  560. handles which belong to you before your program
  561. terminates. If a DOS call fails, you may obtain
  562. an AmigaDOS error code from the IoErr function.
  563. Opening a DOS device such as PRT: or SER: is
  564. allowed and a specification such as
  565. CON:0/0/640/200/Title can be used to open a new
  566. console window. Input and Output return the
  567. default file handles provided by DOS for your
  568. program. These often refer to the Shell´s
  569. console window but may be re-directed the user.
  570. You should be aware that a program started from
  571. Workbench has no default input or output
  572. handles.
  573. File Locks may be obtained from the Lock or
  574. DupLock functions and may be used to uniquely
  575. identify a volume, directory or file.
  576. CurrentDir accepts a lock referring to a new
  577. directory and returns the previous current
  578. directory. Examine and ExamineNext provide
  579. information on locked files. Remember to UnLock
  580. file locks once you have finished with them.
  581.  
  582.  
  583. BCPL
  584.  
  585.  
  586. AmigaDOS uses some conventions of the BCPL
  587. language in which it was originally written.
  588. BCPL pointers (called BPTRs in the C include
  589. files) are shifted right by 2 bits compared to
  590. the actual machine address. This means that you
  591. must first find the pointer address by
  592. shifting. For example,
  593.  
  594. cli&=PEEKL(PEEKL(process&)+pr_CLI%)<<2
  595. When passing memory to a DOS function, such as
  596. a FileInfoBlock to Examine, it must lie on a 4
  597. byte boundary. If a BPTR is required within a
  598. structure you must shift it right twice before
  599. storing it. This alignment is guaranteed by
  600. both the MaxonBASIC safe_malloc routine and
  601. Exec library memory allocation schemes.
  602. Ideally, you should use the Workbench 2.0,
  603. AllocDosObject function. BCPL strings are often
  604. used within structures. These consist of a
  605. single length byte followed by the data and
  606. must also be aligned in this way.
  607. For those interested in the structure of
  608. AmigaDOS, many of the DOS library functions
  609. simply form an interface to the underlying file
  610. systems. Calling the Read function for example
  611. will fill in a standard message packet with the
  612. arguments you supply, send the message to the
  613. appropriate filing system and wait for a reply.
  614.  
  615.  
  616. Exec1.3
  617.  
  618.  
  619. Headers:     exec/alerts.h, devices.h,
  620.              errors.h, exec.h, execbase.h,
  621.              interrupts.h, io.h, libraries.h,
  622.              lists.h, memory.h, nodes.h,
  623.              ports.h, resident.h,
  624.              semaphores.h, tasks.h, types.h
  625. The Exec library (also known as the system
  626. executive) effectively coordinates the entire
  627. system. It handles task switching, library and
  628. device management, memory allocation, message
  629. passing, inter-task communication and
  630. interrupts as well as providing many low-level
  631. utility routines for manipulating and sorting
  632. linked lists, queues and stacks.
  633. Note that you need to use LIBRARY OPEN
  634. "exec.library" to call the exec functions; C
  635. examples don´t do this.
  636.  
  637.  
  638. Lists
  639.  
  640. In order to keep track of the entire system,
  641. Exec makes extensive use of doubly linked lists
  642. via the List and Node records. The List header
  643. is slightly unusual in that it effectively
  644. contains a dummy head and tail Node which do
  645. not form part of the list. It also contains
  646. some information concerning the nature of the
  647. list. A list structure may be initialised with
  648. the NewList function from Blib/ExecSupport.bas.
  649. The Node record contains pointers to the
  650. previous and next nodes along with optional
  651. node type, priority and name. This record is
  652. often the first member of a larger structure.
  653. MinList and MinNodes provide the functionality
  654. of Lists and Nodes without any type, priority
  655. or name.
  656. You may add and remove list nodes using Insert,
  657. AddHead, AddTail, Remove, RemHead and RemTail.
  658. Enqueue inserts a node according to its
  659. priority. FindName searches a list for the
  660. named node. In order to scan a list yourself,
  661. you must remember to ignore the head and tail
  662. nodes. Valid nodes always have successor and
  663. predecessors, never NIL pointers.
  664.  
  665.  
  666. Memory
  667.  
  668.  
  669. Memory may be allocated via AllocMem and
  670. FreeMem. Provision is made for allocating chip
  671. memory (accessible by the Amiga custom chips).
  672.  
  673.  
  674. Messages
  675.  
  676.  
  677. In order to use message passing you must first
  678. have a Port. This may be obtained from the
  679. system, such as an Intuition window´s UserPort
  680. or from the CreatePort function of
  681. Blib/ExecSupport.bas. Wait, WaitPort, GetMsg,
  682. PutMsg and ReplyMsg can then be used
  683. communicate via this port. The device I/O
  684. mechanism, Intuition´s IDCMP messages and
  685. AmigaDOS´s packet sending are all built on top
  686. of these basic functions.
  687. To communicate with a device it is necessary to
  688. allocate and initialise an IORequest record
  689. using Blib/ExecSupport.bas´s CreateExtIO.
  690. OpenDevice will then fill in the device
  691. information and you must set up the io_Command
  692. and possibly io_Data and io_Length before
  693. calling DoIO (synchronous) or SendIO
  694. (asynchronous). BeginIO, WaitIO, CheckIO and
  695. AbortIO are also available for asynchronous
  696. device I/O. CloseDevice and DeleteIOReq or
  697. DeleteExtIOReq must be used before program
  698. termination. BeginIO is actually a BASIC
  699. keyword because of its unusual calling
  700. conventions.
  701.  
  702.  
  703.  
  704. Expansion                                 1.3
  705.  
  706. Headers:     libraries/configregs.h,
  707.              configvars.h, expansion.h,
  708.              expansionbase.h
  709. The Expansion library is the software that
  710. interfaces to the Auto-Config mechanism of the
  711. Amiga which allocates address space for
  712. controller and memory cards. It is only of use
  713. when writing new device drivers, which is
  714. rather tricky from BASIC!
  715.  
  716.  
  717. Gadtools                                  2.0
  718.  
  719.  
  720. Headers:     libraries/gadtools.h
  721. Gadtools was introduced with Workbench 2.0 and
  722. provides a fairly easy to use scheme for
  723. programming gadgets and menus. Some of the
  724. latest features of the operating system can´t
  725. be accessed via Gadtools however, you will need
  726. to use BOOPSI for this. Having said that the
  727. gadtools facilities have more immediate
  728. functionality than the base BOOPSI facilities.
  729.  
  730.  
  731. Graphics                                  1.3
  732.  
  733.  
  734. Headers:     graphics/clip.h, collide.h,
  735.              coerce.h, copper.h,
  736.              display.h,displayinfo.h, gels.h,
  737.              gfx.h, gfxbase.h, graphint.h,
  738.              modeid.h, monitor.h, rastport.h,
  739.              regions.h, rpattr.h, scale.h,
  740.              sprite.h, text.h, videocontrol.h,
  741.              view.h
  742. There are basically three areas covered by the
  743. Graphics library: display control, drawing and
  744. animation. It is used by Intuition for all
  745. rendering and is closely linked with the Layers
  746. library.
  747.  
  748.  
  749. Display
  750.  
  751. The graphics display primitives make use of
  752. ViewPorts which describe a horizontal strip of
  753. the display. ViewPorts are used by Intuition to
  754. display draggable screens with different modes
  755. and colour palettes. A number of ViewPorts may
  756. be chained together in one View which describes
  757. the complete display.
  758. Display data is described in a BitMap and
  759. consists of one or more ´bitplanes´ which
  760. represent a rectangular array of pixels. In
  761. order to represent different pen colours these
  762. bitplanes are effectively stacked with the
  763. corresponding pixel bits making up a pen
  764. number. The actual colour in which each pen is
  765. displayed is determined by the palette held in
  766. a ColorMap record.
  767. InitBitMap, AllocBitMap, AllocRaster,
  768. GetColorMap, InitVPort and InitView initialise
  769. the structures and MakeVPort, MrgCop and
  770. LoadView generate the ´copper list´ which
  771. coordinates the display hardware to produce the
  772. correct image. These resources must later be
  773. deallocated via FreeRaster, FreeColorMap,
  774. FreeVPortCopLists and FreeCprList.
  775. Note that generating a custom view which is
  776. correct in all aspects on AGA machines is very
  777. difficult.
  778.  
  779.  
  780. Drawing
  781.  
  782. Drawing takes place via a RastPort. The
  783. RastPort contains information concerning the
  784. current co-ordinate positions, pen colours,
  785. drawing mode, text font, line drawing pattern
  786. and graphics layer (used for clipping). Some
  787. commonly used drawing procedures are Move,
  788. Draw, DrawCircle, DrawEllipse, Flood and Text.
  789. SetAPen and SetBPen are used to select
  790. foreground and background pen colours whilst
  791. SetDrMd sets up a drawing mode.
  792. Many graphics operations work on a whole block
  793. of the display area. Examples of this are
  794. scrolling, drawing rectangles, moving images
  795. and clearing the display. The Amiga ´blitter´
  796. (block image transfer) chip may be utilised via
  797. the Graphics library; the calls ScrollRaster,
  798. RectFill, SetRast and ClipBlit provide this.
  799. More control over the blit operation is
  800. provided by the wonderfully named BltBitMap,
  801. BltPattern, BltTemplate, BltBitMapRastPort and
  802. BltMaskBitMapRastPort!
  803. All of the graphics drawing routines may be
  804. used on the RastPort of an Intuition window.
  805. The system will handle all clipping so that
  806. only the visible parts of your window are drawn
  807. into (although you must be careful not to draw
  808. all over the window borders).
  809.  
  810.  
  811. Animation
  812.  
  813. The animation routines provide facilities for
  814. controlling ´sprites´ (images which move around
  815. the display). Simple sprites correspond to
  816. hardware sprites such as the one used for the
  817. mouse pointer. These are used as the basis of
  818. VSprites (virtual sprites) which make effective
  819. use of the available hardware sprites. These
  820. images are never actually drawn in the
  821. RastPort, instead they are superimposed over it
  822. by the graphics hardware.
  823. Another form of movable image is the bob
  824. (blitter object). These are drawn by software
  825. and consequently are slower but give more
  826. flexibility. Workbench attaches bobs to the
  827. mouse pointer in order to provide draggable
  828. icons.
  829. Animated images are controlled via an AnimComp
  830. (animation component) which are linked together
  831. to provide an AnimOb (animation object). Any of
  832. these structures may form a GEL (graphics
  833. element) which may be moved around the display
  834. at different velocities with acceleration
  835. control.
  836.  
  837.  
  838. Icon1.3
  839.  
  840.  
  841. Headers:     workbench/icon.h
  842. The Icon library provides application access to
  843. the .info files used by the Workbench. The
  844. GetDiskObject function loads the icon for a
  845. specified file and returns a pointer to a
  846. DiskObject record defined in Workbench.bc. In
  847. general, programs should only add to or examine
  848. an icons unit and not adjust the imagery or
  849. default tool. The FindToolType and
  850. MatchToolValue functions may be used for this
  851. purpose.
  852. To create or save an icon, PutDiskObject must
  853. be called. The icon may be one previously
  854. obtained from GetDiskObject or simply hard-
  855. coded into the program. To dispose of a
  856. DiskObject structure, call FreeDiskObject
  857. although care must be taken to restore any
  858. tooltypes which have been changed.
  859.  
  860.  
  861. IFFParse                                 2.04
  862.  
  863.  
  864. Headers:     libraries/iffparse.h
  865. IFFParse is a new library added with Release 2
  866. of the operating system but also available
  867. under 1.3. It handles the reading and writing
  868. of IFF (interchange file format) files.
  869. IFFParse merely handles the job of
  870. ´understanding´ the file format, interpreting
  871. or generating the file contents is completely
  872. up to you. The library has support for DOS
  873. files, the Amiga clipboard, user defined stream
  874. types and IFF property chunks.
  875. The general method of using IFFParse is to
  876. first call AllocIFF to obtain the IFFHandle
  877. used to refer to the file. You can then use the
  878. AmigaDOS Open or IFFParse OpenClipboard
  879. function to initialise an iff_Stream and call
  880. InitIFFasDOS or InitIFFasClip. OpenIFF will
  881. then begin reading or writing.
  882. By default, the ParseIFF function will simply
  883. read the entire file and tell you that it´s
  884. done it. In order to do something useful you
  885. must first call StopChunk to inform the parser
  886. of which chunks you are interested in.
  887. PropChunk may be used to record property chunks
  888. which can be accessed via FindProp.
  889. Writing IFF is performed through PushChunk and
  890. PopChunk. To begin writing a chunk, specify the
  891. name, ID and size (or IFFSIZE_UNKNOWN).
  892. WriteChunkBytes or WriteChunkRecords will
  893. actually output the data and PopChunk will
  894. complete the chunk, adding the correct size and
  895. pad byte if necessary.
  896. For a full description of the use of IFFParse,
  897. refer to the Amiga ROM Kernel Manuals:
  898. Libraries. C language examples and the IFF
  899. specification may also be found in the Devices
  900. manual.
  901.  
  902.  
  903. Intuition                                 1.3
  904.  
  905.  
  906. Headers: intuition/cghooks.h, classes.h,
  907. classusr.h, gadgetclass.h, icclass.h,
  908. imageclass.h, intuition.h, intuitionbase.h,
  909. preferences.h, screens.h, sghooks.h
  910. Intuition is responsible for the windowing
  911. interface of the Amiga. It handles screens,
  912. windows, menus, gadgets and requesters and
  913. provides a high level mechanism for programs to
  914. receive mouse, keyboard and other system
  915. events. It also supports BOOPSI (Basic Object-
  916. Orientated Progamming System for Intuition)
  917. which is the foundation on which many of recent
  918. extensions to the operating system, such as
  919. datatypes are built.
  920. One thing which Intuition does not do is give
  921. scrolling text windows. For this you must use
  922. the console device.
  923.  
  924.  
  925. Windows
  926.  
  927.  
  928. Probably the most important object handled by
  929. Intuition is the window. A window can be opened
  930. by first creating and initialising a NewWindow
  931. record and passing it to the OpenWindow
  932. function. A pointer to a Window record will be
  933. returned and the NewWindow may then be freed or
  934. re-used. The NewWindow record contains
  935. information such as the window size, default
  936. title, system gadgets (close gadget, depth
  937. gadgets, sizing gadget etc.) and refresh type
  938. (simple, smart or superbitmap).
  939. The RPort field of the Window points to a
  940. Graphics library RastPort which may be used for
  941. drawing into the window. The Window structure
  942. should generally be treated as read-only with
  943. adjustments to the window being carried out via
  944. the appropriate Intuition library functions. A
  945. program is responsible for closing each of its
  946. windows with CloseWindow.
  947.  
  948.  
  949.  
  950. Screens
  951.  
  952. All windows exist on Intuition screens. By
  953. default, the Workbench screen will be used but
  954. programs may open as many screens as they wish
  955. in a similar manner to opening windows. A
  956. NewScreen record must be supplied to OpenScreen
  957. which then returns a pointer to a Screen. This
  958. pointer can then be used for subsequent new
  959. windows and later closed with CloseScreen. The
  960. Screen structure contains BitMap, ViewPort and
  961. ColorMap records as used by Graphics.
  962.  
  963.  
  964.  
  965. Menus
  966.  
  967. A menu bar may be attached to a window once it
  968. has been opened via the SetMenuStrip. The Menu
  969. and MenuItem records are used to describe the
  970. menu bar, items and sub-items. You must call
  971. ClearMenuStrip before closing a window or
  972. attaching a new menu strip.
  973.  
  974.  
  975. Gadgets
  976.  
  977.  
  978. Intuition gadgets are the buttons, scroll bars
  979. and text input boxes used by the system. These
  980. are created by setting up a linked list of
  981. Gadget records each containing the position,
  982. size and type of a single gadget. The BoolInfo,
  983. StringInfo and PropInfo structures contain
  984. further details for particular gadget types.
  985. The actual appearance of a gadget is determined
  986. by Image, Border and IntuiText records which
  987. are once again attached to the Gadget
  988. structure. These graphical objects are also
  989. used for rendering menus and Intuition provides
  990. support routines for using them from your own
  991. code.
  992. Once initialised, gadgets must be added to a
  993. windows gadget list and refreshed before they
  994. appear on the display. Further manipulation is
  995. possible with AddGadget, RemGadget,
  996. RefreshGList, GadgetOn and GadgetOff. In order
  997. to determine the current state of a gadget you
  998. may examine certain fields in the relevant data
  999. structure.
  1000.  
  1001.  
  1002. IDCMP
  1003.  
  1004. In order to keep track of what the user is
  1005. doing, your program must monitor each window´s
  1006. IDCMP (Intuition Direct Communication Message
  1007. Port) for incoming IntuiMessages. When opening
  1008. a window or calling ModifyIDCMP you may specify
  1009. which events will be received for a given
  1010. window. Keypresses, menu selections, gadget
  1011. operations, mouse clicks or movements, disk
  1012. insertions, resizes and close events are all
  1013. reported in this way. Exec´s Wait, GetMsg and
  1014. ReplyMsg functions are the usual method of
  1015. handling these messages.
  1016. Your program may also be notified that its
  1017. window requires ´refreshing´, i.e. something
  1018. has obscured part of its display which now
  1019. needs redrawing. The system (through the Layers
  1020. library) does provide a facility for automatic
  1021. refreshing although it does involve some
  1022. overhead. To do your own refreshing, simply
  1023. call BeginRefresh, draw the entire window
  1024. contents and call EndRefresh. This will
  1025. optimise drawing so that only the damaged areas
  1026. are drawn into. Intuition takes care of drawing
  1027. the window gadgets itself.
  1028.  
  1029.  
  1030. BOOPSI
  1031.  
  1032.  
  1033. BOOPSI (or Basic Object Oriented Programming
  1034. System for Intuition) first appeared in
  1035. Workbench 2.0. It has provides the object
  1036. orientated foundation for many of the newer
  1037. facilities of intuition, such as the colorwheel
  1038. gadget and datatypes. It provides an easier way
  1039. to use Intuition gadgets although perhaps not
  1040. as easy as using the Gadtools library.
  1041. The real power of BOOPSI comes from writing
  1042. your own custom classes to extend the system.
  1043. It is only possible to give a brief overview of
  1044. Intuition here but it is the section of the
  1045. Amiga operating system which the applications
  1046. programmer will spend much of his or her time
  1047. working with. Indeed, large books have been
  1048. written on the subject. Take time to
  1049. familiarise yourself with its operation and try
  1050. to stick to the standard user interface where
  1051. possible.
  1052.  
  1053.  
  1054. Keymap                                    1.3
  1055.  
  1056. Headers:     devices/keymap.h
  1057.  
  1058. This file defines the Keymap structure type
  1059. which contains all the necessary information to
  1060. translate physical key presses into ASCII
  1061. sequences. This information is used by the
  1062. Console device and Intuition to translate raw
  1063. key codes from the hardware via Input device
  1064. into readable characters and cursor control
  1065. sequences.
  1066. Note that the Console device supports commands
  1067. to read and write the keymap associated with a
  1068. given console window and the system default
  1069. keymap.
  1070.  
  1071.  
  1072. Layers                                    1.3
  1073.  
  1074.  
  1075. Headers:     graphics/layers.h
  1076. Co-operates with the Graphics library in order
  1077. to provide overlapping ´layers´ with automatic
  1078. clipping and backup and restore of hidden
  1079. areas. To quote the ROM Kernel Manual; ÒThe
  1080. Layers Library takes care of the mundane
  1081. things, the low level, repetitive tasks that
  1082. are needed to keep track of where to put which
  1083. bitsÓ. When using Intuition, the operation of
  1084. layers is mainly transparent to the programmer.
  1085. Note that many layers functions actually form
  1086. part of the Graphics library.
  1087. Essentially, a layer is a list of clipping
  1088. rectangles associated with a BitMap. These
  1089. ClipRect records form a graphics Region.
  1090. Examples of Regions are the visible portion of
  1091. a window, or the areas exposed by scrolling
  1092. part of the display. Many utility routines for
  1093. adding rectangles and regions together exist in
  1094. the Graphics library.
  1095. Layers may be created, deleted, moved, resized,
  1096. depth arranged and scrolled. It can be seen
  1097. that these form the basis of Intuition´s
  1098. windowing system. Automatic backup of hidden
  1099. areas for refreshing is available as is manual
  1100. refreshing via BeginUpdate and EndUpdate. A
  1101. layer may also use its own private BitMap which
  1102. may be larger than the screen.
  1103.  
  1104.  
  1105. Locale                                    2.1
  1106.  
  1107.  
  1108. Headers:     libraries/locale.h
  1109. The Locale library was introduced in Workbench
  1110. 2.1 so that programs can adapt to different
  1111. languages, date formats and currencies. To use
  1112. its catalog facilities you will need the
  1113. CatComp developers´ tool from Commodore.
  1114.  
  1115.  
  1116. Lowlevel                                  3.1
  1117.  
  1118.  
  1119. Headers:     libraries/lowlevel.h
  1120. Introduced in Workbench 3.1, the low level
  1121. library adds facilities for games programmers
  1122. in the hope that by using this their software
  1123. will work on future machines, whereas direct
  1124. hardware access might not.
  1125.  
  1126.  
  1127. Nonvolatile                               3.1
  1128.  
  1129.  
  1130. Headers:     libraries/nonvolatile.h
  1131. The non-volatile library is designed for CD32
  1132. games to provide a ´save game´ facility using
  1133. the NVRAM of the CD32 or another method if
  1134. running on a machine without NVRAM. This was
  1135. introduced in version 3.1 of the operating
  1136. system.
  1137.  
  1138.  
  1139. Realtime                                  3.1
  1140.  
  1141.  
  1142. Headers:     libraries/reatime.h
  1143. The realtime library is designed for ´playing´
  1144. events that happen in real time.
  1145.  
  1146.  
  1147. Rexx2.04
  1148.  
  1149.  
  1150.  
  1151. Headers:     rexx/errors.h, rexxio.h,
  1152.              rxslib.h, storage.h
  1153. The Rexx library provides facilities for
  1154. sending ARexx commands, checking errors etc.
  1155. Although we use the name Rexx.bh for the
  1156. include file the library is actually called
  1157. "rexxsyslib.library".
  1158.  
  1159.  
  1160. Translator                                1.3
  1161.  
  1162.  
  1163. Headers:     libraries/translator.h
  1164. Translator is a disk loaded library which used
  1165. to be supplied with the operating system. It
  1166. essentially exists for a single function call;
  1167. Translate&. This converts a string of English
  1168. language text into phonetics suitable for use
  1169. by the Narrator device. In general we do not
  1170. recommend the use of this as it is no longer
  1171. supplied as part of the operating system; if
  1172. you are still using it the BASIC TRANSLATE$
  1173. function is easier to use.
  1174.  
  1175.  
  1176. Utility                                  2.04
  1177.  
  1178.  
  1179. Headers:     utility/date.h, hooks.h,
  1180.              tagitem.h, name.h, pack.h,
  1181.              utility.h
  1182.  
  1183. The utility library provides a range of
  1184. facilities from tag list manipulation, date
  1185. conversions and taking advantage of the integer
  1186. math functions of the 68020 and above. You may
  1187. find it useful to use utility.bc on its own as
  1188. this will give definitions for such things as
  1189. TAG_DONE&.
  1190.  
  1191.  
  1192. Workbench                                2.04
  1193.  
  1194. Headers:     workbench/startup.h, workbench.h
  1195.  
  1196. The Workbench.bc file gives the definition of a
  1197. DiskObject as used for Workbench icons and
  1198. supported by the Icon library. For further
  1199. details refer to the Icon library description.
  1200. The Workbench library itself contains the
  1201. functions for installing AppIcons, AppWindows
  1202. and AppMenuItems.
  1203.  
  1204.  
  1205. Devices
  1206.  
  1207. i.devices;
  1208. Amiga devices are used by the system for I/O.
  1209. Each device must support a minimal set of
  1210. commands including read, write, stop, start and
  1211. flush. Whilst this is may be sufficient for a
  1212. simple stream type device such as a serial
  1213. driver, other devices require extensions to the
  1214. basic model. Hence, many devices support ´non-
  1215. standard´ commands which are specific to that
  1216. particular device.
  1217. Most devices exist as a separate task within
  1218. the system, i.e. they run simultaneously with
  1219. your program. Often, a device will support
  1220. multiple ´units´ such as a number of disk
  1221. drives or audio channels. I/O is achieved by
  1222. sending messages, I/O requests, to the device.
  1223. Programs may either wait for their completion
  1224. (synchronous I/O) or continue with other things
  1225. while the request is being carried out
  1226. (asynchronous I/O).
  1227. To use a device you must therefore have an
  1228. understanding of the Exec library´s message
  1229. passing system. Messages require a ´reply port´
  1230. which your program must provide although this
  1231. may be shared between several devices or used
  1232. for other purposes. I/O requests must also be
  1233. correctly initialised which is handled by the
  1234. Blib/ExecSupport.bas function, CreateExtIO.
  1235. Devices often use their own format of I/O
  1236. request with special fields tagged onto the
  1237. end.
  1238. Some devices, in addition to the message based
  1239. commands described above, also provide directly
  1240. callable functions, much like those given by
  1241. libraries. In fact, the internal representation
  1242. of a device is simply an extension of the Amiga
  1243. library mechanism. Such devices require a base
  1244. pointer to be initialised before their
  1245. functions can be used.
  1246. One example of such a device is the Timer
  1247. device; of course most of the time it is much
  1248. easier to use the BASIC ONÉTIMER statement
  1249. since this will handle ´talking´ to the timer
  1250. device for you.
  1251.  
  1252. ´REM $INCLUDE Exec.bh
  1253. ´REM $INCLUDE Timer.bh
  1254.  
  1255. REM $INCLUDE BLib/ExecSupport.bas
  1256. defint a-z
  1257. ´ return a pointer to a timer request. if any
  1258. problem, return NULL
  1259. FUNCTION create_timer&(BYVAL unit&)
  1260.  STATIC r&, timerport&, timerIO&
  1261.  create_timer& = NULL&
  1262.  timerport& = CreatePort&(NULL&, 0)
  1263.  IF timerport& <> NULL& THEN
  1264.   timerIO& =
  1265. CreateExtIO&(timerport&,timerequest_sizeof)
  1266.   IF timerIO& <> NULL& THEN
  1267.     r& = OpenDevice&(SADD("timer.device" +
  1268. CHR$(0)), _
  1269.            unit&, timerIO&, 0)
  1270.     IF r& = 0 THEN
  1271.      create_timer& = timerIO&
  1272.     ELSE
  1273.      delete_timer timerIO&
  1274.     END IF
  1275.   ELSE
  1276.     DeletePort timerport& ´ Delete message port
  1277.   END IF
  1278.  END IF
  1279. END FUNCTION
  1280. SUB delete_timer(BYVAL tr&)
  1281.  STATIC tp&
  1282.  
  1283.  IF tr& <> NULL& THEN
  1284.   tp& = PEEKL(tr& + tr_node +
  1285. IORequestio_Message + _
  1286.                mn_ReplyPort)
  1287.   IF tp& <> 0 THEN DeletePort tp&
  1288.   CloseDevice tr&
  1289.   DeleteExtIO tr&
  1290.  END IF
  1291. END SUB
  1292.  
  1293. This illustrates the various setup required for
  1294. device I/O. The create_timer& function, creates
  1295. a message port called timerport&. A message
  1296. port is created. The I/O request block, in this
  1297. case a timerequest, is allocated and
  1298. initialised for use on that port. The correct
  1299. device unit is opened using the I/O request
  1300. block and returned as the result of the
  1301. function. The delete_timer sub-program ´un-
  1302. does´ this by deleting the port, closing the
  1303. device and deleting the I/O request block.
  1304. Note that, at each stage, the program checks
  1305. for errors and exits gracefully if
  1306. unsuccessful. It should be pointed out that the
  1307. OpenDevice call, unlike OpenLibrary, returns
  1308. zero for success or an appropriate error code.
  1309. In order to send an I/O request, the
  1310. appropriate fields for the device must first be
  1311. filled in. Often this is simply a matter of
  1312. setting io_Command to the command number,
  1313. io_Data to point to the data to be sent or
  1314. receive buffer and io_Length to its size. The
  1315. amount read or written will be returned in
  1316. io_Actual. Other devices have different
  1317. conventions. The following Exec functions are
  1318. available for device I/O: DoIO (synchronous,
  1319. waits for completion), SendIO (asynchronous),
  1320. CheckIO, WaitIO and AbortIO.
  1321. After successfully opening a device, the
  1322. io_Device and io_Unit fields may be copied into
  1323. another suitable I/O request block in order to
  1324. send multiple requests without having to reopen
  1325. the device.
  1326. The functions mentioned above are Exec
  1327. functions; normally these are all you will
  1328. need. Sometimes you will want to use device
  1329. specific functions. To do this for the timer
  1330. device with the function shown above you could
  1331. use:
  1332.  
  1333.  
  1334. tr& = create_timer&(UNIT_MICROHZ&)
  1335.  
  1336. LIBRARY VARPTR "timer.device", _
  1337.  PEEKL(tr& + tr_node + IORequestio_Device)
  1338.  
  1339.  
  1340. We can now call the AddTime, SubTime or CmpTime
  1341. functions as the above has set the TimerBase
  1342. variable for us. After using these you must
  1343. clean up with
  1344.  
  1345.  
  1346. LIBRARY VARPTR "timer.device", NULL&
  1347. delete_timer tr&
  1348.  
  1349.  
  1350. otherwise the BASIC runtimes will try to close
  1351. the device as if it was a true library.
  1352.  
  1353.  
  1354. Audio                                     1.3
  1355.  
  1356.  
  1357.  
  1358. Headers:     devices/audio.h
  1359.  
  1360. The Audio device handles sound output and
  1361. arbitration for the system. It should be used
  1362. even when writing to the hardware registers
  1363. directly in order to avoid conflicts with other
  1364. programs which may be running.
  1365. An IOAudio request block is used for audio
  1366. device I/O. When OpenDevice is called, you may
  1367. specify channels to be allocated via the
  1368. ioa_Request. The ioa_Length field in the
  1369. ioa_Request was as if you had send a
  1370. ADCMD_ALLOCATE command. An ioa_Length of zero
  1371. simply opens the device for later channel
  1372. allocation. Many commands work on multiple
  1373. audio channels determined by the io_Unit field.
  1374. The ADCMD_ALLOCATE command takes a sound
  1375. precedence in io_Message.mn_Node.ln_Pri to
  1376. determine whether it can override other sounds
  1377. which are in progress. Sounds may be started
  1378. with a CMD_WRITE after filling in the
  1379. appropriate fields of the IOAudio request
  1380. block.
  1381. Note that you must start i/o with BeginIO
  1382. rather than SendIO/DoIO.
  1383. The Amiga generates sounds from waveform or
  1384. sample data which must be located in Chip
  1385. memory. Even simple waveforms such as square,
  1386. sine or sawtooth waves must be represented by
  1387. an array of signed byte values.
  1388.  
  1389.  
  1390. CD                                       3.1
  1391.  
  1392.  
  1393.  
  1394. Headers:     devices/cd.h
  1395. The CD device first appeared with Workbench 3.1
  1396. and is used to control a CDROM drive as on the
  1397. CD32, although it can also be used with add-on
  1398. drives on other Amigas.
  1399.  
  1400.  
  1401. Clipboard                                 1.3
  1402.  
  1403.  
  1404.  
  1405. Headers:     devices/clipboard.h
  1406. The Amiga Clipboard provides a rendezvous for
  1407. applications that wish to ´cut´ and ´paste´
  1408. data. It supports multiple clip units, IFF
  1409. (interchange file format), disk spooling,
  1410. random access and delayed ´post´ write
  1411. requests. It is highly recommended that all
  1412. programs supporting block operations use the
  1413. Clipboard.
  1414. Clipboard I/O uses an IOClipReq which is
  1415. identical to a standard request with the
  1416. addition of the io_ClipID field. Although the
  1417. device supports 255 separate unit numbers
  1418. (requested through OpenDevice), the
  1419. PRIMARY_CLIP unit should be used unless
  1420. requested through user preferences. Note that
  1421. the clipboard.device file must be present in
  1422. DEVS: for use.
  1423. The sequence of events for cutting a block to
  1424. the clipboard is to CreateExtIO an IOClipReq,
  1425. OpenDevice the appropriate unit, CMD_WRITE with
  1426. io_Offset and io_ClipID set to zero. The
  1427. io_Data and io_Length fields indicate the
  1428. length of the data. Any number of CMD_WRITEs
  1429. may be used, terminated by a CMD_UPDATE to
  1430. complete the clip.
  1431. Pasting is achieved by sending CMD_READS
  1432. (io_Offset must again be initialised to zero)
  1433. until the returned io_Actual is zero,
  1434. indicating end of clip.
  1435. In order to support the clipboard, a program
  1436. must understand IFF. The most common IFF forms
  1437. used are FTXT (formatted text) and ILBM
  1438. (interleaved bitmap) for graphics. For a full
  1439. description of the IFF standard, please refer
  1440. to the ROM Kernel Manuals: Devices, Third
  1441. Edition.
  1442. Easier clipbaord support is available via the
  1443. Datatypes library; however this will only work
  1444. under Workbench 3 and above.
  1445.  
  1446.  
  1447. Console                                   1.3
  1448.  
  1449.  
  1450.  
  1451. Headers:     devices/console.h, conunit.h
  1452. The Console device provides ANSI terminal
  1453. capabilities within an Intuition window. ANSI
  1454. control sequences, line buffering and editing
  1455. (as used by the CLI and Shell) are supported.
  1456. The Console device may also be accessed in a
  1457. file-based manner via CON: under AmigaDOS.
  1458. Opening a Console device involves creating a
  1459. port, IOStdReq and Intuition window. An
  1460. OpenDevice of unit 0 with io_Data and io_Length
  1461. set up for the Window structure will fill in
  1462. io_Device with the device base pointer and
  1463. io_Unit as a pointer to a ConUnit record. Many
  1464. useful values such as the cursor position and
  1465. dimensions may be read from this data
  1466. structure.
  1467. Characters are output to the window and read
  1468. back using CMD_WRITE and CMD_READ in the usual
  1469. way. Control sequences to request special event
  1470. reporting or keyboard mapping information may
  1471. also be sent in this way. Note that the console
  1472. unit must be closed before the associated
  1473. Intuition window.
  1474. In addition to I/O operations, the console
  1475. device offers several library style functions
  1476. such as RawKeyConvert to translate raw keycodes
  1477. into text characters or control sequences. In
  1478. order to use these, the LIBRARY VARPTR  must be
  1479. initialised from a valid io_Device. Opening
  1480. unit -1 of the device may be used to obtain
  1481. this base pointer without opening a new console
  1482. window.
  1483.  
  1484.  
  1485. Gameport                                  1.3
  1486.  
  1487.  
  1488.  
  1489. Headers:     devices/gameport.h
  1490. Gameport is the device which handles mouse and
  1491. digital joystick input. There is no system
  1492. support for proportional joysticks. This
  1493. information is in turn passed on to the Input
  1494. device to form part of the event stream.
  1495. Two units are available, corresponding to the
  1496. Amiga´s two joystick ports. Unit 0 is normally
  1497. used for the mouse leaving unit 1 available for
  1498. other purposes. You may configure the Gameport
  1499. device to respond to specific events from a
  1500. particular type of controller. Each action is
  1501. returned in the form of an InputEvent.
  1502.  
  1503.  
  1504. Input                                     1.3
  1505.  
  1506.  
  1507.  
  1508. Headers:     devices/input.h, inputevent.h
  1509. The purpose of the Amiga Input device is to
  1510. collect and organise the stream of user input
  1511. events from the keyboard, mouse, disk drives
  1512. etc. into what is sometimes referred to as the
  1513. ´food chain´. Intuition and the Console device
  1514. use this to react to user actions and programs
  1515. may add to or adjust input events as required.
  1516. The most common reason for directly opening the
  1517. Input device is to add ´hot keys´ (keypresses
  1518. which activate a program or operation
  1519. regardless of which application is running) to
  1520. the system by inserting a handler into the
  1521. input chain. However under workbench 2 and
  1522. above you should use the Commodities library
  1523. instead.
  1524. For other applications, it is usually
  1525. preferable to use Intuition´s IDCMP scheme or
  1526. access the Console, GamePort or Timer devices.
  1527.  
  1528.  
  1529. Keyboard                                  1.3
  1530.  
  1531.  
  1532.  
  1533. Headers:     devices/keyboard.h
  1534. The Keyboard device gives system access to the
  1535. Amiga keyboard and is usually only accessed by
  1536. the Input device. Commands to read the keyboard
  1537. matrix and to add reset handlers for emergency
  1538. processing upon user reset are also supported.
  1539. Warning: reading key events directly from the
  1540. Keyboard device will prevent them from reaching
  1541. the Input device and system event stream. Use
  1542. Intuition or the Console or Input device
  1543. instead.
  1544.  
  1545.  
  1546. Narrator                                  1.3
  1547.  
  1548.  
  1549.  
  1550.  
  1551. Headers:     devices/narrator.h
  1552. The Amiga Narrator is the device which used to
  1553. be used to produce recognisable human-like
  1554. speech from phonetic text. When used in
  1555. conjunction with the Translator library,
  1556. English language text to speech translation can
  1557. be achieved. Unfortunately, narrator is no
  1558. longer part of the newer versions of the
  1559. operating system. If you are still using the
  1560. speech facilities it is generally much easier
  1561. to use the BASIC SAY command. However if you
  1562. want additional control, then you will need to
  1563. use the Narrator device directly.
  1564.  
  1565.  
  1566. Parallel                                  1.3
  1567.  
  1568.  
  1569. Headers:     devices/parallel.h
  1570. The Parallel device is used for bi-directional
  1571. I/O via the Centronics compatible parallel
  1572. port. It is used by the Printer device which
  1573. should be employed for all printer output.
  1574. The IOExtPar request is used and is initialised
  1575. upon calling OpenDevice. Standard commands can
  1576. be used to read and write data. The device can
  1577. be programmed to accept a number of ´end of
  1578. transfer´ characters if required.
  1579.  
  1580.  
  1581. Printer                                   1.3
  1582.  
  1583.  
  1584.  
  1585. Headers:     devices/printer.h, prtbase.h,
  1586.              prtgfx.h
  1587. The Printer device is a disk loaded device
  1588. which via different printer drivers provides
  1589. translation of ANSI control sequences and full
  1590. colour or monochrome screen dumps. Output is
  1591. directed through SER: or PAR: according to
  1592. current user preferences.
  1593. Note that for many text applications it is
  1594. simpler to use the BASIC LPRINT or PRINT#
  1595. commands.
  1596. The Printer device uses 3 types of I/O
  1597. requests; IOStdReq for CMD_START and CMD_WRITE
  1598. etc., IOPrtCmdReq for sending printer commands
  1599. directly (PRD_PRTCOMMAND) and IODRPReq to
  1600. request a graphic dump of a RastPort
  1601. (PRD_DUMPRPORT). These may be allocated with
  1602. CreateExtIO.
  1603. The standard I/O commands all work as expected,
  1604. translating ANSI command sequences where
  1605. necessary. Note that if a printer driver does
  1606. not support a particular command, it will
  1607. simply be ignored. A common mistake is to send
  1608. escape codes suitable for your printer rather
  1609. than standard ANSI commands. See your system
  1610. documentation for a complete list of the
  1611. supported commands. The PRD_RAWWRITE I/O
  1612. command sends unprocessed data to the printer.
  1613. One of the main reasons for using the Printer
  1614. device directly is to utilise the graphic dump
  1615. facilities. A sub-rectangle of a RastPort may
  1616. be printed with the supplied ColourMap,
  1617. ViewModes (including HAM, Extra Half Bright
  1618. etc.), aspect ratio and page positioning. Note
  1619. that the printer device is not limited by Amiga
  1620. screen resolutions.
  1621.  
  1622.  
  1623. Ramdrive                                  1.3
  1624.  
  1625. The Ramdrive device has function calls to
  1626. remove the DOS RAD: device.
  1627.  
  1628.  
  1629. SCSI2.04
  1630.  
  1631.  
  1632.  
  1633. Headers:     devices/scsidisk.h, hardblocks.h
  1634. SCSI (small computer system interface) hardware
  1635. is used on the Amiga 3000 computer and
  1636. A2091/A590 hard drives to transfer data under
  1637. the control of the SCSI device. This device is
  1638. also used to control the IDE interfaces on the
  1639. A1200 and A4000. This device can cope with
  1640. standard I/O commands as well as some Trackdisk
  1641. commands and HD_SCSICMD to issue a SCSI-direct
  1642. command to any SCSI unit on the bus.
  1643. The RigidDiskBlock structure used to provide
  1644. automatic mounting of hard drive partitions
  1645. also forms part of the scsi.bc file. Note that
  1646. different hard drives use other driver software
  1647. and mount information. All file level access
  1648. must be done through AmigaDOS and not through
  1649. the device interface.
  1650.  
  1651.  
  1652. Serial                                    1.3
  1653.  
  1654.  
  1655.  
  1656. Headers:     devices/serial.h
  1657. The Serial device controls the Amiga´s built in
  1658. RS-232C compatible serial port. It supports a
  1659. variety of transfer protocols and baud rates.
  1660. Note that output intended for a printer should
  1661. instead be sent to the Amiga Printer device.
  1662. An IOExtSer request block contains the
  1663. parameters required for serial transfer. This
  1664. is achieved by use of standard device commands
  1665. with some extra commands providing control over
  1666. various parameters.
  1667. Some applications requiring high speed serial
  1668. transfer, notably MIDI programs, may ´miss´
  1669. data due to system software overhead. If it is
  1670. necessary to write to the hardware directly,
  1671. this should only be done after successfully
  1672. allocating the appropriate bits through the
  1673. Misc resource.
  1674.  
  1675.  
  1676. Timer                                     1.3
  1677.  
  1678.  
  1679.  
  1680. Headers:     devices/timer.h
  1681. Provides general purpose timing through an Exec
  1682. style device. Two timer resolutions are
  1683. supported, vertical blank (through UNIT_VBLANK)
  1684. for long duration requests and microhertz
  1685. (UNIT_MICROHZ) for short burst timing.
  1686. The Timer device can also be used to read or
  1687. set the system clock and for library routines
  1688. involving time calculations based upon I/O
  1689. requests.
  1690. The device is intended for interval timing and
  1691. does not support stopwatch or alarm clock style
  1692. functionality For general purpose application
  1693. ´prods´ for updating scroll bars or list
  1694. displays, Intuition windows can provide
  1695. ´intuitick´ events at a rate of around 10 per
  1696. second.
  1697. The Timer device uses a timerequest structure
  1698. for I/O which is simply an IORequest with
  1699. fields for seconds and microseconds added to
  1700. it. When sending timerequests to the timer
  1701. device via SendIO, you must be careful not to
  1702. re-use the request block until the device has
  1703. replied to it. Any number of requests may be
  1704. sent and they will be returned in the
  1705. appropriate order. Using DoIO will simply delay
  1706. your program for a period of time in a similar
  1707. way to the dos.library Delay sub-program.
  1708. One bug which exists in the Timer device under
  1709. Kickstart 1.3 and before is that asking for a
  1710. time delay of 0 or 1 microseconds can crash the
  1711. system.
  1712.  
  1713.  
  1714.  
  1715.  
  1716. Trackdisk                                 1.3
  1717.  
  1718. Headers:     devices/trackdisk.h
  1719. Trackdisk is the device used by the Amiga
  1720. filing system to read and write floppy disks.
  1721. It is intended for advanced users only. Some
  1722. standard commands are supported and in
  1723. addition, many device specific commands to
  1724. control the motor, seek to a specific track,
  1725. format the disk, check disk and drive status
  1726. and read/write raw MFM data are available.
  1727.  
  1728.  
  1729.  
  1730. Resources
  1731.  
  1732. In general, resources handle arbitration of
  1733. shared hardware. Since the Amiga multitasks,
  1734. different programs or devices may require
  1735. access to the hardware and to ensure they do
  1736. not conflict, this is done through the
  1737. appropriate resource.
  1738. Important note: resources are just one step
  1739. above direct hardware manipulation. There is
  1740. usually a higher level device or library
  1741. interface that is easier to use, maintain and
  1742. upgrade and which shares the hardware more
  1743. efficiently between applications.
  1744. You must open a resource before calling its
  1745. functions. An example of this is:
  1746.  
  1747.  
  1748. rem $include exec.bh
  1749. rem $include disk.bh
  1750.  
  1751. DiskBase& = OpenResource&(SADD("disk.resource"
  1752. + CHR$(0)))
  1753.  
  1754.  
  1755.  
  1756. To call the functions in a resource you need to
  1757. ´tell´ the BASIC runtimes that this is the base
  1758. pointer of the resource:
  1759.  
  1760.  
  1761.  
  1762.  LIBRARY VARPTR "disk.resource", DiskBase&
  1763.  
  1764.  
  1765. You can now call the resource´s functions.
  1766. You may notice that there is no CloseResource
  1767. call; unlike the closing calls for libraries
  1768. and devices. However you must reset the library
  1769. base pointer to 0 like this:
  1770.  
  1771.  
  1772.  LIBRARY VARPTR "disk.resource", 0
  1773.  
  1774.  
  1775.  otherwise the BASIC runtimes will try and
  1776. close the resource as if it was a library.
  1777.  
  1778.  
  1779. BattClock                                 2.0
  1780.  
  1781.  
  1782.  
  1783. Headers:     resources/battclock.h
  1784. This resource accesses the Amiga´s battery
  1785. backed clock; normally you should not access
  1786. this directly; use the timer device if you need
  1787. to set the date/time.
  1788.  
  1789.  
  1790. BattMem                                   2.0
  1791.  
  1792.  
  1793.  
  1794. Headers:     resources/battclock.h,
  1795.              battmembitsamiga.h,
  1796.              battmembitsamix.h,
  1797.              battmembitsshared.h
  1798. This resource accesses the Amiga´s battery
  1799. backed up configuration RAM; normally you
  1800. should not access this.
  1801.  
  1802.  
  1803. CardRes                                  2.05
  1804.  
  1805.  
  1806.  
  1807.  
  1808. Headers:     resources/card.h
  1809. The Card Resource is used to control the PCMCIA
  1810. credit card slot of the Amiga 600 and 1200.
  1811.  
  1812.  
  1813. CIA 1.3
  1814.  
  1815. Headers:     resources/cia.h
  1816.  
  1817.  
  1818. This resource grants access to the interrupts
  1819. and timer bits of the 8520 CIA (complex
  1820. interface adaptor) chips. Some applications
  1821. such as MIDI and time coding programs require
  1822. such extreme accuracy and low overhead timing.
  1823. However, the vast majority of programs should
  1824. use the Timer device.
  1825. The CIA resource is unique in that it actually
  1826. is actually two resources: "ciaa.resource" and
  1827. "ciab.resource" corresponding to the two CIA
  1828. chips. You should use the LIBRARY VARPTR
  1829. statement to switch between using the two
  1830.  The BASIC calling of the CIA resource
  1831. functions differs from the C convention in that
  1832. the BASIC doesn´t include the resource base as
  1833. the first parameter.
  1834. There are only four interval timers available
  1835. and some of these will already be in use by the
  1836. system. The correct method of allocating a
  1837. timer is to add a timer interrupt using
  1838. AddICRVector. There are two CIA chips with
  1839. resource names of "ciaa.resource" and
  1840. "ciab.resource". Normally, you should open
  1841. ciab.resource and attempt to allocate timer B,
  1842. or timer A if it was already in use.
  1843.  
  1844.  
  1845. Disk1.3
  1846.  
  1847.  
  1848.  
  1849. Headers:     resources/disk.h
  1850. The Amiga supports up to 4 floppy disk units
  1851. which may be reserved through use of the Disk
  1852. resource. Routines exist to permanently
  1853. allocate or temporarily ´borrow´ a disk unit
  1854. although you should be aware that the Trackdisk
  1855. device normally allocates all units for its own
  1856. use.
  1857.  
  1858.  
  1859. FileSystem                                1.3
  1860.  
  1861.  
  1862. Headers:     devices/hardblocks.h,
  1863.              devices/bootblock.h,
  1864.              resources/filesysres.h
  1865. As has been mentioned, the AmigaDOS filing
  1866. system is built upon a number of ´file
  1867. handlers´ which communicate via a standard
  1868. packet based interface. The two most common
  1869. file handlers used by floppy and hard disks are
  1870. the Fast File System (FFS) and Old File System
  1871. (OFS).
  1872. FileSystem.bc contains a number of structures
  1873. and definitions which are used by the system to
  1874. determine and update the current configuration.
  1875. A list of available file systems may be
  1876. obtained by opening the FileSystem resource.
  1877.  
  1878.  
  1879. Misc1.3
  1880.  
  1881. Headers:     resources/misc.h
  1882. The Misc resource is used to arbitrate the use
  1883. of several important registers which control
  1884. the serial and parallel hardware. It should be
  1885. used when a program wishes to drive such
  1886. hardware directly rather than through the
  1887. standard device interface.
  1888. The correct way to allocate these bits is to
  1889. call MR_ALLOCMISCRESOURCE with the appropriate
  1890. constant and an identification name. If the
  1891. call returns NULL&, you now have exclusive
  1892. access until MR_FREEMISCRESOURCE is called.
  1893. Note that all versions of the Serial device up
  1894. to and including 1.3 contain a bug which
  1895. prevents them from correctly freeing the serial
  1896. bits when closed but still resident in memory.
  1897. The workaround for this is to Forbid, FindName
  1898. the serial device on the ExecBase device list,
  1899. RemDevice it and Permit.
  1900.  
  1901.  
  1902. Potgo                                     1.3
  1903.  
  1904.  
  1905. Headers:     resources/potgo.h
  1906. The Potgo resource allows control of the
  1907. hardware POTGO register connected to some I/O
  1908. pins on the joystick ports. The Gameport device
  1909. and Intuition provide other methods of reading
  1910. joysticks and mouse buttons. The functions
  1911. AllocPotBits, FreePotBits and WritePotgo should
  1912. be used to access these bits.
  1913.  
  1914.  
  1915. Gadgets
  1916.  
  1917.  
  1918. With Workbench 3.0, Commodore extended the
  1919. range of System gadgets available by using
  1920. BOOPSI gadgets. These BOOPSI gadgets are really
  1921. libraries that are normally stored in the
  1922. gadgets drawer inside the classes drawer of you
  1923. system disk. These are true libraries and we
  1924. have placed the corresponding .bh and .bc files
  1925. in a separate gadgets draw, so you can open
  1926. them with,
  1927.  
  1928.  
  1929. ´REM $INCLUDE Gadgets/ColorWheel.bh
  1930. LIBRARY OPEN "gadgets/colorwheel.gadget", 39
  1931.  
  1932.  
  1933.  
  1934.  
  1935. Gadgets/ColorWheel                        3.0
  1936.  
  1937.  
  1938. Headers:     gadgets/colorwheel.h
  1939. This BOOPSI class provides the ColorWheel
  1940. gadget, as used by the Palette preferences. It
  1941. also has a couple of sub-programs of its own
  1942. for converting RGB to HSB colours.
  1943.  
  1944.  
  1945. Gadgets/GradientSlider                    3.0
  1946.  
  1947.  
  1948. Headers:     gadgets/gradientslider.h
  1949. This BOOPSI class provides the Gradient Slider
  1950. gadget, as used in conjunction with the
  1951. ColorWheel gadget. Note that the GradientSlider
  1952. gadget doesn´t have any of its own functions,
  1953. but we provide a dummy .bmap file so that it
  1954. can still be opened.
  1955.  
  1956.  
  1957. Gadgets/Tapedeck                          3.1
  1958.  
  1959.  
  1960. Headers:     gadgets/tapedeck.h
  1961. With Workbench 3.1, Commodore introduced this
  1962. BOOPSI class to provide a consistent way of
  1963. controlling animation and sound play back. We
  1964. provide a dummy .bmap file so that this gadget
  1965. can be opened even though it doesn´t provide
  1966. any of its own functions.
  1967.  
  1968.  
  1969. Datatypes
  1970.  
  1971.  
  1972. Workbench 3 introduced a very powerful way of
  1973. extending the data that can be handled by
  1974. programs without the need for them to
  1975. ´understand´ the file formats involved. Like
  1976. gadgets, datatypes are built on to the BOOPSI
  1977. facilities of intuition and are stored in the
  1978. datatypes drawer of your classes drawer;
  1979. however you don´t need open the datatypes
  1980. themselves. You will need to use the
  1981. corresponding .bc or .bh file for their
  1982. constants and data structures.
  1983.  
  1984.  
  1985. Datatypes/AmigaguideClass                 3.0
  1986.  
  1987.  
  1988. Headers:     datatypes/amigaguideclass.h
  1989. The Amigaguide datatype can be used to ´drive´
  1990. Amigaguide. The datatypes/amigaguide.bc class
  1991. contains the IDs and constants for accessing
  1992. this.
  1993.  
  1994.  
  1995. Datatypes/AnimationClass                  3.1
  1996.  
  1997.  
  1998. Headers:     datatypes/animationclass.h
  1999. The AnimationClass datatype was introduced with
  2000. Workbench 3.1 for playing animations. The
  2001. datatypes/animationclass.bc file contains the
  2002. IFF ids and constants for using the animation
  2003. datatype.
  2004.  
  2005.  
  2006. Datatypes/DatatypesClass                  3.0
  2007.  
  2008.  
  2009. Headers:     datatypes/datatypesclass.h
  2010. The datatypes class is the base class on which
  2011. all other datatypes are built. This header
  2012. files also contains the structures and
  2013. constants that are used when writing datatypes.
  2014.  
  2015.  
  2016. Datatypes/PictureClass                    3.0
  2017.  
  2018.  
  2019. Headers:     datatypes/pictureclass.h
  2020. The PictureClass data type is used for
  2021. manipulating graphics images. The
  2022. datatypes/pictureclass.bc file contains the IFF
  2023. IDs and constants for using the picture
  2024. datatype.
  2025.  
  2026.  
  2027. Datatypes/SoundClass                      3.0
  2028.  
  2029.  
  2030. Headers:     datatypes/soundclass.h
  2031. The SoundClass is used for playing sounds. The
  2032. datatypes/soundclass.bc file contains the IFF
  2033. IDs and constants for using the sound datatype.
  2034.  
  2035.  
  2036. Datatypes/TextClass                       3.0
  2037.  
  2038.  
  2039. Headers:     datatypes/textclass.h
  2040. The TextClass is used for formatted and un-
  2041. formatted text. The datatypes/textclass.bc file
  2042. contains the IFF IDs, constants and structures
  2043. for using the text datatype.
  2044.  
  2045.  
  2046. BLib
  2047.  
  2048. The files in the Blib drawer fall into the
  2049. following classes:
  2050.  
  2051. ·  Routines  that  are  in  the  C   library
  2052.    Amiga.lib
  2053. ·  Sub-programs and functions that implement C
  2054.    macros from the Commodore include files,
  2055. ·  Extra  utility routines that we  hope  you
  2056.    will  find useful but have no C counterpart.
  2057.    These  we  won´t  document here  because  we
  2058.    hope   they   will  evolve  with  subsequent
  2059.    releases.
  2060.  
  2061.  
  2062. ExecSupport.bas
  2063.  
  2064.  
  2065. This corresponds to the amiga.lib functions
  2066. that deal with Exec features, such as
  2067. CreatePort, DeletePort, CreateExtIo,
  2068. DeleteExtIO and NewList. It also contains
  2069. CreateTask and DeleteTask, but these may only
  2070. be used if the task is written in C or
  2071. assembler.
  2072.  
  2073.  
  2074. HookEntryTask.bas
  2075.  
  2076.  
  2077. This contains a single routine
  2078. CreateHookEntryTask which is similar to
  2079. CreateTask but can be used to create a task
  2080. written in BASIC. The assembly language code
  2081. used by this is shown in TaskHookEntry.s. Note
  2082. that a garbage collection may be disastrous to
  2083. either the parent or created task.
  2084.  
  2085.  
  2086. BoopsiSupport.bas
  2087.  
  2088.  
  2089. Boopsi.bas contains implementations of the
  2090. macros in intuition/classes.h and the
  2091. CoerceMethodA&, DoMethodA& and DoSuperMethodA&
  2092. routines from Amiga.lib.
  2093.  
  2094.  
  2095. Gfxmacros.bas
  2096.  
  2097.  
  2098. This contains implementations of the macros in
  2099. graphics/gfxmacros.h. This includes the
  2100. SafeSetOutlinePen and SafeSetWriteMask sub-
  2101. programs which call the corresponding Workbench
  2102. 3.0 calls but fall back to a method which will
  2103. work under older versions of the operating
  2104. system.
  2105.  
  2106.  
  2107. Other
  2108.  
  2109. Some of the Amiga MaxonBASIC include files do
  2110. not fall under the category of libraries,
  2111. devices, resources, or BOOPSI classes, they are
  2112. merely definitions that you may find useful.
  2113. In order to use these units you simply include
  2114. them with rem $include at the start of your
  2115. program. No other preparation is required.
  2116.  
  2117.  
  2118. Hardware
  2119.  
  2120.  
  2121. Headers:     hardware/adkbits.h, blit.h,
  2122.              cia.h, custom.h, dmabits.h,
  2123.              intbits.h
  2124. The hardware.bc file contains a collection of
  2125. definitions necessary when directly reading and
  2126. writing the Amiga hardware registers. Whilst
  2127. the operating system is running you should
  2128. never do this unless you have gained exclusive
  2129. access to the hardware through the correct
  2130. system functions. Failure to do so can result
  2131. in unexpected crashes, loss of data, hard disks
  2132. etc. You have been warned!
  2133. You should be aware that some hardware
  2134. registers trigger actions upon read or write
  2135. accesses. Great care must be taken with these
  2136. registers to ensure the correct behaviour.
  2137.  
  2138.  
  2139.  
  2140. Prefs
  2141.  
  2142.  
  2143. Headers:     prefs/font.h, icontrol.h,
  2144.              input.h, locale.h, overscan.h,
  2145.              palette.h, pointer.h, prefhdr.h,
  2146.              printergfx.h, printerps.h,
  2147.              printertxt.h, screenmode.h,
  2148.              serial.h, sound.h, wbpattern.h
  2149. The prefs.bc file contains the structures and
  2150. constants used to define the IFF file formats
  2151. used by the various Preferences editors.
  2152. Normally you will only need these if writing an
  2153. alternative preferences editor.
  2154.  
  2155.  
  2156. Obsolete names
  2157.  
  2158. Over the lifetime of the Amiga´s operating
  2159. system Commodore have changed some of the names
  2160. that are used for constants. They recommend
  2161. that the old names are no longer used. As this
  2162. is the first release of MaxonBASIC to come with
  2163. constant files, we do not provide the old
  2164. names. Unfortunately though, you may see
  2165. programs in other languages that use the old
  2166. names. In particular the ROM Kernel Manuals
  2167. that were current at the time of writing still
  2168. use some of the old names. So you can convert
  2169. these to the modern names we have listed them
  2170. here.
  2171.  
  2172.  
  2173. IFFParse library
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179. Old Name             New Name
  2180. IFFSCC_INIT          IFFCMD_INIT
  2181. IFFSCC_CLEANUP       IFFCMD_CLEANUP
  2182. IFFSCC_READ          IFFCMD_READ
  2183. IFFSCC_WRITE         IFFCMD_WRITE
  2184. IFFSCC_SEEK          IFFCMD_SEEK
  2185.  
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191. ASL library
  2192.  
  2193. Originally the ASL library used a single tag
  2194. name for both the File and Font Requesters.
  2195. Where they are used for both, there are now
  2196. separate names starting with ASLFR for the file
  2197. requester and ASLFO for the font requester as
  2198. shown in the table below:
  2199.  
  2200. Old Name      New Name(s)   
  2201. rf_File       fr_File       
  2202. rf_Dir        fr_Drawer     
  2203. rf_LeftEdge   fr_LeftEdge   
  2204. rf_TopEdge    fr_TopEdge    
  2205. rf_Width      fr_Width      
  2206. rf_Height     fr_Height     
  2207. rf_NumArgs    fr_NumArgs    
  2208. rf_ArgList    fr_ArgList    
  2209. rf_UserData   fr_UserData   
  2210. rf_Pat        fr_Pattern    
  2211. ASL_Hail      ASLFR_TitleTe ASLFO_TitleTe
  2212.               xt            xt
  2213. ASL_Window    ASLFR_Window  ASLFO_Window
  2214. ASL_LeftEdge  ASLFR_InitalL ASLFO_InitalL
  2215.               eftEdge       eftEdge
  2216. ASL_TopEdge   ASLFR_Initial ASLFO_Initial
  2217.               TopEdge       TopEdge
  2218. ASL_Width     ASLFR_Initial ASLFO_Initial
  2219.               Width         Width
  2220. ASL_Height    ASLFR_Initial ASLFO_Initial
  2221.               Height        Height
  2222. ASL_HookFunc  ASLFR_HookFun ASLFO_HookFun
  2223.               c             c
  2224. ASL_File      ASL_InitialFi 
  2225.               le
  2226. ASL_Dir       ASL_InitialDr 
  2227.               awer
  2228. ASL_FontName  ASLFO_Initial 
  2229.               Name
  2230. ASL_FontHeigh ASLFO_Initial 
  2231. t             Size
  2232. ASL_FontStyle ASLFO_Initial 
  2233. s             Style
  2234. ASL_FontFlags ASLFO_Initial 
  2235.               Flags
  2236. ASL_FrontPen  ASLFO_InitialF 
  2237.               rontPen
  2238. ASL_BackPen   ASLFO_Initial 
  2239.               BackPen
  2240. ASL_MinHeight ASLFO_MinHeig 
  2241.               ht
  2242. ASL_MaxHeight ASLFO_MaxHeig 
  2243.               ht
  2244. ASL_OKText    ASLFR_Positiv ASLFO_Positiv
  2245.               eText         eText
  2246. ASL_CancelTex ASLFR_Negativ ASLFO_Negativ
  2247. t             eText         eText
  2248. ASL_FuncFlags ASLFR_Flags1  ASLFO_Flags
  2249. ASL_ModeList  ASLFO_ModeLis 
  2250.               t
  2251. ASL_ExtFlags1 ASLFR_Flags2  
  2252. ASL_Pattern   ASLFR_InitalP 
  2253.               attern
  2254. FILB_DOWILDFU FRB_FILTERFUN 
  2255. NC            C
  2256. FILB_DOMSGFUN FRB_INTUIFUNC 
  2257. C
  2258. FILB_SAVE     FRB_DOSAVEMOD 
  2259.               E
  2260. FILB_NEWIDCMP FRB_PRIVATEID 
  2261.               CMP
  2262. FILB_MULTISEL FRB_FOMULTISE 
  2263. ECT           LECT
  2264. FILB_PATGAD   FRB_DOPATTERN 
  2265.               S
  2266. FILF_DOWILDFU FRF_FILTERFUN 
  2267. NC            C
  2268. FILF_DOMSGFUN FRF_INTUIFUNC 
  2269. C
  2270. FILF_SAVE     FRF_DOSAVEMOD 
  2271.               E
  2272. FILF_NEWIDCMP FRF_PRIVATEID 
  2273.               CMP
  2274. FILF_MULTISEL FRF_DOMULTISE 
  2275. ECT           LECT
  2276. FILF_PATGAD   FRF_DOPATTERN 
  2277.               S
  2278. FIL1B_NOFILES FRB_DRAWERSON 
  2279.               LY
  2280. FIL1B_MATCHDI FRB_FILETERDR 
  2281. RS            AWERS
  2282. FIL1F_NOFILES FRF_DRAWERSON 
  2283.               LY
  2284. FIL1F_MATCHDI FRF_FILTERDRA 
  2285. RS            WERS
  2286. FONB_FRONTCOL FOB_DOFRONTPE 
  2287. OR            N
  2288. FONB_BACKCOLO FOB_DOBACKPEN 
  2289. R
  2290. FONB_STYLES   FOB_DOSTYLE   
  2291. FONB_DRAWMODE FOB_DODRAWMOD 
  2292.               E
  2293. FONB_FIXEDWID FOB_FIXEDWIDT 
  2294. TH            HONLY
  2295. FONB_NEWIDCMP FOB_PRIVATEID 
  2296.               CMP
  2297. FONB_DOMSGFUN FOB_INTUIFUNC 
  2298. C
  2299. FONB_DOWILDFU FOB_FILTERFUN 
  2300. NC            C
  2301. FONF_FRONTCOL FOF_DOFRONTPE 
  2302. OR            N
  2303. FONF_BACKCOLO FOF_DOBACKPEN 
  2304. R
  2305. FONF_STYLES   FOF_DOSTYLE   
  2306. FONF_DRAWMODE FOF_DODRAWMOD 
  2307.               E
  2308. FONF_FIXEDWID FOF_FIXEDWIDT 
  2309. TH            HONLY
  2310. FONF_NEWIDCMP FOF_PRIVATEID 
  2311.               CMP
  2312. FONF_DOMSGFUN FOF_INTUIFUNC 
  2313. C
  2314. FONF_DOWILDFU FOF_FILTERFUN 
  2315. NC            C
  2316.  
  2317.  
  2318.  
  2319.  
  2320.  
  2321.  
  2322. Intuition
  2323.  
  2324. The obsolete names in Intuition were obsolete
  2325. as of version 2.0 so only very old code should
  2326. use them. Sadly they still appear in some of
  2327. the ROM Kernel Manual Examples. Some of these
  2328. are merely different casings of the modern
  2329. usage which would make no difference in BASIC
  2330. in any case, so they haven´t been listed here.
  2331.  
  2332. Old Name             New Name
  2333. GADGHIGHBITS         GFLG_GADGHIGHBITS
  2334. GADGHCOMP            GFLG_GADGHCOMP
  2335. GADGHBOX             GFLG_GADGHBOX
  2336. GADGHIMAGE           GFLG_GADGHIMAGE
  2337. GADGHNONE            GFLG_GADGHNONE
  2338. GADGIMAGE            GFLG_GADGIMAGE
  2339. GRELBOTTOM           GFLG_RELBOTTOM
  2340. GRELRIGHT            GFLG_RELRIGHT
  2341. GRELWIDTH            GFLG_RELWIDTH
  2342. GRELHEIGHT           GFLG_RELHEIGHT
  2343. SELECTED             GFLG_SELECTED
  2344. GADGDISABLED         GFLG_DISABLED
  2345. LABELMASK            GFLG_LABELMASK
  2346. LABELITEXT           GFLG_LABELITEXT
  2347. LABELSTRING          GFLG_LABELSTRING
  2348. LABELIMAGE           GFLG_LABELIMAGE
  2349. RELVERIFY            GACT_RELVERIFY
  2350. GADGIMMEDIATE        GACT_IMMEDIATE
  2351. ENDGADGET            GACT_ENDGADGET
  2352. FOLLOWMOUSE          GACT_FOLLOWMOUSE
  2353. RIGHTBORDER          GACT_RIGHTBORDER
  2354. LEFTBORDER           GACT_LEFTBORDER
  2355. TOPBORDER            GACT_TOPBORDER
  2356. BOTTOMBORDER         GACT_BOTTOMBORDER
  2357. BORDERSNIFF          GACT_BORDERSNIFF
  2358. TOGGLESELECT         GACT_TOGGLESELECT
  2359. BOOLEXTEND           GACT_BOOLEXTEND
  2360. STRINGLEFT           GACT_STRINGLEFT
  2361. STRINGCENTER         GACT_STRINGCENTER
  2362. STRINGRIGHT          GACT_STRINGRIGHT
  2363. LONGINT              GACT_LONGINT
  2364. ALTKEYMAP            GACT_ALTKEYMAP
  2365. STRINGEXTEND         GACT_STRINGEXTEND
  2366. ACTIVEGADGET         GACT_ACTIVEGADGET
  2367. GADGETTYPE           GTYP_GADGETTYPE
  2368. SYSGADGET            GTYP_SYSGADGET
  2369. SCRGADGET            GTYP_SCRGADGET
  2370. GZZGADGET            GTYP_GZZGADGET
  2371. REQGADGET            GTYP_REQGADGET
  2372. SIZING               GTYP_SIZING
  2373. WDRAGGING            GTYP_WDRAGGING
  2374. SDRAGGING            GTYP_SDRAGGING
  2375. WUPFRONT             GTYP_WUPFRONT
  2376. SUPFRONT             GTYP_SUPFRONT
  2377. WDOWNBACK            GTYP_WDOWNBACK
  2378. SDOWNBACK            GTYP_SDOWNBACK
  2379. CLOSE                GTYP_CLOSE
  2380. BOOLGADGET           GTYP_BOOLGADGET
  2381. GADGET0002           GTYP_GADGET0002
  2382. PROPGADGET           GTYP_PROPGADGET
  2383. STRGADGET            GTYP_STRGADGET
  2384. CUSTOMGADGET         GTYP_CUSTOMGADGET
  2385. GTYPEMASK            GTYP_GTYPEMASK
  2386. SIZEVERIFY           IDCMP_SIZEVERIFY
  2387. NEWSIZE              IDCMP_NEWSIZE
  2388. REFRESHWINDOW        IDCMP_REFRESHWINDOW
  2389. MOUSEBUTTONS         IDCMP_MOUSEBUTTONS
  2390. MOUSEMOVE            IDCMP_MOUSEMOVE
  2391. GADGETDOWN           IDCMP_GADGETDOWN
  2392. GADGETUP             IDCMP_GADGETUP
  2393. REQSET               IDCMP_REQSET
  2394. MENUPICK             IDCMP_MENUPICK
  2395. CLOSEWINDOW          IDCMP_CLOSEWINDOW
  2396. RAWKEY               IDCMP_RAWKEY
  2397. REQVERIFY            IDCMP_REQVERIFY
  2398. REQCLEAR             IDCMP_REQCLEAR
  2399. MENUVERIFY           IDCMP_MENUVERIFY
  2400. NEWPREFS             IDCMP_NEWPREFS
  2401. DISKINSERTED         IDCMP_DISKINSERTED
  2402. DISKREMOVED          IDCMP_DISKREMOVED
  2403. WBENCHMESSAGE        IDCMP_WBENCHMESSAGE
  2404. ACTIVEWINDOW         IDCMP_ACTIVEWINDOW
  2405. INACTIVEWINDOW       IDCMP_INACTIVEWINDOW
  2406. DELTAMOVE            IDCMP_DELTAMOVE
  2407. VANILLAKEY           IDCMP_VANILLAKEY
  2408. INTUITICKS           IDCMP_INTUITICKS
  2409. IDCMPUPDATE          IDCMP_IDCMPUPDATE
  2410. MENUHELP             IDCMP_MENUHELP
  2411. CHANGEWINDOW         IDCMP_CHANGEWINDOW
  2412. LONELYMESSAGE        IDCMP_LONELYMESSAGE
  2413. WINDOWSIZING         WFLG_SIZEGADGET
  2414. WINDOWDRAG           WFLG_DRAGBAR
  2415. WINDOWDEPTH          WFLG_DEPTHGADGET
  2416. WINDOWCLOSE          WFLG_CLOSEGADGET
  2417. SIZEBRIGHT           WFLG_SIZEBRIGHT
  2418. SIZEBBOTTOM          WFLG_SIZEBBOTTOM
  2419. REFRESHBITS          WFLG_REFRESHBITS
  2420. SMART_REFRESH        WFLG_SMART_REFRESH
  2421. SIMPLE_REFRESH       WFLG_SIMPLE_REFRESH
  2422. SUPER_BITMAP         WFLG_SUPER_BITMAP
  2423. OTHER_REFRESH        WFLG_OTHER_REFRESH
  2424. BACKDROP             WFLG_BACKDROP
  2425. REPORTMOUSE          WFLG_REPORTMOUSE
  2426. GIMMEZEROZERO        WFLG_GIMMEZEROZERO
  2427. BORDERLESS           WFLG_BORDERLESS
  2428. ACTIVATE             WFLG_ACTIVATE
  2429. WINDOWACTIVE         WFLG_WINDOWACTIVE
  2430. INREQUEST            WFLG_INREQUEST
  2431. MENUSTATE            WFLG_MENUSTATE
  2432. RMBTRAP              WFLG_RMBTRAP
  2433. NOCAREREFRESH        WFLG_NOCAREREFRESH
  2434. WINDOWREFRESH        WFLG_WINDOWREFRESH
  2435. WBENCHWINDOW         WFLG_WBENCHWINDOW
  2436. WINDOWTICKED         WFLG_WINDOWTICKED
  2437. NW_EXTENDED          WFLG_NW_EXTENDED
  2438. VISITOR              WFLG_VISITOR
  2439. ZOOMED               WFLG_ZOOMED
  2440. HASZOOM              WFLG_HASZOOM
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447. C for BASIC programmers
  2448.  
  2449.  
  2450. Users programming the Amiga in any computer
  2451. language will discover that most of the
  2452. documentation, books and example programs which
  2453. exist are based around the C language. This is
  2454. partly because much of the machine´s operating
  2455. system was originally written in C and partly
  2456. because of the language´s current popularity
  2457. and the early availability of an Amiga C
  2458. compiler.
  2459. We have gone to a great deal of effort to
  2460. ensure that MaxonBASIC supports the Amiga in a
  2461. comprehensive manner; you aren´t tidied to just
  2462. the set of OS routines that we have built into
  2463. the BASIC. However, whether you are using BASIC
  2464. because it is the language which you are used
  2465. to or simply because you find it easier to use,
  2466. you will find a basic knowledge of C most
  2467. useful when trying to use the Amiga to its
  2468. full.
  2469. In the following section we will attempt to
  2470. furnish the reader with a basic working
  2471. knowledge of C, enough to understand the system
  2472. documentation and example programs. We would
  2473. like to stress that it is by no means intended
  2474. to teach C to BASIC programmers (why would we
  2475. want to do such a thing?), merely to provide
  2476. enough information to allow you to figure it
  2477. out for yourself.
  2478.  
  2479.  
  2480. Data structures
  2481.  
  2482.  
  2483.  
  2484. Basic types
  2485.  
  2486.  
  2487. Like  most  languages, C provides a  number  of
  2488. basic  types  which  represent  characters  and
  2489. numbers;  these may be employed for  variables,
  2490. constants,  structured types etc. You  can  use
  2491. this section for converting C types to BASIC.
  2492.  
  2493.  
  2494. Here  is  a  list of them and their  MaxonBASIC
  2495. equivalents:
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  C type         BASIC type    byte size
  2501.  char           see below     1
  2502.  int            % (integer)   2/4
  2503.  short          % (integer)   2
  2504.  long           &       (long 4
  2505.                 intger)
  2506.  unsigned char  see below     1
  2507.  unsigned int   see below     2/4
  2508.  unsigned       see below     2
  2509.  short
  2510.  unsigned long  no equivalent 4
  2511.  
  2512. The first thing to notice is that int can have
  2513. two sizes. This is because the type int is used
  2514. to specify the natural integer type. It may be
  2515. either a long or a short integer. In practice,
  2516. most Amiga programs are written for long
  2517. integers only but you cannot always assume that
  2518. this is the case.
  2519. BASIC´s types are always signed, but C also has
  2520. unsigned types like unsigned short; this has a
  2521. range of 0 to 65535 rather than -32768 to
  2522. 32767. If you need to perform arithmetic on
  2523. such a value then you should convert it to a
  2524. long integer first.
  2525. The char type in C stores a single byte;
  2526. there´s no exact equivalent of this in BASIC
  2527. but they can be stored as one element of a
  2528. string or in an integer variable ignoring the
  2529. top byte.
  2530. Another point of confusion is that both signed
  2531. and unsigned character types exist. Each of
  2532. these can be used for storing numbers or ASCII
  2533. characters. Although char is supposed to mean a
  2534. signed quantity, C compilers often give the
  2535. option of making it default to unsigned to
  2536. avoid bizarre problems when converting to other
  2537. types. Because of this confusion Commodore use
  2538. the following named types in their header
  2539. files:
  2540.  
  2541.  Commodore      Range      of byte size
  2542.  type           values
  2543.  BYTE           -128 to 127   1
  2544.  UBYTE          0 to 255      1
  2545.  WORD           -32768     to 2
  2546.                 32767
  2547.  UWORD          0 to 65535    2
  2548.  LONG           -2147483648   4
  2549.                 to 2147483647
  2550.  ULONG          0          to 4
  2551.                 4294967295
  2552.  BOOL           0-1           2
  2553.  
  2554. MaxonBASIC does not provide an unsigned long
  2555. type. Instead, you will have to make do with
  2556. longer integers. In practice, this does not
  2557. present too much of a problem as you may
  2558. specify hex numbers to allow use of the full 32
  2559. bits. Unsigned long is often used for bit
  2560. flags.
  2561.  
  2562.  
  2563. Constants
  2564.  
  2565.  
  2566. In  general, constant values look much the same
  2567. in both languages. One important distinction is
  2568. between  character and string  constants  which
  2569. use   different  delimiters.  These  and  other
  2570. constants are illustrated below.
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  type of constant      example
  2576.  decimal               123
  2577.  signed number         -287
  2578.  decimal long          96L
  2579.  hex                   0x1800
  2580.  octal                 0375
  2581.  character             ´a´
  2582.  string                ÒhelloÓ
  2583.  
  2584.  
  2585.  
  2586.  
  2587. In  addition  to this, there are  some  special
  2588. rules for character constants and strings.  The
  2589. backslash  character  (\)  is  used  to  denote
  2590. certain special control sequences.
  2591.  
  2592.  
  2593. You  should also be aware that strings  may  be
  2594. split  over  several lines  without  using  any
  2595. special concatenation character.
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  character sequence    represents
  2601.  \n                    end of line
  2602.  \r                    carriage return
  2603.  \l                    line feed
  2604.  \t                    tab
  2605.  \f                    form feed
  2606.  \0                    end of string
  2607.  \D                    decimal
  2608.                        character code
  2609.  \xDD                  hex     character
  2610.                        code
  2611.  
  2612. Although C has a const keyword to define
  2613. constants, most programs make use of the
  2614. #define directive of the preprocessor. The
  2615. preprocessor acts like an extra pass of the
  2616. compiler which goes around substituting defined
  2617. values or names and including other files.
  2618. Although #define is capable of great
  2619. sophistication, you will often see it used to
  2620. specify a numeric or string constant as in
  2621.  
  2622.  
  2623. #define VANILLAKEY 0x00200000
  2624.  
  2625.  
  2626. Commodore often use the convention of defining
  2627. a flag bit number and value with B and F, e.g.
  2628. MEMB_CLEAR refers to the bit number whilst
  2629. MEMF_CLEAR is the actual value you would use in
  2630. expressions.
  2631. Another method of defining a list of related
  2632. constants in C is an enumeration. For example
  2633.  
  2634.  
  2635.  enum Colours { Red, Green, Blue };
  2636.  
  2637.  
  2638. is equivalent to the BASIC
  2639.  
  2640.  
  2641. CONST Red%=0, Green%-1, Blue%=2
  2642.  
  2643.  
  2644. This type may be referred to as enum Colours
  2645. and is equivalent to int.
  2646.  
  2647.  
  2648. Pointers
  2649.  
  2650. Now we are getting to more interesting things.
  2651. C supports typed and untyped pointers. A
  2652. pointer of unknown type is known as a ´void´
  2653. pointer. Essentially a pointer contains the
  2654. address of the data that it points to, so you
  2655. can store a pointer with POKEL and read it with
  2656. PEEKL. pointers are always stored as long
  2657. integers (with the & sign on the end in BASIC).
  2658. Pointers are denoted by the * character. For
  2659. example,
  2660.  
  2661.  
  2662.  void *something;
  2663.  char *name;
  2664.  
  2665.  
  2666. In the second example, the star means that it
  2667. is a character pointer; these tend to be used
  2668. where you would use a string in BASIC but they
  2669. are stored differently, rather than storing the
  2670. length of the string and its address the string
  2671. ends when a 0 character (like CHR$(0)) is
  2672. found. That is why you use
  2673. SADD(strname$+CHR$(0)) to pass a string to the
  2674. operating and why we provide the PEEK$ function
  2675. to convert a C string to BASIC.
  2676. .A pointer to a pointer is declared as
  2677.  
  2678.  
  2679.  int **table;
  2680.  
  2681.  
  2682. The star character is also used as a
  2683. ´dereferencing´ operator, i.e. it gives you
  2684. what the pointer is actually pointing at. This
  2685. corresponds to PEEKB/PEEKW/PEEKL depending on
  2686. the size of the data. For example,
  2687.  
  2688.  
  2689.  initial = *name;
  2690.  
  2691.  
  2692. would put the character pointed to by name into
  2693. the variable initial. Thus the BASIC equivalent
  2694. would be
  2695.  
  2696.  
  2697.  initial=PEEKB(name)
  2698.  
  2699.  
  2700.  Note that the equals sign in C represents an
  2701. assignment rather than equivalence as it does
  2702. in Pascal.
  2703. The opposite of the * operator is & or ´address
  2704. of´. It gives you a pointer to the object
  2705. rather than its value and is used in much the
  2706. same way as BASIC´s VARPTR operator. The symbol
  2707. NULL is often used to specify a pointer that is
  2708. not pointing anywhere. Its actual value is
  2709. zero.
  2710.  
  2711. The  Amiga  header files from Commodore  define
  2712. several pointer types used by the system.
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  pointer type       purpose
  2718.  APTR               a void pointer
  2719.  BPTR               an    AmigaDOS   BCPL
  2720.                     pointer,      shifted
  2721.                     right by 2 bits
  2722.  CPTR               general       purpose
  2723.                     pointer
  2724.  STRPTR             pointer to a C  null-
  2725.                     terminated string
  2726.  
  2727. An unusual feature of C pointers is that adding
  2728. and subtracting numbers from them gives you a
  2729. pointer to the next or previous object, i.e.
  2730. adding one to a long pointer makes it point to
  2731. the next longword in much the same way as
  2732. adding one to a character pointer causes it to
  2733. point to the next character. If you are
  2734. converting such pointer arithmetic to BASIC you
  2735. will need to multiply the offsets by the size
  2736. of the data. This is how arrays are
  2737. implemented.
  2738.  
  2739.  
  2740. Arrays
  2741.  
  2742. Pointers and arrays in C are very closely
  2743. linked. Defining an array of 10 integers is a
  2744. matter of saying
  2745.  
  2746.  
  2747.  int array[10];
  2748.  
  2749.  
  2750. C always starts array numbering at zero but the
  2751. 10 doesn´t give the index of the last element
  2752. in the array, it gives the size of the array.
  2753. The expression array[9] would thus give the
  2754. last element in the array. Because of the way
  2755. arrays work, just saying array actually yields
  2756. a pointer to the start of the array and array+3
  2757. is a pointer to the fourth (numbering starts
  2758. from zero, remember) element of it! Note that C
  2759. uses square brackets rather than parentheses
  2760. for arrays.
  2761. It is possible to miss out the number of
  2762. elements in an array declaration. This can be
  2763. very dangerous as the compiler can no longer
  2764. warn you if you are writing to array elements
  2765. that don´t actually exist but it is a powerful
  2766. technique. It allows you to have arrays of no
  2767. fixed size, dynamic arrays, or to determine the
  2768. array dimensions at run time.
  2769. It is this laxness of type checking that
  2770. permits C programmers to miss out the []
  2771. characters on many occasions, use a simple
  2772. character pointer to point to a string and to
  2773. say ´pointer´ when they really mean ´array´.
  2774. Beware.
  2775. Multi-dimensional arrays are used in the
  2776. following way.
  2777.  
  2778.  
  2779.  short minutes[24][60];
  2780.  minutes[12][0] = minutes[23][59];
  2781.  
  2782.  
  2783. In other words, a 24-deep array where each
  2784. element is itself an array of 60 short
  2785. integers.
  2786.  
  2787. Pointers  and  arrays  are  one  of  C´s   most
  2788. powerful features. Although confusing at first,
  2789. they  are very useful. The following comparison
  2790. table may help to clear up a few points.
  2791.  
  2792.  
  2793.  
  2794.  
  2795.  C           BASIC            comment
  2796.  expression  equivalent
  2797.  *name       PEEKL(name&)     value
  2798.                               which  name
  2799.                               is
  2800.                               pointing
  2801.                               to
  2802.  grid[8][12  grid[8,12]       using     a
  2803.  ]                            multi-
  2804.                               dimensiona
  2805.                               l array
  2806.  *messages[  PEEKL(messages&  extracting
  2807.  2]          +2*4)            value   via
  2808.                               a  table of
  2809.                               pointers
  2810.  
  2811.  
  2812.  
  2813.  
  2814.  
  2815.  
  2816. Structures and Unions
  2817.  
  2818.  
  2819. Structures are very important part of C and are
  2820. something  that have to be converted  to  PEEKs
  2821. and  POKEs  in BASICs. A structure may  contain
  2822. simple  types, pointers, arrays and have  other
  2823. structures  embedded within it. To  demonstrate
  2824. this, here is the C declaration o a structure.
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830. struct student {
  2831.  struct Tutor *next;
  2832.  struct History
  2833. info;
  2834.  char name [32];
  2835.  short int age,
  2836. stay;
  2837. };
  2838.  
  2839. The  first  element is called  next  and  is  a
  2840. pointer to another structure called Tutor.  The
  2841. *  indicates  that it is a pointer.  This  will
  2842. take  up  4 bytes and so would be accessed  via
  2843. PEEKL and POKEL in BASIC.
  2844. The  next  field, info is actually a  structure
  2845. called  History embedded within this structure,
  2846. so  it  would  take  up as many  bytes  as  the
  2847. History structure, lets say that is 10 bytes.
  2848. Next  comes  an  array of 32 characters  called
  2849. name.  To  access the individual characters  we
  2850. would  use  PEEKB. Finally there are two  short
  2851. integers which as we have seen before will take
  2852. up  2  bytes and so could be accessed via PEEKW
  2853. and  POKEW. To use a similar definition to  the
  2854. MaxonBASIC Amiga include files for this  record
  2855. we would have:
  2856.  
  2857.  
  2858. ´ Fields of student
  2859. CONST next_offset%=0
  2860. CONST info_offset%=4
  2861. CONST name_offset%=14
  2862. CONST age_offset%=46
  2863. CONST stay_offset%=48
  2864. CONST student_sizeof%=50
  2865.  
  2866.  
  2867. So where
  2868.  
  2869.  st.name[i]=c
  2870. was used in C you would use
  2871.  
  2872.  POKEB st&+name_offset%+i,c
  2873. in BASIC and given
  2874.  
  2875.  i= stp->stay
  2876. you would have
  2877.  
  2878.  i=PEEKW(PEEKL(stp&)+stay_offset%)
  2879.  
  2880.  
  2881. Notice the difference here between the C .  and
  2882. ->  operators. The first accesses the structure
  2883. directly  whereas  the second  uses  a  pointer
  2884. deference (hence the PEEKL call in the BASIC).
  2885. Unions   follow  a  very  similar   syntax   to
  2886. structures  although  instead  of  each  member
  2887. being  placed sequentially in memory  they  are
  2888. overlaid on top of one another.
  2889. These  are used to represent data which may  be
  2890. accessed  in  a number of ways or  a  structure
  2891. which  may  contain different  sets  of  values
  2892. depending upon the circumstances.
  2893.  
  2894.  
  2895. Type checking
  2896.  
  2897. Because   C  has  the  concept  of  types,   on
  2898. occasions  where you need to convert  from  one
  2899. type  to  another  (often caused  by  functions
  2900. which   use  generic  pointers  and   types   -
  2901. allocating memory for example) C allows you  to
  2902. specify  a ´coercion´. Simply placing the  type
  2903. name  in  brackets  before the  value  performs
  2904. this.
  2905.  
  2906.  
  2907.  button = (struct Gadget *)
  2908.      AllocMem(sizeof(struct Gadget),
  2909.      MEMF_CLEAR | MEMF_PUBLIC);
  2910.  
  2911.  
  2912. Here, the void pointer returned by AllocMem  is
  2913. being  explicitly  typed to  a  gadget  pointer
  2914. before  assignment to button. By  contrast,  in
  2915. BASIC  you  must  make sure that  you  use  the
  2916. correct structure offsets yourself.
  2917.  
  2918.  
  2919. Programs
  2920.  
  2921.  
  2922.  
  2923. Functions
  2924.  
  2925. The  declaration of a function in C looks  very
  2926. much  like  a  modern BASIC  version.  Function
  2927. prototypes  are often used which  look  like  a
  2928. function  definition without any code following
  2929. it,  just like a DECLARE statement. Here is  an
  2930. example which demonstrates the layout  of  a  C
  2931. function:
  2932.  
  2933.  
  2934.  int main(int argc, char *argv[])
  2935.  {
  2936.      int counter;
  2937.      char digits[] = {1, 2, 3};
  2938.      return 5;
  2939.  }
  2940.  
  2941.  
  2942. The   function  return  type  is  given   first
  2943. followed  by  the name and bracketed  parameter
  2944. list.  The } or ´close curly bracket´ is the  C
  2945. equivalent  of  the  END  keyword  followed  by
  2946. whatever   you   are  ending.   The{   has   no
  2947. counterpart in BASIC but marks the beginning of
  2948. a set of statements.
  2949. You  will  see  a lot of these curly  brackets.
  2950. It´s  often easier just to ignore them all when
  2951. trying to understand a C program!
  2952. Any  local variables associated with a function
  2953. come immediately after the opening bracket  and
  2954. may  be  initialised after an equals sign.  The
  2955. previous  example  shows initialisation  of  an
  2956. array using more curly brackets, structures can
  2957. be   initialised  in  the  same  way.  This  is
  2958. initialisation  is  a bit like  having  a  DATA
  2959. statement for the values and then reading  them
  2960. into the variable.
  2961. Unlike   BASIC,  C  makes  little   distinction
  2962. between a sub-program and a function. In  C,  a
  2963. sub-program is known as a void function, i.e. a
  2964. function  with  no return value.  Similarly,  a
  2965. function which takes no parameters is  said  to
  2966. have a void parameter list. A simple example of
  2967. this is:
  2968.  
  2969.  
  2970.  void simple_function(void);
  2971.  
  2972.  
  2973. instead of
  2974.  
  2975.  
  2976. SUB simple_function
  2977.  
  2978.  
  2979. For  functions  which do return  a  value,  the
  2980. return  statement  may  be  used  to  exit  the
  2981. function  with the given number. This  is  like
  2982. assigning  a  value  to the function  name  and
  2983. doing  an EXIT FUNCTION. Any number of  returns
  2984. may  appear in a single function and no  return
  2985. value  is  necessary  for void  functions.  The
  2986. exit() function will leave the entire program.
  2987. There´s   no  main  program  in  C,   all   the
  2988. executable  code  is in functions.  Main  is  a
  2989. special  function which is run when the program
  2990. starts   up.  By  convention,  it   takes   two
  2991. parameters: argc, the argument count and  argv,
  2992. an  array  of string pointers for each  command
  2993. line argument passed to the program ending with
  2994. a  null  pointer.  These  can  be  obtained  in
  2995. MaxonBASIC via COMMAND$ function. Main  returns
  2996. an  int  which  is an error code  or  zero  for
  2997. success.
  2998. C  also allows functions with a variable number
  2999. of  arguments. This is denoted in  the  command
  3000. declaration by three dots. Suffice  it  to  say
  3001. that  subsequent  parameters are  accessed  via
  3002. pointers  and that no type checking is  carried
  3003. out.  The  most  used command of  this  ilk  is
  3004. printf()  detailed  towards  the  end  of  this
  3005. section.
  3006. If a C programmer decides that he or she is not
  3007. interested  in the return value of a  function,
  3008. they  can  call  it just as if it  was  a  void
  3009. function or procedure call. This is often  used
  3010. by  lazy  people who don´t check to see  if  an
  3011. error has occurred.
  3012.  
  3013.  
  3014. Macros
  3015.  
  3016. As  has  been  mentioned, C uses a preprocessor
  3017. which  can be used for simple text substitution
  3018. or defining constants. However, it does have  a
  3019. facility  for parameter substitution.  This  is
  3020. usually  used  for  short sequences  which  are
  3021. tedious to enter time and time again but  which
  3022. do   not  warrant  a  function  definition.  An
  3023. example of this might be
  3024.  
  3025.  
  3026. #define   RECSIZE(n)  (n  *  sizeof(Record)   +
  3027. sizeof(Header))
  3028.  
  3029.  
  3030. When   referred   to   via   RECSIZE(10),   the
  3031. preprocessor  will substitute  the  calculation
  3032. with  n equal to the value 10. In effect,  such
  3033. macros  are  mini functions and you  may  treat
  3034. them as such.
  3035. Advanced  macro programming is something  of  a
  3036. black  art with additional operators and  rules
  3037. applying.  However, in general if you implement
  3038. a macro as a BASIC function or procedure (as is
  3039. done  in  the MaxonBASIC Blib operating  system
  3040. files) you will get along fine.
  3041.  
  3042.  
  3043. Expressions
  3044.  
  3045.  
  3046. The  diversity  of operators  in  C  and  their
  3047. precedence is a source of great confusion, even
  3048. (or  especially, depending upon your  point  of
  3049. view) for C programmers. Let´s start off with a
  3050. list  of  all  the  operators and  their  BASIC
  3051. equivalents. The following table is  in  the  C
  3052. order  of precedence, i.e. the ones at the  top
  3053. are  done first. Don´t worry about the gaps  on
  3054. the BASIC side; we´ll come to that later.
  3055.  
  3056.  
  3057.  
  3058.  
  3059.   C operators         BASIC operators
  3060.   () [] -> .          () () PEEKL +
  3061.   ! ~ ++ -- + - * &   NOT INCR DECR PEEKL
  3062.                       VARPTR
  3063.   * / %               * / \ MOD
  3064.   + -                 + -
  3065.   << >>               << >>
  3066.   < <= > >=           < <= > >=
  3067.   == !=               = <>
  3068.   &                   AND
  3069.   ^                   XOR
  3070.   |                   OR
  3071.   &&                  
  3072.   ||                  
  3073.   ?:                  
  3074.   =  += -= *= /=  %=  = (not an operator)
  3075.   &= ^= |= <<= >>=
  3076.   ,                   
  3077.  
  3078. As you can see, many of these are simply a
  3079. matter of using different symbols. However,
  3080. there are some major differences. Taking it
  3081. from the top, -> means use the pointer before
  3082. this operator add on the offset for the field
  3083. afterwards and use this instead. So
  3084. The ++ and -- operators are a way of changing a
  3085. value by one. They correspond to the INCR and
  3086. DECR statements in BASIC but in C they are
  3087. operators and can be used in expressions. They
  3088. have the unusual property of returning a
  3089. different value depending upon the order. For
  3090. example, a++ gives the value of a before
  3091. incrementing it whereas ++a increments a and
  3092. then gives its value.
  3093. When combined with pointers, ++ and -- can be
  3094. used as follows:
  3095.  
  3096.  
  3097.  nextchar = *name_ptr++;
  3098.  sameagain = *--name_ptr;
  3099.  
  3100.  
  3101. These statements return a character via the
  3102. pointer, updating it to point to the next or
  3103. previous characters. This implements post-
  3104. increment and pre-decrement stacks.
  3105. Note that C has a single divide operator rather
  3106. than different ones for integers and floating
  3107. point.
  3108. The bitwise operators (&, |, ^) are identical
  3109. to AND, OR, XOR in BASIC but C also gives
  3110. logical operators. These guarantee a certain
  3111. sequence of execution which must be simulated
  3112. with nested IF statements in BASIC. Logical
  3113. ´and´ (&&) says that the second part will only
  3114. be executed if the first part is non-zero.
  3115. Logical ´or´ (||) doesn´t bother with the right
  3116. hand expression if it has already found that
  3117. the first part is false.
  3118. The logical operators can be used to great
  3119. effect (in traditionally cryptic style) if
  3120. function calls form part of the expressions. In
  3121. the following example, no data will be written
  3122. if ReadData returned FALSE.
  3123.  
  3124.  
  3125.  if (ReadData(source, buffer) != FALSE &&
  3126.      WriteData(dest, buffer) != FALSE)
  3127.          printf(ÒOK\nÓ);
  3128.  
  3129.  
  3130. The entry shown as ?: in the table is in fact
  3131. two parts of a single construct sometimes known
  3132. as the tertiary operator. In fact, it is a
  3133. short circuit form of the ´if´ statement which
  3134. takes three parts; a condition, a true part and
  3135. a false part. To clarify, the statement
  3136.  
  3137.  
  3138.  value = (inputch < 10) ? inputch : 10;
  3139. is equivalent to the BASIC
  3140.  
  3141.  if inputch < 10 then value = inputch else
  3142. value = 10
  3143.  
  3144.  
  3145. It may surprise you to see = (assignment)
  3146. listed as an operator (remember, this is
  3147. different from the BASIC = which tests for
  3148. equality like == does in C). Equals is an
  3149. operator because it returns a value, the value
  3150. assigned. This means you can string them
  3151. together as in a = b = c = 99. You can even
  3152. start putting them inside expressions and
  3153. conditional expressions, e.g.
  3154.  
  3155.  
  3156.  if ((mem = malloc(100)) == NULL) panic();
  3157.  
  3158.  
  3159. which calls malloc with the number 100, assigns
  3160. the return value to the variable mem and tests
  3161. if equal to NULL. If used sensibly, this
  3162. practice can condense several lines of code but
  3163. taken to extremes it makes many complex
  3164. expressions difficult to read at a glance.
  3165. There are a number of flavours of the
  3166. assignment operator which add a number to a
  3167. variable and suchlike. In C you may say value
  3168. += 10 rather than value = value + 10 or
  3169. inc(value,10).
  3170. Finally, the comma operator is used to separate
  3171. multiple expressions in much the same way as
  3172. the semicolon separates statements. In effect,
  3173. it returns the value of the rightmost
  3174. expression.
  3175.  
  3176.  
  3177. Control structures
  3178.  
  3179. Let´s start with the if statement in both
  3180. languages.
  3181.  
  3182.                      
  3183. if (a < b)           if a < b then
  3184.  do_something();      do_something
  3185. else                 else
  3186.                       do_something_else
  3187. do_something_else(); end if
  3188.  
  3189. Note the parentheses round the if expression,
  3190. the lack of then and the extra semicolons.
  3191. Don´t go typing this into your BASIC program
  3192. because it will get confused!
  3193. A more complex if statement would use more than
  3194. one statement in each case (shown by more curly
  3195. brackets) and possible a number of ifs strung
  3196. together, as in
  3197.  
  3198.  
  3199.  if (opened)
  3200.  {
  3201.      LoadPicture(file, buffer);
  3202.      Display(picture);
  3203.      count += 1;
  3204.  }
  3205.  else if (error != NOT_FOUND)
  3206.      ErrorRequester();
  3207.  else
  3208.  {
  3209.      printf(ÒWhat picture?\nÓ);
  3210.      return 20;
  3211.  }
  3212.  
  3213.  
  3214. Very similar looping structures exist in both
  3215. BASIC and C. While loops are almost identical
  3216. to WHILEÉWEND loops (without the curly
  3217. brackets, course.
  3218. do..while loops can be translated into DO..LOOP
  3219. while such as
  3220.  
  3221.                      
  3222. do                   
  3223. {                    DO
  3224.  c = getch(stream);   c = getch(stream)
  3225.  counter++;           INCR c
  3226. } while (c == ´ ´);  LOOP WHILE c = Ò Ò%
  3227.  
  3228. The break statement corresponds to EXIT LOOP
  3229. etc. where as the continue statement jumps to
  3230. the end of the loop and tests again.
  3231. The goto statement is just like in BASIC
  3232. although label names are always identifiers
  3233. rather than numbers.
  3234. One C control construct which you may find more
  3235. difficult to understand is the for loop. Whilst
  3236. the BASIC version is restricted to stepping
  3237. through a number range, the C version is much
  3238. more general. It can be used to step through
  3239. linked lists, maintain two counters etc. To
  3240. understand C for loops you must keep in mind
  3241. the general structure of the statement which
  3242. is:
  3243.  
  3244.  
  3245.  for (initialisation; condition; continuation)
  3246.      loop_body;
  3247.  
  3248.  
  3249. The initialisation part is always performed
  3250. before the loop begins, typically this is used
  3251. to set up start values. The loop body will be
  3252. executed while the condition expression is non-
  3253. zero. After the loop body, the continuation
  3254. statement is carried out. This usually updates
  3255. the loop counters. Any of these sections may be
  3256. missed out by simply specifying a semicolon.
  3257. This may become clear with the aid of a few
  3258. short examples. The C is first, followed by the
  3259. BASIC equivalent.
  3260.  
  3261.  
  3262. C:       for (n = 1; n < 10; n++)
  3263. BASIC:   FOR N = 1 TO 10
  3264.  
  3265.  
  3266.  
  3267. C:       for (a = 256; a; a -= 8)
  3268. BASIC:   FOR A = 256 TO 0 STEP -8
  3269.  
  3270.  
  3271.  
  3272. C:       for (node = &first; node; node =
  3273. node.next)
  3274. BASIC:     node& = VARPTR(first&)
  3275.      WHILE node&
  3276.          node& = PEEKL(node&+next_offset)
  3277.      WEND
  3278.  
  3279.  
  3280. For a more complex example (you will see much
  3281. worse):
  3282.  
  3283.  
  3284. for (ptr = &start, i = 0; i != 11; i += *ptr,
  3285. ptr++)
  3286.  
  3287.  
  3288. assuming ptr is pointing to 2 byte integers, is
  3289. equivalent to
  3290.  
  3291.  
  3292.  ptr& = VARPTR(start)
  3293.  i = 0
  3294.  
  3295.  WHILE i <> 11
  3296.      i = i + PEEKW(ptr&)
  3297.      ptr&=ptr&+2
  3298.  WEND
  3299.  
  3300.  
  3301. Enough of loops. One final control construct is
  3302. the select case statement. In C these look
  3303. like:
  3304.  
  3305.  
  3306.  select (action)
  3307.  {
  3308.      case 1:
  3309.          error = SaveFile(buffer);
  3310.          break;
  3311.  
  3312.      case 2:
  3313.          CloseBuffer(buffer);
  3314.          break;
  3315.  
  3316.  
  3317.      default:
  3318.          break;
  3319.  }
  3320.  
  3321.  
  3322. An important pitfall which you should watch out
  3323. for is that omitting the break statement at the
  3324. end of a case causes control flow to
  3325. unconditionally fall through to the next case.
  3326. This is often used in ´cunning´ ways by
  3327. advanced C programmers.
  3328.  
  3329.  
  3330. The standard C library
  3331.  
  3332. We will not attempt to describe the standard C
  3333. library although there are a few functions
  3334. singled out for special attention. The first of
  3335. these is printf().
  3336. Printf is to C what PRINT USING is to BASIC.
  3337. Most formatted output is performed via this
  3338. single command; there´s no equivalent to
  3339. ordinary PRINT. Rather than using # etc.,
  3340. printf() uses the percent character as a
  3341. special marker.
  3342. When printf() sees a percent sign, it then
  3343. picks up the next argument in the list and
  3344. applies formatting to it according to
  3345. additional characters following the percent
  3346. sign. It can be used to print strings and
  3347. numbers in various ways.
  3348.  
  3349.                            
  3350. printf('Hello\n');         Hello
  3351. printf('Number = %d\n',    Number = 10
  3352. 10);                       In hex: 2A...
  3353. printf('In hex: %X...',    Name: Bob,
  3354. 42};                       Age: 67
  3355. printf('Name: %s, Age:
  3356. %d',
  3357.    &person, age);
  3358.  
  3359. Some other functions of note are the ´str´
  3360. family. These include strcpy (copy a string,
  3361. note that the destination comes first), strncpy
  3362. (length limited copy), strcmp (compare two
  3363. strings, returns zero if the same), stricmp
  3364. (case insensitive comparison) and strcat (add a
  3365. string to the end of another). There are many
  3366. more.
  3367. This concludes our introduction to reading C
  3368. programmers; we hope that this section helps
  3369. the examples in the ROM Kernel manuals and
  3370. other books seem less frightening!
  3371.  
  3372.  
  3373.