home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
- M O U S E 8 0
-
- by Maurice Randall
-
- MOUSE 80 is a device driver for the Commodore 1351 mouse or
- compatibles. It is designed to be used with the 128 in 80 column 'text
- mode' only. This driver will fill a void that most people do not realize
- existed. The 1351 mouse has been around for a while now, and there are
- mouse drivers for it. The demo disk that comes with the mouse has an
- assortment of drivers for the 64 mode and the 128 mode, but the 128 mode
- driver is only for 40-column use. It makes use of a sprite for the pointer
- that is visible on the screen. Sprites are not available on the 80-column
- screen. Sprites are easily simulated on the 128's 80-column graphic screen,
- but then you are limited to creating 'graphic text'. GEOS works this way,
- and GEOS is an excellent system, but there is still a need for applications
- written to use the 128's native text mode.
-
- What makes this driver different is the fact that it moves the pointer
- about the text screen smoothly. There have been other mouse drivers for the
- 80-column text screen, but these move the mouse pointer around the screen a
- full character at a time. They work fine, but the smoothness of movement
- isn't there. The only smooth mouse pointer I'm aware of for the 128 is
- incorporated into the Pocket Series software from Digital Solutions. But
- their mouse routines are not available to the public. Therefore, I have
- designed MOUSE 80 so that other software developers might make use of the
- 1351 mouse with a smooth moving pointer in their programs. Any new
- development for the 128 should definitely make use of the new hardware that
- is available, and MOUSE 80 will help give a more professional appearance to
- the program.
-
- MOUSE 80 can be used with a BASIC or ML program. It uses a jump table
- to call its routines and you can also read or change various variables that
- are used by MOUSE 80. MOUSE 80 installs at $1300 but can be located
- anywhere in Bank 15 memory by using the 'MouseMover' utility that is
- included on this disk as a demo. MouseMover will create a new version of
- MOUSE 80 for you. The utility is very straightforward and does not require
- much documentation for its use. It's written in BASIC and is fully
- commented and demonstrates a few of MOUSE 80's features. To run
- 'MouseMover' choose Run It for MOUSE 80 or press R while you're reading this
- text.
-
- MouseMover requires two support files, one is 'mouse80.o', of course,
- and the other is 'mover.o', which supplies a few machine language routines
- to speed up some tasks that would be a little too slow for BASIC to handle.
- MouseMover will create a file called 'mouse80.xxxx', where 'xxxx' equals the
- selected load address. You can then use this new version of MOUSE 80 in
- your program if you need it to load at a different address than $1300.
-
- To use MOUSE 80, you would include the following statement in a BASIC
- loader:
-
- bload"mouse80.o"
-
- Once your main program begins, you can use the various jump addresses
- and variables locations to initially install the mouse wedge into the IRQ
- interrupt sequence, turn the mouse pointer on and off, or to find or set the
- pointer on the screen. You can locate the pointer according to its pixel
- location. You can also confine the mouse to a defined region or 'window'.
- You can tell if either button is being pressed. You can also instruct MOUSE
- 80 to set up a jump address for the application to call if one of the
- buttons is pressed.
-
- If you don't like the looks of the mouse pointer, you can change its
- appearance by altering the eight bytes that make up its picture.
-
- There are four graphic characters from the upper/lower case set that
- are used by MOUSE 80. If you need to use these characters, you can choose
- any other four characters instead. It would be a very rare program that
- would have to use each of the 512 characters that are available.
-
- Whenever you are accessing the screen, you should 'hide' the mouse
- pointer to prevent garbage from appearing on the screen. The 80-column VDC
- chip is very touchy, and does not like the mouse when the screen is
- scrolling, or if you are typing characters into the same location that the
- mouse is occupying. So, just call 'HIDEMOUS' before any screen access and
- call 'SHOWMOUS' when finished. When the mouse is hidden, the pointer is not
- displayed, but movement is still possible. So, you could use this to your
- advantage for various things such as menus. As the mouse is moved up and
- down, you could highlight the menu item that is being pointed at, much like
- what is usually done with the CRSR keys. If you call the routine,
- 'STOPMOUS', then the pointer is not only hidden, but its location also is
- not updated. It will remain frozen in the spot it was in when the routine
- was called. The buttons are still active so that you can still check for
- either button being pressed. Either 'SHOWMOUS' or 'HIDEMOUS' will then make
- the mouse active again. 'HIDEMOUS' will leave the pointer hidden.
-
- The following is a list of available routines and variables along with
- their locations in memory:
-
- Name ML Basic Description
- -------------------------------------------------------------------------
- INSTALL JSR $1300 SYS 4864 Initially installs the mouse wedge
- REMOVE JSR $1303 SYS 4867 Removes the mouse wedge from the system.
- HIDEMOUS JSR $1306 SYS 4870 Hides the pointer from view.
- SHOWMOUS JSR $1309 SYS 4873 Displays the pointer on the screen.
- STOPMOUS JSR $130C SYS 4876 Stops the mouse and hides it.
- CKSTATUS JSR $130F SYS 4879 Check location of mouse on screen.
- USERJUMP JSR $1312 SYS 4882 User callable according to buttons.
-
- (Locations $1315-$1317 are not used. They are reserved for future use.)
-
- There are a number of variables that may be read or set. Here is a
- listing of those variables, their location offset in relation to the
- starting address and a brief description.
-
- The following bytes define the region in which to confine the mouse pointer.
- The default settings are for the entire screen.
-
- LTXLIMIT +24,25 Left border (lsb,msb) (0-319)
- UPYLIMIT +26 Upper border (0-199)
- RTXLIMIT +27,28 Right border (lsb,msb) (0-319)
- LOYLIMIT +29 Lower border (0-199)
-
- the following locations define the present location of the mouse. These are
- best checked by machine language. When using BASIC, the mouse could move
- between the time it takes to check the X position and the Y position.
-
- XCHAR +30 Column location of the mouse.
- YCHAR +31 Row location of the mouse.
- CXPOS +32,33 Horizontal pixel location of the mouse.
- CYPOS +34 Vertical pixel location of the mouse
-
- From BASIC, (or ML) you could check these locations after accessing the
- routine called 'CKSTATUS' at $130F with a SYS 4879. The exact location of
- the mouse when 'CKSTATUS' is accessed is saved here until the next time the
- routine is accessed.
-
- BXCHAR +35 Column location.
- BYCHAR +36 Row location.
- BCXPOS +37,38 Horizontal pixel location.
- BCYPOS +39 Vertical pixel location.
-
- These next two locations may be set in order to place the mouse pointer at a
- specific location on the screen. 'SETXPOS' should be set to a two-byte
- value ranging from 0-319, and 'SETYPOS' should be 0-199. Always POKE the
- value into SETXPOS+1 last, because after MOUSE 80 checks these bytes, bit 7
- of SETXPOS+1 will be set which makes MOUSE 80 ignore these values. If you
- were to set this location before the other three (from BASIC), they would
- most likely be read before you are done setting the other bytes and so the
- mouse would not be placed in the desired location. From machine language,
- it is not a problem since you can disable the interrupts first.
-
- SETXPOS +40,41 Place pointer at this X location.
- SETYPOS +42 Place pointer at this Y location.
- LTBUTTON +43 Current status of left button.
- RTBUTTON +44 Current status of right button.
- LTCHECK +45 Latched status of left button.
- RTCHECK +46 Latched status of right button.
-
- These next four bytes are used as user defined addresses that may be called
- in machine language whenever a button is pressed. They are described in
- better detail later.
-
- LTADDR +47,48 Address for left button.
- RTADDR +49,50 Address for right button.
- LTINT +51,52 Interrupt address.
- RTINT +53,54 Interrupt address.
-
- MSEPORT +55 Active joystick port (1 or 2)
-
- MOUSEPIC +56-63 This is the picture of the pointer.
-
- These next four bytes designate the screencodes of the characters that will
- be used for the mouse pointer. You may use the default characters or change
- these bytes to select different characters. If you should happen to use a
- character that is displayed elsewhere on the screen, then the mouse pointer
- will appear at that location also. This may not be too desirable, but could
- possibly be used for a special effect.
-
- ULCORNER +64 Character that is used for upper left.
- (Default is ASCII 113)
- URCORNER +65 Character that is used for upper right.
- (Default is ASCII 114)
- LLCORNER +66 Character that is used for lower left.
- (Default is ASCII 115)
- LRCORNER +67 Character that is used for lower right.
- (Default is ASCII 116)
-
- And these four bytes are the attribute bytes for the characters that are to
- be redefined. The default setting for each one is $80, which would select
- the character from the upper/lower case set. Set the locations to $00 if
- you wish to use characters from the uppercase/graphics set.
-
- ULMSATTR +68 Attribute byte for upper left.
- URMSATTR +69 Attribute byte for upper right.
- LLMSATTR +70 Attribute byte for lower left.
- LRMSATTR +71 Attribute byte for lower right.
-
- * * * * * * * * * * * * *
-
- The mouse picture located at 'MOUSEPIC' is made up of eight bytes.
- These eight bytes and their values look like this:
-
- BYTE BINARY HEXADECIMAL DECIMAL
- -------------------------------------------
- byte 0 11000000 $C0 192
- byte 1 11111000 $F8 248
- byte 2 11111110 $FE 254
- byte 3 11111000 $F8 248
- byte 4 10011100 $9C 156
- byte 5 00001110 $0E 14
- byte 6 00000111 $07 7
- byte 7 00000000 $00 0
-
- If you study the 'ones' in the binary representation, you will see the
- picture of the mouse. By changing these eight bytes, you can change the
- appearance of the mouse pointer.
-
- One thing to keep in mind whenever you are making reference to the
- mouse location in the horizontal axis, is that the mouse is moved two pixels
- at a time, horizontally. Even though there are 640 pixels on the X-axis,
- the mouse will be referenced at points ranging from 0 to 319. So, if the
- mouse is at location 100, it is actually sitting at pixel 200 on the screen.
-
- You can have MOUSE 80 set up a user callable jump address in the jump
- table according to the values placed at LTADDR and RTADDR. For instance, if
- you place a two-byte value at LTADDR, it will be transferred to MOUSE 80's
- jump table at $1312 whenever the left button is pressed. You may then JSR
- $1312 to your own routine. If you place a two-byte address at LTINT, then
- that address will be called by MOUSE 80 during the interrupt sequence
- whenever the left button is pressed. The address at $1312 is not affected
- by the setting at LTINT. LTINT is transferred to an internal location
- within MOUSE 80. MOUSE 80 calls this routine for you whenever the button is
- pressed. To block either of these features, simply zero out the locations.
- The same idea applies for RTADDR and RTINT and the right button. By using
- this feature, you never have to check the status of the buttons yourself.
-
- If you do need to check the buttons, there is more than one way to do
- it. You can test the location at 'LTBUTTON'. If bit 7 is set or if the
- location contains any value greater than 127, then this means that the left
- button is being pressed. If the location contains any value greater than
- zero, then the button was pressed sometime during the last eight interrupt
- sequences. Bit 7 always represents the button's status for the most recent
- interrupt, bit 6 for the previous one and so forth on down to bit 0. So, if
- bit 3 at 'LTBUTTON' is 'off', then the left button was not pressed 5
- interrupts ago. By allowing you to read the status of the button for a
- period of eight interrupts, you might be able to catch a button press even
- after the user lets up on the button. 'RTBUTTON' contains the status for
- the right button.
-
- * * * * * * * * * * * * *
-
- For the curious, here is how MOUSE 80 works. It is really quite simple
- when you think about it. First of all, the 80-column text screen is just
- that, a text screen. Graphics are not possible, which means that we cannot
- address individual pixel locations. We have to address character locations,
- so we are limited to displaying objects (or characters) in a matrix that is
- 80 columns wide and 25 rows high. So, whenever you see what looks like
- graphics on the text screen, you are seeing either the graphic characters
- that Commodore has provided us or you are seeing redefined characters that
- are being displayed about the screen. MOUSE 80 uses four redefined
- characters and so it actually occupies four character locations on the
- screen at all times. The four locations are always attached to each other
- in a matrix that is two characters wide and two characters high. Reference
- is always made to the upper left character. For instance, if the mouse is
- located at column 0 and row 0, it is occupying the following four locations:
-
- column 0, row 0
- column 0, row 1
- column 1, row 0
- column 1, row 1
-
- Now, to get the mouse displayed on the screen, MOUSE 80 creates its own
- little bitmap in memory. Once it knows where it is located on the screen,
- it then determines where within this bitmap that it should be located. For
- instance, if the mouse is at the upper left of the screen, it would be at
- column 0 and row 0. Let's say that the actual pixel location of the mouse
- is at pixel 3 horizontally and pixel 5 vertically. These locations fall
- within the upper left character location of the screen. Now we draw the
- mouse pointer in our own little bitmap at position 3 on the X axis and
- position 5 on the Y axis. The bitmap is 16 pixels by 16 pixels but we keep
- the entire mouse picture within the bitmap and we keep the upper left pixel
- of the mouse within the upper left quarter of the bitmap. This means that
- the X coordinate can be from 0-7 and the Y coordinate can be from 0-6.
- (Remember, the x coordinates move two pixels at a time).
-
- Now that we have drawn the mouse into the bitmap, it is time to fetch
- the character definitions from the four locations that the mouse is
- occupying on the screen. First the character from column 0, row 0 is
- fetched and drawn to the upper left quarter of the bitmap. Each bit when
- drawn is actually EOR'D with the picture of the mouse. The remaining three
- characters are then drawn in the other three quarters of the bitmap in the
- same manner. By Exclusive ORing each bit with the mouse picture, the mouse
- and the character are each visible. If bits that are 'on' are overlapping
- each other, then the bits will be 'off'. This makes the mouse visible if
- the character it passes over should be a solid block.
-
- Now that our little bitmap is completely drawn, we send each quarter of
- it to the four different character definitions that MOUSE 80 uses for its
- pointer. Then it is drawn to the screen by sending those four characters to
- the screen. Each time the mouse moves, this bitmap is redrawn. So the
- effect of a smooth moving mouse is not through the use of sprites or
- graphics, but actually through the use of four redefined characters.
-
- This is why you must call 'HIDEMOUS' or 'STOPMOUS' before any screen
- access in the area that the pointer is, or if the entire screen is going to
- scroll. These routines will remove the mouse picture from the screen, and
- replace the actual characters that should be residing in the four locations
- of the screen where the mouse is.
-
- Things to remember:
-
- * Call 'INSTALL' to initially install the mouse. 'INSTALL' initializes
- numerous variables, so you must set any desired variables after this call.
- 'INSTALL' leaves the mouse in a frozen and hidden state.
-
- * Call 'SHOWMOUS' to make the pointer visible and active.
-
- * Call 'HIDEMOUS' or 'STOPMOUS' during any screen activity in the area of
- the mouse.
-
- * 'HIDEMOUS' leaves the mouse active, but makes it invisible.
-
- * 'STOPMOUS' makes the mouse invisible and also freezes its position.
-
- * 'X' coordinates range from 0-319 because the mouse is moved two pixels at
- a time horizontally.
-
- * Call 'REMOVE' to remove MOUSE 80 from the IRQ sequence before ending your
- application. 'REMOVE' calls 'STOPMOUS' and then resets the IRQ vector to
- its original state.
-
- MOUSE 80 should open up a whole new avenue of professional appearing
- applications for the 128.
-
- MR
- **** End of Text ****