home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / Information / AUTOBOOT-09-86 < prev    next >
Encoding:
Text File  |  2019-04-13  |  9.3 KB  |  184 lines

  1. *********************************************************************
  2. This article is being presented through the *StarBoard* Journal of
  3. the FlagShip/StarShip, SIGS (Special Interest Groups) on the
  4. Delphi and GEnie telecommunications networks.  Permission is
  5. hereby granted to non-profit organizations only to reprint this
  6. article or pass it along electronically as long as proper credit
  7. is given to both the author and the *StarBoard* Journal.
  8. *********************************************************************
  9.  
  10.                               C128 AUTOBOOT
  11.                                    or
  12.                      How Does This Darn Thing Work?
  13.                                    by
  14.                               Gary W Funk
  15.                          (GARYWAYNE on DELPHI)
  16.                            (GWAYNE on GEnie)
  17.  
  18.  
  19.     Once upon a time, not so many years ago... (what?  Oh, all right).
  20. It all started about a year ago.  I was at work, doing what I do best,
  21. calling the area bulletin boards to see what had transpired during the
  22. week-end.  The boss came in and asked, 'What are you doing'?  I
  23. replied, 'What I do best!'  'Oh,' he said as he left the room shaking
  24. his head.  And then the U.P.S. Driver came in and said he had a
  25. package for me.  It was the new Commodore 128s I had ordered.  I
  26. logged off of the board I was on and went out to see.  There sat two
  27. big boxes; I waited for the rest, but there were no more. 'Oh well,' I
  28. thought; 'order eight and get three.  At least I can keep one.'
  29. And I did.
  30.  
  31.     So, out of the box it comes. Onto the bench. Sure do look pretty!
  32. Nice design, good color. Love the feel of the keyboard.  But what to do
  33. with it?  No software yet.  Quick! To the phone.  Call my software
  34. distributor.  'Send me one of each of whatever you have for the C128.'
  35. And now wait.  Like he** I will.  Not having software never stopped
  36. me before.  Get the mags and see what others have said and done.
  37.  
  38.     That is how it started (what this article is leading up
  39. to).  One of the features I really like about the C128 is its
  40. ability to boot from the disk on powerup.  So, that was the first item
  41. on my list of things to figure out.  I started reading everything I
  42. could find and asking questions of anyone who would listen and give a
  43. reasonable answer.  Then one day in the mail came the October 1985 issue
  44. of Creative Computing (the second computer magazine I ever subscribed to;
  45. the first was 73, soon to lead to Byte, soon to lead to KiloByte, to lead
  46. to KiloBaud, to lead to MicroComputing, .... but that is another story).
  47. Anyway, as I was saying, in the October issue, in the "Commodore's Port"
  48. section, there was the answer to my question (so I thought).  I read
  49. the article, typed in the program, and ran it.  It worked!  But it did
  50. not seem right.  Oh, the program did what I wanted it to do, but it
  51. just seemed a round-about-way to get the job done.  Oh well.  So I
  52. kept asking and reading.
  53.  
  54.     Then it happened.  The September 1986 issue of The Transactor
  55. arrived; and as I always do, I read it front to back.  But wait.  Read
  56. that again.  Yes, that's it!  It was Jim Butterfield to the rescue (was
  57. there ever any doubt).  If you REALLY want to know the How, What, Why,
  58. Where of the disk boot, get that issue and read it.  Here I will only
  59. explain how to boot a program and how my AUTOBOOT 101 works.
  60.  
  61.     First, when the computer is powered up, or when you type BOOT in
  62. direct mode, the computer reads track 1, sector 0 of the disk and loads
  63. the information there into RAM 0 locations $0B00 to $0BFF.  If the first
  64. three characters are "CBM", then the disk will autoboot.  That is what we
  65. want.
  66.  
  67.     As I stated, bytes 0, 1, and 2 are "CBM".  Bytes 4, 5, 6, and 7,
  68. control 'boot sectors'.  Bytes 4 and 5 give the address where the
  69. sectors should be loaded.  Byte 6 tells which bank.  And byte 7 tells
  70. how many blocks to load.
  71.  
  72.     We want to start with byte 7.  If byte 7 is not 0 [chr$(0)], the
  73. computer will print whatever is there to the screen, preceded by the
  74. word 'BOOTING', until it reads a CHR$(0).  So, if byte 7 starts with
  75. 'BOBSTERM PRO 128' and this is followed by a CHR$(0), we will see,
  76. 'BOOTING BOBSTERM PRO 128...' printed to our screen.  You can have many
  77. characters displayed, but I have limited it to 160. That should be more
  78. than enough for just about any use.  (hehe)
  79.  
  80.     After the 0 byte above, there will be more text followed by another 0
  81. byte.  This text will be the name of the program that we want to load
  82. and run and a CHR$(0).  This text will not be displayed on the screen,
  83. but is used by the computer to know what program (filename) to load.
  84.  
  85.     Next there should be a machine language routine that takes control
  86. from the powerup routine.  This can be a simple RTS [CHR$(60)] or a JMP
  87. [CHR$(76)] to where the program starts.
  88.  
  89.     Now for the good part about Autoboot101.  (I know! Another boot
  90. program, as if there aren't enough of them already.)  Autoboot101 takes
  91. advantage of the load-a-file feature built into the computer.  Upon
  92. power-up, the computer will BLOAD a program.  This is the same as LOAD
  93. "filename",8,1.  The program is loaded where it belongs.  To date, I do not
  94. know of any autoboot maker that takes advantage of this feature.
  95. For machine language programs, the process was easy.  After the text is
  96. displayed and the program is loaded, a small machine language program
  97. finishes the process.  To run machine language, a SYS  starts the
  98. program; the SYS would JMP to the start address.  This part is
  99. easy.  And if it is an auto-run machine language program that will start
  100. itself, my program would just RTS to basic.
  101.  
  102.     But with a BASIC program, SYS (or JMP) to the start of BASIC will just
  103. result in a SYNTAX error.  So, I dug out the manuals and started reading.
  104. I knew there was a way; there had to be a routine to do this.  Something
  105. has to tell RUN what to do.  I wanted to know where it was.  I looked in
  106. all the KERNAl calls (I knew it was a BASIC routine, I just forgot I knew
  107. it) and couldn't find anything.  Well, call DELPHI, go to CONFerence and
  108. start looking for someone who can help.  And there he was in all
  109. his glory.  TROUBLESOME!  ('Ah ha,' I thought to myself.)  Page him and
  110. hope he is not busy. 'Page TROUBLESOME' - 'Sorry, he is busy right now.'
  111. Darn!  Well, go to the FORUM and read the messages; I'll try later.
  112. Start reading, and TROUBLESOME wants to talk.  Oh boy, quick to CONF!
  113. 'Do you want to talk to him?'.  Yes yes yes I answer.  'HELP,' I
  114. type.  'What is trouble?' he types.  'Need help with kernal call,' I
  115. type, and so on and on.  Well to make this short, he told me it is a basic
  116. call and to look at page 523 of the Reference Guide and sure-nuf there
  117. it was!
  118.  
  119.     Back to the issue at hand.  We need to run a program, so what
  120. better than to JMP to AF99, which is RUN-A-PROGRAM.  How neat.  So,
  121. that is all there is to it.  Quick and simple.  Let the computer do
  122. all the work.  If you are still confused, just look at the simple
  123. program below, and it should help.  If you still don't understand,
  124. I will hold a conference on the subject (that is, if Jim Butterfield
  125. will be there to dig me out of any hole I may find myself in).
  126.  
  127.  
  128.    a$="cbm"                               :rem need this to tell computer
  129.                                                this is a boot disk
  130.    
  131.    n$=chr$(0)+chr$(0)+chr$(0)+chr$(0)     :rem to fill up bytes 3-6
  132.    
  133.    b$="text"+chr$(0)                      :rem text we want displayed on
  134.                                                screen followed by
  135.                                                terminator byte
  136.    c$="filename"+chr$(0)                  :rem name of file followed by
  137.                                                terminator byte
  138.    
  139.    d$=chr$(76)+chr$(lobyte)+chr$(hibyte)  :rem jmp to start address of
  140.                                                program
  141. OR
  142.    
  143.    d$=chr$(60)                            :rem rts return to basic
  144.    
  145.    z$=a$+n$+b$+c$+d$                      :rem combine strings into one
  146.  
  147.    open15,8,15                            :rem open command channel to disk
  148.  
  149.    open2,8,2,"#"                          :rem open disk file buffer
  150.  
  151.    print#15,"b-p";2;0                     :rem point to buffer
  152.  
  153.    print#2,z$                             :rem write z$ to buffer
  154.  
  155.    print#15,"u2";2;0;1;0                  :rem block write channel 2 to track
  156.                                                1 sector 0
  157.  
  158.    print#15,"b-a";0;1;0                   :rem allocate track 1 sector 0 in
  159.                                                of the bam
  160.  
  161.    close2:close15                         :rem close command and disk channel
  162.  
  163.  
  164.     If you want to see this program in action, just look for AUTOBOOT
  165. 101 in the download section.
  166.  
  167.                                 See you soon.  Gary
  168.  
  169. ---------------------------------------------------------------------
  170.    
  171. Credit where credit is due:
  172.    
  173.     I would like to thank:
  174.          Sheldon Leemon; for his article in Creative Computing.
  175.          Jim Butterfield; for his article in The Transactor.
  176.          Troublesome; for his time and effort on DELPHI.
  177.    
  178.     And a very special thank you to:
  179.          DEB; for making this such a wonderful pleasant place to
  180.             be.  Thanks!
  181.    
  182. Next month I hope to be able to tell you how to make the C128 boot a
  183. program in 64 mode (that is if I get any response to this one)!
  184.