home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / Information / CHACK_7.TXT < prev    next >
Encoding:
Text File  |  2019-04-13  |  161.1 KB  |  3,597 lines

  1.  
  2.                    ########
  3.              ##################
  4.          ######            ######
  5.       #####
  6.     #####  ####  ####      ##       #####   ####  ####  ####  ####  ####   #####
  7.   #####    ##    ##      ####     ##   ##   ##  ###     ##    ####  ##   ##   ##
  8.  #####    ########     ##  ##    ##        #####       ##    ## ## ##   ##
  9. #####    ##    ##    ########   ##   ##   ##  ###     ##    ##  ####   ##   ##
  10. #####  ####  ####  ####  ####   #####   ####  ####  ####  ####  ####   ######
  11. #####                                                                     ##
  12.  ######            ######           Issue #7
  13.    ##################               Feb. '94
  14.        ########
  15.  
  16. -----------------------------------------------------------------------------
  17. Editor's Notes:
  18. by Craig Taylor (duck@pembvax1.pembroke.edu)
  19.  
  20. This net-magazine is still alive after over two years suprising even
  21. myself. There should be more to come also!! And it's been late everytime
  22. it's been released. :-) I dunno - I'm trying not to make that a
  23. tradition but next time I don't think I'm going to set any firm dates so
  24. it can't possibly be late.
  25.  
  26. Lesee, first to address some questions and queries that have been going
  27. on over the network:
  28.  
  29.   - The C project that I mentioned a while back is now officially
  30.     defunct, dead, resting in peace... whatever you want to call it.
  31.     There may be other individuals working on their own version of an
  32.     ANSI C compiler but the group that was setup is no longer.
  33.     Basically, it was a problem of too many programmers, too few
  34.     managers (and we know programmers *grins* - They all want to do it
  35.     their way. Incidentilly - my way _was_ the best. ;-) )
  36.  
  37.   - The C65 exists but there are very few of them out there and
  38.     GrapeVine no longer sells them (out of stock I believe). It was only
  39.     made in small quantities for prototype work. There have been
  40.     numerous individuals reading comp.sys.cbm that see mention of the
  41.     C65 and assume that this creature Commodore released. Commodore sold
  42.     a warehouse and its contents to Grapevine and Grapevine stumbled
  43.     across them and sold 'em. They are functional but due to the low
  44.     number of them available I doubt that there will be any C65 targated
  45.     applications. (Someone prove me wrong, please?)
  46.  
  47.   - Geesh - That stupid article about the 1351 mouse that I kept
  48.     promising from issue 2 on I've officially declared dead. It may come
  49.     around later but for now it's dead. It's existed as a promise in one
  50.     form or another since issue 2 so this message officially kills it.
  51.  
  52.   - Also there was some confusion last time about my wording about not
  53.     writing any more articles and such (or rather, not as many as I had
  54.     been). Basically, yes - I'm still going to do C=Hacking - it's just
  55.     that because of time, frustration, school and jobs that I don't have
  56.     as much time to devote to researching and writing articles. That's
  57.     all that I meant to say - some people were concerned that C=Hacking
  58.     was no longer going to be released...
  59.  
  60. As always, here's the obligatory begging for authors on any type of
  61. software or hardware project that involves the Commodore computers.
  62. Please, Please if you or your user group has any information or material
  63. concerning the Commodore computers that you think may be appropriate for
  64. C=Hacking let me know via e-mail at duck@pembvax1.pembroke.edu. I'm
  65. looking for anything from hardware schematic, programming theory to
  66. actual programming techniques, programs.
  67.  
  68. The articles in this issue of C=Hacking I'm especially pleased with.
  69. There are two articles concerning the VIC chip and its operations that
  70. detail how certain "magical" techniques are performed. Also, Marko
  71. Makela has written a very detailed, interesting article on various
  72. memory techniques for the C-64. We also have a summary of the ACE
  73. programming / operating system and a referance guide on how to write
  74. applications for it. I've also included an InterNet guide that I've
  75. started writing to show individuals how to use the InterNet to get
  76. Commodore-64/128/Vic-20 related material. Included within that is a list
  77. of FTP sites containing numerous programs.
  78.  
  79. =============================================================================
  80.  
  81.   Please note that this issue and prior ones are available via anonymous
  82.   FTP from ccosun.caltech.edu (among others) under pub/rknop/hacking.mag
  83.   and via a mailserver which documentation can be obtained by sending
  84.   mail to "duck@pembvax1.pembroke.edu" with a subject line of
  85.   "mailserver" and the line "help" in the body of the mesage.
  86.  
  87. =============================================================================
  88.  
  89.   NOTICE: Permission is granted to re-distribute this "net-magazine", in
  90.   whole, freely for non-profit use. However, please contact individual
  91.   authors for permission to publish or re-distribute articles
  92.   seperately. A charge of no greater than 5 US dollars or equivlent may
  93.   be charged for library service / diskette costs for this
  94.   "net-magazine".
  95.  
  96. =============================================================================
  97. In This Issue:
  98.  
  99. Commodore Trivia Corner
  100.  
  101. This section of C=Hacking will contain numerous questions that will test
  102. your knowledge of trivia for the Commodore computers. Each issue they'll
  103. be answers to the previous issues questions and new questions. How much
  104. do you know?
  105.  
  106. InterNet Resources for the Commodore 64 / 128 V1.0
  107.  
  108. This article goes into detail about the available resources on the InterNet
  109. and is meant to introduce people to the wonderful, wacky world of the
  110. InterNet. It covers what the InterNet is, what capabilities it has and
  111. how to access those capabilities. In addition, it also includes Howard
  112. Herman's latest list of File Transfer sites for the Commodore computers.
  113.  
  114. Hiding kilobytes
  115.  
  116. Most Commodore 64 programs do not utilize even nearly all of the 64 kB
  117. random access memory space. By default, there are only 44 kilobytes of
  118. accessible RAM. This article describes how you can take the hiding 20
  119. kilobytes to use.
  120.  
  121. FLD - Scrolling the Screen
  122.  
  123. This article, using a technique described by Pasi Ojala in the last
  124. issue of C=Hacking, gives an example of a program using Flexible Line
  125. Distance technique.
  126.  
  127. Tech-tech - more resolution to vertical shift
  128.  
  129. At one time half of the demos had pictures waving horizontally on the width
  130. of the whole screen. This effect is named tech-tech and it is done using
  131. character graphics. How exactly and is the same possible with sprites ?
  132.  
  133. ACE-128/64 PROGRAMMER'S REFERENCE GUIDE (version 0.9, for Release #10)
  134.  
  135. This article explains the complete system interface for the ACE-128/64
  136. computing environment.  It is intended to be used by programmers for
  137. developing software to run on top of the ACE kernel.  ACE is a program
  138. for the Commodore 128 and Commodore 64 that provides a command shell
  139. environment that is similar to that of Unix.
  140.  
  141. ===============================================================================
  142. Commodore Trivia Corner
  143. by Jim Brain (brain@mail.msen.com)
  144.  
  145. Everyone who reads this article has had, or presently owns a Commodore
  146. computer of some kind.  I own more than one, which is not uncommon among
  147. Commodore enthusiasts.  Well, I bought my first Commodore computer in
  148. 1982, a brand new Vic-20 with some game cartridges.  I had wanted an
  149. Atari, but father knew best and he told the then 11 year old son that
  150. computers would shape my life more than any game machine.  Well, it is
  151. 11 years later and a Computer Engineering Degree earned, and I have
  152. spent many a night during that time playing on many models of Commdore
  153. equipment.  Now, I would like to share the knowledge I have with you in
  154. an interesting way.
  155.  
  156. As you now know a little about me, let us see how much you know about
  157. the machines and company that binds us all together.  The following is
  158. an installment of Commodore Trivia.  These questions have been gleaned
  159. from books, magazines, persoanl knowledge, work on the machines in
  160. questions, and other fellow commodore users happy to share interesting
  161. bits of semi- useless knowledge concerning the CBM systems.
  162.  
  163. This installment consists of two parts, the December 1993 edition
  164. complete with answers and the January 1994 edition without answers.
  165. Each new issue of Commodore Hacking Magazine will contain more
  166. questions, as well as answers to the previous issue's questions.  Each
  167. new edition is also posted every month on the 12th of the month on the
  168. Usenet newsgroup comp.sys.cbm. Winners will be announced on the
  169. newsgroup, and prizes may be awarded. For anyone wishing to submit
  170. answers from this article, please email your responses with question
  171. numbers preceeding each answer to :
  172.  
  173.   brain@msen.com
  174.   
  175. The answers to this edition will be posted on the 12th of February in
  176. comp.sys.cbm with the next edition of questions.  Have fun trying to
  177. answer the questions and feel free to send me a note with new questions.
  178. I can always use them.
  179.  
  180.   [Ed's Note: In addition, the mailserver that I have setup for
  181.   C=Hacking will make provisions to allow individuals to retrieve the
  182.   newest set of questions and last month's answers. Currently not
  183.   implemented, it should be available soon. Details in the next issue.
  184.  
  185.   Also due to C= Hacking being published fairly irregularly and not
  186.   every month the column here will contain answers to the last issue of
  187.   C=Hacking's questions and have new questions for the month that it's
  188.   released in.]
  189.  
  190. -----------------------------------------------------------------------------
  191. Here are the answers to the 10 questions in Commdore Triva Edition #1 for
  192. December 1993. [that were posted on comp.sys.cbm]
  193.  
  194. Q $000) Commodore started out into computing with the PET series of
  195.         computers.  I am not sure if the first ones had PET emblem, but
  196.         nonetheless, What does P E T stand for?
  197.  
  198. A $000) Personal Electronic Transactor
  199.         Since the acronym was made up before the expansion, the following
  200.         are also valid:
  201.   
  202.     Personal Electronic Translator
  203.     Peddle's Ego Trip
  204.                       
  205. Q $001) Commodore planned to manufacture a successor series to the 
  206.         successful Commodore 64 home computer.  Both were intended to
  207.         be Business machines.  We all know this resulted in the Commodore
  208.         Plus 4, but what were the machines originally called and what was
  209.         the difference between the two?
  210.  
  211. A $001) the 364, which had, among other things, a larger Plus 4 style case
  212.         that housed the regular keyboard plus a numeric keypad. the 264
  213.         turned into the Plus 4, with 64K of RAm.  We will never know much
  214.         more about the 364, since it got scrapped.
  215.   
  216. Q $002) How much free memory does a Vic-20 have (unexpanded)?
  217.      
  218. A $002) Oooh! There are many answers for this.
  219.       The VIC has 3583 bytes of RAM for BASIC
  220.       The VIC has 4096 bytes of RAM for ML
  221.       The VIC has 5120 bytes of RAM. 4K of RAM + 1K for Video.
  222.       
  223. Q $003) What early 80's Commodore software company had a Light Bulb
  224.         as a company logo?
  225.  
  226. A $003) Skyles Electric Works.
  227.      
  228.       The Vic-20 came out with a few peripherals I want the model
  229.       numbers for the :
  230.  
  231. Q $004) Disk Drive
  232.      
  233. A $004) VIC-1540 - Same as 1541, only faster serial spped.
  234.       
  235. Q $005) Cassette Player
  236.      
  237. A $005) VIC-1530
  238.      
  239. Q $006) Printer
  240.      
  241. A $006) VIC 1515, which, by a miscommunication, could only use 7.5" paper.
  242.         Evidently, someone thought 8.5" meant full width of paper w/ perfs!
  243.         This printer was quickly supplanted and overtaken by the 1525, which
  244.         should own this title in the first place!
  245.  
  246. Q $007) 16 K Ram Expansion.
  247.      
  248. A $007) VIC-1111
  249.            
  250. Q $008) Commodore Introduced 3 printers that used the same printer mechanism.
  251.         What are the model numbers.
  252.  
  253. A $008) MPS 802 (Square Dots, Serial), CBM 1526 (Round Dots, Serial), 
  254.         PET 4023 (Round Dots, IEEE-488).
  255.  
  256. Q $009) What is the diferences between the printers in #9
  257.      
  258. A $009) MPS 802 (Square Dots, Serial), CBM 1526 (Round Dots, Serial), 
  259.         PET 4023 (Round Dots, IEEE-488).
  260.       
  261. -----------------------------------------------------------------------------
  262. Here are the questions for Commodore Trivia Edition #2 for January 1994.        
  263.  
  264. Q $00A) What was the Code-Name of the Amiga while in Development?
  265.  
  266. Q $00B) What is Lord British's Real Name (The creator of the Ultima
  267.         Series)?
  268.   
  269. Q $00C) What is the POKE location and value that will fry an early model
  270.         PET?
  271.   
  272. Q $00D) On the Plus 4 and C-16, the VIC chip was replaced with the TED
  273.         chip.  What does TED stand for?
  274.   
  275. Q $00E) Commodore Produced a Letter Quality Printer in North America
  276.         (maybe elsewhere) for the Commdore Serial Line.  Name it.
  277.  
  278. Q $00F) What is the version of DOS in the 1541?
  279.  
  280. Q $010) What is the Version of BASIC in the Plus 4 and the C-16?
  281.  
  282. Q $011) What are the nicknames of the original three custom Amiga chips?
  283.  
  284. Q $012) Commodore produced a 64 in a PET case.  What is its name and model
  285.         number?
  286.   
  287. Q $013) Commodore sold a 1 megabyte floppy disk drive in a 1541 case.
  288.         Give the model number.
  289.   
  290. Q $014) What does GCR stand for?
  291.  
  292. Q $015) Commdore produced a drive to accompany the Plus 4 introduction.
  293.         Give the model number.
  294.   
  295. Q $016) What does SID stand for?
  296.  
  297. Q $017) What does the acronym KERNAL stand for?
  298.  
  299. Q $018) What version of DOS does the 1571 have?
  300.  
  301. Q $019) What other two Commdore Disk Drives share the same DOS version
  302.         number as the 1571?
  303.  
  304. Q $01A) How many files will the 1571 hold?
  305.       
  306. Q $10B) How many files will the 1541 hold?
  307.      
  308. Q $01C) What did Commodore make right before entering the computer market?
  309.      
  310. Q $01D) Commodore introduced an ill-fated 4 color plotter.  Give the model
  311.         number.
  312.   
  313. Q $01E) Some formats of CP/M write disks using the MFM format.  What does
  314.         MFM stand for?
  315.   
  316. Q $01F) On the Commodore 128, the user manual left two commands undocumented.
  317.         One works, and the other gives a not-implemented error.  Name both
  318.         commands and what each one does or does not do.
  319.  
  320. Some are easy, some are hard, try your hand at it.
  321.  
  322.     Jim Brain
  323.     brain@msen.com
  324. =============================================================================
  325. InterNet Resources for the Commodore 64 / 128 V1.0
  326. by Craig Taylor (duck@pembvax1.pembroke.edu)
  327.  
  328. [This article is placed into public domain by the author. Copying encouraged]
  329.  
  330. The Internet
  331.  
  332. Let me start this article with a quote by another author that everyone
  333. should heed when dealing with the InterNet:
  334.  
  335. "One warning is perhaps in order---this territory we are entering can
  336. become a fantastic time-sink.  Hours can slip by, people can come and
  337. go, and you'll be locked into Cyberspace.  Remember to do your work!
  338.  
  339. With that, I welcome you, the new user, to The Net."
  340.  
  341.                     brendan@cs.widener.edu
  342.                      - Author, Zen and the Art of the Internet
  343.  
  344. What is the InterNet?
  345.  
  346. What exactly is the InterNet? Imagine if you will, when you were a kid
  347. stringing wires between houses in your neighborhood so that you could
  348. talk with the kids that lived beside you. You could talk to those beside
  349. you but not the ones that lived across town. Now, suppose that you
  350. wanted to relay a message to a buddy across town. The only feasible way
  351. would be to send a message to the guy next door; then have him send it
  352. to the correct person. 
  353.  
  354. This is the basic system of the Internet. Computers connected to other
  355. computers that are connected to others. In the above paragrph
  356. communication was limited because of geography - how close individuals
  357. were. The InterNet system; while geography does play a factor, relies
  358. more on how the sites grew up and were established as to how messages
  359. will get passed back and forth. 
  360.  
  361. There are also other networks hooked up to the InterNet that provide
  362. auxilary services to their local group of computers. One large one is
  363. BITNET and UUCP.  Various bbs's also carry items from the InterNet such
  364. as the BitNet news. In addition, online services such as Genie,
  365. Compuserve, and others offer "gate-ways" or ways of getting access to
  366. the resources of the InterNet.
  367.  
  368. Access To The InterNet
  369.  
  370. Gaining Access to the InterNet There are several ways of gaining access
  371. to the InterNet. Your local college may be your best low-cost
  372. opportunity. Typically, if you are a student or faculty or staff, you
  373. may qualify to have an account that allows you to access all the
  374. InterNet facilities described above. If you don't fall into any of these
  375. categories your next best bet is an online service such as America
  376. Online, Genie, or Compuserve as these all support what is known as an
  377. InterNet gateway - allowing you t o access the InterNet through t hem.
  378. (At this time, I don't believe Prodigy has an InterNet gateway - if I'm
  379. wrong I'm sure I'll get tons of mail. Other online services also exist -
  380. I've only listed what I consider the "primary" ones.)
  381.  
  382. Once you've gotten access to the InterNet you may be asking "Okay, I
  383. know what the InterNet _can_ give me - how do I do it?"  Unfortunately,
  384. because the InterNet is run on differant computer systems this will vary
  385. from system to system. Your best bet would be to examine the
  386. documentation and help screens associated with the online service or
  387. college's facilities. Study them over until you can quote them backwards
  388. (well, not quite that much) - Study them over until you understand what
  389. they are saying. Also, having someone who is already experienced with
  390. the InterNet aid you in your explorations is a great help.
  391.  
  392. What is E-MAIL?
  393.  
  394. There are numerous individuals using the InterNet each day. Each is also
  395. able to write the other through the use of Electronic Mail or, as it's
  396. commonly called "e-mail". 
  397.  
  398. To send a message to me you'd use your mail program (the actual
  399. procedure varies depending on what type of machine you use) and tell it
  400. to send the message to my user name, "duck" at my site that I login at -
  401. (currently going to Pembroke State University) hence
  402. "pembvax1.pembroke.edu". So the full address with an "@" sign the
  403. computer needs to use to know how to seperate the computer name and the
  404. user name is "duck@pembvax1.pembroke.edu". 
  405.  
  406. It's easy to talk to somebody in Mexico, Germany, Australia with this
  407. method and it's quicker than the U.S. Postal system (which, on the
  408. InterNet you'll see referred to as Snail Mail (or s-mail) due to it's
  409. slow delivery time compared to e-mail). Projects, Questions, Answers,
  410. Ideas and general chit-chat on how the family is doing, etc can be
  411. relayed over the InterNet.
  412.  
  413. There are also numerous abbreviations and notations that are used in
  414. E-Mail. Some of them are:
  415.  
  416. ttyal8r     - Talk to you later
  417. rtfm      - Read the *uckin' manual
  418. imho      - In My Humble Opinion
  419. rotfl     - Rolls on the Floor Laughing
  420. lol       - Laughs Out Loud.
  421. l8r       - Later
  422. ;-)       - (winks)
  423. :-)       - (smile)
  424. :-(       - (frowns)
  425.  
  426. There are _many_ _many_ more - you can also find a huge list of the
  427. smiley faces (turn your head sideways and look at the ones in
  428. parenthesis above) on the InterNet.
  429.  
  430. You may also hear the phrase "my e-mail bounced". What this means is
  431. that your message, much like a bounced check, did not work right and it
  432. was returned to your account. Typically this happens because of
  433. incorrect addresses, or an incorrect user name.
  434.  
  435. Email Servers
  436.  
  437. Another large way of getting information is from individuals running
  438. what are E-Mail servers from their accounts or from specific accounts.
  439. From Email servers you may request certain files; catalogs of programs
  440. that are availble for request; send messages to be distributed to other
  441. individuals and automatically subscribe yourself to the mailing list for
  442. new items. 
  443.  
  444. The only Email Server specifically designed for the Commodore computers
  445. is one ran by the author. It major intent is that of distributing the
  446. Commodore Hacking magazine as well as programs that are in the
  447. magazine. To get help on how to use it send a message to the author in
  448. the following format:
  449.   To:   duck@pembvax1.pembroke.edu
  450.   Subj: MAILSERV
  451.   Body of message: HELP
  452.  
  453. This specific mailserver is ran twice a day so you should get your reply
  454. within approximately 12 hours. Please be sure to have a subject line of
  455. "MAILSERV".
  456.  
  457. If anyone knows of any other Email Servers existing for the Commodore
  458. computers please let the author know.
  459.  
  460. NewsGroups
  461.  
  462. One of the primary purposes of the InterNet is for educational research
  463. and discussion. For this purpose, there are currently over 2000
  464. newsgroups established dealing with a wide range of social, politicial,
  465. science, computer and educational topics. Some of these range to inane,
  466. whimsical, to practical and useful. 
  467.  
  468. Two of these for the Commodore 64/128 line of computers are:
  469.     comp.sys.cbm
  470.     comp.binaries.cbm
  471.  
  472. The names for the newsgroups start with a short abbreviation such as
  473. "comp" for computers, "sci" for science, "bio" for biology, etc...  The
  474. second group of letters stand for the type of newsgroup "sys for system,
  475. binaries for binaries etc..." while the third describes it better -
  476. "cbm" in this case for Commodore Business Machines. 
  477.  
  478. The newsgroup, Comp.Sys.Cbm supports discussion about anything under the
  479. sun involving the Commodore 8 bit line of computers (and lately, even
  480. talking about the old old ancient calculators that Commodore mae that
  481. might not have even been 8 bit). Comp.Binaries.Cbm allows programs to be
  482. "posted" or made available to everyone who wishes them. There are
  483. programs available that will let you take the "encrypted" text-only
  484. version of the program that you see on the screen and convert them into
  485. the correct binary p rogram.
  486.  
  487. Basically the rules for newsgroups are: 1) Enjoy yourself, 2) Don't
  488. harass others and 3) Try to stay on topic. Newsgroups are read by many
  489. many people - typically you'll get a response to an inquiry within only
  490. an hour or so - sometimes even sooner. But because they're read by so
  491. many people chatter or "babble" as it's known, is also discouraged.
  492. Don't hesitate to post any questions, concerns or comments but make sure
  493. in each message that you post that you have a reason to post.
  494.  
  495. So What's Out There?
  496.  
  497. So why should you be interested in the Internet? Imagine, if you will,
  498. being able to ask questions to numerous individuals, download the latest
  499. in shareware and public-domain software, know the "rumours" and topics
  500. before they exist all for free? (Or at least, only for what your
  501. "hookup" method charges - see Gaining Access to the InterNet latter).
  502. That's what's out on the Internet. Any question you have - there is sure
  503. to be an answer for - any software you're looking for you stand an
  504. extremely good chance of finding something along the lines of your
  505. needs.
  506.  
  507. The major benefit of the Internet as I see it consists of the continued
  508. support for the Commodore computers. Because all these differant means
  509. of obtaining information are not sponsored by any one specific company
  510. or individual the Commodore 8-bit line of computers are guranteed
  511. continued support over the Internet. In addition, because the Internet
  512. strongly frowns upon Commercial advertising you won't find numerous ads
  513. or any other material urging you to "buy this, buy that" like you will
  514. on some other serv ices.
  515.  
  516. FTP Sites
  517.  
  518. FTP stands for File Transfer Protocols and is a method of obtaining
  519. programs that are stored on another system's computers. There are
  520. numerous FTP sites out there in InterNet land - one of the best
  521. currently available for the Commodore computers is that of R.Knop's site
  522. at ccosun.caltech.edu. 
  523.  
  524. [ The following is a list of FTP sites for the Commodore 64 and 128
  525. computes and is currenty maintained by Howard Herman
  526. (h.herman@GEnie.geis.com) and is used with his permission. He usually
  527. posts an updated list to comp.sys.cbm newsgroup every month or so.]
  528. -----------------------------------------------------------------------------
  529. This is the list of FTP sites containing software and programs
  530. specific to the Commodore 64 and 128 computers.
  531.  
  532. I will try to keep this list as current and accurate as possible, so
  533. that it can be a useful resource for users of the newsgroup.
  534.  
  535. PLEASE cooperate and send E-mail to me with any corrections and
  536. updates.  If a site has closed or no longer carries CBM software, let
  537. me know and it will be deleted.  If you uncover a site not listed,
  538. tell me so that it can be added.
  539. -----
  540.  
  541. To use this list on a UNIX system, just type 'ftp <sitename>', where
  542. <sitename> is any of the sites listed below.  Use 'anonymous' as
  543. your login, and your E-mail address for the password.  You can change
  544. and list directories with 'cd' and 'dir', respectively, and download
  545. files to your system using 'get'.  Be sure to specify either 'binary'
  546. if you are getting a program, or 'ascii' for a text file before you
  547. begin the download.
  548. -----
  549.  
  550. In addition to the sites listed below there are hundreds of other
  551. FTP sites on INet with interesting files covering every topic
  552. imaginable.  Take some time to seek out and explore these too.
  553.  
  554. Enjoy!
  555. -----
  556.  
  557. Host sol.cs.ruu.nl   (131.211.80.17)
  558. Last updated 00:39  4 Sep 1993
  559.     Location: /pub/MIDI/PROGRAMS
  560.       DIRECTORY rwxr-xr-x      1024  Aug 26 09:58   C64
  561.     Location: /pub/MIDI/DOC
  562.       FILE      rw-r--r--     40183  Jan 19  1993   C64midi-interface.txt
  563.  
  564. Host uceng.uc.edu   (129.137.33.1)
  565. Last updated 04:38  6 Sep 1993
  566.     Location: /pub/wuarchive/systems/cpm/c128
  567.       FILE      rw-r--r--     24576  Nov  6  1986   c128-mex.com
  568.     Location: /pub/wuarchive/systems/cpm/c64
  569.       FILE      rw-r--r--      1615  Mar 14  1984   c64-cpm.msg
  570.       FILE      rw-r--r--      1536  Feb  9  1985   c64modem.com
  571.       FILE      rw-r--r--      4199  Feb 10  1984   c64modem.doc
  572.       FILE      rw-r--r--     19200  Feb  9  1985   md730c64.com
  573.       FILE      rw-r--r--      2192  Oct  1  1984   md730c64.doc
  574.     Location: /pub/wuarchive/doc/misc/if-archive/infocom/tools
  575.       FILE      r--r--r--      5798  Aug  5 14:42   c64todat.tar.Z
  576.  
  577. Host aix370.rrz.uni-koeln.de   (134.95.80.1)
  578.     Location: /.disk2/usenet/comp.archives/auto/comp.sys.cbm
  579.       DIRECTORY rwxrwxr-x       384  comp.sys.cbm
  580.  
  581. Host ftp.csv.warwick.ac.uk     (137.205.192.5)
  582. Last updated 00:00 18 Jan 1994
  583.     Location: /pub/c64
  584.       FILE      rw-r--r--       909 Jan  8 19:52 C64progs.doc
  585.       FILE      rw-r--r--     19558 Jan  8 19:49 backgamm.sfx
  586.       FILE      rw-r--r--     21384 Jan  8 19:49 chequebo.sfx
  587.       FILE      rw-r--r--     11449 Jan  8 19:49 countdow.sfx
  588.       FILE      rw-r--r--     18136 Jan  8 19:49 draughts.sfx
  589.       FILE      rw-r--r--      5011 Jan  8 19:49 loader.sfx
  590.       FILE      rw-r--r--     17423 Jan  8 19:49 whitewas.sfx
  591. Descriptions:
  592. ============
  593. backgamm - Backgammon board game
  594. chequebo - Cheque Book Organiser, written in basic with UK pound sign as
  595.            currency, but could be changed to suit another.
  596. countdow - LOAD"count example",8,1 and watch the countdown during loading.
  597. draughts - Draughts board game.
  598. loader   - Press RESTORE key and MENU on disk will be automatically re-loaded.
  599. whitewas - Colour squares board game.
  600.     Location: /tmp/c64
  601.      >Temporary files stored here.  If /tmp directory not found, try
  602.      >again at another time.  /tmp directory not always available.
  603.  
  604. Host clover.csv.warwick.ac.uk   (137.205.192.6)
  605. Last updated 13:29 27 Sep 1993
  606.     Location: /pub/c64
  607.       FILE      rw-r--r--       812  c64progs.doc
  608.       FILE      rw-r--r--     73696  c64progs.sfx
  609.  
  610. Host nexus.yorku.ca   (130.63.9.66)
  611. Last updated 00:00 21 Dec 1993
  612.     Location: /pub/Internet-info
  613.       FILE      rw-r--r--      6308  commodore.ftp
  614.      >An older version of this listing.
  615.  
  616. Host rigel.acs.oakland.edu   (141.210.10.117)
  617. Last updated 01:42  3 Sep 1993
  618.     Location: /pub2/cpm
  619.       DIRECTORY rwxr-xr-x      1536  Jun  4  1992   c128
  620.       DIRECTORY rwxr-xr-x       512  c64
  621.     Location: /pub2/cpm/c64
  622.       FILE      rw-r--r--      1615  Mar 14  1984   c64-cpm.msg
  623.       FILE      rw-r--r--      1536  Feb  9  1985   c64modem.com
  624.       FILE      rw-r--r--      4199  Feb 10  1984   c64modem.doc
  625.       FILE      rw-r--r--     19200  Feb  9  1985   md730c64.com
  626.       FILE      rw-r--r--      2192  Oct  2  1984   md730c64.doc
  627.  
  628. Host oak.oakland.edu
  629. Last updated 00:00 18 Dec 1993
  630.     Location: /pub2/cpm
  631.      >For CP/M software, most all of which will run on the C128.
  632.  
  633. Host src.doc.ic.ac.uk   (146.169.2.1)
  634.     Location: /usenet/comp.archives/auto
  635.       DIRECTORY rwxr-xr-x       512  comp.sys.cbm
  636.     Location: /usenet/comp.archives
  637.       DIRECTORY rwxr-xr-x       512  commodore-64-128
  638.       DIRECTORY rwxr-xr-x       512  May  3  1991   c64
  639.     Location: /media/visual/collections/funet-pics/jpeg/games
  640.       DIRECTORY rwxr-xr-x       512  Mar 20 05:48   c64
  641.     Location: /media/visual/collections/funet-pics/jpeg/comp/games
  642.       DIRECTORY rwxr-xr-x       512  May  6 03:55   c64
  643.  
  644. Host tupac-amaru.informatik.rwth-aachen.de   (137.226.112.31)
  645. Last updated 04:59  7 Oct 1992
  646.     Location: /pub/rz.archiv/simtel/cpm
  647.       DIRECTORY rwxr-xr-x       512  c64
  648.       DIRECTORY rwxr-xr-x       512  Sep 21 20:56   c128
  649.  
  650. Host wuarchive.wustl.edu   (128.252.135.4)
  651. Last updated 02:40 23 May 1993
  652.     Location: /systems/amiga/incoming/misc
  653.       FILE      rw-rw-r--     21815  Jan 23 14:26   C64View.lha
  654.       FILE      rw-rw-r--       120  Jan 23 14:26   C64View.readme
  655.     Location: /mirrors/cpm
  656.       DIRECTORY rwxr-xr-x       512  c64
  657.       DIRECTORY rwxr-xr-x      1536  Nov 22  1992   c128
  658.  
  659. Host watsun.cc.columbia.edu   (128.59.39.2)
  660. Last updated 02:07  8 Sep 1993
  661.     Location: /kermit2/old
  662.       DIRECTORY rwxrwxr-x      1024  Jul 12 18:30   c64
  663.     Location: /kermit/bin
  664.  
  665. Host cs.columbia.edu   (128.59.1.2)
  666. Last updated 01:29 12 Sep 1993
  667.     Location: /archives/mirror1/kermit
  668.       FILE      rw-rw-r--     15016  Aug 24  1988   c644th.prg.gz
  669.       FILE      rw-rw-r--       733  Sep 29  1992   c64help.txt.gz
  670.       FILE      rw-rw-r--      6095  Sep 29  1992   c64ker1660.sda.gz
  671.       FILE      rw-rw-r--      5904  Sep 29  1992   c64kerfast.sda.gz
  672.       FILE      rw-rw-r--     26484  Sep 29  1992   c64kerv22a.sda.gz
  673.       FILE      rw-rw-r--     42552  Sep 29  1992   c64kerv22b.sda.gz
  674.       FILE      rw-rw-r--     31982  Sep 29  1992   c64slkv22s.sda.gz
  675.  
  676. Host plaza.aarnet.edu.au   (139.130.4.6)
  677. Last updated 00:00 28 Dec 1993
  678.     Location: /pub/kermit/c
  679.       FILE      r--r--r--      3073  Aug 16  1988   c64boot.bas
  680.       FILE      r--r--r--      1547  Aug 16  1988   c64boot.c
  681.       FILE      r--r--r--      1151  Aug 16  1988   c64boot.clu
  682.       FILE      r--r--r--      3002  Aug 16  1988   c64boot.for
  683.       FILE      r--r--r--      3315  Aug 16  1988   c64boot.sim
  684.      >There are more Kermit files which are not listed.  Be sure to
  685.      >get the complete set of C64/128 Kermit files.
  686.  
  687. Host flubber.cs.umd.edu   (128.8.128.99)
  688. Last updated 00:00 03 Jan 1994
  689.     Location: /rec/newballistic
  690.       FILE      rw-r--r--      8576  Mar 23 21:21   balistic.c64
  691. --------------------------------
  692.  
  693. Host f.ms.uky.edu (128.163.128.6)
  694. Last updated 00:00 28 Dec 1993
  695.     Location: /archive/c64.zip
  696.  
  697. Host ftp.funet.fi (128.214.6.100)
  698. Last updated 06:11 22 Mar 1993
  699.     Location: /pub/pics/jpeg/games
  700.       DIRECTORY rwxrwxr-x       512  Mar 20 02:07   c64
  701.     Location: /pub/misc
  702.       DIRECTORY rwxrwxr-x       512  Mar 13 23:30   c64
  703.     Location: /pub/kermit
  704.       DIRECTORY rwxrwxr-x      1024  Jan 13  1992   c64
  705.     Location: /pub/amiga/audio/misc/sid-tunes
  706.       FILE      rw-rw-r--    671490  Jun 18  1992   C64MusicShow-1.lha
  707.       FILE      rw-rw-r--    316521  Jun 18  1992   C64MusicShow-2.lha
  708.               /pub/cbm
  709.  
  710. Host nic.switch.ch   (130.59.1.40)
  711. Last updated 00:39 31 Aug 1993
  712.     Location: /mirror/kermit/bin
  713.  
  714. Host gmdzi.gmd.de   (129.26.8.90)
  715. Last updated 01:08  1 Aug 1993
  716.     Location: /if-archive/infocom/tools
  717.       FILE      rw-rw-r--      5668  Apr 27 15:00   c64.to.dat
  718.  
  719. Host micros.hensa.ac.uk   (148.88.8.84)
  720.     Location /kermit
  721.       DIRECTORY rwxr-x---      1024  Nov 11 09:20   c64
  722.  
  723. Host wilbur.stanford.edu   (36.14.0.36)
  724.     Location /pub/emulators
  725.       DIRECTORY rwxr-xr-x       512  Jun 30 00:57   c64
  726.  
  727. Host syrinx.umd.edu (128.8.2.114)
  728. Last updated 00:00 28 Dec 1993
  729.     Location: /rush/c64-sounds
  730.  
  731. Host tolsun.oulu.fi (130.231.96.16)
  732. Last updated 01:53  6 Sep 1993
  733.     Location: /pub
  734.       DIRECTORY rwxr-xr-x      1024  Jul 15  1990   c64
  735.     Location: /incoming
  736.       DIRECTORY ---------      1024  Jun 20  1992   c64
  737.         /pub/amiga/4/c64trans.zoo
  738.         /pub/c64
  739.      >Uploading to /pub/c64 is disabled because of lack of disk space.
  740.      >However, for downloading it is still fully accessible.
  741.      >Currently there is no administration for /pub/c64.
  742.      >/pub/amiga is active, though.
  743.  
  744. Host ccosun.caltech.edu (131.215.139.2)
  745. Last updated 00:00 31 JAN 1994
  746.     Location: /pub/rknop
  747.     Location: /pub/rknop/misc
  748.      > 64/128 programs can be found within directories according to
  749.      > function.  When searching, be sure to check related directories.
  750.  
  751. Host ucsd.edu (128.54.16.1)
  752. Last updated 04:46  6 Sep 1993
  753.     Location: /midi/software
  754.       DIRECTORY rwxr-xr-x       512  Jan 27  1992   c64
  755.  
  756. Host cs.dal.ca   (129.173.4.5)
  757. Last updated 01:36 12 Sep 1993
  758.     Location: /comp.archives
  759.       DIRECTORY rwxrwxr-x      3584  Apr  7 04:05   c64
  760.                pub/comp.archives/comp.sys.cbm
  761.  
  762. Host ccnga.uwaterloo.ca
  763. Last updated 00:00 01 Jan 1994
  764.     Location: /pub/cbm/vbm110.uua
  765.      > For VBM Bitmap Viewer version 1.10
  766.  
  767. Host bert.psyc.upei.ca
  768. Last updated 00:00 31 Jan 1994
  769.     Location: /pub
  770.      > All the releases of the major demo parties of '93
  771.  
  772. --------------------------------
  773. Send all info regarding changes/additions/corrections [to the FTP list] to:
  774.  
  775. 72560.3467@CompuServe.COM   or:     h.herman1@GEnie.geis.COM
  776. =============================================================================
  777. Hiding kilobytes
  778. by Marko M"akel"a <Marko.Makela@Helsinki.FI>
  779.  
  780. Most Commodore 64 programs do not utilize even nearly all of the 64 kB
  781. random access memory space. By default, there are only 44 kilobytes of
  782. accessible RAM. This article describes how you can take the hiding 20
  783. kilobytes to use.
  784.  
  785.  
  786. _Memory management_
  787.  
  788.   The Commodore 64 has access to more memory than its processor can
  789. directly handle. This is possible by banking the memory. There are
  790. five user configurable inputs that affect the banking. Three of them
  791. can be controlled by program, and the rest two serve as control lines
  792. on the memory expansion port.
  793.  
  794.   The 6510 MPU has an integrated I/O port with six I/O lines. This
  795. port is accessed through the memory locations 0 and 1. The location 0
  796. is the Data Direction Register for the Peripheral data Register, which
  797. is mapped to the other location. When a bit in the DDR is set, the
  798. corresponding PR bit controls the state of a corresponding Peripheral
  799. line as an output. When it is clear, the state of the Peripheral line
  800. is reflected by the Peripheral register. The Peripheral lines are
  801. numbered from 0 to 5, and they are mapped to the DDR and PR bits 0 - 5,
  802. respectively. The 8502 processor, which is used in the Commodore 128,
  803. has seven Peripheral lines in its I/O port. The seventh line is connected
  804. to the Caps lock or ASC/CC key.
  805.  
  806.   The I/O lines have the following functions:
  807.  
  808.      Direction  Line  Function
  809.      ---------  ----  --------
  810.         out      P5   Cassette motor control. (0 = motor spins)
  811.         in       P4   Cassette sense. (0 = PLAY button depressed)
  812.         out      P3   Cassette write data.
  813.         out      P2   CHAREN
  814.         out      P1   HIRAM
  815.         out      P0   LORAM
  816.  
  817.   The default value of the DDR register is $2F, so all lines except
  818. Cassette sense are outputs. The default PR value is $37 (Datassette
  819. motor stopped, and all three memory management lines high).
  820.  
  821.   Like most chips in the Commodore 64, the 6510 MPU uses the NMOS
  822. (N-channel metal oxide semiconductor) technology. The NMOS switches
  823. produce strong logical '0' levels, but weak '1' levels. The opposite
  824. is the PMOS (P-channel metal oxide semiconductor) technology, which
  825. cannot pull strong signals low, but is able to drive them high. The CMOS
  826. technology (complementary metal oxide semiconductor), which combines
  827. these two technologies, is able to drive both logical levels.
  828.  
  829.   Because most integrated circuits in the C64 use the NMOS technology,
  830. all hardware lines that are not outputs are driven to +5 volts with a
  831. weak current. This is usually accomplished by pull-up resistors, large
  832. resistances between the hardware lines and the +5 volt power supply
  833. line. The resistors can be inside a chip or on the printed circuit
  834. board. This allows any NMOS or CMOS chip to drive the line to the
  835. desired state (low or high voltage level).
  836.  
  837.   The difference between an input and an output is that an output uses
  838. more current to drive the signal to the desired level. An input and an
  839. output outputting logical '1' are equivalent for any other inputting
  840. chip. But if a chip is trying to drive a signal to ground level, it
  841. needs more current to sink an output than an input. You can even use
  842. outputs as inputs, i.e. read them in your program.
  843.  
  844.         You can use this feature to distinquish between the left
  845.       shift and the shift lock keys, although they are connected
  846.       to same hardware lines. The shift lock key has smaller
  847.       resistance than the left shift. If you make both CIA 1
  848.       ports to outputs (write $FF to $DC03 and $DC01) prior
  849.       reading the left shift key, only shift lock can change the
  850.       values you read from CIA 1 port B ($DC01).)
  851.  
  852.   So, if you turn any memory management line to input, the external
  853. pull-up resistors will make it look like it is outputting logical
  854. '1'. This is actually why the computer always switches the ROMs in
  855. upon startup: Pulling the -RESET line low resets all Peripheral lines
  856. to inputs, thus driving all three processor-driven memory management
  857. lines high.
  858.  
  859.   The two remaining memory management lines are -EXROM and -GAME on
  860. the cartridge port. Each line has a pull-up resistor, so the lines are
  861. '1' by default. (In the Commodore 128, you can set the state of these
  862. two lines prior to selecting the C64 mode, provided that you write the
  863. mode switch routine yourself.)
  864.  
  865.   Even though the memory banking has been implemented with a 82S100
  866. Programmable _Logic_ Array, there is only one control line that seems
  867. to behave logically at first sight, the -CHAREN line. It is mostly
  868. used to choose between I/O address space and the character generator
  869. ROM. The following memory map introduces the oddities of -CHAREN and
  870. the other memory management lines. It is based on the memory maps in
  871. the Commodore 64 Programmer's Reference Guide, pp. 263 - 267, and some
  872. errors and inaccuracies have been corrected.
  873.  
  874.   The leftmost column of the table contains addresses in hexadecimal
  875. notation. The columns aside it introduce all possible memory
  876. configurations. The default mode is on the left, and the absolutely
  877. most rarely used Ultimax game console configuration is on the right.
  878. (There have been at least two Ultimax cartridges on the market.) Each
  879. memory configuration column has one or more four-digit binary numbers
  880. as a title. The bits, from left to right, represent the state of the
  881. -LORAM, -HIRAM, -GAME and -EXROM lines, respectively. The bits whose
  882. state does not matter are marked with "x". For instance, when the
  883. Ultimax video game configuration is active (the -GAME line is shorted
  884. to ground, -EXROM kept high), the -LORAM and -HIRAM lines have no effect.
  885.  
  886.  
  887.       default                                                         Ultimax
  888.         1111    101x    1000    011x    001x    1110    0100    1100    xx01
  889.                                 00x0
  890. 10000
  891. -----------------------------------------------------------------------------
  892.  F000
  893.         Kernal  RAM     RAM     Kernal  RAM     Kernal  Kernal  Kernal  ROMH(*
  894.  E000
  895. -----------------------------------------------------------------------------
  896.  D000   IO/C    IO/C    IO/RAM  IO/C    RAM     IO/C    IO/C    IO/C    I/O
  897. -----------------------------------------------------------------------------
  898.  C000   RAM     RAM     RAM     RAM     RAM     RAM     RAM     RAM      -
  899. -----------------------------------------------------------------------------
  900.  B000
  901.         BASIC   RAM     RAM     RAM     RAM     BASIC   ROMH    ROMH     -
  902.  A000
  903. -----------------------------------------------------------------------------
  904.  9000
  905.         RAM     RAM     RAM     RAM     RAM     ROML    RAM     ROML    ROML(*
  906.  8000
  907. -----------------------------------------------------------------------------
  908.  7000
  909.  
  910.  6000
  911.         RAM     RAM     RAM     RAM     RAM     RAM     RAM     RAM      -
  912.  5000
  913.  
  914.  4000
  915. -----------------------------------------------------------------------------
  916.  3000    
  917.  
  918.  2000   RAM     RAM     RAM     RAM     RAM     RAM     RAM     RAM      -
  919.  
  920.  1000
  921. -----------------------------------------------------------------------------
  922.  0000   RAM     RAM     RAM     RAM     RAM     RAM     RAM     RAM     RAM
  923. -----------------------------------------------------------------------------
  924.  
  925.     *) Internal memory does not respond to write accesses to these areas.
  926.  
  927.  
  928.     Legend: Kernal      E000-FFFF       Kernal ROM.
  929.  
  930.             IO/C        D000-DFFF       I/O address space or Character
  931.                                         generator ROM, selected by -CHAREN.
  932.                                         If the CHAREN bit is clear,
  933.                                         the character generator ROM is
  934.                                         chosen. If it is set, the
  935.                                         I/O chips are accessible.
  936.  
  937.             IO/RAM      D000-DFFF       I/O address space or RAM,
  938.                                         selected by -CHAREN.
  939.                                         If the CHAREN bit is clear,
  940.                                         the character generator ROM is
  941.                                         chosen. If it is set, the
  942.                                         internal RAM is accessible.
  943.  
  944.             I/O         D000-DFFF       I/O address space.
  945.                                         The -CHAREN line has no effect.
  946.  
  947.             BASIC       A000-BFFF       BASIC ROM.
  948.  
  949.             ROMH        A000-BFFF or    External ROM with the -ROMH line
  950.                         E000-FFFF       connected to its -CS line.
  951.  
  952.             ROML        8000-9FFF       External ROM with the -ROML line
  953.                                         connected to its -CS line.
  954.  
  955.             RAM         various ranges  Commodore 64's internal RAM.
  956.  
  957.             -           1000-7FFF and   Open address space. 
  958.                         A000-CFFF       The Commodore 64's memory chips
  959.                                         do not detect any memory accesses
  960.                                         to this area except the VIC-II's
  961.                                         DMA and memory refreshes.
  962.  
  963.     NOTE:   Whenever the processor tries to write to any ROM area
  964.             (Kernal, BASIC, CHAROM, ROML, ROMH), the data will get
  965.             "through the ROM" to the C64's internal RAM.
  966.  
  967.             For this reason, you can easily copy data from ROM to RAM,
  968.             without any bank switching. But implementing external
  969.             memory expansions without DMA is very hard, as you have to
  970.             use the Ultimax memory configuration, or the data will be
  971.             written both to internal and external RAM.
  972.  
  973.             However, this is not true for the Ultimax game
  974.             configuration. In that mode, the internal RAM ignores all
  975.             memory accesses outside the area $0000-$0FFF, unless they are
  976.             performed by the VIC, and you can write to external memory
  977.             at $1000-$CFFF and $E000-$FFFF, if any, without changing
  978.             the contents of the internal RAM.
  979.  
  980.  
  981. _A note concerning the I/O area_
  982.  
  983.   The I/O area is divided as follows:
  984.  
  985.      Address range  Owner
  986.      -------------  -----
  987.        D000-D3FF    MOS 6567/6569 VIC-II Video Interface Controller
  988.        D400-D7FF    MOS 6581 SID Sound Interface Device
  989.        D800-DBFF    Color RAM (only lower nybbles are connected)
  990.        DC00-DCFF    MOS 6526 CIA Complex Interface Adapter #1
  991.        DD00-DDFF    MOS 6526 CIA Complex Interface Adapter #2
  992.        DE00-DEFF    User expansion #1 (-I/O1 on Expansion Port)
  993.        DF00-DFFF    User expansion #2 (-I/O2 on Expansion Port)
  994.  
  995.   As you can see, the address ranges for the chips are much larger
  996. than required. Because of this, you can access the chips through
  997. multiple memory areas. The VIC-II appears in its window every $40
  998. addresses. For instance, the addresses $D040 and $D080 are both mapped
  999. to the Sprite 0 X co-ordinate register. The SID has one register
  1000. selection line less, thus it appears at every $20 bytes. The CIA
  1001. chips have only 16 registers, so there are 16 copies of each in their
  1002. memory area.
  1003.  
  1004.   However, you should not use other addresses than those specified by
  1005. Commodore. For instance, the Commodore 128 mapped its additional I/O
  1006. chips to this same memory area, and the SID responds only to the
  1007. addresses D400-D4FF, also when in C64 mode. And the Commodore 65,
  1008. which unfortunately did not make its way to the market, could narrow
  1009. the memory window reserved for the MOS 6569/6567 VIC-II (or CSG 4567
  1010. VIC-III in that machine).
  1011.  
  1012.  
  1013. _The video chip_
  1014.  
  1015.   The MOS 6567/6569 VIC-II Video Interface Controller has access to
  1016. only 16 kilobytes at a time. To enable the VIC-II to access the whole
  1017. 64 kB memory space, the main memory is divided to four banks of 16 kB
  1018. each. The lines PA0 and PA1 of the second CIA are the inverse of the
  1019. virtual VIC-II address lines VA14 and VA15, respectively. To select a
  1020. VIC-II bank other than the default, you must program the CIA lines to
  1021. output the desired bit pair. For instance, the following code selects
  1022. the memory area $4000-$7FFF (bank 1) for the video controller:
  1023.  
  1024.     LDA $DD02 ; Data Direction Register A
  1025.     ORA #$03  ; Set pins PA0 and PA1 to outputs
  1026.     STA $DD02
  1027.     LDA $DD00
  1028.     AND #$FC  ; Mask the lowmost bit pair off
  1029.     ORA #$02  ; Select VIC-II bank 1 (the inverse of binary 01 is 10)
  1030.     STA $DD00
  1031.  
  1032.   Why should you set the pins to outputs? Hardware RESET resets all
  1033. I/O lines to inputs, and thanks to the CIA's internal pull-up
  1034. resistors, the inputs actually output logical high voltage level. So,
  1035. upon -RESET, the video bank 0 is selected automatically, and older
  1036. Kernals could leave it uninitialized.
  1037.  
  1038.   Note that the VIC-II always fetches its information from the
  1039. internal RAM, totally ignoring the memory configuration lines. There
  1040. is only one exception to this rule: The character generator ROM.
  1041. Unless the Ultimax mode is selected, VIC-II "sees" character generator
  1042. ROM in the memory areas 1000-1FFF and 9000-9FFF. If the Ultimax
  1043. configuration is active, the VIC-II will fetch all data from the
  1044. internal RAM.
  1045.  
  1046.  
  1047. _An application: Making an operating system extension_
  1048.  
  1049.   If you are making a memory resident program and want to make it as
  1050. invisible to the system as possible, probably the best method is
  1051. keeping most of your code under the I/O area (in the RAM at
  1052. $D000-$DFFF). This area is very safe, since programs utilizing it are
  1053. rare, since they are very difficult to implement and to debug. You
  1054. need only a short routine in the normally visible RAM that pushes the
  1055. current value of the processor's I/O register $01 on stack, switches
  1056. RAM on to $D000-$DFFF and jumps to this area. Returning from the
  1057. $D000-$DFFF area is possible even without any routine in the normally
  1058. visible RAM area. Just write an RTS or an RTI to an I/O register and
  1059. return through it.
  1060.  
  1061.   But what if your program needs to use I/O? And how can you write the
  1062. return instruction to an I/O register while the I/O area is switched
  1063. off? You need a swap area for your program in normally visible memory.
  1064. The first thing your routine at $D000-$DFFF does is copying the I/O
  1065. routines (or the whole program) to normally visible memory, swapping
  1066. the bytes. For instance, if your I/O routines are initially being
  1067. stored at $D200-$D3FF, exchange the bytes in $D200-$D3FF with the
  1068. contents of $C000-$C1FF. Now you can call the I/O routines from your
  1069. routine at $D000-$DFFF, and the I/O routines can switch the I/O area
  1070. temporarily on to access the I/O chips. And right before exiting your
  1071. program at $D000-$DFFF swaps the old contents of that I/O routine area
  1072. in, e.g. exchanges the memory areas $D200-$D3FF and $C000-$C1FF
  1073. again.
  1074.  
  1075.   What I/O registers can you use for the return instruction? There are
  1076. basically two alternatives: 8-bit VIC sprite registers or either CIA's
  1077. serial port register. The VIC registers are easiest to use, as they
  1078. act precisely like memory places: you can easily write the desired
  1079. value to a register. But the CIA register is usually better, as
  1080. changing the VIC registers might change the screen layout.
  1081.  
  1082.   However, also the SP register has some drawbacks: If the machine's
  1083. CNT1 and CNT2 lines are connected to a frequency source, you must stop
  1084. either CIA's Timer A to use the SP register method. Normally the 1st
  1085. CIA's Timer A is the main hardware interrupt source. And if you use
  1086. the Kernal's RS232, you cannot stop the 2nd CIA's Timer A either. Also,
  1087. if you don't want to lose any CIA interrupts, you might want to know
  1088. that executing the RTS or RTI at SP register has the side effect of
  1089. reading the Interrupt Control Register, thus acknowledging an interrupt
  1090. that might have been waiting.
  1091.  
  1092.   If you can't use either method, you can use either CIA's ToD seconds
  1093. or minutes or ToD alarm time for storing an RTI. Or, if you don't want
  1094. to alter any registers, use the VIC-II's light pen register. Before
  1095. exiting, wait for appropriate raster line and trig the light pen latch
  1096. with CIA1's PB4 bit. However, this method assumes that the control
  1097. port 1's button/light pen line remains up for that frame. After
  1098. trigging the light pen, causing the light pen Y co-ordinate register
  1099. ($D014) to be $40 or $60, you have more than half a frame time to
  1100. restore the state of the I/O chips and return through the register.
  1101.  
  1102.   You can also use the SID to store an RTI or RTS command. How is this
  1103. possible, you might ask. After all, the chip consists of read only or
  1104. write only registers. However, there are two registers that can be
  1105. controlled by program, the envelope generator and oscillator outputs
  1106. of the third voice. This method requires you to change the frequency
  1107. of voice 3 and to select a waveform for it. This will affect on the
  1108. voice output by turning the voice 3 off, but who would keep the voice
  1109. 3 producing a tone while calling an operating system routine?
  1110.  
  1111.   Also keep in mind that the user could press RESTORE while the Kernal
  1112. ROM and I/O areas are disabled. You could write your own non-maskable
  1113. interrupt (NMI) handler (using the NMI vector at $FFFA), but a fast
  1114. loader that uses very tight timing would still stop working if the
  1115. user pressed RESTORE in the middle of a data block transfer. So, to
  1116. make a robust program, you have to disable NMI interrupts. But how is
  1117. this possible? They are Non-Maskable after all. The NMI interrupt is
  1118. edge-sensitive, the processor jumps to NMI handler only when the -NMI
  1119. line drops from +5V to ground. To disable the interrupt, simply cause
  1120. an NMI with CIA2's timer, but don't read the Interrupt Control
  1121. register. If you need to read $DD0D in your program, you must add a
  1122. NMI handler just in case the user presses RESTORE. And don't forget to
  1123. raise the -NMI line upon exiting the program.  Otherwise the RESTORE
  1124. key does not work until the user issues a -RESET or reads the ICR
  1125. register explicitly. (The Kernal does not read $DD0D, unless it is
  1126. handling an interrupt.) This can be done automatically by the two
  1127. following SP register examples due to one of the 6510's undocumented
  1128. features (refer to the descriptions of RTS and RTI below).
  1129.  
  1130.         ; Returning via VIC sprite 7 X co-ordinate register
  1131.  
  1132.         Initialization:   ; This is executed when I/O is switched on
  1133.                 LDA #$60
  1134.                 STA $D015 ; Write RTS to VIC register $15.
  1135.  
  1136.         Exiting:          ; NOTE: This procedure must start at VIC register
  1137.                           ; $12. You have multiple alternatives, as the VIC
  1138.                           ; appears in memory at $D000+$40*n, where $0<=n<=$F.
  1139.  
  1140.                 PLA       ; Pull the saved 6510 I/O register state from stack
  1141.                 STA $01   ; Restore original memory bank configuration
  1142.                           ; Now the processor fetches the RTS command from the
  1143.                           ; VIC register $15.
  1144.  
  1145.  
  1146.         ; Returning via CIA 2's ToD or ToD alarm seconds register
  1147.  
  1148.         Initialization:   ; This is executed when I/O is switched on
  1149.                 LDA #$40  
  1150.                 STA $DD08 ; Set ToD tenths of seconds
  1151.                           ; (clear it so that the seconds register
  1152.                           ; would not overflow)
  1153.                           ; If ToD alarm register is selected, this
  1154.                           ; instruction will be unnecessary.
  1155.                 STA $DD09 ; Set ToD seconds
  1156.                 LDA $DD0B ; Read ToD hours (freeze ToD display)
  1157.  
  1158.         Exiting:          ; NOTE: This procedure must start at CIA 2 register
  1159.                           ; $6. As the CIA 2 appears in memory at $DD00+$10*n,
  1160.                           ; where 0<=n<=$F, you have sixteen alternatives.
  1161.                 PLA
  1162.                 STA $01   ; Restore original memory bank configuration
  1163.                           ; Now the processor fetches the RTS command from
  1164.                           ; the CIA 2 register $9.
  1165.  
  1166.  
  1167.         ; Returning via CIA 2's SP register (assuming that CNT2 is stable)
  1168.  
  1169.         Initialization:   ; This is executed when I/O is switched on
  1170.                 LDA $DD0E ; CIA 2's Control Register A
  1171.                 AND #$BF  ; Set Serial Port to input
  1172.                 STA $DD0E ; (make the SP register to act as a memory place)
  1173.                 LDA #$60
  1174.                 STA $DD0C ; Write RTS to CIA 2 register $C.
  1175.  
  1176.         Exiting:          ; NOTE: This procedure must start at CIA 2 register
  1177.                           ; $9. As the CIA 2 appears in memory at $DD00+$10*n,
  1178.                           ; where 0<=n<=$F, you have sixteen alternatives.
  1179.                 PLA
  1180.                 STA $01   ; Restore original memory bank configuration
  1181.                           ; Now the processor fetches the RTS command from
  1182.                           ; the CIA 2 register $C.
  1183.  
  1184.  
  1185.         ; Returning via CIA 2's SP register, stopping the Timer A
  1186.         ; and forcing SP2 and CNT2 to output
  1187.  
  1188.         Initialization:   ; This is executed when I/O is switched on
  1189.                 LDA $DD0E ; CIA 2's Control Register A
  1190.                 AND #$FE  ; Stop Timer A
  1191.                 ORA #$40  ; Set Serial Port to output
  1192.                 STA $DD0E ; (make the SP register to act as a memory place)
  1193.                 LDA #$60
  1194.                 STA $DD0C ; Write RTS to CIA register $C.
  1195.  
  1196.         Exiting:          ; NOTE: This procedure must start at CIA 2 register
  1197.                           ; $9. As the CIA 2 appears in memory at $DD00+$10*n,
  1198.                           ; where 0<=n<=$F, you have sixteen alternatives.
  1199.                 PLA
  1200.                 STA $01   ; Restore original memory bank configuration
  1201.                           ; Now the processor fetches the RTS command from
  1202.                           ; the CIA 2 register $C.
  1203.  
  1204.         ; Returning via SID oscillator 3 output register
  1205.  
  1206.         Initialization:   ; This is executed when I/O is switched on
  1207.                 LDA #$20  ; Select sawtooth waveform
  1208.                 STA $D412 ; but do not enable the sound
  1209.                 LDY #$00  ; Select frequency
  1210.                 STY $D40E ; (system clock)/$FF00,
  1211.                 LDA #$FF  ; causing the OSC3 output to increment by one
  1212.                 STY $D40F ; every $10000/$FF00 cycles.
  1213.  
  1214.                 LDA #$0E
  1215.                 LDX #$60
  1216.  
  1217.                 BIT $D41B ; Wait for the oscillator 3 output
  1218.                 BMI *-3   ; to be in the range
  1219.                 BVS *-5   ; $00-$3F.
  1220.                 BIT $D41B ; Wait for the oscillator 3 output
  1221.                 BVC *-3   ; to be at least $40.
  1222.  
  1223.                 STA $D40F ; Slow down the frequency to (system clock)/$0E00.
  1224.                 CPX $D41B ; Wait for the oscillator 3
  1225.                 BNE *-3   ; output to reach $60 (RTS)
  1226.  
  1227.                 STY $D40F ; Reset the frequency of voice 3
  1228.                           ; (stop the OSC3 register from increasing)
  1229.  
  1230.         Exiting:          ; NOTE: This procedure must start at SID register
  1231.                           ; $18. As the SID appears in memory at $D400+$20*n,
  1232.                           ; where 0<=n<=$20, you have thirty-two alternatives.
  1233.                           ; However, in C128 there are only eight alternatives,
  1234.                           ; as the SID is only at $D400-$D4FF.
  1235.  
  1236.                 PLA
  1237.                 STA $01   ; Restore original memory bank configuration
  1238.                           ; Now the processor fetches the RTS command from
  1239.                           ; the SID register $1B.
  1240.  
  1241.  
  1242.   For instance, if you want to make a highly compatible fast loader,
  1243. make the ILOAD vector ($0330) point to the beginning of the stack
  1244. area. Remember that the BASIC interpreter uses the first bytes of
  1245. stack while converting numbers to text. A good address is $0120.
  1246. Robust programs practically never use so much stack that it could
  1247. corrupt this routine. Usually only crunched programs (demos and alike)
  1248. use all stack in the decompression phase. They also make use of the
  1249. $D000-$DFFF area.
  1250.  
  1251.   This stack routine will jump to your routine at $D000-$DFFF, as
  1252. described above. For performance's sake, copy the whole byte transfer
  1253. loop to the swap area, e.g. $C000-$C1FF, and call that subroutine
  1254. after doing the preliminary work. But what about files that load over
  1255. $C000-$C1FF? Wouldn't that destroy the transfer loop and jam the
  1256. machine? Not necessarily. If you copy those bytes to your swap area at
  1257. $D000-$DFFF, they will be loaded properly, as your program restores
  1258. the original $C000-$C1FF area.
  1259.  
  1260.   If you want to make your program user-friendly, put a vector
  1261. initialization routine to the stack area as well, so that the user can
  1262. restore the fast loader by issuing a SYS command, rather than loading
  1263. it each time he has pressed RESET.
  1264.  
  1265.  
  1266. _An example: A "hello world" program_
  1267.  
  1268.   To help you in getting started, I have written a small example
  1269. program that echoes the famous message "hello, world!" to standard
  1270. output (normally screen) using the Kernal's CHROUT subroutine. After
  1271. the initialization routine has been run, the program can be started by
  1272. commanding SYS 300. I used the Commodore 128's machine language
  1273. monitor to put it up, but it was still pretty difficult to debug the
  1274. program. Here it is in uuencoded format:
  1275.  
  1276. begin 644 hello
  1277. M`0@+",D'GC(P-C$```!XI0%(*?B%`:(,O3`(G2P!RA#WHHN]/`B=8]W*T/=H
  1278. MA0%88*4!JBGX"01XA0%,I-WF`:*!C@W=H@".!=WHC@3=HMV.#MVB0(X,W<8!
  1279. M8*4!2`D#A0&@#+DSP"#2_X@0]VB%`6`A1$Q23U<@+$],3$5(BDBM^O](K?O_
  1280. M2*D6C?K_J<"-^_\@W-T@`,!HC?O_:(WZ_R`=P"#<W6BHJ0!(NOX"`=`#_@,!
  1281. 5A`&@/[X`P+EDW9D`P(J99-V($/!@
  1282. `
  1283. end
  1284.  
  1285.   In order to fully understand the operation of this program, you need
  1286. to know how the instructions RTI, RTS and PHA work. There is some work
  1287. going on to reverse engineer the NMOS 6502 microprocessor to large
  1288. extent, and it is now known for most instructions what memory places
  1289. they access during their execution and for what purpose. The internal
  1290. procedures haven't been described in detail yet, but these
  1291. descriptions should be easier to read anyway.
  1292.  
  1293.   For curiosity, I quote here the description of all instructions that
  1294. use the stack. The descriptions of internal operations are yet
  1295. inaccurate, but the memory accesses have been verified with an
  1296. oscilloscope. I will mail copies the whole document upon request. When
  1297. finished, the document will be put on an FTP site.
  1298.  
  1299.  
  1300.      JSR
  1301.  
  1302.         #  address R/W description
  1303.        --- ------- --- -------------------------------------------------
  1304.         1    PC     R  fetch opcode, increment PC
  1305.         2    PC     R  fetch address's low byte to latch, increment PC
  1306.         3  $0100,S  R
  1307.         4  $0100,S  W  push PCH on stack, decrement S
  1308.         5  $0100,S  W  push PCL on stack, decrement S
  1309.         6    PC     R  copy latch to PCL, fetch address's high byte to
  1310.                        latch, copy latch to PCH
  1311.  
  1312.  
  1313.      RTS
  1314.  
  1315.         #  address R/W description
  1316.        --- ------- --- -----------------------------------------------
  1317.         1    PC     R  fetch opcode, increment PC
  1318.         2    PC     R  read next instruction byte (and throw it away),
  1319.                        increment PC
  1320.         3  $0100,S  R  increment S
  1321.         4  $0100,S  R  pull PCL from stack, increment S
  1322.         5  $0100,S  R  pull PCH from stack
  1323.         6    PC     R  increment PC
  1324.  
  1325.  
  1326.      BRK
  1327.  
  1328.         #  address R/W description
  1329.        --- ------- --- -----------------------------------------------
  1330.         1    PC     R  fetch opcode, increment PC
  1331.         2    PC     R  read next instruction byte (and throw it away),
  1332.                        increment PC
  1333.         3  $0100,S  W  push PCH on stack, decrement S
  1334.         4  $0100,S  W  push PCL on stack, decrement S
  1335.         5  $0100,S  W  push P on stack (with B flag set), decrement S,
  1336.                        set I flag
  1337.         6   $FFFE   R  fetch PCL
  1338.         7   $FFFF   R  fetch PCH
  1339.  
  1340.  
  1341.      RTI
  1342.  
  1343.         #  address R/W description
  1344.        --- ------- --- -----------------------------------------------
  1345.         1    PC     R  fetch opcode, increment PC
  1346.         2    PC     R  read next instruction byte (and throw it away),
  1347.                        increment PC
  1348.         3  $0100,S  R  increment S
  1349.         4  $0100,S  R  pull P from stack, increment S
  1350.         5  $0100,S  R  pull PCL from stack, increment S
  1351.         6  $0100,S  R  pull PCH from stack
  1352.  
  1353.  
  1354.      PHA, PHP
  1355.  
  1356.         #  address R/W description
  1357.        --- ------- --- -----------------------------------------------
  1358.         1    PC     R  fetch opcode, increment PC
  1359.         2    PC     R  read next instruction byte (and throw it away),
  1360.                        increment PC
  1361.         3  $0100,S  W  push register on stack, decrement S
  1362.  
  1363.  
  1364.      PLA, PLP
  1365.  
  1366.         #  address R/W description
  1367.        --- ------- --- -----------------------------------------------
  1368.         1    PC     R  fetch opcode, increment PC
  1369.         2    PC     R  read next instruction byte (and throw it away),
  1370.                        increment PC
  1371.         3  $0100,S  R  increment S
  1372.         4  $0100,S  R  pull register from stack
  1373.  
  1374.  
  1375.   The example program consists of three parts. The first part
  1376. transfers the other parts to appropriate memory areas. The second part
  1377. is located in stack area (300-312), and it invokes the third part, the
  1378. main module.
  1379.  
  1380.   The loader part ($0801-$08C7) is as follows:
  1381.  
  1382.         1993 SYS2061
  1383.  
  1384.         080D SEI          Disable interrupts.
  1385.         080E LDA $01
  1386.         0810 PHA          Store the state of the processor's I/O lines.
  1387.         0811 AND #$F8
  1388.         0813 STA $01      Select 64 kB RAM memory configuration.
  1389.  
  1390.         0815 LDX #$0C     Copy the invoking part to 300-312.
  1391.         0817 LDA $0830,X
  1392.         081A STA $012C,X
  1393.         081D DEX
  1394.         081E BPL $0817
  1395.  
  1396.         0820 LDX #$8B     Copy the main part to $DD64-$DDEE.
  1397.         0822 LDA $083C,X
  1398.         0825 STA $DD63,X
  1399.         0828 DEX
  1400.         0829 BNE $0822
  1401.  
  1402.         082B PLA          Restore original memory configuration.
  1403.         082C STA $01
  1404.         082E CLI          Enable interrupts.
  1405.         082F RTS          Return.
  1406.  
  1407.   The user invokes the following part by issuing SYS 300. This part
  1408. changes the memory configuration and jumps to the main part.
  1409.  
  1410.         012C LDA $01
  1411.         012E TAX          Store original memory configuration to X register.
  1412.         012F AND #$F8
  1413.         0131 ORA #$04
  1414.         0133 SEI          Disable interrupts.
  1415.         0134 STA $01      Select 64 kB RAM memory configuration.
  1416.         0136 JMP $DDA4    Jump to the main part.
  1417.  
  1418.   The main part actually consists of two parts. It may be a bit
  1419. complicated, and it might teach new tricks to you.
  1420.  
  1421.         DDA4 TXA
  1422.         DDA5 PHA          Push original memory configuration on stack.
  1423.         DDA6 LDA $FFFA
  1424.         DDA9 PHA
  1425.         DDAA LDA $FFFB
  1426.         DDAD PHA          Store the original values of $FFFA and $FFFB.
  1427.         DDAE LDA #$16
  1428.         DDB0 STA $FFFA    Set ($FFFA) to point to RTI.
  1429.         DDB3 LDA #$C0
  1430.         DDB5 STA $FFFB
  1431.         DDB8 JSR $DDDC    Swap the auxiliary routines in.
  1432.         DDBB JSR $C000    Disable NMI's and initialize CIA2.
  1433.         DDBE PLA
  1434.         DDBF STA $FFFB    Restore original values to $FFFA and $FFFB.
  1435.         DDC2 PLA
  1436.         DDC3 STA $FFFA
  1437.         DDC6 JSR $C01D    Print the message.
  1438.         DDC9 JSR $DDDC    Swap the auxiliary routines out.
  1439.         DDCC PLA
  1440.         DDCD TAY          Load original memory configuration to Y register.
  1441.         DDCE LDA #$00     Push desired stack register value on stack
  1442.         DDD0 PHA          (clear all flags, especially the I flag).
  1443.         DDD1 TSX
  1444.         DDD2 INC $0102,X  Increment the return address.
  1445.         DDD5 BNE $DDDA    (RTS preincrements it, but RTI does not.)
  1446.         DDD7 INC $0103,X
  1447.         DDDA STY $01      Restore original memory configuration.
  1448.  
  1449.         (The 6510 fetches the next instruction from $DDDC, which is now
  1450.         connected to the CIA2's register $C, the Serial Port register.
  1451.         The initialization routine wrote an RTI to it. The processor also
  1452.         reads from $DDDD as a side effect of the instruction fetch,
  1453.         thus re-enabling NMI's.)
  1454.  
  1455.         DDDC LDY #$3F     Subroutine: Swap the memory areas $C000-$C03F
  1456.         DDDE LDX $C000,Y              and $DD64-$DDA3 with each other.
  1457.         DDE1 LDA $DD64,Y
  1458.         DDE4 STA $C000,Y
  1459.         DDE7 TXA
  1460.         DDE8 STA $DD64,Y
  1461.         DDEB DEY
  1462.         DDEC BPL $DDDE 
  1463.         DDEE RTS
  1464.  
  1465.         C000 INC $01      Enable the I/O area.
  1466.         C002 LDX #$81
  1467.         C004 STX $DD0D    Enable Timer A interrupts of CIA2.
  1468.         C007 LDX #$00
  1469.         C009 STX $DD05
  1470.         C00C INX
  1471.         C00D STX $DD04    Prepare Timer A to count from 1 to 0.
  1472.         C010 LDX #$DD
  1473.         C012 STX $DD0E    Cause an interrupt.
  1474.  
  1475.         (The instruction sets SP to output, makes Timer A to count
  1476.         system clock pulses, forces the CIA to load the initial value
  1477.         to the counter, selects one-shot counting and starts the timer.)
  1478.  
  1479.         C015 LDX #$40
  1480.  
  1481.         (The processor now jumps to the NMI handler ($C016), and
  1482.         the SP register starts to act as a memory place.)
  1483.  
  1484.         C017 STX $DD0C    Write an RTI to Serial Port register.
  1485.         C01A DEC $01      Disable the I/O area.
  1486.         C01C RTS          Return.
  1487.  
  1488.         C01D LDA $01
  1489.         C01F PHA
  1490.         C020 ORA #$03     Enable I/O and ROMs.
  1491.         C022 STA $01
  1492.         C024 LDY #$0C     Print the message.
  1493.         C026 LDA $C033,Y
  1494.         C029 JSR $FFD2
  1495.         C02C DEY
  1496.         C02D BPL $C026
  1497.         C02F PLA
  1498.         C030 STA $01      Restore the 64 kB memory configuration.
  1499.         C032 RTS
  1500.  
  1501.         C033 "!DLROW ,OLLEH"
  1502.  
  1503.         (The string is backwards in memory, since I don't want to
  1504.         waste cycles in explicit comparisons. This method results in
  1505.         more readable code than doing a forward loop with an index
  1506.         value $100-(number of characters).)
  1507.  
  1508.   This program is not excellent. It has the following bugs:
  1509.  
  1510.    o The 6510's memory management lines P0 and P1 (LORAM and HIRAM,
  1511.      respectively) are assumed to be outputs. If you issued the
  1512.      command POKE0,PEEK(0)AND252, this program would not work.
  1513.      This could be easily corrected by setting the P0 and P1 lines
  1514.      to output in the beginning of the interfacing routine (300 - 312):
  1515.  
  1516.         LDA $00
  1517.         ORA #$02
  1518.         STA $00
  1519.  
  1520.    o The program does not restore the original state of the CIA2
  1521.      Control Register A or Interrupt Control Register. It might be
  1522.      impossible to start using the Kernal's RS-232 routines after
  1523.      running this.
  1524.  
  1525.    o If the user redirected output to cassette or RS-232, interrupts
  1526.      would be required. However, they are completely disabled.
  1527.  
  1528.    o If a non-maskable interrupt occurs while the loader part is being
  1529.      executed, the program will screw up. This will happen also in the
  1530.      main part, if an NMI is issued after disabling ROMs and I/O in
  1531.      $0134 but before exchanging the contents of the memory places
  1532.      $C016 and $DD7A.
  1533.  
  1534.  
  1535. _Freezer cartridges_
  1536.  
  1537. There are many cartridges that let you to stop almost any program for
  1538. "back-up" purposes. One of the most popular of these freezer
  1539. cartridges is the Action Replay VI made by Datel Electronics back in
  1540. 1989. The cartridge has 8 kilobytes RAM and 32 kilobytes ROM on board,
  1541. and it has a custom chip for fiddling with the C64 cartridge port
  1542. lines -EXROM, -GAME, -IRQ, -NMI and BA.
  1543.  
  1544. If the -NMI line is not asserted (the NMI interrupts are enabled), all
  1545. freezer cartridges should be able to halt any program. When the user
  1546. presses the "freeze" button, the cartridges halt the processor by
  1547. dropping the BA line low. Then they switch some of their own ROM to
  1548. the $E000 - $FFFF block by selecting the UltiMax configuration with
  1549. the -EXROM and -GAME lines. After this, they assert the -NMI line and
  1550. release the BA line. After completing the current instruction, the
  1551. processor will take the NMI interrupt and load the program counter
  1552. from the vector at $FFFA, provided that the NMI line was not asserted
  1553. already.
  1554.  
  1555. This approach is prone to many flaws. Firstly, if the processor is
  1556. executing a write instruction when the program is being halted, and if
  1557. the write occurred outside the area $0000 - $0FFF, the data would get
  1558. lost, if the UltiMax configuration was asserted too early. This can be
  1559. corrected to some extent by waiting at least two cycles after
  1560. asserting the BA line, as the processor will not stop during write
  1561. cycles. However, this is of no help if the processor has not gotten to
  1562. the write stage yet.
  1563.  
  1564. Secondly, if the instruction being executed is outside the area
  1565. $0000 - $0FFF, or if it accesses any data outside that area, the
  1566. processor will fetch either wrong parameters or incorrect data, or
  1567. both. If the instruction does not write anything, will only corrupt
  1568. one processor register.
  1569.  
  1570. Thirdly, if the NMI interrupts are disabled, pressing the "freeze"
  1571. button does not have any other immediate effect than leaving the
  1572. UltiMax mode asserted, which makes any system RAM outside the area
  1573. $0000 - $0FFF unavailable. It also forces the I/O area ($D000 - $DFFF)
  1574. on. If the program has any instructions or data outside the lowmost
  1575. four kilobytes, it will eventually jam, as that data will be something
  1576. else than the program expects.
  1577.  
  1578. One might except that reading from open address space should return
  1579. random bytes. But, in at least two C64's, the bytes read are mostly
  1580. $BD, which is the opcode for LDA absolute,X. So, if the processor has
  1581. a "good luck", it will happily execute only LDA $BDBD,X commands, and
  1582. it might survive to the cartridge ROM area without jamming. Or it
  1583. could eventually fetch a BRK and jump to the cartridge ROM via the
  1584. IRQ/BRK vector at $FFFE. The Action Replay VI has the familiar
  1585. autostart data in the beginning of both the ROML and ROMH blocks by
  1586. default, and that data could be interpreted as sensible commands. The
  1587. Action Replay VI was indeed able to freeze my test program, even
  1588. though I had covered its -RESET, -IRQ and -NMI lines with a piece of
  1589. tape, until I relocated the program to the first 4 kilobyte block.
  1590.  
  1591.  
  1592. _Building an unbeatable freezer circuit_
  1593.  
  1594. As you can see, it is totally impossible to design a freezer cartridge
  1595. that freezes any program. If the program to be freezed has disabled
  1596. the NMI interrupts, and if its code runs mostly at $0000 - $0FFF or
  1597. $D000 - $DFFF, the computer will more probably hang than succeed in
  1598. freezing the program.
  1599.  
  1600. However, it is possible to make some internal modifications to a C64,
  1601. so that it can freeze literally any program. You need to expand your
  1602. machine to 256 kilobytes following the documents on ftp.funet.fi in
  1603. the /pub/cbm/hardware/256kB directory. It will let you to reset the
  1604. computer so that all of the 64 kilobytes the previous program used,
  1605. will remain intact. If you add a switch to one of the memory expansion
  1606. controller's chip selection lines, the program being examined will
  1607. have no way to screw the machine up, as the additional memory management
  1608. registers will not be available.
  1609.  
  1610. A few enhancements to this circuit are required so that you can freeze
  1611. the programs without losing the state of the I/O chips. You will also
  1612. need to replace the Kernal ROM chip with your own code, if you do not
  1613. want to lose the state of the A, X, P and S registers. Unfortunately
  1614. this circuit will not preserve the state of the processor's Peripheral
  1615. lines (its built-in I/O port mapped to the memory addresses 0 and 1),
  1616. nor does it record the program counter (PC). I have a partial solution
  1617. to the PC problem, though.
  1618.  
  1619. If you are interested in this project, contact me. I will design the
  1620. additional hardware, and I will program the startup routines, but I
  1621. certainly do not have the time to program all of the freezer software.
  1622. Most of the freezer software could be in RAM, so it would be very easy
  1623. to develop it, and you could even use existing tools by patching them
  1624. slightly.
  1625.  
  1626. =============================================================================
  1627. FLD - Scrolling the screen
  1628. by Marek Klampar (klampar@elf.stuba.sk)
  1629.  
  1630.  
  1631.                  Scrolling the screen
  1632.                  --------------------
  1633.       [inspirated by Pasi Ojala article 'Opening the borders' from issue#6]
  1634.  
  1635. From Pasi 'Albert' Ojala's (po87553@cs.tut.fi or albert@cc.tut.fi) article:
  1636.  
  1637.   _Scrolling the screen_
  1638.  
  1639.   VIC begins to draw the screen from the first bad line. VIC will know
  1640.   what line is a bad line by comparing its scan line counter to the
  1641.   vertical scroll register : when they match, the next line is a bad
  1642.   line. If we change the vertical scroll register ($d011), the first bad
  1643.   line will move also. If we do this on every line, the line counter in
  1644.   VIC will never match with it and the drawing never starts (until it is
  1645.   allowed to do so).
  1646.  
  1647.   When we don't have to worry about bad lines, we have enough time to
  1648.   open the borders and do some other effects too. It is not necassary to
  1649.   change the vertical scroll on every line to get rid of the bad lines,
  1650.   just make sure that it never matches the line counter (or actually the
  1651.   least significant 3 bits).
  1652.  
  1653.   You can even scroll the bad lines independently and you have FLD -
  1654.   Flexible Line Distance. You just allow a bad line when it is time to
  1655.   display the next character row. With this you can bounce the lines or
  1656.   scroll a hires picture very fast down the screen.
  1657.  
  1658. (*** end of Albert's paragraph ***)
  1659.  
  1660.   Well, everything important was written. I'm just adding this:
  1661.  
  1662. For moving hires picture replace ORA #$10 by ORA #$30.
  1663.  
  1664. For another FX try to replace part of irq routine begining with ORA #$10 by:
  1665.     ORA #$C0
  1666.     STA $D016,
  1667. remove  JSR CHOFS,
  1668. replace    LDX OFSET
  1669. by    LDX #$ff
  1670. and enjoy =)
  1671.  
  1672.  
  1673. The demonstartion program for FLD application
  1674. ;---------------------------------------
  1675. ; Commodore Cracker 1993
  1676. ;---------------------------------------
  1677. FROM     = $32
  1678. TO       = $FA
  1679. ;---------------------------------------
  1680.       *= $C000
  1681. ;---------------------------------------
  1682. INIT    LDA #0
  1683.       STA DIR     ; Direction
  1684.       LDA #$FF    ; Set garbage
  1685.       STA $3FFF
  1686.       LDA #FROM
  1687.       STA OFSET   ; Set ofset
  1688.       SEI         ; Disable interrupt
  1689.       LDA #$7F    ; Disable timer interrupt
  1690.       STA $DC0D
  1691.       LDA #1      ; Enable raster interrupt
  1692.       STA $D01A
  1693.       LDA #<IRQ   ; Set irq vector
  1694.       STA $0314
  1695.       LDA #>IRQ
  1696.       STA $0315
  1697.       LDA #0      ; To evoke our irq routine on 0th line
  1698.       STA $D012
  1699.       CLI         ; Enable interrupt
  1700.       RTS
  1701. ;---------------------------------------
  1702. IRQ     LDX OFSET
  1703. L2    LDY $D012   ; Moving 1st bad line
  1704. L1    CPY $D012
  1705.       BEQ L1      ; Wait for begin of next line
  1706.       DEY         ; IY - bad line
  1707.       TYA
  1708.       AND #$07    ; Clear higher 5 bits
  1709.       ORA #$10    ; Set text mode
  1710.       STA $D011
  1711.       DEX
  1712.       BNE L2
  1713.       INC $D019   ; Acknowledge the raster interrupt
  1714.       JSR CHOFS
  1715.       JMP $EA31   ; Do standard irq routine
  1716. ;---------------------------------------
  1717. OFSET .BYTE FROM
  1718. DIR   .BYTE 0
  1719. ;---------------------------------------
  1720. CHOFS LDA DIR     ; Change OFSET of screen
  1721.       BNE UP
  1722.       INC OFSET   ; Down
  1723.       LDA OFSET
  1724.       CMP #TO
  1725.       BNE SKIP
  1726.       STA DIR
  1727. SKIP    RTS
  1728. ;---------------------------------------
  1729. UP    DEC OFSET   ; Up
  1730.       LDA OFSET
  1731.       CMP #FROM
  1732.       BNE SKIP
  1733.       LDA #0
  1734.       STA DIR
  1735.       RTS
  1736.  
  1737. =============================================================================
  1738. Tech-tech - more resolution to vertical shift.
  1739. by Pasi 'Albert' Ojala (po87553@cs.tut.fi _or_ albert@cc.tut.fi)
  1740. Written on 16-May-91  Translation 02-Jun-92
  1741.  
  1742. (All timings are in PAL, principles will apply to NTSC too)
  1743.  
  1744. One time half of the demos had pictures waving horizontally on the
  1745. width of the whole screen. This effect is named tech-tech, and the
  1746. audience was puzzled. You can move the screen only eight pixels using
  1747. the horizontal scroll register. This effect was done using character
  1748. graphics. How exactly and is the same possible with sprites ?
  1749.  
  1750.  
  1751. Horizontal scroll register can move the screen by eight pixels. This
  1752. isn't even nearly enough to produce a really stunning effect. You have
  1753. to move the graphics itself, fortunately with a resolution of one
  1754. character position (one byte) only, the rest can be done with the scroll
  1755. register. During one scan line there is no time to move the actual data,
  1756. you can only move a pointer. Changing the video matrix pointer won't
  1757. help, because VIC (video interface controller) will fetch the character
  1758. codes only at certain times, called bad lines. You can change the
  1759. character set pointer instead, because VIC reads the data it displays
  1760. directly from the character set memory.
  1761.  
  1762.  
  1763. Character set-implementation has its restrictions
  1764.  
  1765. Because horizontal movement is done by changing the character sets, the
  1766. picture or text must be pure graphic and the character codes in the
  1767. video matrix must be in a numerical order. The normal picture is in the
  1768. first character memory and in the next one it is shifted one character
  1769. position to the right. One video bank can hold only seven full character
  1770. memories besides the video matrix. This limits the movement of the
  1771. picture to 56 pixels. It is possible to get more movement if you use
  1772. smaller picture or another video bank.
  1773.  
  1774. The shift is done so that on each scan line we update the horizontal
  1775. scroll register ($D016) with the three lowest bits of the shift value.
  1776. We use the other bits to select the right character set ($D018). In a
  1777. tech-tech the shift value changes during the display of the whole
  1778. picture, and the values are stored in a table. In addition to that, the
  1779. shift values should be put into two tables, one for the horizontal
  1780. scroll register and another for the character set select. This is
  1781. necessary, because there is no time for extra calculations on a bad
  1782. line.
  1783.  
  1784. Because we have to change the character set and x-scroll dynamically, we
  1785. also need a raster routine to show a tech-tech. A raster routine is a
  1786. routine which is synchronized to the electron beam. This eats up the
  1787. processor time: the bigger the picture, the less time is left over for
  1788. other activities. On other than bad lines you can do other funny things,
  1789. like change the color of the background or border.
  1790.  
  1791.  
  1792. An example program
  1793.  
  1794. The demo program uses video bank 2, memory addesses $4000-7fff. The
  1795. video matrix is in the beginning of the bank. Only inverted chars are
  1796. used for the graphics, this way we have all eight character memories
  1797. available and the maximum shift is 64 pixels. The area for the tech-tech
  1798. in the video matrix is eight character rows high, but it has identical
  1799. graphics on every line. This is why we use only 320 bytes from each
  1800. character set.
  1801.  
  1802. You can use a joystick to control the movement of the tech-tech. The
  1803. stick decreases or increases the shift add value in a resolution of a
  1804. half pixel. When the shift reaches its highest/lowest value, the
  1805. direction of the add is reversed. Just experiment with it.
  1806.  
  1807.  
  1808. You can do it on the screen, how about borders ?
  1809.  
  1810. Because you cannot get characters to the border, you might think that it
  1811. is impossible to make a tech-tech effect in the borders. It takes so
  1812. much time to change sprite x-coordinates, that you can change only some
  1813. of them. There is time for five sprite moves, if you do not need to
  1814. change the most significant (9th) bit of the x-coordinate. On the other
  1815. hand, you could design the movements directly to the sprites and then
  1816. just change the images, but then the movements would be constant.
  1817.  
  1818. However, there is one trick you can use to get all of the sprites on the
  1819. screen, with variable movements and color bars etc. You do not change
  1820. the x-coordinates, but the data itself on each scan line. In fact you
  1821. change the sprite image pointers. There is multiple sprite pictures,
  1822. where the graphics is shifted horizontally, just like the normal
  1823. tech-tech charsets. Because of this, the sprites have to be placed side
  1824. by side. No gaps are allowed. By changing the image pointers you can get
  1825. the graphics to move horizontally on each line as you wish. With
  1826. multicolor sprites you have to remember that one pixel corresponds to
  1827. two bits - the movement is not so smooth.
  1828.  
  1829. Wait ! How come there is enough time to change the sprite pointers, when
  1830. there is not time to change the coordinates ? This is another pointer
  1831. trick. VIC reads the sprite image pointers from the end of the current
  1832. video matrix, normally $07f8. You just have to change the video matrix
  1833. pointer ($D018) to change all of the image pointers. This takes only
  1834. eight cycles and there is plenty of time left for other effects on each
  1835. scan line. If you use only one video bank, you can get the sprite
  1836. picture to 16 different places. This allows also another kind of
  1837. effects, just use your imagination.
  1838.  
  1839. --------------------------------------------------------------------------
  1840. Tech-tech demo program (PAL)
  1841.  
  1842. BANK=   $96     ; The value of the video bank register (CIA2) in the tech-area
  1843. ZP=     $FB     ; Zero page for indirect addressing
  1844. START=  $4400   ; Start of the charsets (we use inverted chars)
  1845. SCREEN= $4000   ; Position of the video matrix
  1846. SHIFTL= $CF00   ; x-shift, lowest 3 bits
  1847. SHIFTH= $CE00   ; x-shift, highest 3 bittid (multiplied with two)
  1848. POINTER= $033C  ; Pointer to shift-table
  1849. VALUE=  $033D   ; Shift now
  1850. SPEED=  $033E   ; Shift change
  1851.  
  1852. *= $C000  ; Start address..
  1853.  
  1854. INIT    SEI             ; Disable interrupts
  1855.         LDA #$7F
  1856.         STA $DC0D       ; Disable timer interrupt
  1857.         LDA #$81
  1858.         STA $D01A       ; Enable raster interrupt
  1859.         LDA #<IRQ
  1860.         STA $0314       ; Our own interrupt handler
  1861.         LDA #>IRQ
  1862.         STA $0315
  1863.         LDA #49         ; The interrupt to the line before the first bad line
  1864.         STA $D012
  1865.         LDA #$1B
  1866.         STA $D011       ; 9th bit of the raster compare
  1867.  
  1868.         LDY #0
  1869.         LDX #$40
  1870.         STX ZP+1
  1871.         STY ZP
  1872.         TYA
  1873. LOOP0   STA (ZP),Y      ; Clear the whole video bank ($4000-7FFF)
  1874.         INY
  1875.         BNE LOOP0
  1876.         INC ZP+1
  1877.         BPL LOOP0
  1878.  
  1879.         LDA #>START
  1880.         STA ZP+1
  1881.         LDA #$32        ; Character ROM to address space ($D000-)
  1882.         STA $01
  1883. LOOP1   TYA             ; (Y-register is zero initially)
  1884.         LSR
  1885.         LSR
  1886.         LSR
  1887.         TAX
  1888.         LDA TEXT,X      ; Which char to plot ?
  1889.         ASL             ; Source
  1890.         ASL
  1891.         ASL
  1892.         TAX             ; low byte to X
  1893.         LDA #$D0
  1894.         ADC #0          ; high byte (one bit) taken into account
  1895.         STA LOOP2+2 ; Self-modifying again..
  1896. LOOP2   LDA $D000,X
  1897.         STA (ZP),Y
  1898.         INX
  1899.         INY
  1900.         TXA
  1901.         AND #7
  1902.         BNE LOOP2       ; Copy one char
  1903.         CPY #0
  1904.         BNE LOOP1       ; Copy 32 chars (256 bytes)
  1905.         LDA #$37        ; Memory configuration back to normal
  1906.         STA $01
  1907.  
  1908. LOOP3   LDA START,Y       ; Copy the data to each charset, shifted by one
  1909.         STA START+2056,Y  ;  position to the right
  1910.         STA START+4112,Y
  1911.         STA START+6168,Y
  1912.         STA START+8224,Y
  1913.         STA START+10280,Y
  1914.         STA START+12336,Y
  1915.         STA START+14392,Y
  1916.         INY
  1917.         BNE LOOP3
  1918.         LDA #0          ; Clear the pointer, value and speed
  1919.         STA POINTER
  1920.         STA VALUE
  1921.         STA SPEED
  1922.  
  1923. LOOP4   TYA             ; (Y was zero)
  1924.         ORA #$80        ; Use the inverted chars
  1925.         STA SCREEN,Y    ; Set the character codes to video matrix
  1926.         STA SCREEN+40,Y
  1927.         STA SCREEN+80,Y
  1928.         STA SCREEN+120,Y
  1929.         STA SCREEN+160,Y
  1930.         STA SCREEN+200,Y
  1931.         STA SCREEN+240,Y
  1932.         STA SCREEN+280,Y
  1933.         LDA #239        ; leave the last line empty
  1934.         STA SCREEN+320,Y
  1935.         INY
  1936.         CPY #40
  1937.         BNE LOOP4       ; Loop until the whole area is filled
  1938.         CLI             ; Enable interrupts
  1939.         RTS
  1940.  
  1941. IRQ     LDA #BANK       ; Change the video bank, some timing
  1942.         STA $DD00
  1943.         NOP
  1944.         NOP
  1945.  
  1946.         LDY POINTER     ; Y-register will point to x-shift
  1947.         JMP BAD         ; next line is a bad line
  1948. LOOP5   NOP
  1949. LOOP6   LDA SHIFTL,Y    ; Do the shift
  1950.         STA $D016       ; 3 lowest bits
  1951.         LDA SHIFTH,Y
  1952.         STA $D018       ; another 3 bits
  1953.         NOP : NOP : NOP : NOP : NOP : NOP ; waste some time
  1954.         NOP : NOP : NOP : NOP : NOP : NOP
  1955.         NOP : NOP : NOP
  1956.         LDA $D012       ; check if it is time to stop
  1957.         CMP #$78
  1958.         BPL OVER
  1959.         INY   ; next position in table
  1960.         DEX
  1961.         BNE LOOP5       ; No bad line, loop
  1962. BAD     LDA SHIFTL,Y    ; This is a bad line, a bit more hurry
  1963.         STA $D016
  1964.         LDA SHIFTH,Y
  1965.         STA $D018
  1966.         INY
  1967.         LDX #7          ; New bad line coming up
  1968.         JMP LOOP6
  1969.  
  1970. OVER    LDA #$97        ; Video bank to 'normal'
  1971.         STA $DD00
  1972.         LDA #22         ; Same with the charset
  1973.         STA $D018
  1974.         LDA #8          ; and the horizontal scroll register
  1975.         STA $D016
  1976.  
  1977.         LDA $DC00       ; Let's check the joysticks
  1978.         AND $DC01
  1979.         TAX
  1980.         LDY SPEED
  1981.         AND #8          ; Turned right, add speed
  1982.         BNE EIP
  1983.         INY
  1984.         CPY #4          ; Don't store, too much speed
  1985.         BPL EIP
  1986.         STY SPEED
  1987. EIP     TXA
  1988.         AND #4          ; Turned left
  1989.         BNE ULOS
  1990.         DEY
  1991.         CPY #$FC        ; Too much ?
  1992.         BMI ULOS
  1993.         STY SPEED
  1994. ULOS    LDA VALUE       ; Add speed to value (signed)
  1995.         CLC
  1996.         ADC SPEED
  1997.         BPL OK
  1998.         LDA SPEED       ; Banged to the side ?
  1999.         EOR #$FF
  2000.         CLC
  2001.         ADC #1
  2002.         STA SPEED
  2003.         LDA VALUE
  2004. OK      STA VALUE
  2005.         LSR             ; Value is twice the shift
  2006.         TAX             ; Remember the shift
  2007.         AND #7          ; lowest 3 bits
  2008.         ORA #8          ; (screen 40 chars wide)
  2009.         LDY POINTER
  2010.         STA SHIFTL,Y
  2011.         TXA
  2012.         LSR
  2013.         LSR
  2014.         LSR             ; highest 3 bits too
  2015.         ASL             ;  multiplicated by two
  2016.         STA SHIFTH,Y
  2017.         DEC POINTER
  2018.  
  2019.         LDA #1          ; Ack the interrupt
  2020.         STA $D019
  2021.         JMP $EA31       ; The normal interrupt routine
  2022.  
  2023. TEXT    SCR "THIS IS TECH-TECH FOR C=64 BY ME" ; Test text
  2024.                         ; SCR converts to screen codes
  2025.  
  2026. --------------------------------------------------------------------------
  2027. Basic loader for the Tech-tech demo program (PAL)
  2028.  
  2029. 1 S=49152
  2030. 2 DEFFNH(C)=C-48+7*(C>64)
  2031. 3 CH=0:READA$,A:PRINTA$:IFA$="END"THENPRINT"<clr>":SYS49152:END
  2032. 4 FORF=0TO31:Q=FNH(ASC(MID$(A$,F*2+1)))*16+FNH(ASC(MID$(A$,F*2+2)))
  2033. 5 CH=CH+Q:POKES,Q:S=S+1:NEXT:IFCH=ATHEN3
  2034. 6 PRINT"CHECKSUM ERROR":END
  2035. 100 DATA 78A97F8D0DDCA9818D1AD0A9AD8D1403A9C08D1503A9318D12D0A91B8D11D0A0, 3802
  2036. 101 DATA 00A24086FC84FB9891FBC8D0FBE6FC10F7A94485FCA9328501984A4A4AAABD5E, 4749
  2037. 102 DATA C10A0A0AAAA9D069008D4EC0BD00D091FBE8C88A2907D0F4C000D0DDA9378501, 4128
  2038. 103 DATA B9004499084C99105499185C99206499286C99307499387CC8D0E5A9008D3C03, 3258
  2039. 104 DATA 8D3D038D3E0398098099004099284099504099784099A04099C84099F0409918, 3236
  2040. 105 DATA 41A9EF994041C8C028D0DB5860A9968D00DDEAEAAC3C034CE1C0EAB900CF8D16, 4464
  2041. 106 DATA D0B900CE8D18D0EAEAEAEAEAEAEAEAEAEAEAEAEAEAEAAD12D0C9781016C8CAD0, 5850
  2042. 107 DATA D9B900CF8D16D0B900CE8D18D0C8A2074CBBC0A9978D00DDA9168D18D0A9088D, 4132
  2043. 108 DATA 16D0AD00DC2D01DCAAAC3E032908D008C8C00410038C3E038A2904D00888C0FC, 3160
  2044. 109 DATA 30038C3E03AD3D03186D3E03100EAD3E0349FF1869018D3E03AD3D038D3D034A, 2139
  2045. 110 DATA AA29070908AC3C039900CF8A4A4A4A0A9900CECE3C03A9018D19D04C31EA1408, 2759
  2046. 111 DATA 091320091320140503082D1405030820060F1220033D3634200219200D050F12, 652
  2047. 200 DATA END,0
  2048.  
  2049. --------------------------------------------------------------------------
  2050. Uuencoded C64 executable version of the demo program (PAL)
  2051.  
  2052. begin 644 tech.64
  2053. M`0@-"`$`4[(T.3$U,@`F"`(`EJ5(*$,ILD.K-#BJ-ZPH0[$V-"D`7`@#`$-(J
  2054. MLC`ZAT$D+$$ZF4$D.HM!)+(B14Y$(J>9(CS7R,G4Q3X\P\S2/B(ZGC0Y,34R;
  2055. M.H``DP@$`(%&LC"D,S$Z4;*E2"C&*,HH020L1JPRJC$I*2FL,3:JI4@HQBC*1
  2056. M*$$D+$:L,JHR*2DI`+0(!0!#2+)#2*I1.I=3+%$Z4[)3JC$Z@CJ+0TBR0:<S?
  2057. M`,P(!@"9(D-(14-+4U5-($524D]2(CJ``!D)9`"#(#<X03DW1CA$,$1$0T$YN
  2058. M.#$X1#%!1#!!.4%$.$0Q-#`S03E#,#A$,34P,T$Y,S$X1#$R1#!!.3%".$0Q+
  2059. M,40P03`L(#,X,#(`9@EE`(,@,#!!,C0P.#9&0S@T1D(Y.#DQ1D)#.$0P1D)%G
  2060. M-D9#,3!&-T$Y-#0X-49#03DS,C@U,#$Y.#1!-$$T04%!0D0U12P@-#<T.0"S+
  2061. M"68`@R!#,3!!,$$P04%!03E$,#8Y,#`X1#1%0S!"1#`P1#`Y,49"13A#.#A!]
  2062. M,CDP-T0P1C1#,#`P1#!$1$$Y,S<X-3`Q+"`T,3(X```*9P"#($(Y,#`T-#DYE
  2063. M,#@T0SDY,3`U-#DY,3@U0SDY,C`V-#DY,C@V0SDY,S`W-#DY,S@W0T,X1#!%,
  2064. M-4$Y,#`X1#-#,#,L(#,R-3@`30IH`(,@.$0S1#`S.$0S13`S.3@P.3@P.3DPU
  2065. M,#0P.3DR.#0P.3DU,#0P.3DW.#0P.3E!,#0P.3E#.#0P.3E&,#0P.3DQ."P@?
  2066. M,S(S-@":"FD`@R`T,4$Y148Y.30P-#%#.$,P,CA$,$1"-3@V,$$Y.38X1#`P-
  2067. M1$1%045!04,S0S`S-$-%,4,P14%".3`P0T8X1#$V+"`T-#8T`.<*:@"#($0PN
  2068. M0CDP,$-%.$0Q.$0P14%%045!14%%045!14%%045!14%%045!14%%045!040Q,
  2069. M,D0P0SDW.#$P,39#.$-!1#`L(#4X-3``-`MK`(,@1#E".3`P0T8X1#$V1#!"Q
  2070. M.3`P0T4X1#$X1#!#.$$R,#<T0T)"0S!!.3DW.$0P,$1$03DQ-CA$,3A$,$$Y_
  2071. M,#@X1"P@-#$S,@"!"VP`@R`Q-D0P040P,$1#,D0P,41#04%!0S-%,#,R.3`XN
  2072. M1#`P.$,X0S`P-#$P,#,X0S-%,#,X03(Y,#1$,#`X.#A#,$9#+"`S,38P`,X+'
  2073. M;0"#(#,P,#,X0S-%,#-!1#-$,#,Q.#9$,T4P,S$P,$5!1#-%,#,T.49&,3@V7
  2074. M.3`Q.$0S13`S040S1#`S.$0S1#`S-$$L(#(Q,SD`&PQN`(,@04$R.3`W,#DP;
  2075. M.$%#,T,P,SDY,#!#1CA!-$$T031!,$$Y.3`P0T5#13-#,#-!.3`Q.$0Q.40PI
  2076. M-$,S,45!,30P."P@,C<U.0!G#&\`@R`P.3$S,C`P.3$S,C`Q-#`U,#,P.#)$_
  2077. M,30P-3`S,#@R,#`V,$8Q,C(P,#,S1#,V,S0R,#`R,3DR,#!$,#4P1C$R+"`V&
  2078. 4-3(`<PS(`(,@14Y$+#````````HS!
  2079. ``
  2080. end
  2081.  
  2082. =============================================================================
  2083. ACE-128/64 PROGRAMMER'S REFERENCE GUIDE (version 0.9, for Release #10)
  2084. by Craig Bruce  <csbruce@ccnga.uwaterloo.ca>
  2085.  
  2086. 1. INTRODUCTION
  2087.  
  2088. ACE is a program for the Commodore 128 and Commodore 64 that provides a
  2089. command shell environment that is similar to that of Unix.  It is still
  2090. in the development stage, but enough of it is complete to be useful.
  2091. BTW, "ACE" means "Advanced Computing Environment" (well, advanced for
  2092. the 128/64).
  2093.  
  2094. So what is ACE all about?  Well, originally I tried a very ambitious
  2095. project of writing a multitasking operating system for the 128.  It got
  2096. it partially working, but it was much too fragile and incomplete to be
  2097. released.  It was a white-elephant project.  So, then then it came to me
  2098. that I was aiming much too high.  What I needed was a much simpler
  2099. system, one that would give the type of programming interface and
  2100. built-in features that I wanted, but one that was close enough to the
  2101. Commodore Kernal that it would not require much of a programming effort
  2102. to hack together a minimal implementation.  And thus, there was ACE-128
  2103. Release #1.  And I saw it was good.
  2104.  
  2105. What I wanted was a system that would be easier to program than the
  2106. Commodore Kernal with all its weird and wonderful device types,
  2107. non-existent memory management, and single-application design.  The
  2108. first important feature of this environment was to be able to pass
  2109. arguments from a command line to an application program by typing them
  2110. on the command line of the shell.  It is so annoying to load up a
  2111. program in BASIC, run it, and have it ask you for filenames in some
  2112. highly inconvenient way.
  2113.  
  2114. Another important system feature is to make near and far memory
  2115. management part of the system, and to make far memory convenient to use
  2116. for storing massively bulky data.  And so it was.  Also, we want to use
  2117. custom device drivers.  Commodore didn't really come through with the
  2118. device drivers it provided.  They are all REALLY SLOW.  And so that was,
  2119. also, although more custom device drivers are needed.  We want to have
  2120. the capability of making programs work together, rather than having
  2121. programs that are totally incompatible.  This functionality is still
  2122. under construction.  Programs will work together in this uni-tasking
  2123. environment by allowing a program to execute another program as a
  2124. sub-task, and then having control return to the calling program upon
  2125. exit.  Finally, we want some good quality applications and a powerful
  2126. command shell.  This is still being worked on and progress is coming
  2127. slowly.  Oh, almost forgot; we also want all programs to work on both
  2128. the C64 and C128, and they do.
  2129.  
  2130. This documentation refers to ACE release #10, which has not been
  2131. released yet (or even programmed).  In fact, the current release is #9.
  2132. Release #10 will be spruced up from the inside out to support the system
  2133. interface described in this document.  The current release is not being
  2134. described, because some of its features are not the best they could
  2135. possibly be.  Note, however, that the basic features, like "open",
  2136. "read", "dirread", and argv are not going to change.  Note also that the
  2137. version number of this "P.R.G." is 0.9.  This is because this is the
  2138. first incarnation of this document and, considering its nature, is bound
  2139. to hold a large number of small errors.
  2140.  
  2141. 2. SYSTEM INTERFACE
  2142.  
  2143. This section describes the interface between user programs and the ACE
  2144. kernel. I am very careful throughout this interface specification about
  2145. revealing any internal details that you do not strictly need to know.
  2146. The interface with ACE is not specified in terms of absolute addresses;
  2147. to aid in portability and extensibility, all interfaces are specified in
  2148. terms of symbolic assembler labels.  All of the ACE code is currently
  2149. written for the Buddy-128 assembler. Also, because these interface
  2150. absolute addresses are subject to change from version to version of the
  2151. kernel, executables compiled for use with an old version of ACE may not
  2152. work with a new version.
  2153.  
  2154. 2.1. ZERO-PAGE VARIABLES
  2155.  
  2156. There are four zero-page variables used for passing arguments in most
  2157. system calls.  They are as follows:
  2158.  
  2159. SYMBOL   BYTES   DESCRIPTION
  2160. -------  -----   -----------
  2161. zp           2   zeropage pointer
  2162. zw           2   zeropage word
  2163. mp           4   memory pointer
  2164. syswork     16   system work area / arguments
  2165.  
  2166. The first two, "zp" and "zw" are used in most calls.  They store simple
  2167. 16-bit values; "zp" usually stores pointers to strings in RAM0 memory.
  2168. The "mp" variable is 32-bits in length and is used exclusively for
  2169. passing far memory pointers for use with the far memory routines.  All
  2170. three of these variables will remain unchanged inside of system call
  2171. unless they will contain a return value.  "syswork" is a 16-byte array
  2172. used mainly when there are too many arguments for other variables to
  2173. hold, and all non-input and non-output bytes of "syswork" are subject to
  2174. change by the kernel.  All input arguments placed in the "syswork"
  2175. locations will be preserved unless otherwise indicated. [Note: In
  2176. Release #9, "zp" took on the rolls of both "zp" and "mp"].
  2177.  
  2178. 2.2. SYSTEM VARIABLES
  2179.  
  2180. There are several non-zeropage variables for storing system status and
  2181. return values:
  2182.  
  2183. SYMBOL          BYTES   DESCRIPTION
  2184. ----------      -----   -----------
  2185. errno               1   error number code returned by failed system calls
  2186. aceID               2   proof that user program is running on top of ACE
  2187. aceArgc             2   argument count for current process
  2188. aceArgv             2   argument vector address for current process
  2189. aceMemTop           2   highest address, plus one, that user prog can use
  2190. aceShellPath        2   ptr to storage for search path for executable programs
  2191. aceShellAlias       2   ptr to storage for shell command aliases
  2192. aceCurDirName       2   ptr to storage for the current directory name
  2193. aceExitData         2   ptr to storage for exit status from the last called prg
  2194. aceDirentBuffer <next>  storage for directory entries read from disk
  2195. aceDirentLength     -   really a constant: length in bytes of "aceDirentBuffer"
  2196. aceDirentBytes      4   bytes in file (usually inexact)
  2197. aceDirentDate       8   date of file in "YY:YY:MM:DD:HH:MM:SS:TW" format
  2198. aceDirentType       4   type of file in null-terminated string
  2199. aceDirentFlags      1   flags of file, "drwx*-et" format
  2200. aceDirentNameLen    1   length of name of file
  2201. aceDirentName      17   null-terminated name of file
  2202.  
  2203. ERRNO: "errno" is used to return error codes from system calls.  When a
  2204. system call ends in error, it sets the carry flag to "1", puts the error
  2205. code in "errno", and returns to the user program, after undoing any
  2206. system work completed at the time the error is encountered and aborting
  2207. the operation.  An error code number is stored in binary in the
  2208. single-byte "errno" location. The symbolic names for the possible error
  2209. codes are given in the next section. If no error occurs in a system
  2210. call, the carry flag will be cleared on return from the call.  Note that
  2211. not all system calls can run into errors, so not all set the carry flag
  2212. accordingly.
  2213.  
  2214. ID: "aceID" is a two-byte variable.  Its purpose is to allow user
  2215. programs to be sure that they are executing on top of ACE.  The low byte
  2216. (i.e., the first byte) must be equal to the symbolic constant "aceID1",
  2217. and the high, "aceID2". This will allow ACE applications to inform idiot
  2218. users that they cannot simply BOOT the program from BASIC, but rather
  2219. they must run ACE first.
  2220.  
  2221. ARGC: "aceArgc" is a two-byte unsigned number.  It gives the number of
  2222. arguments passed to the application by the program (usually the command
  2223. shell) that called the application.  The first argument is always the
  2224. name of the application program, so the count will always be at least
  2225. one.  Other arguments are optional.
  2226.  
  2227. ARGV: "aceArgv" is a two-byte RAM0 pointer.  Pay attention.  This
  2228. pointer points to the first entry of an array of two-byte pointers which
  2229. point to the null-terminated strings that are the arguments passed to
  2230. the application program by the caller.  (A null-terminated string is one
  2231. that ends with a zero byte).  To find the address of the N-th argument
  2232. to an application, multiply N by two, add the "aceArgv" contents to
  2233. that, and fetch the pointer from that address.  In this scheme, the
  2234. ever-present application name is the 0-th argument.  The argv[argc]
  2235. element of the argument vector will always contain a value of $0000, a
  2236. null pointer.
  2237.  
  2238. MEM-TOP: "aceMemTop" is a two-byte RAM0 pointer.  This points to one
  2239. byte past the highest byte that the application program is allowed to
  2240. use.  All application programs are loaded into memory at address
  2241. "aceAppAddress" (next section), and all memory between the end of the
  2242. progam code and "aceMemTop" can be used for temporary variables, file
  2243. buffers, etc.  The main problem with this approach is that there are no
  2244. guarantees about how much memory your application will get to play with.
  2245. Many applications, such as simple file utilities, can simply use all
  2246. available memory for a file buffer, but other programs, such as a file
  2247. compressor, may have much greater demand for "near" memory.  [Note: this
  2248. variable has a different name in Release #9].
  2249.  
  2250. SHELL-PATH: "aceShellPath" is a two-byte RAM0 pointer.  This points to
  2251. the page of memory that stores the pathnames of directories to search
  2252. through in order to find executable files.  Each pathname is stored as a
  2253. null-terminated string, and the list is terminated by an empty string
  2254. (containing only the zero character).  This is intended to be used by
  2255. the shell program, or any other program that is so inclined, to examine
  2256. or alter the search path.  The search paths specified in the path page
  2257. are global variables and are used by all programs that make the "exec"
  2258. system call.  This mechanism for reading/altering the executable search
  2259. path may be changed in the future.
  2260.  
  2261. SHELL-ALIAS: "aceShellAlias" is a two-byte RAM0 pointer.  This points to
  2262. the page of memory that stores the aliases to be used with the command
  2263. shell.  An alias is a string that is substituted in the place of a
  2264. command name on a shell command line whenever a certain command name
  2265. comes up.  For example, you might specify if the user enters the command
  2266. "list a:" that the command name "list" be string-replaced with "cls;xls
  2267. -l".  Each alias is stored with the command name first, followed by an
  2268. equals character ("="), followed by the string to substitute, followed
  2269. by a zero.  The alias list is terminated by an empty string.  This
  2270. mechanism may be extended in the future to allow multiple pages of
  2271. aliases, or may be changed completely.
  2272.  
  2273. CUR-DIR-NAME: "aceCurDirName" is a two-byte RAM0 pointer.  It points to
  2274. the null-terminated string indicating the current directory.  The user
  2275. is not supposed to modify this value, and the value will not always give
  2276. a full pathname.  The implementation of this feature may need to change
  2277. in future versions of ACE.
  2278.  
  2279. ACE-EXIT-DATA: "aceExitData" is a two-byte RAM0 pointer.  It points to
  2280. the 256-byte buffer allocated for user programs to give detailed return
  2281. information upon exiting back to their parent program.  See the "exit"
  2282. system call.  User programs are allowed to read and write this storage.
  2283. An example use of this feature would be a compiler program returning the
  2284. line number and character position, and description of a compilation
  2285. error to a text editor, so the editor can position the cursor and
  2286. display the error message for user convenience.  The implementation of
  2287. this feature may need to change in future versions of ACE.
  2288.  
  2289. DIRENT-BUFFER: "aceDirentBuffer" is a buffer used for storing directory
  2290. information read with the "dirread" system call, and is
  2291. "aceDirentLength" bytes long.  Only a single directory entry is
  2292. (logically) read from disk at a time.  The individual fields of a read
  2293. directory entry are accessed by the fields described next.  This field
  2294. is also used for returning disk name information and the number of bytes
  2295. free on a disk drive (see the "dirread" system call).
  2296.  
  2297. DIRENT-BYTES: "aceDirentBytes" is a four-byte (32-bit) unsigned field.
  2298. As always, the bytes are addressed from least significant to most
  2299. significant. This field gives the number of bytes in the file.  Note
  2300. that this value may not be exact, since Commodore decided to store sizes
  2301. in disk blocks rather than bytes.  For devices that report only block
  2302. counts (i.e., every disk device currently supported), the number of
  2303. bytes returned is the number of blocks multiplied by 254.  This field,
  2304. as well and the other dirent fields are absolute addresses, not offsets
  2305. from aceDirentBuffer.
  2306.  
  2307. DIRENT-DATE: "aceDirentDate" is an eight-byte array of binary coded
  2308. decimal values, stored from most significant digits to least
  2309. significant.  The first byte contains the BCD century, the second the
  2310. year, and so on, and the last byte contains the number of tenths of
  2311. seconds in its most significant nybble and a code for the day-of-week in
  2312. its least significant nybble.  Sunday has code 1, Monday 2, etc.,
  2313. Saturday 7, and a code of 0 means "unknown".  This is the standard
  2314. format for all dates used in ACE.  This format is abstracted as
  2315. "YY:YY:MM:DD:HH:MM:SS:TW".  For disk devices that don't support dates,
  2316. this field will be set to all zeroes, which can be conveniently
  2317. interpreted as the NULL date, negative infinity, or as the time that
  2318. J.C. was a seven-year-old boy.
  2319.  
  2320. DIRENT-TYPE: "aceDirentType" is a three-character (four-byte)
  2321. null-terminated string.  It indicates what type the file is, in
  2322. lowercase PETSCII.  Standard types such as "SEQ" and "PRG" will be
  2323. returned, as well and other possibilities for custom device drivers.
  2324.  
  2325. DIRENT-FLAGS: "aceDirentFlags" is a one-byte field that is interpreted
  2326. as consisting of eight independent one-bit fields.  The abstract view of
  2327. the fields is "drwx*-et".  "d" means that the item is a subdirectory
  2328. (otherwise it is a regular file), "r" means the item is readable, "w"
  2329. means the item is writable, and "x" means the item is executable.  The
  2330. "x" option is really not supported currently.  "*" means the item is
  2331. improperly closed (a "splat" file in Commodore-DOS terminology).  The
  2332. "-" field is currently undefined.  "e" means that the value given in the
  2333. "aceDirentBytes" field is actually exact, and "t" means the file should
  2334. be interpreted as being a "text" file (otherwise, its type is either
  2335. binary or unknown).  The bit fields are all booleans; a value of "1"
  2336. means true, "0", false.  The "d" bit occupies the 128-bit position, etc.
  2337.  
  2338. DIRENT-NAME-LEN: "aceDirentNameLen" is a one-byte number.  It gives the
  2339. number of characters in the filename.  It is present for convenience.
  2340.  
  2341. DIRENT-NAME: "aceDirentName" is a 16-character (17-byte) null-terminated
  2342. character string field.  It gives the name of the file or directory or
  2343. disk. Filenames used with ACE are limited to 16 characters.
  2344.  
  2345. 2.3. SYSTEM CONSTANTS
  2346.  
  2347. There are several symbolic constants that are used with the ACE system
  2348. interface:
  2349.  
  2350. SYMBOL                   DESCRIPTION
  2351. -------------------      -------------------------
  2352. aceAppAddress            the start address of applications
  2353. aceID1                   the id characters used to identify ACE applications
  2354. aceID2                   ...
  2355. aceID3                   ...
  2356. aceMemNull               the far memory type code used to indicate null ptrs
  2357. aceMemREU                far mem type code for Ram Expansion Unit memory
  2358. aceMemInternal           far mem type code for internal memory
  2359. aceMemRLREU              far mem type code for REU memory accessed thru RAMLink
  2360. aceMemRL                 far mem type code for direct-access RAMLink memory
  2361. aceErrStopped            error code for syscall aborted by STOP key
  2362. aceErrTooManyFiles       err: too many files already opened to open another
  2363. aceErrFileOpen           err: don't know what this means
  2364. aceErrFileNotOpen        err: the given file descriptor is not actually open
  2365. aceErrFileNotFound       err: named file to open for reading does not exist
  2366. aceErrDeviceNotPresent   err: the specified physical device is not online
  2367. aceErrFileNotInput       err: file cannot be opened for reading
  2368. aceErrFileNotOutput      err: file cannot be opened for writing
  2369. aceErrMissingFilename    err: pathname component is the null string
  2370. aceErrIllegalDevice      err: the specified device cannot do what you want
  2371. aceErrWriteProtect       err: trying to write to a disk that is write-protected
  2372. aceErrFileExists         err: trying to open for writing file that exists
  2373. aceErrFileTypeMismatch   err: you specified the file type incorrectly
  2374. aceErrNoChannel          err: too many open files on disk drive to open another
  2375. aceErrInsufficientMemory err: ACE could not allocate the memory you requested
  2376. aceErrOpenDirectory      err: you are trying to open a dir as if it were a file
  2377. aceErrDiskOnlyOperation  err: trying to perform disk-only op on char device
  2378. aceErrNullPointer        err: trying to dereference a null far pointer
  2379. aceErrInvalidFreeParms   err: bad call to "pagefree": misaligned/wrong size
  2380. aceErrFreeNotOwned       err: trying to free far memory you don't own
  2381. stdin                    file descriptor reserved for stdin input stream
  2382. stdout                   file descriptor reserved for stdout output stream
  2383. stderr                   file descriptor reserved for stderr output stream
  2384.  
  2385. "aceAppAddress", as discussed before, is the address that application
  2386. programs are loaded into memory at.  They must, of course, be compiled
  2387. to execute starting at this address.
  2388.  
  2389. The "aceMem" group of constants are for use with the "pagealloc" system
  2390. call, except for "aceMemNull", which may be used by application programs
  2391. for indicating null far pointers.  The "pagealloc" call allows you to
  2392. specify what types of memory you are willing to accept.  This is
  2393. important because the difference types of memory have different
  2394. performance characteristics.  ACE will try to give you the fastest
  2395. memory that is available.  Ram Expansion Unit memory has startup and
  2396. byte-transfer times of about 60 us (microseconds) and 1 us,
  2397. respectively.  This is the fastest type of far memory.  Internal memory
  2398. has a startup time of 24 us and a byte-transfer time of between 7 and 14
  2399. us (depending on whether accessing RAM0 or RAM1+).  REU memory accessed
  2400. through a RAMLink has a terrible startup time of 1000 us and a
  2401. byte-transfer time of 2 us.  Direct-access RAMLink memory has a startup
  2402. time of 1000 us and a byte-transfer time of 16 us.  All these times are
  2403. for the C128 in 2 MHz mode.
  2404.  
  2405. The "aceErr" group gives the error codes returned by system calls.  The
  2406. error codes are returned in the "errno" variable.  Not all possible
  2407. error codes from Commodore disk drives are covered, but the important
  2408. ones are.  Finally, the "std" files group give the symbolic file
  2409. descriptor identifiers of the default input, output, and error output
  2410. file streams.
  2411.  
  2412. 2.4. SYSTEM CALLS
  2413.  
  2414. All system calls are called by setting up arguments in specified
  2415. processor registers and memory locations, executing a JSR to the system
  2416. call address, and pulling the return values out of processor registers
  2417. and memory locations.
  2418.  
  2419. 2.1. FILE CALLS
  2420.  
  2421. NAME   :  open
  2422. PURPOSE:  open a file
  2423. ARGS   :  (zp) = pathname
  2424.           .A   = file mode ("r", "w", or "a")
  2425. RETURNS:  .A   = file descriptor number
  2426.           .CS  = error occurred flag
  2427. ALTERS :  .X, .Y, errno
  2428.  
  2429. Opens a file.  The name of the file is given by a pointer to a
  2430. null-terminated string, and may contain device names and pathnames as
  2431. specified in the ACE user documentation.  The file mode is a PETSCII
  2432. character.  "r" means to open the file for reading, "w" means to open
  2433. the file for writing, and "a" means to open the file for appending
  2434. (writing, starting at the end of the file).  An error will be returned
  2435. if you attempt to open for reading or appending a file that does not
  2436. exist, or if you attempt to open for writing a file that does already
  2437. exist.  If you wish to overwrite an existing file, you will have to call
  2438. "remove" to delete the old version before opening the new version for
  2439. writing.
  2440.  
  2441. The function returns a file descriptor number, which is a small unsigned
  2442. integer that is used with other file calls to specify the file that has
  2443. been opened.  File descriptors numbered 0, 1, and 2 are used for stdin,
  2444. stdout, and stderr, respectively.  The file descriptor returned will be
  2445. the minimum number that is not currently in use.  These numbers are
  2446. system-wide (rather than local to a process as in Unix), and this has
  2447. some implications for I/O redirection (see the "fdswap" call below).
  2448.  
  2449. Restrictions: only so many Kernal files allowed to be open on a disk
  2450. device, and there is a system maximum of open files.  You will get a
  2451. "too many files" error if you ever exceed this limit.  Also, because of
  2452. the nature of Commodore-DOS, there may be even tighter restrictions on
  2453. the number of files that can be simultaneously open on a single disk
  2454. device, resulting in a "no channel" error.  Note that this call checks
  2455. the status channel of Commodore disk drives on each open, so you don't
  2456. have to (and should not anyway).
  2457.  
  2458. If the current program exits either by calling "exit" or simply by doing
  2459. the last RTS, all files that were opened by the program and are still
  2460. open will be automatically closed by the system before returning to the
  2461. parent program.
  2462.  
  2463. NAME   :  close
  2464. PURPOSE:  close an open file
  2465. ARGS   :  .A   = File descriptor number
  2466. RETURNS:  .CS  = error occurred flag
  2467. ALTERS :  .A, .X, .Y, errno
  2468.  
  2469. Closes an open file.  Not much to say about this one.
  2470.  
  2471. NAME   :  read
  2472. PURPOSE:  read data from an open file
  2473. ARGS   :  .X   = File descriptor number
  2474.           (zp) = pointer to buffer to store data into
  2475.           .AY  = maximum number of bytes to read
  2476. RETURNS:  (zw) = .AY=number of bytes actually read in
  2477.           .CS  = error occurred flag
  2478.           .ZS  = EOF reached flag
  2479. ALTERS :  .X, errno
  2480.  
  2481. Reads data from the current position of an open file.  Up to the
  2482. specified maximum number of bytes will be read.  You should not give a
  2483. maximum of zero bytes, or you may misinterpret an EOF (end of file).
  2484. The buffer must be at least the size of the maximum number of bytes to
  2485. read.  The data are not interpreted in any way, so it is the
  2486. programmer's responsibility to search for carriage return characters to
  2487. locate lines of input, if he so desires. However, for the console the
  2488. input is naturally divided up into lines, so each call will return an
  2489. entire line of bytes if the buffer is large enough.  There are no
  2490. guarantees about the number of bytes that will be returned, except that
  2491. it will be between 1 and the buffer size.  So, if you wish to read a
  2492. certain number of bytes, you may have to make multiple read calls.
  2493.  
  2494. The call returns the number of bytes read in both the .AY register pair
  2495. and in (zw), for added convenience.  [Note: in ACE Release #9, the
  2496. number of bytes read are returned only in the .AY registers, not in
  2497. (zw).]  A return of zero bytes read means that the end of the file has
  2498. been reached.  An attempt to read beyond the end of file will simply
  2499. give another EOF return.  End of file is also returned in the .Z flag of
  2500. the processor.
  2501.  
  2502. NAME   :  write
  2503. PURPOSE:  write data to an open file
  2504. ARGS   :  .X   = file descriptor number
  2505.           (zp) = pointer to data to be written
  2506.           .AY  = length of data to be written in bytes
  2507. RETURNS:  .CS  = error occurred
  2508. ALTERS :  .A, .X, .Y, errno
  2509.  
  2510. Writes data at the current position of an open file.  [Note: ACE Release
  2511. #9 also alters locations (zw) when writing to the console.  This problem
  2512. will be corrected.]
  2513.  
  2514. NAME   :  fastopen
  2515. PURPOSE:  open a file for fast reading
  2516. ARGS   :  (zp) = Name
  2517.           .A   = file mode (must be "r")
  2518. RETURNS:  .A   = file descriptor number
  2519.           .CS  = error occurred flag
  2520. ALTERS :  .X, .Y, errno
  2521.  
  2522. This performs the same function as the regular "open" call, except this
  2523. style of file accessing will allow files to be read much faster than the
  2524. other.  On devices that are so equipped, the "fastload" burst command is
  2525. used (similar shortcuts may be possible with other devices too).  The
  2526. drawback of this increased speed is that no other device I/O can take
  2527. place while a file is opened for "fast" access, not even to other
  2528. devices, except for output to the console.  Other files can be open,
  2529. just not accessed.  You also cannot open more than one "fast" file at a
  2530. time.  Interrupts will be disabled while a file is open for fast
  2531. accessing, so the user cannot re-enable them, for technical reasons.
  2532. The arguments to this call are exactly the same as the regular "open" to
  2533. make it easy to switch from using one to the other.  [Note: these "fast"
  2534. calls do not exist in Release #9].
  2535.  
  2536. NAME   :  fastclose
  2537. PURPOSE:  close the file that was opened for fast reading
  2538. ARGS   :  .A   = File descriptor number
  2539. RETURNS:  .CS  = error occurred flag
  2540. ALTERS :  .A, .X, .Y, errno
  2541.  
  2542. Closes the file that was opened for fast reading.
  2543.  
  2544. NAME   :  fastread
  2545. PURPOSE:  read data from the file opened for fast reading
  2546. ARGS   :  .X   = File descriptor number
  2547.           (zp) = pointer to buffer to store data into
  2548.           .AY  = maximum number of bytes to read
  2549. RETURNS:  (zw) = .AY=number of bytes actually read in
  2550.           .CS  = error occurred flag
  2551.           .ZS  = EOF reached flag
  2552. ALTERS :  .X, errno
  2553.  
  2554. Read data from the (one) file that is currently opened for "fast"
  2555. reading. The arguments and semantics are equivalent to the regular
  2556. "read" call.
  2557.  
  2558. NAME   :  bload
  2559. PURPOSE:  binary load
  2560. ARGS   :  (zp) = pathname
  2561.           .AY  = address to load file
  2562.           (zw) = highest address that file may occupy, plus one
  2563. RETURNS:  .AY  = end address of load, plus one
  2564.           .CS  = error occurred flag
  2565. ALTERS :  .X, errno
  2566.  
  2567. Binary-load a file directly into memory.  If the file will not fit into
  2568. the specified space, an error will be returned and the load truncated if
  2569. the device supports truncation; otherwise, important data may be
  2570. overwritten.
  2571.  
  2572. NAME   :  remove
  2573. PURPOSE:  delete a file
  2574. ARGS   :  (zp) = pathname
  2575. RETURNS:  .CS  = error occurred flag
  2576. ALTERS :  .A, .X, .Y, errno
  2577.  
  2578. Delete the named file.
  2579.  
  2580. NAME   :  rename
  2581. PURPOSE:  rename a file or directory
  2582. ARGS   :  (zp) = old filename
  2583.           (zw) = new filename
  2584. RETURNS:  .CS  = error occurred flag
  2585. ALTERS :  .A, .X, .Y, errno
  2586.  
  2587. Renames a file or directory.  If a file with the new name already
  2588. exists, then the operation will be aborted and a "file exists" error
  2589. will be returned.  On most devices, the file to be renamed must be in
  2590. the current directory and the new name may not include any path, just a
  2591. filename.
  2592.  
  2593. NAME   :  devinfo
  2594. PURPOSE:  give information about device
  2595. ARGS   :  .X   = file descriptor number
  2596. RETURNS:  .A   = device type code
  2597.           .X   = number of columns on device
  2598.           .Y   = number of rows per "page" of device
  2599.           .CS  = error occurred flag
  2600. ALTERS :  errno
  2601.  
  2602. This call returns information about the device of an open file.  There
  2603. are four possible values for the device type code: 0==console,
  2604. 1==character-oriented device, and 2==disk device.  The number of rows
  2605. and columns per "page" of the device are also returned.  For the
  2606. console, this will be the current window size.  For a character-oriented
  2607. device, it will be the natural size (typically 80 columns by 66 rows),
  2608. and for a disk, it will be 40 columns in 64 mode or 80 columns in 128
  2609. mode, both by 66 rows.
  2610.  
  2611. NAME   :  fdswap
  2612. PURPOSE:  swap two file descriptor numbers
  2613. ARGS   :  .X   = first file descriptor number
  2614.           .Y   = second file descriptor number
  2615. RETURNS:  .CS  = error occurred flag
  2616. ALTERS :  .A, .X, .Y, errno
  2617.  
  2618. This call swaps meanings of two file descriptor numbers.  The file
  2619. descriptors may be either in use or not use when the call is made.  This
  2620. call is intended to be used to redirect the stdin, stdout, and stderr
  2621. file streams.  To do this, simply open the new file intended to be, for
  2622. example, stdout, and swap the file descriptor number returned from the
  2623. open with file descriptor number 1 (stdout).  Poof.  Then call your
  2624. subroutine or external program, and on return, swap the two file
  2625. descriptors back, and close the redirection file.
  2626.  
  2627. 2.2. DIRECTORY CALLS
  2628.  
  2629. NAME   :  diropen
  2630. PURPOSE:  open a directory for scanning its directory entries
  2631. ARGS   :  (zp) = directory pathname
  2632. RETURNS:  .A   = file descriptor number
  2633.           .CS  = error occurred flag
  2634. ALTERS :  .X, .Y, errno
  2635.  
  2636. This call opens a directory for reading its entries.  It returns a
  2637. "file" descriptor number to you to use for reading successive directory
  2638. entires with the "dirread" call.  The pathname that you give to this
  2639. call must be a proper directory name like "a:" or "c:2//c64/games/:",
  2640. ending with a colon character. You can have directories from multiple
  2641. devices open for reading at one time, but you cannot have the directory
  2642. of one device open multiple times.  Also note that you cannot pass
  2643. wildcards to this call; you will receive the entire directory listing.
  2644.  
  2645. NAME   :  dirclose
  2646. PURPOSE:  close a directory opened for scanning
  2647. ARGS   :  .A   = file descriptor number
  2648. RETURNS:  .CS  = error occurred flag
  2649. ALTERS :  .A, .X, .Y, errno
  2650.  
  2651. Closes a directory that is open for reading.  You can make this call at
  2652. any point while scanning a directory; you do not have to finish scanning
  2653. an entire directory first.
  2654.  
  2655. NAME   :  dirread
  2656. PURPOSE:  read the next directory entry from an open directory
  2657. ARGS   :  .X   = file descriptor number
  2658. RETURNS:  .Z   = end of directory flag
  2659.           .CS  = error occurred flag
  2660.           aceDirentBuffer = new directory entry data
  2661. ALTERS :  .A, .X, .Y, errno
  2662.  
  2663. Reads the next directory entry from the specified open directory into
  2664. the system interface global variable "aceDirentBuffer" described
  2665. earlier.  After opening a directory for reading, the first time you call
  2666. this routine, you will receive the name of the disk (or directory).  The
  2667. "aceDirentNameLen" and "aceDirentName" fields are the only ones that
  2668. will contain information; the rest of the fields should be ignored.
  2669.  
  2670. Each subsequent call to this routine will return the next directory
  2671. entry in the directory.  All of the "dirent" fields will be valid for
  2672. these.
  2673.  
  2674. Then, after all directory entries have been read through, the last call
  2675. will return a directory entry with a null (zero-length) name.  This
  2676. corresponds to the "blocks free" line in a Commodore disk directory
  2677. listing.  The "aceDirentBytes" field for this last entry will be set to
  2678. the number of bytes available for storage on the disk.  On a Commodore
  2679. disk drive, this will be the number of blocks free multiplied by 254.
  2680. After reading this last entry, you should close the directory.
  2681.  
  2682. At any time, if something bizarre happens to the listing from the disk
  2683. that is not considered an error (I don't actually know if this is
  2684. possible or not), then the .Z flag will be set, indicating the abrupt
  2685. ending of the directory listing.
  2686.  
  2687. NAME   :  isdir
  2688. PURPOSE:  determine whether the given pathname is for a file or a directory
  2689. ARGS   :  (zp) = pathname
  2690. RETURNS:  .A   = device identifier
  2691.           .X   = is a disk device flag
  2692.           .Y   = is a directory flag
  2693.           .CS  = error occurred flag
  2694. ALTERS :  errno
  2695.  
  2696. Given a properly formatted directoryname or filename, this routine will
  2697. return whether the name is for a file or a directory, whether the device
  2698. of the file or directory is a disk or character device, and the system
  2699. identifier for the device.  The two flags return $FF for true and $00
  2700. for false.  The device identifier is superfluous for now, but a
  2701. "devinfo" call may be added later. Note that this file does not indicate
  2702. whether the file/directory actually exists or not.
  2703.  
  2704. NAME   :  chdir
  2705. PURPOSE:  change the current working directory
  2706. ARGS   :  (zp) = new directory pathname
  2707. RETURNS:  .CS  = error occurred flag
  2708. ALTERS :  .A, .X, .Y, errno
  2709.  
  2710. Changes the current working directory to the named directory.  Too bad
  2711. the Commodore Kernal doesn't have a similar call.  Unlike the "cd" shell
  2712. command, the argument has to be a properly formatted directory name.
  2713. Note that only directories in native partitions on CMD devices are
  2714. supported by this command; the 1581's crummy idea of partitions is not
  2715. supported.
  2716.  
  2717. NAME   :  cdhome
  2718. PURPOSE:  change the current working directory back to the "home" directory
  2719. ARGS   :  <none>
  2720. RETURNS:  .CS  = error occurred flag
  2721. ALTERS :  .A, .X, .Y, errno
  2722.  
  2723. Changes the current working directory back to the "home" directory that
  2724. is defined in the "config.sys" file as the initial directory.
  2725.  
  2726. NAME   :  mkdir
  2727. PURPOSE:  create a new directory
  2728. ARGS   :  (zp) = pathname of new directory
  2729. RETURNS:  .CS  = error occurred flag
  2730. ALTERS :  .A, .X, .Y, errno
  2731.  
  2732. Creates a new directory.  I'm not sure, but I think that the current
  2733. directory has to be the parent directory of the directory you want to
  2734. create.  This may be required by CMD devices, which will be the lowest
  2735. common denominator for directory support.  [Note: this call is not
  2736. implemented in Release #9].
  2737.  
  2738. NAME   :  rmdir
  2739. PURPOSE:  delete an empty existing directory
  2740. ARGS   :  (zp) = pathname of empty directory to remove
  2741. RETURNS:  .CS  = error occurred flag
  2742. ALTERS :  .A, .X, .Y, errno
  2743.  
  2744. Deletes an existing directory.  The directory must be empty (have no
  2745. directory entries) in order for this command to succeed.  Again, I am
  2746. pretty sure that you have to be "in" the parent directory of the one to
  2747. be deleted, since this is probably required by CMD devices.  [Note: this
  2748. call is not implemented in Release #9].
  2749.  
  2750. 2.3. MEMORY CALLS
  2751.  
  2752. The calls given in this section are to be used for accessing "far"
  2753. memory in ACE, which includes all REU, RAMLink, RAM1 and above, and
  2754. sections of RAM0 that are not in the application program area.
  2755. Applications are not allowed to access "far" memory directly, because
  2756. the practice of bypassing the operating system would undoubtedly lead to
  2757. problems (can you say "MS-DOS"?).
  2758.  
  2759. All of these calls use a 32-bit pointer that is stored in the zero-page
  2760. argument field "mp" (memory pointer).  This field is to be interpreted
  2761. as consisting of low and high words.  The low word, which of course come
  2762. first, is the offset into the memory "bank" that is contained in the
  2763. high word. Users may assume that offsets within a bank are continuous,
  2764. so operations like addition may be performed without fear on offsets, to
  2765. access subfields of a structure, for example.  You may not, however,
  2766. make any interpretation of the bank word.  An application should only
  2767. access far memory that it has allocated for itself via the "pagealloc"
  2768. call.
  2769.  
  2770. NAME   :  zpload
  2771. ARGS   :  [mp] = source far memory pointer
  2772.           .X   = destination zero-page address
  2773.           .Y   = transfer length
  2774. RETURNS:  .CS  = error occurred flag
  2775. ALTERS :  .A, .X, .Y, errno
  2776.  
  2777. Load zero-page locations with the contents of far memory.  "mp", of
  2778. course, gives the address of the first byte of far memory to be
  2779. retrieved.  The X register is loaded with the first address of the
  2780. storage space for the data on zero page.  It must be in the application
  2781. zero-page space.  The Y register holds the number of bytes to be
  2782. transferred, which, considering that transfers must be to the
  2783. application zero-page storage, must be 126 bytes or less.  This routine
  2784. will return a "reference through null pointer" if [mp] contains a null
  2785. pointer.
  2786.  
  2787. NAME   :  zpstore
  2788. ARGS   :  .X   = source zero-page address
  2789.           [mp] = destination far memory pointer
  2790.           .Y   = transfer length
  2791. RETURNS:  .CS  = error occurred flag
  2792. ALTERS :  .A, .X, .Y, errno
  2793.  
  2794. This routine is the complement of "zpload"; this transfers data from
  2795. zero page to far memory.  The arguments and restrictions are the same as
  2796. "zpload".
  2797.  
  2798. NAME   :  fetch
  2799. ARGS   :  [mp] = source far memory pointer
  2800.           (zp) = destination RAM0 pointer
  2801.           .AY  = transfer length
  2802. RETURNS:  .CS  = error occurred flag
  2803. ALTERS :  .A, .X, .Y, errno
  2804.  
  2805. This routine will fetch up to 64K of data from far memory into RAM0
  2806. memory where it can be accessed directly by the processor.  The
  2807. arguments should mostly speak for themselves.  You should not fetch into
  2808. RAM0 memory that is not specifically allocated to the application.  You
  2809. will get an error if you try to use a null far pointer.
  2810.  
  2811. NAME   :  stash
  2812. ARGS   :  (zp) = source RAM0 pointer
  2813.           [mp] = destination far memory pointer
  2814.           .AY  = transfer length
  2815. RETURNS:  .CS  = error occurred flag
  2816. ALTERS :  .A, .X, .Y, errno
  2817.  
  2818. This is the complement of "fetch" and operates analogously, except that
  2819. it transfers data from RAM0 to far memory.
  2820.  
  2821. NAME   :  pagealloc
  2822. ARGS   :  .A   = requested number of pages to be allocated
  2823.           .X   = starting "type" of memory to search
  2824.           .Y   = ending "type" of memory to search, inclusive
  2825. RETURNS:  [mp] = far memory pointer to start of allocated memory
  2826.           .CS  = error occurred flag
  2827. ALTERS :  .A, .X, .Y, errno
  2828.  
  2829. This routine allocates a given number of contiguous far-memory pages for
  2830. use by the application, and returns a pointer to the first byte of the
  2831. first page. On calling, the accumulator contains the number of pages to
  2832. allocate (a page is 256 contiguous bytes aligned on a 256-byte address
  2833. (i.e., the low byte of a page address is all zeros)).
  2834.  
  2835. The X and Y registers contain the start and end "types" of far memory to
  2836. search for the required allocation.  The possible types are mentioned in
  2837. the System Constants section.  The numeric values for the "aceMem"
  2838. constants are arranged in order of accessing speed.  So, if your
  2839. application has speed requirements that dictate, for example, that
  2840. RAMLink memory should not be used, then you would call "pagealloc" with
  2841. a search range of .X=0 to .Y=aceMemInternal.  If you wanted to say you
  2842. are willing to accept any memory the system can give to you, you would
  2843. specify .X=0 to .Y=255.  The values of 0 and 255 will be converted to
  2844. the fastest and slowest memory available.  ACE will give you the fastest
  2845. type of memory, from what you specify as acceptable, that it can.  If
  2846. you had an application that you didn't want to waste the high-speed
  2847. memory on, you could first call "pagealloc" asking for slow memory, such
  2848. as .X=aceMemRLREU to .Y=255, and if there is none of that type of memory
  2849. left, make another call with .X=0 to .Y=aceMemRLREU-1.
  2850.  
  2851. This routine will then search its available free memory for a chunk
  2852. fitting your specifications.  If it cannot find one, the routine will
  2853. return a "insufficient memory" error and a null pointer.  Note that this
  2854. error may occur if there is actually the correct amount of memory free
  2855. but just not in a big enough contiguous chunk.  If successful, this
  2856. routine will return in "mp" a pointer to the first byte of the first
  2857. page of the allocated memory.
  2858.  
  2859. If you call a subprogram with the "exec" call while the current program
  2860. is holding far memory, that far memory will be kept allocated to your
  2861. program and will be safe while the child program is executing.  If you
  2862. don't deallocate the memory with "pagefree" before exiting back to your
  2863. parent program, then the system will automatically deallocate all memory
  2864. allocated to you.  So, have no fear about calling "exit" if you are in
  2865. the middle of complicated far memory manipulation when a fatal error
  2866. condition is discovered and you don't feel like figuring out what memory
  2867. your program owns and deallocating it.
  2868.  
  2869. Some applications will want to have the most amount of memory to work
  2870. with, and if there is free space in the application program area that
  2871. the program is not using directly, then you may want to use that as
  2872. "far" memory.  To do this, you will need to write your own stub routines
  2873. that manage page allocation and deallocation requests to the near
  2874. memory, and calls the "pagealloc" and "pagefree" routines to manage the
  2875. far memory.  The "sort" program distributed with ACE does this.  Please
  2876. note that you CANNOT simply free the unused memory of the application
  2877. program area and expect the system to manage it.  Bad stuff would
  2878. happen.
  2879.  
  2880. Some applications will want to have a byte-oriented memory allocation
  2881. service rather than a page-oriented service.  You can build a
  2882. byte-oriented service on top of the page-oriented service in your
  2883. application programs that manage memory for the application and ask the
  2884. system for pages whenever more memory is required by the application.
  2885. Note that this still means that allocated memory will be freed
  2886. automatically when an application exits.  The "sort" program implements
  2887. this byte-oriented service, so you can check its source code to see how
  2888. this is done (or to simply cut and paste the code into your own
  2889. program).
  2890.  
  2891. NAME   :  pagefree
  2892. ARGS   :  [mp] = far memory pointer to start of memory to be freed
  2893.           .A   = number of pages to be freed
  2894. RETURNS:  .CS  = error occurred flag
  2895. ALTERS :  .A, .X, .Y, errno
  2896.  
  2897. This deallocates memory that was allocated to a process by using the
  2898. "pagealloc" system call.  You will get an error return if you try to
  2899. deallocate memory that you don't own.
  2900.  
  2901. 2.4. SCREEN CONTROL CALLS
  2902.  
  2903. This section describes the system calls that are available to
  2904. application programmers for full-screen applications.  These calls are
  2905. intended to be general enough to handle different screen hardware (the
  2906. VIC and VDC chips and a VIC soft-80-column bitmap screen, and possibly
  2907. others).  These calls are also designed to be efficient as possible, to
  2908. discourage progammers from attempting to bypass using them.  Bypassing
  2909. these calls would be a bad thing.
  2910.  
  2911. The calls are designed around the C-128/PET concept of a window.  There
  2912. is only one active window on the display at a time, which may be is
  2913. large as the entire screen or as small as 1x1 character cells.  This
  2914. window is very cheap to setup and tear down.  An application can have
  2915. multiple windows on the screen by switching the active window around.
  2916.  
  2917. In the calls below, all mention of "sw" in the arguments and return
  2918. values refer to the "syswork" array.  For many calls, there is a
  2919. "char/color/ high-attribute" argument.  This argument determines which
  2920. parts of a screen location will be modified.  There are three components
  2921. to each screen location: the character code, the color code, and the
  2922. high-attributes.  The character code is exactly the same as the PETSCII
  2923. code for the character that you want to display (unlike the screen-code
  2924. arrangement that Commodore chose). There are 128 individual characters
  2925. in the normal PETSCII positions, and 128 reversed images of the
  2926. characters in the most sensible other positions.  The codes are as
  2927. follows:
  2928.  
  2929. CODES (hex)   DESCRIPTION
  2930. -----------   -----------
  2931. $00-$1f       reverse lowercase letters
  2932. $20-$3f       digits and punctuation
  2933. $40-$5f       lowercase letters
  2934. $60-$7f       reverse graphics characters
  2935. $80-$9f       reverse uppercase letters
  2936. $a0-$bf       graphics characters
  2937. $c0-$df       uppercase letters
  2938. $e0-$ef       reverse digits and punctuation
  2939.  
  2940. There are sixteen color codes, occupying the lower four bits of the color
  2941. value.  These are RGBI codes, as follows:
  2942.  
  2943. CODE(dec)   (hex)   (bin)   DESCRIPTION
  2944. ---------   -----   -rgbi   -----------
  2945.         0      $0   %0000   black
  2946.         1      $1   %0001   dark grey
  2947.         2      $2   %0010   blue
  2948.         3      $3   %0011   light blue
  2949.         4      $4   %0100   green
  2950.         5      $5   %0101   light green
  2951.         6      $6   %0110   dark cyan on VDC, medium grey on VIC-II
  2952.         7      $7   %0111   cyan
  2953.         8      $8   %1000   red
  2954.         9      $9   %1001   light red
  2955.        10      $a   %1010   purple
  2956.        11      $b   %1011   light purple on VDC, orange on VIC-II
  2957.        12      $c   %1100   brown
  2958.        13      $d   %1101   yellow
  2959.        14      $e   %1110   light grey
  2960.        15      $f   %1111   white
  2961.  
  2962. Finally, there are the high-attribute bits.  These occupy the four most
  2963. significant bits of the color value.  Depending on the type of display
  2964. (VIC text, VDC text, or VIC/VDC bitmap), these bits have one of three
  2965. meanings: character attributes, background character color, or no
  2966. effect.  Thus, care must be taken in using these bits; they will have
  2967. different effects on different displays.  The background character codes
  2968. are the same as the foreground character codes listed above.  The
  2969. character attributes have the following meanings:
  2970.  
  2971. BIT VALUE   (dec)   (hex)   DESCRIPTION
  2972. -avub----   -----   -----   -----------
  2973. %10000000     128     $80   alternate characterset (italic)
  2974. %01000000      64     $40   reverse character
  2975. %00100000      32     $20   underline
  2976. %00010000      16     $10   blink
  2977.  
  2978. These values are additive (or, should I say, "or-ative"); you can use
  2979. any combination of them at one time.  Normally, you may wish to leave
  2980. the high-attribute bits alone, unless you take the values to give them
  2981. from the color palettes (next section).  To specify which of you wish to
  2982. have changed, set bits in the "char/color/high-attribute" argument to
  2983. system calls.  The flags have the following values.  They are or-ative
  2984. as well:
  2985.  
  2986. BIT VALUE   (dec)   (hex)   DESCRIPTION
  2987. -cah-----   -----   -----   -----------
  2988. %10000000     128     $80   modify character
  2989. %01000000      64     $40   modify color
  2990. %00100000      32     $20   modify high-attribute bits
  2991.  
  2992. The screen calls that deal with placing characters on the screen refer
  2993. to screen locations using absolute addresses of locations in screen
  2994. memory.  This scheme is used for increased efficiency.  You can obtain
  2995. information about the absolute screen address of the top left-hand
  2996. corner of the current window and the number of screen addresses between
  2997. successive rows, to figure out screen addresses for your applications.
  2998. For added convenience, there is a call which will accept row and column
  2999. numbers and return the corresponding absolute screen address.
  3000.  
  3001. The screen-control system calls are as follows:
  3002.  
  3003. NAME   :  winmax
  3004. ARGS   :  <none>
  3005. RETURNS:  <none>
  3006. ALTERS :  .A, .X, .Y
  3007.  
  3008. Sets the current window to cover the entire screen.
  3009.  
  3010. NAME   :  winclear
  3011. ARGS   :  .A   = char/color/high-attribute modification flags
  3012.           .X   = character fill value
  3013.           .Y   = color fill value
  3014. RETURNS:  <none>
  3015. ALTERS :  .A, .X, .Y
  3016.  
  3017. This call "clears" the current window by filling it with the
  3018. character/color you specify.  You can use the char/color/hi-attr to
  3019. limit what gets cleared. [Note: The arguments for this call are slightly
  3020. different in Release #9].
  3021.  
  3022. NAME   :  winset
  3023. ARGS   :  .A   = number of rows in window
  3024.           .X   = number of columns in window
  3025.           sw+0 = absolute screen row of top left corner of window
  3026.           sw+1 = absolute screen column of top left corner of window
  3027. RETURNS:  .CS  = error occurred flag
  3028. ALTERS :  .A, .X, .Y, errno
  3029.  
  3030. Sets the current window to the size you specify.  You will get an error
  3031. return if the window will not fit on the screen or of it does not
  3032. contain at least one character. [Note: This call is not implemented in
  3033. Release #9].
  3034.  
  3035. NAME   :  winsize
  3036. ARGS   :  <none>
  3037. RETURNS:  .A   = number of rows in window
  3038.           .X   = number of columns in window
  3039.           sw+0 = absolute screen row of top left corner of window
  3040.           sw+1 = absolute screen column of top left corner of window
  3041.          (sw+2)= screen address of top left corner
  3042.          (sw+4)= screen address increment between successive rows on screen
  3043. ALTERS :  <none>
  3044.  
  3045. Returns information about the current window. [Note: the arguments are
  3046. slightly different in Release #9].
  3047.  
  3048. NAME   :  winput
  3049. ARGS   : (sw+0)= absolute screen address to start putting data at
  3050.          (sw+2)= character string pointer
  3051.           .X   = length of character string
  3052.           .Y   = color
  3053.           .A   = char/color/high-attribute modification flags
  3054.           sw+4 = fill character
  3055.           sw+5 = total field length
  3056. RETURNS:  <none>
  3057. ALTERS :  .A, .X, .Y
  3058.  
  3059. Puts text onto the screen.  The output region is given by the absolute
  3060. starting screen address and the total field length.  This region must be
  3061. contained on one line of the current window, or bad things will happen.
  3062. A pointer to the characters to be printed is given, as well as the
  3063. length of the character array.  Control characters in this string are
  3064. ignored; they are poked literally onto the screen, including the null
  3065. character.  The length of the character string must be less than or
  3066. equal to the total length of the field.  Remaining spaces in the field
  3067. will be filled in with the "fill character".
  3068.  
  3069. The color of the total field length will be filled in with "color".  You
  3070. can use the "char/color/hi-attr" modification flags to specify what is
  3071. to be changed.  If you were to, for example, specify that the colors of
  3072. the field are not to be changed, then the call would execute faster.
  3073.  
  3074. NAME   :  wincolor
  3075. ARGS   :  .X   = new RGBI screen color
  3076.           .Y   = new RGBI border color
  3077.           .A   = which colors to change ($80=screen + $40=border)
  3078. RETURNS:  .X   = resulting RGBI screen color
  3079.           .Y   = resulting RGBI border color
  3080. ALTERS :  .A
  3081.  
  3082. Sets the color of the screen and border.  You may optionally set one,
  3083. the other, both, or neither.  The resulting colors for colors changed,
  3084. and the existing colors for colors unchaned will be returned.  Note that
  3085. not all screens have an adjustable color, so the border argument may be
  3086. ignored.
  3087.  
  3088. NAME   :  winpos
  3089. ARGS   :  .A   = row
  3090.           .X   = column
  3091. RETURNS: (sw+0)= screen memory address of position
  3092. ALTERS :  .A, .X, .Y
  3093.  
  3094. Given a row and column in the current window, returns the corresponding
  3095. absolute screen memory location for use with other calls.  No errors are
  3096. returned, so garbage in, garbage out.
  3097.  
  3098. NAME   :  wincursor
  3099. ARGS   : (sw+0)= screen address to place cursor
  3100.           .A   = enable flag ($ff=cursor-on / $00=cursor-off)
  3101.           .Y   = color to show cursor in
  3102. RETURNS:  <none>
  3103. ALTERS :  .A, .X, .Y
  3104.  
  3105. Displays or undisplays the cursor at the given screen address.  This
  3106. call returns immediately in either case.  No errors are returned.  Do
  3107. not display anything in or scroll the window while the cursor is being
  3108. displayed, do not display the cursor twice, and do not undisplay the
  3109. cursor twice in a row or bad things will happen.  Also, make sure you
  3110. give the same address when undisplaying the cursor as you did when
  3111. displaying the cursor.  When the system starts, the cursor will be in
  3112. its undisplayed state (duh!).  You also get to specify the color you
  3113. want the cursor to be shown in.  The high-attribute bits of this color
  3114. are ignored.
  3115.  
  3116. NAME   :  winscroll
  3117. ARGS   :  .A   = flags: char/color/hi-attr + $08=up + $04=down
  3118.           .X   = number of rows to scroll up/down
  3119.           sw+4 = fill character
  3120.           .Y   = fill color
  3121. RETURNS:  <none>
  3122. ALTERS :  .A, .X, .Y
  3123.  
  3124. Scrolls the contents of the current window up or down.  You can scroll
  3125. any number of rows at a time.  After scrolling, the bottom (or top) rows
  3126. will be filled with the fill character and color.  You can limit whether
  3127. the characters and/or colors are to be scrolled by using the "flags"
  3128. byte in the usual way.  Scrolling only the characters, for example, will
  3129. be twice as fast as scrolling both characters and attributes.  Whether
  3130. to scroll up or down is specified also using bits in the "flags" field,
  3131. as indicated in the input arguments above.  You can specify scrolling in
  3132. more than one way, and the result will be to scroll in each specified
  3133. direction in turn, in the order up, then down.  In the future, scrolling
  3134. left and right may be added to this call. [Note: The arguments and
  3135. semantics of this call are a little different in Release #9].
  3136.  
  3137. 2.5. CONSOLE CALLS
  3138.  
  3139. The calls in this section refer to the system "console", which includes
  3140. the screen and keyboard.  The screen-related calls are at a higher level
  3141. than the calls in the previous section.
  3142.  
  3143. NAME   :  stopkey
  3144. ARGS   :  <none>
  3145. RETURNS:  .CS  = stop key pressed
  3146. ALTERS :  .A, .X, .Y, errno
  3147.  
  3148. Indicates whether the STOP (RUN/STOP) key is currently being held down
  3149. by the user.  If so, carry flag is set on return (and clear if not).  If
  3150. the stop key is discovered to be pressed by this call, then the keyboard
  3151. buffer will also be cleared.
  3152.  
  3153. NAME   :  getkey
  3154. ARGS   :  <none>
  3155. RETURNS:  .A   = keyboard character
  3156. ALTERS :  .X, .Y
  3157.  
  3158. Waits for the user to type a key (or takes a previous keystroke from the
  3159. keyboard buffer).  Regular characters are returned in their regular
  3160. PETSCII codes, but there are many special control keystrokes.  They are
  3161. not listed here (yet) because I haven't figured out what all of the
  3162. special codes should be, but all 256 possible character values will be
  3163. covered.  Special codes like "page up", etc. should help in
  3164. standardizing control keystrokes for applications.  The key code is
  3165. returned in the accumulator.  No errors are possible.
  3166.  
  3167. NAME   :  concolor
  3168. ARGS   :  .A   = which colors to modify: $02=character + $01=cursor 
  3169.                  + $80=modify high-attributes of colors
  3170.           .X   = new RGBI character color
  3171.           .Y   = new RGBI cursor color
  3172. RETURNS:  .X   = resulting character color
  3173.           .Y   = resulting cursor color
  3174. ALTERS :  .A
  3175.  
  3176. Sets the character and cursor colors to be used by the console for the
  3177. "read" and "write" system calls that refer to files opened to the
  3178. console device. You can use the flags argument to limit what gets
  3179. changed. [Note: flags argument is slightly different in Release #9].
  3180.  
  3181. NAME   :  conpalette
  3182. ARGS   :  <none>
  3183. RETURNS:  sw+0 = main character color
  3184.           sw+1 = cursor color
  3185.           sw+2 = status character color
  3186.           sw+3 = separator character color
  3187.           sw+4 = highlight character color
  3188.           sw+5 = alert character color
  3189.           sw+6 = screen border color
  3190.           sw+7 = screen background color
  3191. ALTERS :  .A, .X, .Y
  3192.  
  3193. Returns the palette of colors that are recommended to be used in
  3194. applications. These colors are chosen by the user in the system
  3195. configuration, so they can be interpreted as being what the user wants
  3196. and expects applications to use. A different selection is made by the
  3197. user for each different screen type, and the palette returned will be
  3198. for the screen type currently in use.  The high-attribute bits of these
  3199. colors are valid.  Eight colors are included in the palette, and you may
  3200. interpret their meaning according to the application. The suggested
  3201. usages are given in the return arguments listed above.
  3202.  
  3203. NAME   :  conscreen
  3204. ARGS   :  .A   = number of text rows required, minimum
  3205.           .X   = number of text columns required, minimum
  3206. RETURNS:  .A   = number of text rows you get
  3207.           .X   = number of text columns you get
  3208.           .CS  = error occurred flag (requested size cannot be given)
  3209. ALTERS :  .Y, errno
  3210.  
  3211. This call selects an appropriate display device, screen, and layout for
  3212. displaying text.  You ask for the minimum number of rows and columns you
  3213. require on the screen, and the call returns to you what you receive.  If
  3214. the system cannot match your minimum requirements, an error will be
  3215. returned, and the current screen will be unchanged.  The clock speed of
  3216. the processor will be changed to match the screen selected, if
  3217. appropriate.
  3218.  
  3219. NAME   :  conpos
  3220. ARGS   :  .A   = row
  3221.           .X   = column
  3222. RETURNS:  .CS  = error encountered flag
  3223. ALTERS :  .A, .X, .Y
  3224.  
  3225. This call will set the screen location that the next console "read" or
  3226. "write" system call will operate from.  If the "cursor" position is
  3227. outside the boundaries of the current window on the screen, an error
  3228. will be returned. [Note: this function is not implemented in Release
  3229. #9].
  3230.  
  3231. 2.6. PROCESS CONTROL CALLS
  3232.  
  3233. This section describes calls that are used to control the execution of
  3234. processes (active programs).  From within one program, you can call for
  3235. the execution of another program, have it execute, and then return to
  3236. the calling program.  Since only one program is allowed in memory at a
  3237. time, some special problems arise.  Also, only rudimentary versions of
  3238. these system calls are implemented in Release #9 and I haven't decided
  3239. completely how they should work.  So, this section is a bit tentative.
  3240.  
  3241. NAME   :  exec
  3242. PURPOSE:  execute external program as a child process
  3243. ARGS   :  (zp) = program name of executable
  3244.           (zw) = start address of argument vector
  3245.           .AY  = number of arguments
  3246.           [mp] = pointer to far memory volatile storage
  3247. RETURNS:  .A   = exit code
  3248.           .X   = number of bytes in "aceExitData" used
  3249.           [mp] = pointer to far memory volatile storage
  3250.           .CS  = error occurred flag
  3251. ALTERS :  .Y, errno
  3252.  
  3253. Calling this routine will cause a new "frame" to be set up on the
  3254. "system stack" (lowering the available application area memory a
  3255. little), the specified program to be loaded into memory over top of the
  3256. current one, the new program to be executed, the old program to be
  3257. reloaded from whatever disk unit it came from originally upon exit of
  3258. the new program, and control to be returned to the old process with the
  3259. return values from the executed program. This is a complicated procedure
  3260. and many things can go wrong.
  3261.  
  3262. The first thing that a process that wants to call another program must
  3263. do is set up the arguments to be passed in.  All arguments must be
  3264. null-terminated strings.  These arguments are to be put into high
  3265. memory, starting from one less than the location pointed to by
  3266. "aceMemTop" and working downward.  It does not matter in which order the
  3267. strings are placed, as long as they are all grouped together.  Then,
  3268. immediately below the strings comes the vector of two-byte RAM0 pointers
  3269. that point to the strings.  This array must be in order, with the lowest
  3270. entry pointing to the first (zero subscript) string, etc., the second
  3271. highest entry pointing to the last string, and the highest entry
  3272. containing the value $0000.  An asciigram follows:
  3273.  
  3274.   HIGHER ADDRESSES
  3275. |           |
  3276. |           | <--(aceMemTop)
  3277. +-----------+
  3278. |           |
  3279. | string    |
  3280. |           |         : collection of null-terminated strings
  3281. |  contents |
  3282. |           |
  3283. |           |
  3284. +-----------+
  3285. |   $0000   |         : argv[N] : null argument pointer
  3286. +-----------+
  3287. | strptrN-1 |         : argv[N-1]
  3288. +-----------+
  3289. | strptrN-2 |         : argv[N-2]
  3290. +-----------+
  3291. .           .
  3292. .           .
  3293. +-----------+
  3294. | strptr 1  |         : argv[1] : first actual argument
  3295. +-----------+
  3296. | strptr 0  | <--(zw) : argv[0] : filename of program to be executed
  3297. +-----------+
  3298. |           |
  3299.   LOWER ADDRESSES
  3300.  
  3301. The first entry should indicate the filename or command name of the
  3302. program being executed, and the subsequent arguments are the actual
  3303. input arguments to the program being called.  The address of the first
  3304. argument vector table entry is loaded into (zw), and the number of
  3305. arguments is loaded into .AY. Note that this value also includes the
  3306. command name, so if, for example, you were to call program "wc" to count
  3307. two filenames "hello" and "goodbye", then you would pass an argument
  3308. count of 3.  The name pointed to by "argv[0]" does not actually have to
  3309. be the literal command name, but the one pointed to by (zp) does.  If a
  3310. relative executable name is given in (zp), then the search path will be
  3311. used to locate the executable.  Oh, don't screw up the organization of
  3312. the arguments or bad things will happen; there is no structure checking.
  3313.  
  3314. After setting up the arguments, you'll want to set up any redirections
  3315. of stdin, stdout, or stderr you'll be needing.  Because there is only
  3316. one open file table in the whole uni-tasking system, you'll have to
  3317. manipulate existing entries using the "fdswap" system call described
  3318. earlier.  The open file table is inherited by the child process.  Note
  3319. that if it closes any of the open files it inherited, then they are also
  3320. closed to your use also.  If the child accidentally leaves open any
  3321. files it opened, they will be closed by the system before you are
  3322. reactivated.
  3323.  
  3324. Finally, before the call is made, you have to save any volatile local
  3325. information into "far" memory.  All application zeropage and application
  3326. area memory will be modified by the called program, so you must save
  3327. whatever you will need to continue after the return to be able to
  3328. continue.  As mentioned earlier, all of the "far" memory that a parent
  3329. program owns will be safe, so you can save your volatile information
  3330. there, in any format you wish.  All you have to do is save the pointer
  3331. to the far memory into the [mp] pointer.  Upon return of the child
  3332. process, the value you put into [mp] will be restored, and you can then
  3333. restore your volatile information out of far storage.  If you wish to
  3334. save no volatile information, then you can just leave garbage in the
  3335. [mp] value, since it will not be interpreted by the system.
  3336.  
  3337. Alright, so now you call the "exec" primitive, the child program is
  3338. loaded, executed, and it returns.
  3339.  
  3340. At this time, the parent program (that's you) is reloaded from wherever
  3341. it was loaded originally and you are returned to the instruction
  3342. immediately following the "jsr exec", with your processor stack intact
  3343. but the rest of your volatile storage invalid.  Even if there is an
  3344. error return (carry flag set), your volatile storage will still need to
  3345. be restored, since the application area may have been overwritten before
  3346. the error was discovered.  In the case of an error return, the child
  3347. process will not have been executed.  If the system is unable to reload
  3348. the parent program (you), then an error return is given to your parent,
  3349. and so on, as far back as necessary.  (This is a minor exception to the
  3350. rule that an error return indicates that a child didn't execute; in this
  3351. case, the child didn't complete).
  3352.  
  3353. You are also returned an "exit code", which will have
  3354. application-specific meaning, although standard programs (e.g., shell
  3355. script) interpret the value as: 0==normal exit, anything else==error
  3356. exit.  The X register is also set to indicate the amount of
  3357. "aceExitData" that is used, to allow for more complicated return values.
  3358.  
  3359. [Note: This call is different in Release #9].
  3360.  
  3361. NAME   :  execsub
  3362. PURPOSE:  execute internal subroutine as a separate process
  3363. ARGS   :  (zp) = address of subroutine
  3364.           (zw) = address of argument vector
  3365. RETURNS:  .A   = exit code
  3366.           .X   = number of bytes in "aceExitData" used
  3367.           .CS  = error occurred flag
  3368. ALTERS :  .Y, errno
  3369.  
  3370. This call is very similar to "exec", except that it calls an internal
  3371. subroutine rather than an external program.  Thus, you don't have to
  3372. save or restore your volatile storage, or worry about loading the child
  3373. or reloading the parent.  You do, however, set up the arguments and file
  3374. redirections as you would for a full "exec".  [Note: this call is
  3375. different in Release #9].
  3376.  
  3377. NAME   :  exit
  3378. PURPOSE:  exit current program, return to parent
  3379. ARGS   :  .A   = exit code
  3380.           .X   = number of bytes in "aceExitData" used
  3381. RETURNS:  <there is no return, brah-ha-ha-ha-ha-ha!!!>
  3382. ALTERS :  <don't bloody well matter>
  3383.  
  3384. This call causes the current program to exit back to its parent. A
  3385. program that exits simply by returning to its environment will give back
  3386. an exit code of 0, which should be interpreted as a normal return.  If
  3387. you wish to indicate a special return, you should use some exit code
  3388. other than zero.  Many utilities will interpret non-zero error codes as
  3389. actual errors and may abort further operations because of this.
  3390.  
  3391. You may set up a return data in "aceExitData", up to 255 bytes worth,
  3392. and load the number of bytes used into .X if you wish.  It is
  3393. recommended that the first field of this data be a special identifier
  3394. code so programs that cannot interpret your data will not try.  You
  3395. cannot give any far pointers in your return data, since all far memory
  3396. allocated to you will be freed by the system before returning to your
  3397. parent.
  3398.  
  3399. NAME   :  memstat
  3400. PURPOSE:  get "far" memory status plus process id
  3401. ARGS   :  <none>
  3402. RETURNS:  .A   = current process id
  3403.          [sw+0]= amount of "far" memory free
  3404.          [sw+4]= total amount of "far" memory
  3405. ALTERS :  .X, .Y
  3406.  
  3407. This call returns the current process id, the number of bytes of far
  3408. memory currently free, and the total amount of far memory.
  3409.  
  3410. 2.7. MISCELLANEOUS CALLS
  3411.  
  3412. NAME   :  utoa
  3413. PURPOSE:  convert unsigned 32-bit number to a decimal PETSCII string
  3414. ARGS   :  .A   = minimum length for return string
  3415.           .X   = zero-page address of 32-bit number
  3416.          (sw+0)= pointer to string buffer to store string
  3417. RETURNS:  .Y   = length of string
  3418. ALTERS :  .A, .X
  3419.  
  3420. This is a utility call in the kernel.  It is really not necessary for it
  3421. to be in the kernel, but so many programs make use of it that it makes
  3422. sense for it to be factored out.  You give a pointer to a 32-bit
  3423. unsigned value in zero page memory, a pointer to a buffer to store that
  3424. string that is at least as long as necessary to store the value plus the
  3425. null-character terminator that will be put on the end of the string, and
  3426. a minimum length value for the string.  If the number requires fewer
  3427. digits than the minimum length, the string will be padded with spaces on
  3428. the left.  Since a 32-bit quantity can only contain an maximum of ten
  3429. decimal digits, the string buffer will only need to be a maximum of
  3430. eleven bytes in size.
  3431.  
  3432. NAME   :  getdate
  3433. PURPOSE:  get the current date and time
  3434. ARGS   : (.AY) = address of buffer to put BCD-format date into
  3435. RETURNS:  <none>
  3436. ALTERS :  .A, .X, .Y
  3437.  
  3438. Returns the current date and time in the BCD format described in the
  3439. paragraph on "aceDirentDate".  It puts it into the at-least-eight-byte
  3440. storage area pointed to by (.AY).
  3441.  
  3442. NAME   :  setdate
  3443. PURPOSE:  set the current date and time
  3444. ARGS   : (.AY) = address of date in BCD format
  3445. RETURNS:  <none>
  3446. ALTERS :  .A, .X, .Y
  3447.  
  3448. Sets the current date and time in the system.  (.AY) points to the BCD
  3449. date string whose format is discussed in the paragraph on
  3450. "aceDirentDate".  No validity checking is performed on the date given.
  3451.  
  3452. NAME   :  cmdopen
  3453. PURPOSE:  open command channel to Commodore disk drives
  3454. ARGS   :  (zp) = device name
  3455. RETURNS:  .A   = file descriptor number
  3456.           .CS  = error occurred flag
  3457. ALTERS :  .X, .Y, errno
  3458.  
  3459. This "cmd" set of system calls really should not be present, but they
  3460. will be needed until the full complement of disk-utility system calls
  3461. are implemented. It is really not recommended that any application
  3462. program rely on these calls being around very long.  This call opens the
  3463. command channel on the named device (standard ACE device name string)
  3464. and returns the file descriptor number to use thereafter.
  3465.  
  3466. NAME   :  cmdclose
  3467. PURPOSE:  close command channel to Commodore disk drives
  3468. ARGS   :  .A   = file descriptor number
  3469. RETURNS:  .CS  = error occurred flag
  3470. ALTERS :  .A, .X, .Y, errno
  3471.  
  3472. This closes an opened command channel to a disk drive.  Closing the
  3473. status will NOT affect any other open files on the disk unit at the
  3474. time.
  3475.  
  3476. NAME   :  cmdsend
  3477. PURPOSE:  send command over command channel to Commodore disk drives
  3478. ARGS   :  .X   = file descriptor number
  3479.          (.AY) = pointer to null-terminated command string
  3480. RETURNS:  .CS  = error occurred flag
  3481. ALTERS :  .A, .X, .Y, errno
  3482.  
  3483. This sends a command string to a disk drive.  Since a null-terminated
  3484. string representation is used, not all Commodore/CMD-DOS commands can be
  3485. sent, but the important ones can be.
  3486.  
  3487. NAME   :  cmdstatus
  3488. PURPOSE:  receive current status from command channel of Commodore disk drives
  3489. ARGS   :  .X   = file descriptor number
  3490.          (.AY) = pointer to buffer for null-terminated status string
  3491. RETURNS:  .A   = status code in binary
  3492.           .CS  = error occurred
  3493. ALTERS :  .X, .Y, errno
  3494.  
  3495. This returns the status of a disk drive in a string as well as the
  3496. binary disk status number in the accumulator.  The given status buffer
  3497. must be at least 50 or so characters long (whatever is the longest
  3498. possible disk status string).
  3499.  
  3500. 3. USER PROGRAM ORGANIZATION
  3501.  
  3502. The ACE system itself is written using the Buddy-128 assembler, so it is
  3503. recommended that applications be written in this also.  User programs
  3504. for ACE have a very simple structure.  Here is the standard "hello,
  3505. world" example program written in Buddy assembler for ACE:
  3506.  
  3507. -----=-----
  3508. .seq acehead.s
  3509. .org aceAppAddress
  3510. .obj "@0:hello"
  3511.  
  3512. jmp main
  3513. .byte aceID1,aceID2,aceID3
  3514.  
  3515. main = *
  3516.    lda #<helloMsg
  3517.    ldy #>helloMsg
  3518.    sta zp+0
  3519.    sty zp+1
  3520.    lda #<helloMsgEnd-helloMsg
  3521.    ldy #>helloMsgEnd-helloMsg
  3522.    ldx #stdout
  3523.    jsr write
  3524.    rts
  3525.  
  3526. helloMsg = *
  3527.    .asc "Hello, cruel world."
  3528.    .byte 13
  3529. helloMsgEnd = *
  3530. -----=-----
  3531.  
  3532. This would normally be put into a file called "hello.s".  The ".s"
  3533. extension means that this is an assembler file (a la Unix).  The first
  3534. thing this program does is include the "acehead.s" file.  This is the
  3535. Buddy assembler file that contains the header information declarations
  3536. required to access the ACE system interface.  The next line gives the
  3537. start address to start assembling to; it must be "aceAppAddress", which
  3538. is the address that ACE will load the program at.  The next line is a
  3539. directive to the assembler to write the executable code to a
  3540. Commodore-DOS "PRG" file named "hello".  This will be the command to
  3541. enter at the ACE shell prompt.
  3542.  
  3543. The next six bytes of object code (which are the first six bytes of a
  3544. program) describe the header required by ACE programs.  The first three
  3545. bytes must be a JMP to the main routine of the program.  The next three
  3546. bytes must have the values "aceID1", "aceID2", and "aceID3",
  3547. respectively.  And that's all there is to it.  The rest of the program
  3548. can be organized however you want it to be.
  3549.  
  3550. In this example, we set up the arguments for the "write" system call to
  3551. print the string "Hello, cruel world." plus a carriage return to
  3552. standard output.  Note that this string does not need a terminating null
  3553. ($00) character since the write call takes a buffer length.  The program
  3554. then returns to its calling environment via an RTS.  This will cause an
  3555. implied "exit(0)" to be performed by the system, returning to the parent
  3556. program.
  3557.  
  3558. Although this program does not take advantage of this, an application
  3559. program may use zero-page locations $0002 through $007f for storage
  3560. without fear of having the storage trodden upon by the system.  Also,
  3561. the processor stack may be used from the point it was at upon entry to
  3562. your program all the way down to the bottom.  I will be doing something
  3563. about ensuring there is always enough processor space for an application
  3564. to use in the future, but for now, all applications have to share the
  3565. single page of processor stack storage.
  3566.  
  3567. Finally, an application program starts at location "aceAppAddress" (plus
  3568. six) and is allowed to use memory all the way up to one byte less than
  3569. the address pointed to by "aceMemTop" for its own purposes.  Currently,
  3570. this amount of space is on the order of magnitude of about 24K.  This
  3571. will be increased in the future.
  3572.  
  3573. Application programs are not to access I/O features or even change the
  3574. current memory configuration during execution.  All I/O and unusual
  3575. contortions must be performed by ACE system calls; otherwise, we could
  3576. end up in as bad a shape as MESS-DOS.
  3577.  
  3578. 4. CONCLUSION
  3579.  
  3580. Cool, eh?
  3581. =============================================================================
  3582. Looking Ahead: (Learned my lesson about "In The Next Issue" :-) (re: the
  3583.                 mouse article etc....) )
  3584.  
  3585. Either a Multi-Tasking article or a look at the Internals of Ace.
  3586.  
  3587. More graphics techniques.
  3588.  
  3589. Answers to the Trivia in this issue.
  3590.  
  3591. More articles and other information.
  3592.  
  3593. (Sorry that this is a little bit more vague than last time - Just have some
  3594.  authors actually finding real jobs, and others that forgot to include what
  3595.  they were going to do for the next issue.)
  3596.  
  3597.