home *** CD-ROM | disk | FTP | other *** search
- *********************************************************************
- This article is being presented through the *StarBoard* Journal of
- the FlagShip/StarShip, SIGS (Special Interest Groups) on the
- Delphi and GEnie telecommunications networks. Permission is
- hereby granted to non-profit organizations only to reprint this
- article or pass it along electronically as long as proper credit
- is given to both the author and the *StarBoard* Journal.
- *********************************************************************
-
- C128 AUTOBOOT
- or
- How Does This Darn Thing Work?
- by
- Gary W Funk
- (GARYWAYNE on DELPHI)
- (GWAYNE on GEnie)
-
-
- Once upon a time, not so many years ago... (what? Oh, all right).
- It all started about a year ago. I was at work, doing what I do best,
- calling the area bulletin boards to see what had transpired during the
- week-end. The boss came in and asked, 'What are you doing'? I
- replied, 'What I do best!' 'Oh,' he said as he left the room shaking
- his head. And then the U.P.S. Driver came in and said he had a
- package for me. It was the new Commodore 128s I had ordered. I
- logged off of the board I was on and went out to see. There sat two
- big boxes; I waited for the rest, but there were no more. 'Oh well,' I
- thought; 'order eight and get three. At least I can keep one.'
- And I did.
-
- So, out of the box it comes. Onto the bench. Sure do look pretty!
- Nice design, good color. Love the feel of the keyboard. But what to do
- with it? No software yet. Quick! To the phone. Call my software
- distributor. 'Send me one of each of whatever you have for the C128.'
- And now wait. Like he** I will. Not having software never stopped
- me before. Get the mags and see what others have said and done.
-
- That is how it started (what this article is leading up
- to). One of the features I really like about the C128 is its
- ability to boot from the disk on powerup. So, that was the first item
- on my list of things to figure out. I started reading everything I
- could find and asking questions of anyone who would listen and give a
- reasonable answer. Then one day in the mail came the October 1985 issue
- of Creative Computing (the second computer magazine I ever subscribed to;
- the first was 73, soon to lead to Byte, soon to lead to KiloByte, to lead
- to KiloBaud, to lead to MicroComputing, .... but that is another story).
- Anyway, as I was saying, in the October issue, in the "Commodore's Port"
- section, there was the answer to my question (so I thought). I read
- the article, typed in the program, and ran it. It worked! But it did
- not seem right. Oh, the program did what I wanted it to do, but it
- just seemed a round-about-way to get the job done. Oh well. So I
- kept asking and reading.
-
- Then it happened. The September 1986 issue of The Transactor
- arrived; and as I always do, I read it front to back. But wait. Read
- that again. Yes, that's it! It was Jim Butterfield to the rescue (was
- there ever any doubt). If you REALLY want to know the How, What, Why,
- Where of the disk boot, get that issue and read it. Here I will only
- explain how to boot a program and how my AUTOBOOT 101 works.
-
- First, when the computer is powered up, or when you type BOOT in
- direct mode, the computer reads track 1, sector 0 of the disk and loads
- the information there into RAM 0 locations $0B00 to $0BFF. If the first
- three characters are "CBM", then the disk will autoboot. That is what we
- want.
-
- As I stated, bytes 0, 1, and 2 are "CBM". Bytes 4, 5, 6, and 7,
- control 'boot sectors'. Bytes 4 and 5 give the address where the
- sectors should be loaded. Byte 6 tells which bank. And byte 7 tells
- how many blocks to load.
-
- We want to start with byte 7. If byte 7 is not 0 [chr$(0)], the
- computer will print whatever is there to the screen, preceded by the
- word 'BOOTING', until it reads a CHR$(0). So, if byte 7 starts with
- 'BOBSTERM PRO 128' and this is followed by a CHR$(0), we will see,
- 'BOOTING BOBSTERM PRO 128...' printed to our screen. You can have many
- characters displayed, but I have limited it to 160. That should be more
- than enough for just about any use. (hehe)
-
- After the 0 byte above, there will be more text followed by another 0
- byte. This text will be the name of the program that we want to load
- and run and a CHR$(0). This text will not be displayed on the screen,
- but is used by the computer to know what program (filename) to load.
-
- Next there should be a machine language routine that takes control
- from the powerup routine. This can be a simple RTS [CHR$(60)] or a JMP
- [CHR$(76)] to where the program starts.
-
- Now for the good part about Autoboot101. (I know! Another boot
- program, as if there aren't enough of them already.) Autoboot101 takes
- advantage of the load-a-file feature built into the computer. Upon
- power-up, the computer will BLOAD a program. This is the same as LOAD
- "filename",8,1. The program is loaded where it belongs. To date, I do not
- know of any autoboot maker that takes advantage of this feature.
- For machine language programs, the process was easy. After the text is
- displayed and the program is loaded, a small machine language program
- finishes the process. To run machine language, a SYS starts the
- program; the SYS would JMP to the start address. This part is
- easy. And if it is an auto-run machine language program that will start
- itself, my program would just RTS to basic.
-
- But with a BASIC program, SYS (or JMP) to the start of BASIC will just
- result in a SYNTAX error. So, I dug out the manuals and started reading.
- I knew there was a way; there had to be a routine to do this. Something
- has to tell RUN what to do. I wanted to know where it was. I looked in
- all the KERNAl calls (I knew it was a BASIC routine, I just forgot I knew
- it) and couldn't find anything. Well, call DELPHI, go to CONFerence and
- start looking for someone who can help. And there he was in all
- his glory. TROUBLESOME! ('Ah ha,' I thought to myself.) Page him and
- hope he is not busy. 'Page TROUBLESOME' - 'Sorry, he is busy right now.'
- Darn! Well, go to the FORUM and read the messages; I'll try later.
- Start reading, and TROUBLESOME wants to talk. Oh boy, quick to CONF!
- 'Do you want to talk to him?'. Yes yes yes I answer. 'HELP,' I
- type. 'What is trouble?' he types. 'Need help with kernal call,' I
- type, and so on and on. Well to make this short, he told me it is a basic
- call and to look at page 523 of the Reference Guide and sure-nuf there
- it was!
-
- Back to the issue at hand. We need to run a program, so what
- better than to JMP to AF99, which is RUN-A-PROGRAM. How neat. So,
- that is all there is to it. Quick and simple. Let the computer do
- all the work. If you are still confused, just look at the simple
- program below, and it should help. If you still don't understand,
- I will hold a conference on the subject (that is, if Jim Butterfield
- will be there to dig me out of any hole I may find myself in).
-
-
- a$="cbm" :rem need this to tell computer
- this is a boot disk
-
- n$=chr$(0)+chr$(0)+chr$(0)+chr$(0) :rem to fill up bytes 3-6
-
- b$="text"+chr$(0) :rem text we want displayed on
- screen followed by
- terminator byte
- c$="filename"+chr$(0) :rem name of file followed by
- terminator byte
-
- d$=chr$(76)+chr$(lobyte)+chr$(hibyte) :rem jmp to start address of
- program
- OR
-
- d$=chr$(60) :rem rts return to basic
-
- z$=a$+n$+b$+c$+d$ :rem combine strings into one
-
- open15,8,15 :rem open command channel to disk
-
- open2,8,2,"#" :rem open disk file buffer
-
- print#15,"b-p";2;0 :rem point to buffer
-
- print#2,z$ :rem write z$ to buffer
-
- print#15,"u2";2;0;1;0 :rem block write channel 2 to track
- 1 sector 0
-
- print#15,"b-a";0;1;0 :rem allocate track 1 sector 0 in
- of the bam
-
- close2:close15 :rem close command and disk channel
-
-
- If you want to see this program in action, just look for AUTOBOOT
- 101 in the download section.
-
- See you soon. Gary
-
- ---------------------------------------------------------------------
-
- Credit where credit is due:
-
- I would like to thank:
- Sheldon Leemon; for his article in Creative Computing.
- Jim Butterfield; for his article in The Transactor.
- Troublesome; for his time and effort on DELPHI.
-
- And a very special thank you to:
- DEB; for making this such a wonderful pleasant place to
- be. Thanks!
-
- Next month I hope to be able to tell you how to make the C128 boot a
- program in 64 mode (that is if I get any response to this one)!