home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Falcon 030 Power 2
/
F030_POWER2.iso
/
ST_STE
/
MAGS
/
ICTARI08.ARJ
/
ictari.08
/
ASSEMBLY
/
MOUSPROB
/
MOUSE.DOC
next >
Wrap
Text File
|
1992-03-04
|
4KB
|
72 lines
About MOUSE.S, MOUSE.TOS & MOUSE.DOC, (this).
Hi folks. I'm MIC and I'm teaching myself to program in assembler. Just
about. One of the first things I want to do is to write a basic shell
with a mouse pointer on it. The games I like are the Dungeon Master,
Civilisation type games, no joysticks usually. And, as I'm getting into
programming they are the type of game I'd like to end up writing.
GEM is probably great if you need windows, but I won't. So, I need to
access the bit of the ST which works the mouse at TOS level. Low low
low down inside the Operating System. Books (great aren't they, they
don't answer back and insist you switch off your computer at 2am like
my wife sometimes does!), books tell me that I need to look at the
Intelligent KeyBoarD (IKBD) for the answer. So I have.
As I understand it, there is a separate mini-computer inside our casing
using a 6301 processor. All it does is look at the keyboard, joystick
ports, and mouse port. If anything interesting happens it creates
within itself a 'packet' of data about the event, then causes an
interrupt (what level I wonder?). At the appropriate time the processor
calls a routine (pointed to by a vector table) who's job is to process
this packet. In my case, all I need to do is move the packet into safe
storage for later.
XBIOS 34 returns a longword. This is the address of the first entry in
a 7 entry table of addresses, a vector array. The 5th entry, or 16
bytes into the table, is the address of a routine to handle the data,
and is the routine called by the IKBD interrupt. I've replaced the
original address with the address of my routine. The original address
is restored at the end.
The OS points a0 to the start of the data packet. My routine just
copies this packet to a buffer. I use the data later. (This routine
must end in RTS and use no more than 1 milisecond of processor time, or
8,000 cycles. Or so more books tell me.).
There are two types of packet for the mouse, absolute and relative. The
default (GEM) type is relative. This relative packet consists of a
header byte which includes bit data about the buttons, a relative X
position byte, signed, and a Y position byte, signed. I'm sticking to
relative for now as it's good enough for GEM.
I hold two variables in memory for the x and y position of the mouse.
At the moment I print the values rather than attempt to draw and undraw
the pointer. At a time within the program that is convenient to the
programmer a routine to alter these variables according to the contents
of the latest data packet is called. Then they're printed on screen.
Simple?
1. In the background, under interrupt, the IKBD loads my buffer
'packet' with a data packet if the mouse is moved or a button pressed.
The main program does nothing about getting the packets after setting
this up, it just watches the packets roll in.
2. The main program does it's job, playing the game, making the sounds,
and being generally very good. Of course. When we have decided to
redraw the mouse pointer the main program looks at the currently held
packet, uses its data to vary the mouse x/y variables, undraws the old
pointer and redraws the new.
That's the theory. My listing MOUSE.S and program MOUSE.TOS tries to
put it into practice. But it reacts strangely. If I move the mouse
slowly, then I get the whole range of movement in a short distance
across the mat. Great. But if I move the mouse quickly, I can cross the
whole mat and not change the variables a lot. I thought it was meant to
be the other way around? Please examine my code and comment! Thanks.
MIC.
Mike Barnard, 52 Westbourne Avenue, Worthing, West Sussex.
BN14 8DF.