Ryan's Web Page | Index/Preface | Chapter I | Chapter II | Chapter III | Chapter IV | Chapter V |
Chapter III: Machine Language Subroutines
Using ModulesIn IMAGE BBS, the "main" program, also known as the "im" file, resides at $4601 in memory. Other modules, called "plus files," load at $0801. The area designated for plus files is $0801-$4000, which is about 14k. (This is about 56 CBM 1541 "blocks.") The main file starts at line 1000. Modules start at line 1. When you enter a module, it is always entered with either a GOTO 1, or GOSUB 1. When a module starts to become too large for the 14k buffer, you can further divide it into sub-modules. The most common way is to use "mini-modules." These are modules that can be up to 4k in length, or about 17 disk blocks. The mini-modules load at $3001 in memory. When one is loaded, it is effectively appended on to the end of the plus file that is currently in memory. Therefore, you cannot start a mini-module at line 1. All of the line numbers in the mini-module must come after the line numbers in the plus file. If there is an overlap, it may crash the system, forcing you to reboot. For this reason, be very careful when you program using modules. There are a few restrictions that you must be aware of. First, the mini-module and the plus file must share the same area of memory. So, even though the maximum size of a plus file is 14k, if you are using a mini-module, the maximum size for the plus file becomes 10k, and the mini module is 4k, which is a total of 14k. There are other sizes of modules, and here is a chart to explain them:
Using ML Modules:If you wish to use ML modules, more commonly known as "++" files, the &,7,dv%,2 command will load them for you. You can call any of the normal IMAGE & routines by loading the Accumulator with the & number, and X and Y with the parameters. Then a JSR $DD01 will call the routine. The area set aside for ML modules is from $C000-CA7F. RS232 Routines:The RS232 routines that IMAGE uses reside in memory from $4300-$45FF. There is a jump table at $4300 which has the ONLY safe entry points into these routines. NOTE: Calling some of these routines will result in "strange" things happening, be very careful.
The SwapperIMAGE uses a sort of virtual memory mechanism to allow the 12k of RAM that is "hidden" in the 64 to be used. RAM from $D000-$FFFF is used to store many of the routines that IMAGE does not need to use as often as others. Examples are the disk input routine (&,2) and the entire editor system! These routines are accessed using the "swapper." This is a routine that swaps the needed routines into memory, and swaps whatever is in that memory to the hidden RAM. The routines are then executed, and then swapped back to the hidden RAM. Thus, the 12k of hidden RAM can be used to store more ML for the IMAGE system. In IMAGE 1.2, all but 2k of this RAM is used, and in future versions, that last 2k will be used! The swapper is located at $CA80. To use it, you set the Accumulator and the Y register with the starting page numbers to swap, and the X register to how many pages of RAM to swap. Thus, to swap memory from $C000-$C2FF with the memory from $C300-$C5FF, you would do this:
To swap it back again, repeat the same sequence of commands. Be very careful when using this routine, since it does not care what it swaps, and will try to swap anything you tell it to! The LightbarThe lightbar is controlled by IRQ routines which read the function keys, and make the necessary screen/memory changes that are requested. There is an & [command] which allows you to get or set the status of the lightbar. This is &,52. There are several functions implemented in this command in version 1.2. You can clear/set/toggle/read any individual checkmark. Here are some examples:
The Editor:The programming of the IMAGE editor is best left to those who know a lot about the IMAGE system. There is an & [command] which will make the necessary calls into the editor ML. This ML resides from $D000-$DFFF, and is swapped into memory from $1000-$1FFF by the swapper when it is called. There are 3 legal entry points, which are accessed by &,54, &,54,1, and &,54,2. The first entry point is the "normal" entry. This puts the user into the editor with an empty buffer. The second entry does not clear the buffer. The last entry is the entry that you would use in [writing] an extended command, if the command which was typed was not a recognized command.
|
Ryan's Web Page | Index/Preface | Chapter I | Chapter II | Chapter III | Chapter IV | Chapter V |