Enterprise Forever

:UK => Programming => Topic started by: gflorez on 2015.July.02. 16:29:48

Title: Universal Mouse Driver
Post by: gflorez on 2015.July.02. 16:29:48
Now that the  PS/2 mouse interface(Pear´s EnterMice (https://enterpriseforever.com/hardware/entermice-joy-ps2-mouse-interface/)) is closer and closer to be real, it's increasingly necessary to have a Mouse Driver that serves to almost any controller type.

The problem here is that a few people still have old interfaces(Boxsoft or Hsoft), and they can't be forgotten when thinking on new developments.

There are already Boxsoft drivers modified to work with Mészáros' serial cards, but they are modified from the GUY KOPEXY's caped ones, and then they can't read a Neos mouse.

Recently I've achieved to mix the Hsoft drivers with the latest 1.1 Boxsoft version. Zozo says they work on the serial side...

Then he suggested me to broaden the INPUT_DEVICE variable:

I more prefer use variable 189:
0: Int Joy
1: Ext 1
2: Ext 2
3: Boxsoft mouse
4: EnterMice
5: serial in Mouse System mode
6: serial in Microsoft mode
(7: the Rat?)

The PaintBox 2.1 already can set the 189 to 0-7 (F1-F8 keys)

I'm not a real programmer, but at last I've managed to approach his wishes....

By now option 5 and 6 do the same(Mouse Systems+internal joy) but I'm studying the 8251a UART to see what I can do to read a Microsoft mouse...

And about the "Rat"(Patkány)... I even don't know how it works....


MOUSEHmix.EXT has to be renamed to Mouse.xr to be usable with Paintbox or the EGI. If you want to test it from basic you must load it and use :pb on EXOS to link the driver.


The next great modification of the driver will be to adapt it to the new Prodatron's MSX protocol. It will allow in EnterMice mode the use of up to five mouse buttons and the Wheel, on new programs.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.July.05. 23:43:23
I'm studying the Hsoft part of the driver. It is odd, very odd. But brilliant....

Here we have the original EXOS rst 30 call:

002B 00 NOP
002C 00 NOP
002D 00 NOP
002E 00 NOP
002F 00 NOP
0030 F3 DI
0031 32 5A 00 LD  (005Ah), A
0034 B7 OR   A
0035 E3 EX  (SP), HL
0036 18 07 JR  003Fh
0038 F5 PUSH AF
0039 37 SCF
003A 18 09 JR  0045h
003C C3 FF 00 JP  00FFh
003F 7E LD  A, (HL)
0040 23 INC  HL
0041 E3 EX (SP), HL
0042 32 59 00 LD (0059h), A
0045 DB B3 IN A,(B3)
0047 32 55 00 LD (0055h), A
004A 3E 00 LD A, 00
004C D3 B3 OUT (B3), A
004E C3 10 C4 JP C410h

Then in the driver they hook a different memory segment and address(where the driver is):

in a, (0B3h)
 ld (4Bh), a
 ld hl, INT   ; This is the subroutine where the read of the serial port is made in the driver
ld (4Fh), hl
ld hl, 0B3D3h
ld (2Bh), hl ; Puts "OUT (B3),A" at 2Bh


Later, in the INT subroutine, this is the way it returns to C410:

INT800:
 pop af
 pop de
 jr nc, INT900 ; EXOS call
 in a, (0B4h)
 and 10101010b
 scf
 jr nz, INT900 ; Interrupt
 ld hl, 0FBF1h
 ld (2Dh), hl
 ld a, 0C9h ; 'É'
 ld (2Fh), a
 pop hl
 ld a, (55h)
 jp 2Bh ; OUT (B3),A;POP AF;EI;RET
; ---------------------------------------------------------------------------

INT900:
 ld hl, 10C3h
 ld (2Dh), hl
 ld a, 0C4h ; 'Ä'
 ld (2Fh), a
 pop hl
 ld a, 0
 jp 2Bh          ;OUT (B3),A;JP C410

It creates for two options two different little codes on that unused bytes from 2Bh to 2Fh..!

On another part the code even auto-modifies itself!

Is for that "details" I doubt the serial mouse can be ported to SimbOS.....
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.July.12. 22:58:07
The Hsoft mouse driver maintains a counter of what byte of the five count cycle is actually reading, and shows it as a number over the "a" letter inside of the "program" word  at the Status Line:

ERZEK10:
 
 add a, 31h ; Ascii  '1'    ;a holds the number on the five count cycle.
 ld hl, (0BFF6h)  ;ST_POINTER
 ld de, 1Bh        ;adds 24
 add hl, de
 ld (hl), a          ;somewhere at the Status Line
 ret

This subroutine was put for test only and can be suppressed.

Edit: It is a count of pressed buttons, from 0 to 3 and again 0, left or right counts,  central button doesn't counts. The result is viewed as the respective ASCII character on the Status Bar.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.July.26. 19:06:16
At last I've managed to fix one error with the buttons.

The principal button of the Boxsoft interface is the right one unlike other computers, and is read at the L column.
On the other side the secondary is at the left but you can't press it in mouse mode(you lose the movement of the pointer), only in joystick mode %&&!.... To make things worse this button is the same fire of the Joy1 controller on J column .

It was not Tim Box's fault, because the Enterprise control ports are very strange and he did what he could to match them with the even more strange Neos mouse. We could consider it a prowess...

On the Entermice mode some things have been modified to avoid incompatibilities and one of them is the position of the buttons.

Now the main button is at the left(no problem with left-handed here...) and is read on the K column.
The right button is the secondary now but is read in the same L column.

What I have achieved now is to store its status on the right place, this is, no mater if  Boxsoft or Entermice mode (3 or 4 on the system var 189, INPUT_DEVICE), the main button will be stored on system Var 188(FIRE_STATUS), and the secondary on bit 7 of system Var 190(SW_Z_STATUS). (I know, it could appear easy... but not for me...)


--------------------------------------------


Also, I present here the implementation of Prodatron's extension for the MSX protocol.

Provided you have an Entermice adapter(not yet...) or an Arduino Ps/2 to MSX adapter+Boxsoft modified interface(my case), the driver now allows mice with up to five buttons and a wheel. Now I can use a basic PS/2 mouse with only two buttons(the reading routine only reads two bytes) or a more actual mouse with wheel(then it reads two more bytes).

Why so much buttons and wheel? Because they are implemented on marvellous SymbOS...(not yet the Enterprise version obviously...)

But the best is that now all these buttons and wheel are accessible on the EXOS variable 190(SW_Z_STATUS) for use on new development or immediately on Basic....

You can read them as this: ASK 190 A will store the status on variable A.

Bits 0 to 3: Z movement(wheel) four signed bits for a scroll displacement of up to 7 or -8 lines.
Bits 4 to 6: three spare buttons. bit 4 is the wheel button.
Bit  7: secondary mouse button.

I have to play with it to discover little errors, but the next mayor change on the next version will be Microsoft serial mouse
 reading. That will took a time, but by now the Entermice option is complete.

As always you must rename the extension to Mouse.xr to use it on the EGI.
And on Basic execute :PB to initialise the mouse driver.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.July.28. 15:30:22
I've realised that just only copying the value of Z(wheel) to the system variable is not sufficient. It isn't because the data read is the displacement occurred between two readings. So if you stop suddenly your finger over the wheel the data read will be zero and all previous movement will be lost.

Then is necessary to add successively the readings to the system variable ignoring it if exceeds 7 or -8.

It will be the task of the User (the program that access the system variable)  to reset the counter and supervise further movement of the wheel. Once  read the movement it must reset the counter again and go to execute the reaction, for example a scroll. And then it must return again and again to read the movement and inmediately reset the counter.

What do you think? I accept suggestions...
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.August.04. 21:41:16
I want to do also a buttons&wheel read by the channel as the driver do when you write "O", "o" or "p" on it.

I have holidays to think on it.... but no real Enterprise.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.August.11. 17:28:12
I refuse to do a new read function on the channel for the spare buttons and wheel. The driver would need changes I'm not prepared to do. Is easier and faster to do a system variable read call and process the data.

But I've been thinking about  potentially writing a click or a  mouse movement on the channel. Maybe when we have net access...
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.August.12. 10:49:19
I've fixed the driver to store the count of Z movement. Now the driver will add the data read to the old value but will stop the count when greater than  7 or lower than -8.

At the moment I don't have my EP to test it.

Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.September.02. 13:02:56
I've tested the modification but it doesn't work as expected.

I want to add two signed bytes, one on "a" with the other in "(hl)".

The result can't be higher than 7 nor lower than -8 as only the first nibble is significant.

This is my attempt:

      add a, (hl)
      cp 128                              ;positive or negative?
      jr c, POSITIVE
      cp 248                             ;lower than -8?
      jr nc, FINISHED             ;
      ld a, 248                          ; -8 is the bottom
      jr FINISHED
POSITIVE:
      cp 8                                 ;higher than 7?
      jr c, FINISHED
      ld a, 7                              ; 7 is the top
FINISHED:                                                  ; the excess  of 7 or -8 has been wipped

It works right with positive results, but not with negatives.

I want to learn what I'm doing bad... can somebody give me advice?
Title: Re: Universal Mouse Driver
Post by: pear on 2015.September.02. 21:20:45
What exactly does not work ?
I tested your code and received the correct results - both numbers positive and negative.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.September.02. 21:46:42
Maybe I have the same Basic problem.....

Thanks.


What I'm trying to do is to maintain an account of pulses for the wheel, then it can't go greater than 7 nor lower than -8. The user(the program accesing the system variable) has to reset it and read later the pulses given.

I will try with the brute force trick from Zozo's.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.September.02. 21:55:04
But, what I' saying? The mouse driver is interrupt-driven....

If the routine is well writen then I will test other assembly lines that can corrupt the result.

Thanks Pear.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.September.05. 22:26:03
I've found the error..... a beginner's one... :

           and 00Fh
           bit 4, a
           jr z, SIGN_DONE
           or 0F0h
SIGN_DONE:      


I used this code to expand the sign from the first nibble of register "a" to all the byte, but of course the test has to be made to bit 3....

Now, as promised, the lowest nibble of system var 190 holds a counter of wheel displacement from 7 to -8.

This is the fixed driver:
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.September.16. 17:51:25
Actually I'm modifying the driver to work with the Mészáros' serial cards reading common Microsoft serial mice instead of the scarce Mouse Systems mice. The protocols are a little different but I think I've found the way to read the two systems.

The controller options(var 189) are now complete:

0: Int Joy
1: Ext 1
2: Ext 2
3: Boxsoft mouse
4: EnterMice
5: serial in Mouse System mode + internal joy
6: serial in Microsoft mode + internal joy

The problem here is: I don't have that serial hardware to verify if it works.....

I don't know how many users of that card exist(probably one or two...). Maybe somebody can try a Microsoft mouse with the driver:
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.September.16. 18:09:59
I've read on old forums that the typical Microsoft or compatible serial mice can read also Mouse Systems protocol. Just in the same way as a Neos mouse can be transformed and act as a sort of joystick: pressing the left button while turning on the computer. Or can be the right button...
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2015.September.17. 08:14:28
I've read on old forums that the typical Microsoft or compatible serial mice can read also Mouse Systems protocol. Just in the same way as a Neos mouse can be transformed and act as a sort of joystick: pressing the left button while turning on the computer. Or can be the right button...
Yes, but only the very old ones (about more than 15 years old). I tested more than 10 old mouses until find ony which are can do this.
Older ones (from early 90's) have a switch at bottom (or hide in the ball hole) for switch the protocol.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.September.17. 08:36:15
Why Hsoft chose Mouse Systems protocol for their serial cards? I think I can answer this question... just the same election happened in the past between Beta and VHS, Firewire and USB, or SCSI and IDE.

Many times superior technology succumb to cheaper implementations of the similar approach.
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2015.September.17. 08:50:36
Why Hsoft chose Mouse Systems protocol for their serial cards?
As I remember it is least same or more popular at these years (early 90's), and it is support 3 buttons, but the Microsoft only 2 buttons.
The built in Hsoft driver in the EPDOS 2.1 support both, you can select with system variable.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.September.17. 09:04:43
Do you have the disassembly of EPDOS 2.1? I'm interested on it. If it has been made in Rom it has non auto-modifiable code.

The Universal driver will support that three or two buttons the same as Entermice does, bits 7 and 4 of the new SW_Z_STATUS System var.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.September.17. 23:36:07
Sorry. Now I understand that EPDOS 2.1 version is not released.

I just only wanted to help. A real programmer should continue the mouse driver.

A good idea could be to insert it on a general purpose Rom, as it actually only weights 4K.

But then it needs to allocate some Ram, both parts, Boxsoft and Hsoft use some areas of the code to store their variables.

On the other side the Hsoft serial side has to be rewritten. It is not necessary to hijack the EXOS interrupt. I think the driver is able to read the five or three bytes in a row like the Entermice-Boxsoft side does with two or five bytes. I don't appreciate slowdown when I connect a PS/2 mouse, and I think the MSX protocol is slower than the 1200bps of the Serial side.

Also is necessary to rewrite the auto-modified code. It seems to be easy.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.October.22. 23:18:03
The Boxsoft-Entermice mouse system only works on graphic screens, this is a fact.




But.... hypothetically speaking... on a text screen an easy implementation of the mouse can be to associate the pointer to the cursor. The EXOS Editor seems being already designed for that purpose, with its scrolling capacities and the free movement of the cursor.

Even it is unnecessary to draw the pointer sprite! It is the most complicate task of the driver.

And, if the mouse driver integration on EXOS is achieved we could have Basic, WP, EXDOS and ISDOS mouse controled....


-----------------------------

Let me dream on feasible hallucinations.... I don't hurt anybody with it...!

Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.October.22. 23:41:52
I keep dreaming:

Better the cursor independent of the pointer(a flashing underline for example), you move the mouse and the pointer moves towards a determined character boundary, then you make a click and the cursor is moved to that place...
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.October.27. 15:15:51
I am researching information about text modes(0 and 2).

The principal problem I've found is that the text lines can be messed on the LPT respect of what is seen on the screen.

How can I know the real order of the text lines?
Title: Re: Universal Mouse Driver
Post by: geco on 2015.October.27. 15:30:39
I am researching information about text modes(0 and 2).

The principal problem I've found is that the text lines can be messed on the LPT respect of what is seen on the screen.

How can I know the real order of the text lines?
in the memory?
From the LPT , 4th and 5th byte gives back the video address of a the text line in each LPB.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.October.27. 16:08:46
Thanks for answer me, Geco.

I understand the way to access the lines information, but in the Video Driver Specification is warned that in text modes the lines may not be on a linear structure. I think that the order is kept on the Editor driver.
Title: Re: Universal Mouse Driver
Post by: geco on 2015.October.27. 16:14:36
Thanks for answer me, Geco.

I understand the way to access the lines information, but in the Video Driver Specification is warned that in text modes the lines may not be not on a linear structure. I think that the order is kept on the Editor driver.
It is possible, unfortunately I do not know the Editor driver, Zozo can help in this  :) , but you can find out the sequence, and the place from the LPT also :)
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.October.28. 19:27:09
I want to put more ideas here:

Once the mouse driver worked within the text modes, it will be easy to program it to hook at initialisation to the deffault video channel if exists.  If on ROM or EXT it should be called to execution as an EXOS command once Basic, Exdos, WP or other is running, not before.

The mouse video channel can be changed later by the User simply closing the MOUSE: channel and opening one other on a different video channel. Then the driver will be compatible with existing programs like the EGI or PaintBox.


Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.November.01. 03:31:41
This is my first attempt in Basic to move a ghost pointer over the screen.

The Basic program modify the byte that represent a character boundary because all lines are correlative.

Please, move the internal joystick to see the effect.


The problem is when you Stop Basic, the Editor device can change the order of the lines when a Scroll is produced or an entire paragraph is Inserted.

I have to guess the sorted order of the lines for the driver be able to move the ghost pointer across the screen.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.November.03. 01:09:05
And this is the test with text 80. Please put the emulator at max velocity and move the internal joystick to see the effect.

It may be disappointing to see how slow is, but take in account that this is software text, and the Basic program has to calculate and poke all the eight rows of the character. Nick chip does it automatically on text 40.

Also, indexation and boolean calculations are better performed on assembler. It will be as fast or more than drawing a mouse pointer, so at the end the pointer movement will be similar.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.November.03. 09:55:35
These two simple programs do perfect grids because when Basic is executing, the coordinates are corrected. You must be able to print a string where you want.

When in the Editor(Basic, WP, EXDOS), the order of the lines on the LPT can be "random". But it has to be some place where there is stored the sequence, that shows a short of window through the buffer .
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.November.03. 23:00:34
Now I understand.....

The LPT displays lines in order, exactly like are shown on screen. What can be on diverse address is the data represented on the lines, but it is not important for drawing the pointer. What really matters are the coordinates, and they are always there at hand.

So, only accessing LPT, the mouse driver can draw the ghost pointer like I've done with the basic program.




I am near... at thousands kilometres but near..
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.November.29. 01:15:46
I have discovered why the ":PB" initialisation command gives an error.

For example: *** Invalid cursor coordinates.

If you immediately execute "PRINT EXTYPE" in Basic you will get 9217, this is, error 217 of EXOS.

In reality what it gives is the memory page where the mouse driver has been loaded and linked.

I think this trick is a developer feature to easier see what's happening inside the driver's variable zone. I don't know what can happen on the EGI or Paintbox if I disable it. May be those programs use the feature to do something, I must test it.

This simple Basic program can serve to retrieve the memory page number, and allows to begin a basic program loading and linking the mouse driver. The only drawback, it only can be executed once because every time a new mouse device is installed...

I must look for a way to test if the driver has been loaded before. Or directly not allow reloading on the driver installation.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.November.29. 14:44:34
Until now the different mouse driver versions didn't have a way to see the version other than the :HELP EXOS command.
 
The next release will bring  a new  command of "imaginative" name, ":MOUSE" that will return us the driver version and the type of control selected on system var no. 189. It also will bring information about Entermice if present.

This new information will be accessible directly once the file "Mouse.xr" is loaded.

Now a program that wants to access the mouse driver can know on every moment its state:

If ":MOUSE" doesn't produce an exception(is loaded) but the driver doesn't let us to open a mouse channel, we still need to initialise the mouse driver with the ":PB" command. 



Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.November.30. 17:38:27
New version of the mouse driver:

If using the EGI put it at EGI.SYS directory .

Usage:

Load the extension and then execute ":PB"  to initialize it.

Now when ":MOUSE" is executed (driver initialized or not) it will show the driver version and its controller mode.

But, if a Entermice is plugged and the controller mode of the driver(sys. var. 189) is 3 or 4(Boxsoft or Entermice), then the mouse ID, hardware version and software version will be also shown.

The following is obvious but, take in account that the driver controller mode must match the Entermice mode to be able to read that extra data.


To do:

-Adapt the reading delays for Entermice efficiency. Easy, Entermice detection already implemented.

-Serial Microsoft, driver controller mode 6. Difficult as I don't have a serial card.

-Implement mouse use with ghost pointer on text modes. Difficult as I still have to study how it can be implemented on the driver.

-May be, when all was done, a relocatable version for better use of RAM. Or better, a ROM version....
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.December.03. 15:08:48
Tests for CPU efficiency done.

Boxsoft+Neos work with at least 3, 1, 1, 1(it only reads two bytes)  with three NOPs on the delay routine.

Entermice work with 1, 1, 1, 1, 1, 1, 1, 1(all the same time) with only two NOPs on the delay routine.

I think they haven't so much differences to implement conditional delays... so I put minimum Neos settings.

It is necessary a test on a 10Mhz Enterprise.
 
-------------

I've found a strange behaviour on the Entermice versions subroutine when setting the delays to 1 or 2 cycles, so I've put 5 cycles, only for reassuring, as that routine is only used at the start or when the command "MOUSE" is executed.



-----------------

To do:


-Serial Microsoft, driver controller mode 6. Difficult as I don't have a serial card.

-Implement mouse use with ghost pointer on text modes. Difficult as I still have to study how it can be implemented on the driver.

-May be, when all was done, a relocatable version for optimal use of RAM. Or better, a ROM version....
Title: Re: Universal Mouse Driver
Post by: pear on 2015.December.03. 15:18:23
What is it a strange behaviour ?
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.December.03. 15:27:16
Instead of the right Hw an Sw versions it reads random figures. I think, being a cascade reading, an error found earlier echoes on  subsequent readings at the end of the chain.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.December.03. 15:28:30
With five cycles of delay it always works perfect.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.December.05. 22:58:07
Zozo, can you also test this Rom I've found inside the big Hsoft file?

What does it? and, can you disassemble it for me?
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.December.07. 14:06:43
Zozo, I've found the text code for that Rom, but it is not for Heass nor for Fenas.

Can you format it for me?
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.December.07. 14:58:50
I have it already formatted, thanks.

It seems preliminary code, so much errors on labels. I can compare it with the real Rom disassembly....
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2015.December.07. 15:22:06
Zozo, I've found the text code for that Rom, but it is not for Heass nor for Fenas.
It is a FENAS source.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.December.07. 15:38:27
It is interesting. Obviously I've not seen it work, but as a Rom it doesn't hang the emulator.

It adds new commands to Basic.
Serial data acquisition is similar to "Mouse.xr".
Also have Keyboard(BRD and UK grids) reading, I think it overrides the stock one.

May be we can add the Neos reading routine inside it... but first I would need a compilable disassembly.
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2015.December.07. 15:59:51
It is use disassembled KEYBOARD driver from the BRD.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.December.07. 17:35:23
Yes, but only on the disassembly, the Rom lacks keyboard reading, only mouse. It only goes up to the INICIAL: label with little changes.

I think it is the Mkey extension. May it be a serial keyboard driver?

May be they released a mouse extension and a keyboard extension, but with only one serial port it was not necessary to put  them  joined. I am only supposing...
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.December.08. 00:34:20
Zozo says that the last modifications don't work  on a 10 MHz Enterprise.

Second tentative for CPU efficience:
 
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2015.December.08. 20:38:45
Now working!
Title: Re: Universal Mouse Driver
Post by: gflorez on 2015.December.08. 22:02:57
Good news!
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.01. 13:55:22
Happy year for all!


----------------------------------------------

Today I bring here a weird experiment. I have fooled the Mouse driver to think that a TEXT 80 mode is a GRAPHIC HIRES one(mode 2 processed as mode 1) .

The attributes of the two modes are very different so the pointer is shown like a mess... the hack is very stable and only produces artefacts when the Editor cursor collides with the Mouse pointer.

Also up and down movements are swapped, and the scroll hides sometimes the pointer or it appears where we don't expect...

Play a little with the internal joystick to see the effect.

It can serve as a teaser of what I want to implement... But I progress very slowly.
Title: Re: Universal Mouse Driver
Post by: endi on 2016.January.01. 14:51:51
try to read the memory address of the row from the lpt row
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.01. 16:25:28
At the moment it is the driver drawing rutine who does the work. I still haven't modified it to manage mode 2.

Edit: Ah, you mean to avoid the scroll effect....
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.04. 15:34:00
I forgot to say, this special Mouse driver has been modified to accept the text screen.

The behaviour of the Editor with the screen lines can be better viewed in this snapshot. The test Basic program creates a new Text 80 window and the Interpreter is maintained in a loop after the Mouse channel is opened.

The mouse pointer works normal, except the bad attributes issue.

But once you press STOP, things turn to be worse...

The solution, like Endi points, is to use the LPT addresses instead of the direct memory addressing the mouse driver uses.
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2016.January.04. 15:42:52
except the bad attributes issue.
It is a normal, not a surprise.
Text 80 use 8 colors on Hires-2 page, two high bits of graphics data used for select color pairs.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.09. 11:00:40
I am now working on the option 6, Microsoft serial. A very big error has stopped me for months...

At least now the pointer moves, but jumpy.

Actually serial movement is mixed with the internal joystick movement. Zozo suggest to leave serial alone, as the mix is no more necessary. It seems easy to do.

And, how about a secondary button for the joysticks options(0, 1 and 2)?

All the other options have at least two buttons(Boxsoft only when emulated on Entermice). On the external joysticks is easy for me to select a candidate button, but I need a secondary button for the keyboard.

Any suggestion? Maybe Enter?
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.09. 16:03:23
By the way, what key combinations  use SimbOS for mouse buttons on the internal joystick mode?

Edit: I've found them: Ins and Stop as main and secondary. That combination is not possible on EXOS...

Alt is in the same row(8 ) as Space. May be Alt+Space? Is there that key combination in EXOS or the Editor?
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.11. 02:29:41
Imagine a program that makes use of the mouse driver. It reads mouse movement and at least the main and secondary buttons. The main button to select some areas or objects in the screen, and the secondary to change aspects of the selection.

Until now this could not be done with the internal and external joystick.

You can say this is false, but I mean only "using the driver".

Changing values to the System Var 189 you can use six modes of input device.

When programming for Entermice, the aplication now can be tested on a bare Enterprise without the adapter, because I have added Enter as the secondary button(main is Space) when using the internal joystick. No more buttons or wheel simulation, sorry, but enough.

Also I have added secondary and centre buttons on external joystick, compatibles with the new second and third fire buttons that Entermice provides.

The buttons will be shown on System Var 190 for proper coding.

For now I am still betatesting.....

Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.18. 10:14:21
As a suggest from Zozo I begun this last weekend to think of a way to implement an automatic detection of the connected controller. This is chronologically what I have been thinking:

There are some problems here, one of them is how to discriminate Boxsoft mode from EnterMice mode.

Theoretically it could be done comparing the lectures of the two columns, J(Boxsoft) and K(EnterMice), in the same cycle, selecting the column that returns different than 0,0. But the user must be moving the mouse in one of the modes, as a lecture returns 0,0 if not moving, the same if not exist or disconnected.

Both modes have extended Prodatron's protocol when in EnterMice adapter, and also Pear's protocol extension.

Pressing main buttons can do, but Entermice mode uses fire of Joy 1, and it collides with detecting the three Joysticks.

On the other side the Joysticks return nothing when in rest position....
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.18. 10:15:56
Then Zozo said:

I suggest ask Prodatron how Symbos detect the mouse. Then need to run this routine on K and if not found run it on J.
If both not found then try to search serial mouse. It is also not found then set the default to internal joy.
These will be done in the initialization part and set the default for the variable 189.

If I know right Symbos try to read few times the mouse, and if only read empty values, then mouse not conected.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.18. 10:17:56
I said:

Mouse on K and J can be read at the same time, the Mouse.xr routine takes the data of the three columns at the same time. Discrimination of Boxoft or EnterMice can be made in only one cycle if the mouse is moving.  The same can be said for the joysticks. Serial can be detected by the movement and, only when initializing the UART, discriminated by the "M" character.


I think the best option is:

A new setting on var 189, for example 7, as automatic.

1-Initialise the driver.
2-Put a counter to 0
3-Test the controllers.
4-Found one of them moving?, take it as the "working" one.
5-If not, default is the the last "working" one, if not the internal joystick.
6-Normal lecture cycle and drawing. If still moving, go to 6
7-Increment the counter only if not moving. If not greater than a given value, go to 6
2-An opportunity for a change.... go to 2.

I think it can work if the pauses on the movement are utilized to search for controllers.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.18. 10:21:07
To discriminate the Joystick 1 from the Boxsoft the only way I know is to search for an "impossible" combination for a joystick:

No more than two direction keys can be pressed at once.
Only the Up-Right, Right-Down, Down-Left or Left-UP pairs are acceptable.

I think is easy to find an impossible value in one or two cycles.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.18. 10:23:36
To find connected controllers:

First step:      Search for activity on the two controller ports, all the 10 rows, reading port B6 bits 0, 1 and 2.
                    Found activity, if in K column the controller is directly an EnterMice.
                    Also if the activity is on J column but on a row greater than 4, the controller is Joystick 2
                    Discriminate the controller on J column lower rows by the procedure on the previous Message.
                    No activity, no mouse nor Joystick.

Second step:  Initialize the UART. Is there activity? If found we have a serial card.
                    Wait for the "M" character. If received it is directly a Microsoft mouse.
                    Initialisation code not received but movement received. Mouse Systems mouse.
                    No UART activity or no movement received. No serial mouse.

Fourth step:   If no activity found, set internal joystick as working controller.

No problem if two controllers are moved, the first found is the working one.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.18. 10:25:35

It can be extrange to search for movement on pauses of movement, but it is possible  because the user leaves resting the "working" controller and touches another, making it the new "working" one.

If the "Search Controller" routine is made fast enough it can be run at any situation, may be "pre-discriminating" serial modes at the initialisation: Is there a "serial card and mouse" connected? Is it a Microsoft mouse?
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.18. 10:27:45
May be we can implement a new system var  with the possible controllers that can be searched. One byte with every bit meaning a controller, put to 0 if forbidden  or 1 if present. The list beginning with joy1, as the internal joystick is always active. This leaves us two bits for future use.

On initialisation, the driver can put serial options to 0 if no serial card or serial mouse plugged are found.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.19. 12:58:17
A new System var can be excessive, better at initialisation an internal variable. Then a command can be  implemented to exclude a controller type, some like this:

:MOUSE EXCLUDE 3 5 6

--------------------------
Implementing commands can be very helpful  if "mouse pointer on a text mode" is achieved, because then it would be easy to open the Mouse device on an Exdos or WP screen only typing something like this:

:MOUSE £102
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.27. 12:25:48
Here is a new version of the mouse driver, this time there are a few modifications done:

-The :PB command has been removed definitively from the driver. Now the driver auto-initialises itself, and the EGI doesn't hang with this version.

-The Enter button now is the secondary mouse button when in Internal joystick mode(option 0).

-Also on the external joysticks(options 1 and 2), the two additional buttons implemented on EnterMice now act as the secondary and middle buttons.

-Now the serial Microsoft(option 6) begins to work (Zozo says it moves, but a little jumpy...).

I will update the links on the EnterMice wiki as fast as possible.

Edit: Done, but the wiki information still needs to be updated accordingly.

Edit: All wiki pages updated.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.28. 11:30:53
I have to explain why the driver didn't work with the EGI when I removed the :PB command on formerly versions.

I think it was because the mouse driver never passed the beta-testing phase. The driver needed to be loaded, then the mouse device was linked but not initialised. Then the user(from Basic or the Paintbox program) needed to  type the :PB command to initialise it.

The coders of the driver wanted to initialise only the mouse, not the entire system, so the initialisation ended with registers "c"=0 and "a" loaded with the memory page where the driver was loaded.  This is why the initialisation command produced an error, 9000+memory page. The characteristic was only needed for testing purposes.

This behaviour was not important with the Paintbox program, because the resulting codes where ignored, but when the EGI loads, it takes over the entire system and initialises it sending the "Action Code 8" to all devices.

My error was that I only changed the :PB command by an  "Action Code 8" entry, not changing the results on registers "c" and "a" at the exit. The value on "a" can be 0 or an error code, but "c" must be 8 if we want the initialisation to be spread to all the devices(EXOS Kernel Specification 9.2.8 ). As a result, the drivers initialisation call always was stopped when it arrived to the mouse driver, so the EXDOS interface and other important devices ceased to be initialized.

It can be that the EGI coder, Rhodri Cusack, knew about that issue but didn't want to correct the Mouse driver by himself, as it wasn't his own creation.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.28. 11:46:29
I forgot to say that, in the actual version, the serial modes buttons and movement no more are mixed with the joystick modes.
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2016.January.28. 13:49:30
The coders of the driver wanted to initialise only the mouse, not the entire system, so the initialisation ended with registers "c"=0 and "a" loaded with the memory page where the driver was loaded.  This is why the initialisation command produced an error, 9000+memory page. The characteristic was only needed for testing purposes.
This is totaly EXOS incompatible solution! A for error code not for anything else.
(And if the MOUSE.XR loaded to segment F0h then you can decide Mouse.XR are present or not...)


Quote
This behaviour was not important with the Paintbox program, because the resulting codes where ignored
I'm sure the origin of PB are from PaintBox. Probably some early version used the ruterned value?

Anyway: good to forgot this strange - and very frustrating - solution!
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.28. 14:12:33
I think they wanted to easily SPEEK the content of the driver variables while modifying the code, so they needed the page address where it had been loaded.

Of course, PB stands for Paintbox, the program types the command internally. May be somebody though the initialising command as a future copyright protection? The command is not mentioned inside the manual...
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2016.January.28. 14:18:40
I think they wanted to easily SPEEK the content of the driver variables while modifying the code, so they needed the page address where it had been loaded.
More easy and compatible solution use a EXOS variable. For example the EXDOS store the EXDOS segment number to variable 64.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.28. 22:36:49
Still there is a spare 190 system var, may be at the end it will be used to store the Ram page if finally the Mouse driver Rom is  made.....




Edit:

Sorry, it's  my mistake, 190 is used for buttons and wheel(sometimes I don't remember what I have created....), but 191   is still unused.  192 and forward is used for Epdos (http://enterprise.iko.hu/variables.htm).

Also below 180, slots from 162 to 179 are still unused.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.31. 00:01:14
I've discovered that the last version of the mouse driver collides with  the Reset funtion of the Enterprise because the mouse device is linked on every initialisation. If the Reset button is pressed the computer freezes on a solid screen. If pressed again it returns normally to Basic but then the driver does't work, the program in Basic is erased and the EGI also can't work.

I think is for that error that the Boxsoft team created the :PB. It only works if initialized individually, because it only can be initialized once.

For now I have to think on a way to fix it. At least this version works the very first time....

Anyone who wants a healthy OS, better use the formerly version...


------------------------------------------

When no mouse is connected, no mather if Boxsoft or Entermice modes, the pointer slowly goes to the bottom right corner.

This is produced because the joystick ports when not in use give all the direction bits set to 1, so a 255 is returned. But 255 is -1 for the Neos reading routine. Then a (-1 , -1 ) is executed every reading loop....



Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2016.January.31. 08:10:41
When no mouse is connected, no mather if Boxsoft or Entermice modes, the pointer slowly goes to the bottom right corner.

This is produced because the joystick ports when not in use give all the direction bits set to 1, so a 255 is returned. But 255 is -1 for the Neos reading routine. Then a (-1 , -1 ) is executed every reading loop....
This can be used for autodetect!
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.31. 13:13:10
Yes, and without moving necessarily the mouse. To receive the same results from a connected mouse you have to move the mouse as slowly and exactly the same diagonal direction, all  while the checking is done.

_-----------------------------------

About the initialization, I plan try to open a false mouse channel. Then what EXOS first do is to look for the device. If not linked then it gives the error and I can know then if I must initialise it again.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.January.31. 20:14:18
Another Mouse driver version.

I have at last fixed the driver initialization. Now the driver resist a soft reset, because when an initialisation code(8 ) is received, it tries to open a channel to the Mouse device. If return code is FAh(*** Device does not exist) the device is linked again. Any other return code say us that the device is active, so no action is done.

Also I have sorted out the buttons of the joystick ports, as I swapped by mistake the Central and the Secondary ones.

Edit: Links on all the EnterMice wikis updated
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.February.01. 00:54:09
I've found a slightly "harmful" error on the driver:

-My Basic program opens a GRAPHICS LORES mode screen. It defaults to channel #101.

-Then it opens a Mouse channel to that screen. The mouse pointer appears...

-I press the STOP key and the Basic program stops but the mouse driver continues working.

-I type TEXT. The  101 channel disappears but the mouse driver continues drawing the pointer on what it thinks is still the graphics screen....

If I move the mouse enough(or the internal joystick in this case) it will produce an error on the EDITOR buffer...., or worse...
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.February.01. 01:30:43
The problem here is that the Mouse driver only checks the Video channel just at the openning of the Mouse channel, but no further checking is done until the Mouse channel is closed.

The graphics screen can even change its dimensions and the Mouse driver will not be aware of it.

I think, at least the existence of the video channel must be checked from time to time. I have to mark this on the "TODO" list.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.February.01. 11:18:40
Courtesy of Nick Milner, the gentleman that brought us the EGI from the distant past, some examples of the use of the Mouse driver in Basic.

They are on the disk 2 of his five disks, WIMPS directory:

MS_TEST.BAS is the example described on the Boxsoft manual.

ICON1.BAS, ICON2.BAS, ICON3.BAS, ICON4.BAS and ICON5.BAS are stages of a work in process program that nick was writing... They give a good idea of what can be achieved with a simple basic program, clicking on icon zones.

Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.February.02. 01:08:15
I'm sorry if someone gets bored while I am thinking aloud....

Following with the plan on how to auto-detecting a controller, a single byte counter can serve to know how much time the mouse has been idle. If the movement received is (0, 0 ) the counter is incremented, if not it will be put to zero.

Then, if a count of, for example, five seconds(250) is reached, the video channel is checked if still open. If yes, an auto-detection routine is triggered if the controller type on System var 189 is set to automatic. Return to the main routine.

If the video channel is found closed, then the mouse channel is also closed.

Edit: Five seconds? better if the limit is the result of experimentation, but I think that  only a second can be enough.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.February.03. 12:42:07
Another version......


I have corrected the PaintBox error introduced two versions ago....

Now the driver reacts to a :PB command only if the MOUSE device is not linked, the same as if an initialisation code(8 ) is received. This is the best of the old driver and the new one. All programs work.

The exit codes of the :PB command are left like in the original Mouse driver, C=0 and A=(in a, (0B3h)). It works....

Here begins a new numeration of the driver's version, starting at 1.100.

Edit: Wiki links updated.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.February.03. 23:25:18
Here is a boring video (https://www.dropbox.com/s/4zi1lpcf0x7qmts/Mouse.xr%20in%20action.mp4?dl=0) I've made with the emulator about using the Mousedriver in Basic, EGI and PaintBox.
Title: Re: Universal Mouse Driver
Post by: geco on 2016.February.04. 08:47:36
Cool :)
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.February.05. 12:09:47
Ron, a friend from Retrowiki(Spain) has put the video demonstration on Youtube (https://www.youtube.com/watch?v=ef9yOXtVqxU).

Edit: A shortened version.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.February.08. 01:25:24
How can I know if the video channel is closed within the interrupt call of the mouse device. EXOS doesn't admit calls when executing the interrupt call. I've tried call 9(read channel status) or 11(b=3 Special function= Video page addess) but both return always FEh(EXOS Function call not allowed)

Is there a list of opened channels that I can read and test easily on memory?
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.February.24. 12:02:57
OK, I can't test if the associated video page has been modified or closed. I will return to this problem if sometime the driver is put on Rom.

-------------------------------------------------


Now, just to clarify my mind, I will present here the logic I pretend for Autodetect mode(sys var 189=7) on the mouse driver.

Checking only for the presence or not of a controller is very difficult, as the controllers can be  digital joysticks, MSX protocol or serial protocol. The presence can be more or less detected only on some of them, MSX and serial, but not on the joysticks.

Then I have though that the easiest way to switch between controllers is to search for activity on the different ports, just when the user stops the active controller and begins to move other.

But in order to use this method, first I need to know if a serial card is present, then, if a mouse is connected, its protocol, Mouse Systems or Microsoft. This can be figured out just at the initialisation of the serial card, so no problem here.

Is a fact that all Enterprises have an internal joystick..., is the only controller that is always connected, so it will be the default state. Priority is EnterMice(4 ), Boxsoft(3 ), Mouse Systems(5 ), Microsoft(6 ),  Joystick 1(1 ), joystick2 (2 ) and Internal Joy(0 ). The first found activity makes it the active controller.

The Autodectect routine can be as this:

-At first the active controller is the internal joystick(0 ).

-Normal mouse reading loop.

-After 50 mouse readings(1 minute ) of the active controller without movement the auto-detection routine is triggered.

-Read columns J and K, rows 1 to 4, on the controllers ports and check for activity.

           -Is there activity on column K? If yes, make EnterMice the active controller and return to Normal mouse reading loop.

           -Is there activity on column J? If yes, check for impossible movements. If found, make Boxsoft the active controller and return to the reading loop.

-If there is a serial mouse we already know what protocol it has so, if there is activity make it the active controller and return to the reading loop.

-read column J rows 1 to 4 and 6 to 9 on the controllers ports and check for activity.

           -Is there activity on rows 1 to 4? If yes, make Joystick 1 the active controller and return to the reading loop.

           -Is there activity on rows 6 to 9? If yes, make Joystick 2 the active controller and return to the reading loop.

-Make the internal Joystick the active controller and return to the reading loop.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.February.24. 16:51:34
Now we have to consider, do we need Joy1 and Joy2 to take part on the mouse auto-detection?

I think that the external joystick ports have to be saved to only play games. They where planed for it, and are used on the vast majority of games, even z80 conversions. They could still be forced to control the mouse pointer if 1 or 2  is selected on sys var 189.

And, what about the Boxsoft mode? I think of it as an aberration... now that finally EnterMice exist...  Tim Box already knew the existence and potential use of the K and L commons on the control connectors. But even so he insisted on using the J common, which from the Enterprise conception was assigned to and used for the external joysticks . The use of the Boxsoft mode collides with programs that expect  joystick movement instead of the extrange data that a mouse gives. Prodatron has announced EnterMice compatibility for the next version of SymbOS, the only program that still needs the Boxsoft mode. That day will be the beginning of the end for the Boxsoft mode... Of course it still could be forced with the system variable 189.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.February.25. 23:38:26
Why Boxsoft+Neos is  so incompatible with some programs?   Is EnterMice as incompatible as Boxsoft?

I mean, the normal value when we type PRINT JOY(1) in Basic is 31, or "000 1 1 1 1 1", if the stick is in the middle position or not connected.

I can't test it in this moment, but I am sure the Neos returns 0 or "00000000" when it doesn't receive /strobe signals, but I'm not totally sure if EnterMice(in Boxsoft mode) gives the same.

This is an important aspect, because "1 1 1 1"(UpDownLeftRight) is a possible but infrequent value  if read from the Neos or EnteMice, so it can be used to know if an interface+mouse is not present. Then it can be discriminated. Also it can serve to know if the Joystick  1 is inactive.

 "0000"(UpDownLeftRight) is an impossible movement if returned from the joystick port, so it can serve to know that a mouse device is present but motionless. No joystick 1 is connected.

There are about other 6 impossible combinations that can serve to discriminate a moving mouse, but  Is a pity that some values can still be possible for both the Boxsoft and Joystick 1 modes.
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2016.February.26. 07:43:01
The default JOY(1) value are 0.
It is also true for Boxsoft (at power on), until the mouse button first time pressed. When pressing mouse button, then send random data (without strobe!), most of times value 15. If mouse moved and button pressed again then value changed.

EnterMice don't send random data without strobe.
Title: Re: Universal Mouse Driver
Post by: pear on 2016.February.26. 08:10:28
A small imcompatibility, but it's probably okay ?
This eliminates the need to remove the mouse when you want to use the joystick.
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2016.February.26. 09:03:22
A small imcompatibility, but it's probably okay ?
Yes, this solution are better!
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.February.26. 09:05:24
Not a great problem, but It convices me even more to not include Boxsoft on the autodetect routine. It is not a fault on the EnterMice side, but a virtue, as it wouldn't collide with some programs when in Boxsoft mode.....
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.February.26. 10:46:09
The default JOY(1) value is 0.

Yes, of course it is. Only that I was playing with the mouse eulation of XEP128, that works different from Boxsoft and EnterMice.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.July.27. 02:34:09
I'm still intrigued on implementing mouse on graphics modes 0 and 2.

I have almost figured out how, but there are little details that prevents me to complete it.


Static pages aren't the problem, it is very easy to make work the mouse driver on a page that has a static LPT. The driver does perfectly on graphics modes only with EXOS calls(@@SIZE and @@ADDR). Text modes can be even more easy, as we only will move the mouse pointer between character boundaries.

The future TEXT 40 mouse mode will have a single defined font character, the same on the 80 mode, with some form of pointer. But to make tests easier, on the first attempts I will use the 255 ASCII(that strange "b" character) on TEXT 40, and a blue underline(also 255) on TEXT 80 mode.

But I also want mouse control on the Editor pages, where the LPT lines can be strangely mixed.

For example, on "normal" Basic Editor pages, TEXT 40 or 80, we have fixed sizes of 40x24 0r 80x24. The mouse driver maintains its X and Y own coordinates, and the LPT can serve to know what character is on the coordinates.

This is the procedure:


-The Enterprise is loaded with a program that makes use of the internal Editor.

-The interrupt routine halts the main program and makes a call to the mouse interrupt routine.

-If there is already a mouse pointer drawn, it is erased. For that, the driver maintains stored the original character that was on the old coordinates. But the Editor could have altered the position of that line on the LPT, so the old address and segment was stored on the last interrupt cycle.

-The LPT is used to know the actual value inside the coordinates.

-The actual value inside the current coordinates is stored, with the exact NICK position, segment+address. A 255 is stored on that position.

-The control is returned to the main program.

This procedure can work, but I want to extend it to all possible editor modes, the four editor lines that remain when a GRAPHICS mode is recalled, the EXDOS or ISDOS editors, or even other languages editors, including of course the WP editor.

I want to call the mouse driver from an editor and it start automatically without the need to open the mouse channel. Only typing :MOUSE ON or :MOUSE OFF, for example.

But an Editor page can have variable size and position on the LPT, and I don't know if there is an easy way to know it.


 

 
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.July.27. 02:55:14
Another problem will follow eventually once the mouse text modes would be implemented, the use of the mouse buttons.

For example, the right button can serve to change the editor cursor to the mouse pointer coordinates, while the left one can act like the Enter key. Even the wheel can be used to scroll the editor page.


But....., within an interrupt call, writing to a channel is forbidden, so the keyboard buffer must be accessed directly to put there the scape sequences or the "0Dh" character. 

How can it be done?
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.July.28. 20:07:19
Let's think on an hypothetical example:

The mouse driver tries to know all parameter of the text page to move there a pointer.

It is not in interrupt mode, so it can call EXOS to check the Editor system var 29, VID_EDIT, to know the channel of the text video page where the Editor is working(more dirty directly on address BFE2h).

Next it call the Special functions @@ADDR and @@SIZE.

But it doesn't know where on the LPT is the video page....(It is necessary for the implementation I am figuring out)

Should it check all the LPT lines for their memory address?
Title: Re: Universal Mouse Driver
Post by: geco on 2016.July.28. 21:39:28
I think, yes, I know only this method. If Zozo does not know a better one...
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.July.28. 23:16:50
OK, thanks. It seems to me not very difficult to check the lines.

Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.August.03. 21:34:25
Thinking about checking the addresses on the LPT for the text modes, I have discovered a way to test if a graphics channel has been modified, and then proceed to close a Mouse channel associated to it.

The  @@ADDR special call returns the display Ram address of the video channel.

I think it is a mater of searching and storing the LPT line that holds that value and compare it often, every second.

Of course this only serves for static video channels, not for Editor video channels.

This is advised on the EXOS video driver specification on page 5 chapter 3:
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.August.07. 21:47:33
I am slowly progressing.

Now, every time a mouse channel is opened, the driver checks on the associated video page the LPT line where it is first displayed. If found, also the 16 bytes of that LPT line are stored for future comparisons to check changes on the video channel. I have tested Paintbox, that alternates two mouse-video channels, and the process doesn't make any noticeable slowdown

Video pages with first line not displayed are rejected.

Limitation to only graphic pages has been removed, but I am still on an early stage implementing the mouse text modes on Machine Code.

Editor modes, hard/soft text, will be managed slightly different, as its first video page line can be or not the first LPT line shown. An account of shown  channel lines has to be made to know the first LPT line on display, before working on them. Discrimination of Editor video channels can be made with the system var no. 29, VID_EDIT.
Title: Re: Universal Mouse Driver
Post by: lgb on 2016.August.08. 01:30:31
I admire your willpower with an universal mouse driver, to be honest :) I think, somehow, it should be part of the "base" system, ie EPs usually should :) have VIDEO: and KEYBOARD: driver to be really useful for anything :) After reading your posts here over the time, I am more and more sure, that the bulk of the problem would be lowered with tighter integration of mouse driver with these "main" stuffs. However it should require an EXOS with built-in mouse driver for example :D Maybe Zozo would consider it later? :) Anyway I like the idea of universal mouse driver, to be honest, I wouldn't have the idea to turn this as this universal stuff as you would like to do ... I don't mean it's a bad thing, but the opposite!!!! :)
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.August.08. 09:30:53
The "Universal" word comes from the more or less achieved task of unify all the direction devices, but at the end only the EnterMice and the internal joystick will be "widely" used. 

Then I also want universality on the modes, graphically or text, because is the only way that the user base can take seriously the mouse device.

But the most "normal" of the modes is the Editor, and it mixes the LPT lines on a way that is incompatible with a mouse pointing device. The solution I have found is to limit the movement to character boundaries.

Of course If I get it done, the driver will be better included on a Rom. This also has its problems, as the variable zone of the driver is inside the code.

Don't worry, what guides me in my efforts is the enjoyment, just like you with Xep...

Only that I'm not a good programmer.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.August.16. 01:32:52
Another problem solved.

My LPT line searching routine works the same on all modes.

Now it searches for any video page line displayed on an LPT line, because it checks sequentially all the LPT video addresses to be contained on the buffer of the video page. Including Attribute mode or hardware text cases.

To do it, first the buffer of the video page has to be calculated multiplying rows x columns x pixels.

Even in the worst case of Editor video pages with all its lines mixed, now the upper LPT line displayed is found correctly.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.August.27. 12:16:51
Now that I can store the first LPT line of the video page associated to the mouse channel, I have returned to my old idea of closing the mouse channel if something changes on the video page.

Now the driver compares the actual LPT line with the stored one, if there isn't movement in five 1/10 of second. This behaviour can be modified later if necessary.

It seems to work, expecially when TEXT is typed when a mouse channel is shown on a video page while on Basic editor mode.

I have to check it better but theoretically it won't work if the lower part of the mouse video page is resized, as only the first video page line is checked.

Also, the mouse channel will remain open, because closing it is a task of Exos, and it is not possible to do a call within an interrupt. The driver will only deactivate itself.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.August.28. 03:42:50
Predictably, all the actions that modify the upper LPT line displayed deactivate the mouse driver.

For example, CLEAR GRAPHICS doesn't close the driver, but DISPLAY TEXT and again DISPLAY GRAPHICS, disables it.

The same with DISPLAY AT, the mouse channel has to be opened after it, but we can use again and again the command, provided that the upper LPT line displayed is left untouched.




I am reasonably satisfied with this approach.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.September.01. 00:08:05
I'm now thinking on the  text modes.

As their pointers are only drawn on character boundaries but they work with pixel coordinates, the driver will have to constantly convert them to text coordinates.

At first I was thinking to check every erase-draw cycle if the pointer has been moved of character boundary. Then, if not moved, the mouse driver could save some processor time not redrawing the pointer on the same place.

But on those modes the pointer will be a lot quicker to calculate and draw than on graphic modes, so I think of that procedure as totally unnecessary as it would waste more than the saved time. The actual routine jumps erase-draw cycles if no movement is detected.

The minimalistic pointer will be erased and drawn every cycle.

Of course this is theoretical, as I still haven't implemented the text modes.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.September.05. 15:32:28
Today I come with something to taste, those with a working Xep128 or an EnterMice can see how a pointer can be represented on a text mode.

First download this beta version of the Mouse driver.

Then install it on the Enterprise, copying it to the SD, floppy or SD-image.

Execute Mouse.xr and the driver is made resident until the next hard reset.

Then type the Basic listing and execute it. The Basic program will stop but you will see that odd red character or a blue underline in the middle of the screen.
 
Move the mouse pointer wherever you like....

You can type something or move the internal joystick while moving the mouse pointer.

Observe that the Editor scroll doesn't interrupt the action.

If you change to 80 text mode or vice versa, please close channel 1 before doing it, as it can cause errors and I still have to refine the driver.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.September.06. 13:05:19
I have made this snapshot for Ep128emu, but the control is made with joy 1 so, very squary and slow movement.
Title: Re: Universal Mouse Driver
Post by: geco on 2016.September.06. 18:29:26
It is good, I see one thing what could be better, if 2 direction is pressed eg right+up then cursor is drawn twice, 1 step up, and then right, 1st drawing step is not needed.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.September.06. 18:46:48
Yes, but it is because EP128emu is using joy1 as mouse controller, and the movements are contiguous, 1 character boundary at a time. I can assure you that with a mouse the pointer jumps naturally long distances when you move fast your hand.

Now you have a working Xep128. Please, why don't you try this beta mouse driver on it? 
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.September.06. 19:57:55
I have to explain it better.

The mouse driver works internally in pixel coordinates on all modes. If you read the Mouse driver system variables, 184 to 187 you will be returned with the coordinates on the pixel grid.

But on text modes the pointer moves by character boundaries, and the driver converts on the fly the pixel coordinates to rows and columns, dividing X and Y by 8(or 16) and 18. Only absolute numbers are allowed, so it can be that some pixel coordinates on very short distances, lower than 8 or 9 pixels, give odd values.
 
As I said before, trying to correct this will lead to more complex routines that would waste more time than the saved.

But with a  mouse controller this "error" is unnoticed, the movement of the pointer is more natural than with a joystick, because diagonals don't have always 45 degrees like on digital controllers.

 
Title: Re: Universal Mouse Driver
Post by: geco on 2016.September.06. 22:30:54
unfortunately the mouse has strange behaviour on XEP at me, MOUSE.XR works like mouse not attached, the cursor goes to the bottom right corner, I tried SWAP, there the pointer moves, but bit abnormally.[attach=1]
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.September.07. 00:20:25
You have to set EnterMice emulation on Xep128 config file. " mousemode = 4"

Then "set 189, 4" on Basic.

Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.September.09. 02:58:16
I have at last fixed the errors when changing modes or the video page is closed. New beta version on the message above.

Also the underline pointer on text 80 has been moved 1 pixel higher for better view.

 ------------------------------

Now I have to find a way to interact with the Editor when clicking.

When found I'll implement a new Mouse command to automatically open a mouse channel on video channel 102.

Typing something like ":MOUSE EDITOR" will serve to have an active mouse pointer on Basic, WP or Exdos.

But prettier names for the command are accepted.....
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.September.09. 12:11:27
But.... the command may be insufficient, It can be tedious to type the command on every Editor session.

I have a better idea: with the mouse driver installed and once inside an application, only a left click will activate it if no other mouse channel is open. Or if the two main buttons are clicked at the same time. This is possible because even without an opened  channel, the driver is still accepting interrupts, and then it can check key clicks all the time.

Of course this can collide with other programs that open a text page without using the editor. I have to study how to implement it.
Title: Re: Universal Mouse Driver
Post by: geco on 2016.September.09. 20:29:11
It is a good idea :-)
Thx , i will try to modifiy the config file.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.September.21. 16:23:40
Now that EP128emu emulates EnterMice, I can put here a snapshot. Obviously it will only work on the beta version (https://enterpriseforever.com/ep128emu/ep128emu/?action=dlattach;attach=16281).

It shows how a mouse pointer can work on a text video page. Observe the red characters at the left. When the mouse pointer and the Editor cursor collide that is what happens. But that is only seen on the screen, not saved on the Editor buffer. If the screen is scrolled the artefacts disappear. Better don't move the two controllers near at the same time.

You can also test Text 80 mode, simply type "text 80"+enter and then "run"+enter.

Still I've not figured out how to inject a escape sequence to the Editor channel(esc+=+Y+X).

The structure of the channel descriptor is not on the EXDOS Technical Information, so I am a little lost...
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.September.23. 23:53:37
I have promoted the mouse driver to 1.102.

The changes are:


-The velocity fix introduced on version 1.1 by Boxsoft didn't had protection  against verbose and  that produced jumps to the pointer on some extreme cases. I want to thank IstvanV for detecting the error and fixing it himself.

-The newly implemented text modes don't produce big problems to the editor modes, so they will remain as definitive. Later I can change the aspect of the underline hi-res pointer if requested. The low-res pointer uses character 127, so it can be redefined.

-A new  check every 5/50 sec of pointer idling has been implemented to test if the video page has been modified. This protects the mouse channel from drawing the pointer out of the video page. The protection is partial, as it only checks the very first LPT line of the video page associated to the mouse channel, but will suit most normal cases. This system works on all video modes, allowing scroll on text modes.

I am still searching for a way to print escape sequences on the Editor channel while on interrupt.... It will allow the use of the mouse on every application that uses the Editor.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.September.29. 08:02:02
With the aid of Epdos commands CHANS and DEVS, I have figured out how can I force the Editor coordinates when inside the mouse driver interrupt.

The descriptions given by the commands, and also the information inside the EXOS disassembly pdf, have convinced me to emulate the little routine that is executed when the "ESC+=" escape sequence is written to the Editor channel.

The problem is that I must emulate the original Editor driver and also the modified Editor driver that is installed with the language Roms.

The original ones manage their variables on fixed memory  address on segment FF, different for Exos 2.0 and 2.1, while the modified Editor driver works with a relocatable memory area. Of course I will discard the Exos 2.0 version, because the mouse driver doesn't work on earlier Enterprise.

As a curiosity, I have found that on Exdos 2.0 the system channel numeration begins on 97h(151), while on the definitive versions it begins on 65h(101).
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.September.30. 10:52:10
The EnterMice wiki (http://wiki.enterpriseforever.com/index.php/Main_Page#EnterMice) has been updated.

Now there is a brief mention to the new text modes. For now I am not putting more because they are still evolving. I hope to change soon the hi-res underline cursor to the same character than on low-res mode. Then, as an added bonus, both pointers will be redefinable on the same character 127. Even I can redefine it as an arrow inside the driver.

I have reduced the warning about closing the mouse channel if the video page changes or is closed, as now the driver auto-checks and deactivates by itself.

Also I have put the superb EP128emu on the emulators chapter.
Title: Re: Universal Mouse Driver
Post by: pear on 2016.September.30. 17:05:04
Polish version was updated.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.02. 13:11:29
Thought out and done, mouse arrow pointer on Text 80.

The driver redefines character 127 to the arrow sign at initialisation so, it can be changed later inside a program.

Also the pointer follows the colour codes of System Var 183(Pointer_colour).
Title: Re: Universal Mouse Driver
Post by: geco on 2016.October.02. 14:14:32
coool :)
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.02. 14:59:43
It is good, I see one thing what could be better, if 2 direction is pressed eg right+up then cursor is drawn twice, 1 step up, and then right, 1st drawing step is not needed.

I want to explain a little why the pointer movement seems a little erratic on short movement compared to the cursor movement.

First to say that the Editor cursor movement  has  freedom to move, four ways, but only one character boundary per cycle, while the pointer can move more ways on longer distances, jumping boundaries. Then, is normal that the cursor track is more precise than the pointer one. Also keep in mind that the Enterprise Editor has a corrected diagonal movement, alternating the two selected keys.

On my text mouse pointer approach the driver maintains internally the graphics pixel coordinates for compatibility, but they are converted to rows and columns to print the text characters. In the conversion some character boundaries are slightly touched but drawn anyway. Is for this that some places seem odd when moving the pointer with the internal joystick. But with a mouse it isn't noticeable.

See the picture attached, how the pointer draws more boundaries than necessary.

Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.08. 01:17:04
I have implemented a new command inside the Mouse driver  that opens a mouse channel.

By now it only works sometimes and with some applications(I still don't know why).

First I have to specify the video channel associated to the Editor channel, every app uses a different one. Then I execute the command.

Here are some examples:
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.08. 18:50:13
WP has been more difficult, as I have discovered that F8(EXOS) only admits commands  of two words. Then, for example,  VAR 186 4 (EnterMice controller mode) is not admitted.

Touching the ruler makes the driver confuse the pointer coordinates.

WP maintains six Video channels and two Editor channels.
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2016.October.08. 19:16:55
WP has been more difficult, as I have discovered that F8(EXOS) only admits commands  of two words. Then, for example,  VAR 186 4 (EnterMice controller mode) is not admitted.
???
It is working, also tested in your snapshot. Anyway also working VAR 186,4
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.08. 19:24:14
I'm not expressing me well, the command is accepted, but not executed.

Try F8 and type VAR 189 0  (Internal joystick controller) on my snapshot. It is unaffected and EnterMice continues being the controller.


I have accessed the vars exiting to Exdos, changing them and re-entering with the Esc key.
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2016.October.08. 19:32:29
Try F8 and type VAR 189 0  (Internal joystick controller) on my snapshot. It is unaffected and EnterMice continues being the controller.
It is problem somewhere in the mouse driver :oops:
If you check again with VAR 189, the right value reported.

(And for example try using COPY command, it is least 3 words :-) )
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.08. 19:52:41
You are right, but this only happens on WP.
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2016.October.08. 20:02:13
And I verified in debuger, at the entry point of mouse expansion got the right parameters from the EXOS after the VAR command.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.08. 20:41:57
Sorry, it seems that something is corrupted on the snapshot. If I try to exit to Exdos it hangs.
Title: Re: Universal Mouse Driver
Post by: IstvanV on 2016.October.09. 10:51:22
The EXOS variable seems to be stored at e0:0bd1 in the snapshot, but it is never read while using WP, it is only written when the VAR 189 command is entered.

Edit: there is apparently a problem with more than one instance of the driver being loaded, one is on segment DEh and another is on E0h, the variable is written to the latter, but the mouse input code runs on the former. That explains why VAR 189 does not work, but the corruption issue still needs to be debugged.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.09. 12:21:01
Thanks. I loaded again the driver, I forgot it....
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.09. 19:44:57
That second instance of the mouse driver is caused by my poor PB fix.

On the original Boxsoft versions of the extension,  a PB command had to be typed to initialise the driver.

The extension was loaded but left ineffective until passing the "PB" string(Paintbox) to the extension.

Paintbox and EGI do this internally but it had to be typed to work in Basic so, when I removed the checking inside the extension, it worked straight on Basic but not on the apps.

Then I re-fixed it, allowing the execution of the PB command only if the extension was installed but not linked. Also I added the extension to the initialization chain, loading c register with an 8 at return, but only if not initialized, to protect EGI reinitialisation. A mix of two worlds. At last it seemed to work.

To test if the mouse driver was linked I tried to open a channel, but forgot to close it. Then sometimes, a mouse channel is opened just before a new instance of the extension is loaded and linked. It seems that the channel survives the process...

------------------------------

On the other side, this has been the only weird way to open a mouse channel on WP, while on the others apps tested, the normal way worked.


------------------------

Now I know a little more about EXOS, and I can use other methods to test if the mouse driver has been linked but,

how can an extension be refused to load if exist the same one already linked?
Title: Re: Universal Mouse Driver
Post by: IstvanV on 2016.October.12. 12:51:05
An issue brought up in another topic (https://enterpriseforever.com/programozas/file-bovites/msg58784/#msg58784): would it be useful to ignore the upper nibble of the mouse wheel byte? The code in the FILE extension currently does that, but MOUSE.XR did not the last time I checked. According to the wiki (http://wiki.enterpriseforever.com/index.php/EnterMice#Data_buffer), those bits are reserved for the horizontal wheel, but this feature is not implemented yet in EnterMice. It was in ep128emu at first, but I deleted it for compatibility reasons. It probably depends on whether Pear has plans to implement horizontal wheel support in a future revision of EnterMice.
Title: Re: Universal Mouse Driver
Post by: pear on 2016.October.12. 13:01:47
I think I got the motivation to do it ;)
By the way, should I correct the issue which remains the last read state of the buttons, after the disappearance of strobe signal (RTS) ?
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.12. 17:47:01
It is very easy to ignore the upper nibble of the wheel, but I thought there was no rush. I better want to implement the Horizontal wheel in the driver if Pear puts it on the EnterMice adapter.

The only "problem" to implement an Horizontal wheel is that its counter has to be put on a new system var, because 190 is complete. The next one free is 191. I can replicate it with the Vertical wheel code.
Title: Re: Universal Mouse Driver
Post by: pear on 2016.October.12. 18:15:32
Horizontal wheel counter, it is an exaggeration :)
Most mices have only 3 states for the horizontal wheel (-1, 0, and +1).
So far I found only one, that has a full 7-bit counter.
Realy problem is that I do not have a hundred percent good way to distinguish mice models.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.12. 19:05:34
Then both can suit, the first only admits increments of 1, 0, or -1 every cycle, and the other the full 4 bits.

But the counter acts the same. The application needs to know how many impulses have been sent since the last reset of the wheel counter. Wheel lecture cycles don't happen the same as mouse lecture cycles.

Every mouse reading cycle the wheel counter is actualised(added the increment), but is the application which decides when to read and immediately reset  the counter.
Title: Re: Universal Mouse Driver
Post by: pear on 2016.October.12. 19:33:43
On the Enterprise side actually not be a problem.
Unfortunately, each of these mices stores information about the horizontal wheel in another way.
Sometimes it is a separate register, and sometimes the same, in which is the information from a vertical wheel.
I do not have good way to distinguish.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.12. 20:03:37
Then, I will wait to the next driver version to ignore that high nibble, or until you found a solution.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.12. 22:37:09
I have achieved  a mouse pointer on WP only by commands, without hacks.

Surprisingly the PB command was needed to work with the Word Processor. I will return sometime  to fix the initialisation of the driver.

I have also a snapshot of a pointer on the lower screen. A mouse pointer transition between video pages is possible, like in Paintbox, as the internal coordinates of the pointer are the same on all video or text modes.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.17. 00:40:10
I have fixed an error introduced with the last version. Scroll was only allowed on text pages, and then Paintbox hung when moving the pointer down on the edition area.

It will be added to the next version.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.22. 09:55:41
Version 1.103 of the Mouse driver:

-Scroll is also allowed on graphics video pages as mentioned on the last post.
 
-The 'MOUSE' command has been replaced by the standard format command 'HELP MOUSE'.

-A new command, 'MOUSE ED'  has been added. It opens a mouse channel nr. 150 on an existing video page whose number channel has been stored on system var 180.

Then, a mouse pointer can be placed on every application that accepts EXOS commands. To close the mouse channel, the obsolete 'PB' command can be used, but as usual it will return an annoying error message. This is necessary  for a proper Painbox operation, Only after fixing the paint program will be possible to fix the error. In the Basic editor the mouse channel can be closed with CLOSE £150:

The procedure is: install the driver if not done before. :LOAD MOUSE.XR. The Epdos command :CHANS can be used to search for an open video channel. Then, the command :VAR 180 XXX is used to inform the Mouse driver  about the video channel number. Once done, the command :MOUSE ED will create the mouse channel number 150.

Some default video channels:

Basic 102
WR     206
EXDOS  0

It is planned to make the command automatic, the Mouse driver will search for the actual default video channel. The command hasn't practical use for now because still the click event is unimplemented.

-A new system variable has been created, number 191. It contains the counter of an horizontal wheel, but still it hasn't being implemented by Pear on the EnterMice protocol. It is stored on the lower four bits of the variable, just the same than the vertical wheel counter on system var 190.

-Some other little improvements have been made on the code.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.24. 12:22:21
MOUSE ED automatic achieved.

To show how it works, load the snapshot and execute consecutively the already typed commands, only press Enter:

:var 180 0  ; but you can put another value, only to erase the initial setting

:mouse ed  ; will open the mouse channel and show the pointer, the mouse driver has found the default video channel

:var 180     ; we ask for the video channel number, it will return 102 for Basic

:PB             ; will close the mouse channel, giving us an annoying error that means 9000+segment where the mouse driver is installed.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.25. 12:17:29
The MOUSE ED command will only work with Editor modes, while being the default channel the Editor channel.

For example, executed inside the EGI it will return "Call not supported by this device" because the default channel is a Video channel. I think the message is enough understandable.

Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.31. 02:07:21
The automatic MOUSE ED command, or every thing that involve to interact with channels, is not as easy as it may seem.

The problem is the addition of language Roms, because newer EDITOR and KEYBOARD modified device drivers where included on the BRD Rom and derivatives.

The stock drivers have the internal devices work area on fixed zones of segment FF, but on the newer versions, the work area is accessed entirely by indexation, allocating memory.

Is for this that I have used a mixed approach, checking if the EDITOR driver is accessed on Rom 0(old version), or not(new version. BRD.rom can be located on a lot of positions but not on 0).

--------------------

Hardware text modes are very reliable, but I have found an error on software text modes that is giving me a headache. It works perfectly until the pointer finds text on a colour combination different than green/black. Then the pointer is drawn sometimes on the right position, and others on the same column but 8 rows lower. 
Title: Re: Universal Mouse Driver
Post by: Zozosoft on 2016.October.31. 08:28:59
Drivers work area are also it diferent locations in EXOS 2.0 and 2.1+
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.October.31. 10:06:30
True, but since its creation the Mouse driver has been incompatible with EXOS 2.0, only works with 2.1(and with your onward versions).


----------------

Here (https://enterpriseforever.com/programming/universal-mouse-driver/?action=dlattach;attach=16389) you can see the error when the pointer pass over the ruler line or the cursor.

Here is the routine that draws the pointer on text modes:

Code: [Select]
DRAW_TMODE:   ; first convert pixel coordinates to column-row coordinates
ld hl,(X1)
rr h;   we need two lower bits of h
rr l
rr h
rr l
srl l
ld a, (VIDEO_MODE)
cp 2
ld b,a
jr z, sigue8; text 80, X1/8
srl l;      ; text 40, X1/16
; dec l; it must start with 0
sigue8: ld a, l
ld (X1C),a; column stored

ld hl,(Y1); we have to divide Y1 by 18
; fast division by nine, by Ricardo Bittencourt, Brazilian MSX developer
; enter     HL = number from 0 to 1440
; exit      A = HL/9
; destroy   HL,DE
;                               
;DIV9:   
INC     HL             
        LD      D,H             
        LD      E,L             
        ADD     HL,HL           
        ADD     HL,HL           
        ADD     HL,HL           
        SBC     HL,DE           
        LD      E,0             
        LD      D,L             
        LD      A,H             
        ADD     HL,HL         
        ADD     HL,HL           
        ADD     HL,DE         
        ADC     A,E             
        XOR     H             
        AND     03FH           
        XOR     H               
        RLCA                   
        RLCA

        srl a ; we still need a division by 2
; dec a; it must start from 0
ld (Y1R),a; row stored
ld c,a

ld a,(LPT_line)
add a,c ; a holds the first line of the video page + row
ld h,0
ld l,a
add hl,hl; x2  ;multiply a*16 and add it to LPT_BASE in hl
add hl,hl; x4
add hl,hl; x8
add hl,hl; x16
ld de,(LPT_BASE)
add hl,de; byte 0 of the LPT line where the cursor has to be drawn
inc hl     ;add 4 to be just over the LPT_address
inc hl
inc hl
inc hl
ld e,(hl)
inc hl
ld d,(hl) ;load hl with the contained address. Remember Nick addressing
ld a,(X1C)
ld l,a
ld h,0
add hl,de ;add X1C to the line address buffer

ld a, 63             ; 00111111  we need this mask to compose the page
rl h
rla
rl h                 ; now we calculate the segment, taking the two last bits of the address
rla
srl h                ; the address is simplified and stored
srl h               
ld (POINTER_PAGE),a
ld (POINTER_ADDR),hl ; now a has the page and hl the address on page 0
push af
in a, (0B0h)        ; the segment is loaded on page-0 and the content is stored
ld (PAGE0), a
pop af
out (0B0h),a

ld a,b; B still contains the video mode;
cp 0
jr nz, SOFT_TEXT_DRAW
; Hard text mode draw
ld a,(hl)
ld (POINTER_CONT),a  ; the content is stored for later
; and 128              ; don't replace the cursor or red characters
; jr nz, siguek

ld a,(POINTER_COLOUR)
ld c,a
ld a,127
rla
rr c
rra                  ; The color bit is added to bit 7 of the arrow character
ld (hl),a            ; the arrow character is "drawn" on the same byte
siguek:
ld a,(PAGE0)
out (0B0h),a     ; The original B0 segment is restored
ret

SOFT_TEXT_DRAW:             ; hl already contains the address
ld a,(POINTER_PAGE)
ld c,a              ; c holds the starting segment of the LPT line
ld b,9              ; b counts the character lines
ld de,POINTER_CONTS ; The place where we store the character boundary content
push de             ; now POINTER_CONTS is on the Stack
ld de,0B4FFh        ; address of character 128 on the Font

buclef:
ld a,(hl);          ; content of the line is loaded on a
ex (sp),hl          ; pointer address goes to the Stack and POINTER_CONTS goes to hl
ld (hl),a           ; the content of the line is stored for later on POINTER_CONTS
inc hl;             ; prepare next byte of POINTER_CONTS
ex (sp),hl          ; pointer address goes to hl and POINTER_CONTS goes to Stack

ex de,hl            ; Font goes to hl and pointer address to de
ld a,(hl)     ; load a line of the character Font on a
push bc ; now we can use the Stack to store the two counters on bc
ld bc,128 ; Font lines are all at fixed increments on page-2
add hl,bc ; prepare next line of Font
ex de,hl            ; pointer address goes to hl and Font goes to de

ld c,a      ; here the colour is added
ld a,(POINTER_COLOUR) ; the system var  stores the pointer colour for all modes
rl c
rra                 ; only four colour combinations, one bit  on 7 and the other on 0
rr c
rr c
rra
rl c
ld a,c
ld (hl),a           ; a line of the arrow character is "drawn" with its color bits

;ld b,0             ; not needed, as b already contains 0
ld a,(COLUMNS) ; next line of the pointer is on the same column so, we add 
ld c,a  ; no. of columns of the actual video page
add hl,bc ; prepare next line of address pointer

pop bc ; we need again the counters
bit 6, h
jr z, siguev ; if the address pointer gets out of 16k then increase the segment
res 6, h
inc c
ld a,c
out (0B0h),a ; the rest of the pointer is on the next page, so we load it
siguev:
djnz buclef
pop de              ; de is no more needed, but we don't want to corrupt the stack
jr siguek

And here the erasing routine:

Code: [Select]
ERASE_TEXT:
ld b,a ; save video mode on b
in a, (0B0h)
ld (PAGE0), a
ld a,(POINTER_PAGE)
out (0B0h),a ;carga el segmento que hemos guardado al dibujar, en page-0
ld hl,(POINTER_ADDR)
ld a,b              ; B still contains the video mode;
cp 0
jr nz, SOFT_TEXT_ERASE

ld a,(POINTER_CONT)
ld (hl),a     ; load the saved content on the saved address
contk:
ld a,(PAGE0)
out (0B0h),a ; restore page-0
ret

SOFT_TEXT_ERASE:            ; hl already contains the address
ld a,(POINTER_PAGE)
ld c,a ; start page of the pointer
ld b,9 ; no. of character lines
ld de,POINTER_CONTS;

buclev:
ex de,hl            ; POINTER_CONTS goes to hl and pointer address goes to de
ld a,(hl)     ; load a line of the stored character  on a
inc hl              ; prepare  POINTER_CONTS for next cycle
ex de,hl            ; pointer address goes to hl and POINTER_CONTS goes to de
ld (hl),a           ; a line of arrow is "drawn"

push bc ; store the counters on the Stack
ld b,0
ld a,(COLUMNS) ; next line of the pointer is on the same column so, we add no. of columns
ld c,a
add hl,bc ; prepare next line of address pointer
pop bc ; we need again the counters
bit 6, h
jr z, siguex ; if the address pointer gets out of 16k then increase the video segment
res 6, h ; the address neds to be simplified
inc c
ld a,c
out (0B0h),a ; the rest of the pointer is on the next page, so we load it
siguex:
djnz buclev
jr contk
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.November.01. 20:51:06
Colour error fixed.

Like on many other times, a silly error...

At least the many tests have served to surface other faults that now I have the chance to fix.

Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.November.07. 00:33:38
I  have re-arranged the commands again.

Now, to put automatically a mouse pointer on an Editor video page, the command is :MOUSE ON.

A new command has been implemented to close the Editor page mouse channel, :MOUSE OFF. It just acts like the Basic command CLOSE £150:.

:PB still can be used, but must be avoided as it does more things that only closing the channel, and returns the annoying error.

-----------------------------

For test purposes only, I have implemented another command , to try to set the cursor coordinates on the pointers position.

On Basic it can be done easily with a line like this:

PRINT £C:CHR$(27);"=";Y+32;X+32;  (being C the Editor channel, and Y and X the coordinates).

But Basic is intrinsically merged with the Editor and it has not worked for me to make a block write call(EXOS 8 ) to the Editor channel, so I have to abandon that path.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.November.08. 02:29:41
Another fix.

Exiting from the EGI and entering WP produced a change on the Mouse driver IRQ. This caused an interrupt jump to page 0 while drawing the pointer, and as the drawing routine use page 0, the execution hung.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.November.10. 01:21:05
This is somewhat a fix, because the pointer can't slide over the ruler line.

Now, when the ruler line is displayed, the mouse pointer area will start on the second row of the video page.

This is important, because the click event  will bring the cursor to the pointer's position, but the ruler is forbidden to the cursor.

--------------

And talking about the always delayed click event, I have found a way while studying the two Editor drivers. Both maintain their variables on the same index positions, so I will be able to implement the two with the same routine, only loading ix or iy registers with the appropriate address, and loading  on Z80 page 1 the segment where is located the Editor variable area.


The Editor lines aren't filled with spaces. A visible line(on screen line) can be empty, written with something, or completely filled of text.

Is because of this that the click event will only move the cursor to near "populated" positions.

Moving the cursor to empty zones implies to fill them at least with spaces, involving modifying a lot of the Editor variables, and this is beyond my possibilities without calling directly the internal routines of the two Editor drivers.
Title: Re: Universal Mouse Driver
Post by: endi on 2016.November.10. 11:29:34
cool, with the new emulator, I will make a mouse controlled game!
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.November.10. 15:33:01
Great!

But don't wait for me, for a game you don't need Mouse pointer on Editor modes.
Title: Re: Universal Mouse Driver
Post by: Povi on 2016.November.10. 16:12:31
Cool!!!

I've just downloaded the snapshots with the mouse cursor on EDITOR:

Will be the click replace the text cursor position?

Will be the scroll wheel scrolls up and down the displayed text?

Edit: I should buy a mouse interface for my EP... :-)
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.November.10. 16:42:23
Yes, I plan to replace the text cursor position, and even simulate an Enter key press when the coordinates of both the cursor and pointer are the same. I think it can be done. But I progress very slowly... I have to learn a lot on the process.

The Scroll is more difficult. Think that the Mouse driver is all made with hacks, because it is driven with interrupts, and on interrupt mode EXOS refuses to accept its calls. On the other side is very fast.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2016.November.24. 01:18:03
I have managed to do the cursor positioning call within the interrupt, only putting 0f3h(DI) on the 0056h address on Z80 page 0.

It works, but corrupts the Editor.  Promising.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.February.20. 11:09:52
Not actually any news about the driver, only to show a simple way to detect if the driver has been already loaded in Basic:

100 WHEN EXCEPTION USE DRIVER_LOADING
110      SET 189,4 ! try to set EnterMice control mode. Only possible if the driver has been installed.
120 END WHEN


1000 HANDLER  DRIVER_LOADING
1010      EXT "LOAD MOUSE.XR" ! The file has to be on the current directory, if not, the program will give us another error.
1020      PRINT "Loading the Mouse Driver"
1030      SET 189,4                  ! Here we assume that the driver has been correctly installed.
1040 END HANDLER

It can be made more complex and effective, setting a variable on the handler to signal the not-loaded status, loading the driver on the main program.  Then, if the file is not found(probably we are on another path), the error can be parsed on the same or on another handler.

It is a good practice to avoid installing several instances of the Mouse Driver.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.March.17. 14:44:25
Now that the SID storm has almost subsided, maybe Geco or Istvan-v have time to study how to make work my Click-event approach on the Mouse Driver.

What I want to do is to move the Editor cursor to the mouse pointer position when a click is done.

I already have created a mouse pointer on text video pages. Once installed the driver, the mouse pointer can be called, for example, from the Basic editor with ":MOUSE ON". Also ":MOUSE OFF" closes the mouse channel.

Hacking a little the interrupt area I have managed to do an EXOS call within the interrupt. Then, every time a click is done on an Editor page, a four bytes string like this is written to the Editor channel:  01Bh&"="&020h+Y&020h+X. Being Y and X the character boundaries of the mouse pointer.

This effectively moves the cursor to a place near the pointer, but corrupts the Editor data.

The "Click-event" is called like this:

 ld a,(0056h)
 push af
 in a, (0B1h)
 push af
 in a, (0B3h)
 out (0B1h), a
 ld a,0f3h     ;  This hack is to prevent the blocking of the EXOS call inside the interrupt
 ld (0056h),a  
 ld de,SET_CURSOR;     This contains something like this "db 27,61,33,33      ; escape sequence set cursor"
 ld a,(EDITOR_CHN)
 ld bc,4
 di
 rst 30h
 db 8
 di
 pop af
 out (0B1h),a
 pop af
 ld (0056h),a;  the value is restored

Edit: snapshot corrected
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.April.04. 17:04:37
It is possible that I have found a way to make the click event work.

Once the mouse driver installed, with the aid of the marvellous debugger that EP128emu offers, I have monitorised when EXOS re-enters to the mouse driver entry point.

Then, I have discovered that it is accessed cyclically aprox. every two seconds by the main EXOS-Editor routine. I have tested this on WP, EXDOS, ISDOS, LISP and HPASCAL.

I have already tested that a click event(EXOS call) done at the entry point is perfectly legal.

Two seconds since the click is a very long waiting, but is better than nothing.

This night at home I will test this.
Title: Re: Universal Mouse Driver
Post by: geco on 2017.April.04. 19:24:27
Two seconds since the click is a very long waiting, but is better than nothing.
Yes, and it seems to be usable speed, even if faster solution is not found in the future.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.April.04. 20:07:08
2 seconds will be the worst case. Then we have to add the cursor movement execution time, but this is made very fast.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.April.05. 03:04:57
The 2 seconds call is done by the BRD, HUN, ESP Rom asking for the var 144 value. It is not done on native English machines without language Rom.

But  the cursor movement call also returns the 254 error code like when done on interrupt mode, ***EXOS function call not allowed. Once forced the call, the same Editor corruption....

Let's start again....
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.June.12. 10:53:43
I'm taking a break from the mouse driver.

The last thing I learned about it was that the "cursor position change" routine when forced corrupts the editor FLG__EDIT read flag, so I must preserve it before calling.

But definitively the call has to be done outside the interrupt. I've tried everything to make it work, but it always corrupts the Editor buffer.

It is understandable, the Editor is constantly passing the control to the Host program (Basic, Exdos, etc), so I can't know if it is safe to make the call at any given time.

The only solution I see is to implant a hook to the RST 30h call, test if a click hast to be done, and then return the control. But there is little space to make that complex hook.



Title: Re: Universal Mouse Driver
Post by: BruceTanner on 2017.June.12. 20:51:56
Not easy I know, but perhaps what the EP really needs to move into the world of mice is a replacement editor: device, so that it can behave as modern computer use would expect (click and highlight a block, press DEL to erase etc), and avoid all your interrupt problems altogether :smt021 . No, I am not putting my hand up...:roll: :roll: :roll: :mrgreen:
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.June.13. 00:52:17
I don't raise my arm either, a new enhanced Editor like you describe overcome my poor Z80 and EXOS knowledge.... I only can reach to modify the actual Editor device.

What I want is a total backward compatibility of the Mouse driver, at least with EXOS 2.1 and the BRD.Rom(HUN, ESP etc). The two share similar versions of the Editor, having the Language.Rom Editor a totally relocatable variable area. But English keyboard Enterprises lack the Language Rom.


A solution can be to create a  new Language.Rom for English keyboard Enterprises, then they also can benefit from the added content of the BRD.Rom, the VDUMP, VLOAD and VSAVE commands.

This can be made blocking the switching between idioms on the BRD.Rom, always UK mode. Once created the UK.Rom, I can modify the Editor for all the Language Roms, adding the Mouse click and more functions inside the modified Editor device. May be scroll? There is an unused zone on the Rom, from 3D00h to 3FF9h, 249 bytes.

But for this first I should precisely learn how the editor device works....
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.June.20. 11:07:57
I am meditating aloud about how to implement the click event on the Editor driver.

Some information has to be passed to the Editor, but other is already available on the mouse system vars.

Important data is the number of Editor channel, always the default, or to know if effectively a mouse-editor channel has been opened.

And other data actually calculated inside the mouse driver, now should be calculated inside the Editor driver, like for example the translation from graphics coordinates to text coordinates.
Title: Re: Universal Mouse Driver
Post by: geco on 2017.June.20. 13:49:56
Did you check how the cursor position is calculated by jostick movement, if it uses coordinates then the it's variables could be patched by mouse coordinates.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.June.20. 15:09:39
Yes, text coordinates are calculated on the "new mouse text" mode from the graphics coordinates, but I've not created system vars for it as I intended to do the key-click inside the Mouse driver. Now It will be done remotely on this new approach:

A flag(a bit on one of the mouse system vars) will indicate the editor driver that the Editor+Mouse mode is active. If not, the Editor returns to its normal tasks. 

Then, if in Editor+Mouse mode, a branch in the code will be executed, much like when I inserted the mouse routine on a game.

But there are a lot of information needed, information that I have stored and already calculated inside the mouse driver:


Code: [Select]
ARROW db 96,112,120,124,126,120,72,8,0; constant
EDITOR_PAGE db 0
EDITOR_INDEX DW  0
EDITOR_CHN db 0
EDITOR_FLAG db 0
VAR_1 db 0
VAR_2 db 0
EDITOR_MODE db 0
LAST_FIRE  db 0
POINTER_ADDR dw 0
POINTER_PAGE  db 0
POINTER_CONT db 0,0,0,0,0,0,0,0,0
LPT_BASE  dw 0
LPT_line  db 0                  ;Line where the video page starts on the LPT
LPT_ADDR  dw 0                  ;Address where the first LPT line of the video page is
LPT_cont  db 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 ;  line content
BUFF_LEN  dw 0
BUFFER_END dw 0
VIDEO_ADDRESS dw 0 ;
COLUMNS   db 0
VIDEOX dw 0 ;
VIDEOY      dw 0
VIDEOXx2 dw 0 ;
VIDEO_MODE db 0 ;
;
VIDEO_COLOUR db 0 ;
SCR_SAVE db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;
;
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
POINTER_ADDRESS dw 0 ;
HALF_VIDEOY dw 0 ;
;Modification here
HELPTXT     db "MOUSE version 1.10D",0Dh
MODEWRD         db "Control: "
MODE0TXT db "0 Internal Joystick   ",0Dh,0Dh
MODE1TXT db "1 External Joystick 1 ",0Dh,0Dh
MODE2TXT db "2 External Joystick 2 ",0Dh,0Dh
MODE3TXT db "3 Boxsoft interface   ",0Dh,0Dh
MODE4TXT db "4 Entermice interface ",0Dh,0Dh
MODE5TXT db "5 Serial Mouse Systems",0Dh,0Dh
MODE6TXT db "6 Serial Microsoft    ",0Dh,0Dh
MODE7TXT db "  Not defined         ",0Dh,0Dh
ENTERMICETXT db 0Dh,"Entermice by Pear",0Dh
EMVERSIONTXT db "Mouse Id. X Hw ver. X.X Sw ver. X.X",0Dh,0Dh
EM_EXISTS db 2             ; 0= not found, 1= found, 2= requested. Always requested at initialization, but afterwards only requested by :MOUSE command
EM_BUFF     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;0-15 bytes, the max that can be counted with a nibble
;end
VIDEO_CHN db 101 ;
; INIOPEN
; EXOS Variable 180
STATUS_POS db 30 ;
; EXOS Variable 181
STATUS_DISP db 0 ;
; EXOS Variable 182
; 0 OFF, 1 ON
POINTER_COLOUR db 0FFh ;
; EXOS Variable 183
X_LOW db 0 ;
;
; EXOS Variable 184
X_HIGH db    0 ; EXOS Variable 185
Y_LOW db 0 ;
; EXOS Variable 186
Y_HIGH db    0 ; EXOS Variable 187
FIRE_STATUS db 0 ;
; EXOS Variable 188
INPUT_DEVICE db 0 ;
; EXOS Variable 189
SW_Z_STATUS db 0 ;
; EXOS Variable 190
H_WHEEL     db 0    ; ready for var 191
X1 dw 0 ;
Y1 dw 0 ;
CLICK db 0
SET_CURSOR   db 27,61,33,33      ; escape sequence set cursor
Y1R     db 0 ; row for text modes
X1C     db 0 ; column for text modes

X_REL db 0 ;
Y_REL db 0 ;
CHN_FLAG db 255 ;
CHN_COUNT   db 0 ;
POS_RD db 0 ;
POS_COUNT db 0 ;
;
X1_EXOS dw 0 ;
;
; X1*2
Y1_EXOS dw 0 ;
; Y1*2
POINTER_DISP db 1 ;
; 0 OFF, 1 ON
PAGE0 db 0 ;
POINTER_ROWS db 0 ;

I think it would be better to access directly the data from the mouse driver if I store the segment and address of the table on two system vars. Then in the future, if the Mouse driver is put on a ROM, the address will point to an allocated Ram with the same information.
Title: Re: Universal Mouse Driver
Post by: BruceTanner on 2017.June.20. 16:19:52
But for this first I should precisely learn how the editor device works....
zozo now has the source code...do you have a copy to refer to? I'm not saying it's simple to understand though...:roll:

Forgive me if you have gone through all of this, I've lost track where you have got to, but...

When editor: is just sitting flashing the cursor it is doing repeated "read channel status" calls to the keyboard channel (EXOS 9) and when a character is ready it does a "read character" (EXOS 5). It knows the keyboard channel because it saved it in a fixed RAM location from the EXOS variable when the editor: channel was opened. So if you found its fixed location, somewhere in the system segment, (might depend on EXOS version), saved it, and changed it to, say, a mouse channel, then it would be doing "read channel status" and "read character" calls to your mouse driver, which could either return a character eg a pretend cursor movement "key", or pass the call on to the keyboard channel which you have saved. Your interrupt routine would then just queue mouse events in a little buffer and your "read channel status" code would remove them from the queue and convert them to fake key presses. So no calling EXOS in interrupts!

Sorry if you've been through all of this, as I say I've lost track where you have got to, but I just thought I would mention it in case there's anything there you haven't tried yet...

B.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.June.20. 18:30:28
I have not started yet, thanks, I am a slow programmer... First I have to imagine what to do.

Your ideas are warmly welcomed, don't worry. It is an honour...
Title: Re: Universal Mouse Driver
Post by: BruceTanner on 2017.June.20. 20:58:49
I have just thought: rather than poking around in editor:'s variables you might be able to use a little-used (never-used? :twisted:) EXOS feature: Capture Channel (EXOS 17). You might be able to use this to cause "read status" and "read character" calls to the keyboard channel to go instead to your mouse channel. The problem might then be doing keyboard calls yourself - you might have to turn off the capture, do the call, and then turn the capture back on again :roll:

I haven't tried it...:mrgreen:
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.June.20. 22:24:41
You have reminded me of an easier way to make transfers between the two devices. The Mouse: channel can be written and read, with strictly legal EXOS calls:

(From the "Boxsoft" and "EnterMice" instructions)
Code: [Select]
Commands issued by printing characters to Mouse channel:

O Turn pointer on
o Turn pointer off
P Request X & Y position

Results or status obtained by reading a character from Mouse channel:

Only read after sending "P":
X Low byte
X High byte
Y Low byte
Y High byte

Always readable:

Fire = "1" if main button depressed, "0" if not.

I can implement, for example, a "p"(lower) command that would return text coordinates on a text-mouse screen, much like the "P"(capital) command does for mouse-graphics screens. This can be useful even for other applications, like Basic.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.June.20. 22:33:47
And I can also use your idea of a redirect call, because once the clock-event would be operative I will need to inject a carriage return(exactly like a keyboard press) to execute the clicked line.

But let's face only one difficult task each time....
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.July.10. 02:36:56
I have found the Keyboard reading loop inside the Editor: device on the language Rom.

Code: [Select]
.
.
.
  D14A  3E 3F        LD    A, 63      ; 00111111b cursor display control, but also counter
  D14C  F5           PUSH  AF         ; A register is saved on the stack
        08           EX    AF, AF'    ; and swapped with A'
        CD D5 DC     CALL  DCD5h      ; if an error code was stored in  (IY+35), the cursor is redrawn
        F1           POP   AF         ; A is restored and replicated on A'
        07           RLCA
        CD 0F DD     CALL  DD0Fh      ; Cursor display on/off depending on Carry
        3A F2 BF     LD    A, (BFF2h) ; FLG_SOFT_IRQ User Interrupt Code in A
        FE 20        CP    32         ; Test
        3E E5        LD    A, 229     ; .STOP 'STOP button pressed' - error message code
        C8           RET   Z          ; STOP error message
        FD 7E 0D     LD    A, (IY+13) ; Editor: Keyboard channel number, 105 on Basic
        F7 09        EXOS  09         ; Read keyboard channel status

        20 18        JR    NZ, D17Dh  ; Jump if error
        B9           CP    C          ; Status test
        28 10        JR    Z, D178h   ; Skip if a character is ready to be read

  D168  08           EX    AF, AF'    ; Number in A' is retrieved to A
        3D           DEC   A          ; and decreased
        20 E0        JR    NZ, D14Ch  ; Loop if still not zero

        08           EX    AF, AF'    ; swap A and A' again
        FD B6 14     OR    (IY+20)    ; Right margin
        C4 53 DB     CALL  NZ, DB53h  ; Clear margins
        CD 08 DC     CALL  DC08h      ; I still don't know what this call does
        18 F0        JR    D168h

  D178  FD 7E 0D     LD    A, (IY+13) ; Editor: Keyboard channel, 105 on Basic
        F7 05        EXOS  05         ; read character

  D17D  FE E5        CP    229        ; .STOP 'STOP button pressed' - error code detected
        C8           RET   Z          ; Return if STOP pressed
        B7           OR    A          ; Detect error code
        28 07        JR    Z, D18Ah   ; Jump if there is no error
        FD CB 28 FE  SET   7, (IY+40) ; Keyboard error indication
        3E D3        LD    A, 221     ; .EKEY 'EDITOR keyboard channel error' - error message code
        C9           RET

  D18A  FD 77 32     LD    (IY+50), A ; A=0
        FD CB 2F 56  BIT   2, (IY+47) ; Modified FLG_EDIT test
        FD CB 2F 96  RES   2, (IY+47) ; Clear AUTO_ERA
.
.
.

Probably I will put the CLICK hook on one of the two CALLs inside the minimum non-pressed-key loop.

------------------------

Also, it seems that the pattern/counter at D14Bh  governs the behaviour of the cursor flickering, the two "0s" are the cycles it is OFF, and the  six "1s" the cycles it is ON, i. e. 2/8 OFF against 6/8 ON. This seems to me like a "heavy" blinking.
Title: Re: Universal Mouse Driver
Post by: BruceTanner on 2017.July.10. 07:42:42
Hi gflorez,

Here's the same code from the actual source with MrL's comments:
Code: [Select]
ld a,63 ;Loop count and cursor flash
; flag (bit-7)
scan_loop: push af
ex af,af'
call TRUE_CURSOR ;Ensure cursor is in correct
pop af ; place and turn it on or
rlca ; off as necessary.
call CURSOR_ON_OFF
;
ld a,(FLAG_SOFT_IRQ##) ;If STOP key has been pressed
cp ?STOP## ; then return with .STOP error
ld a,.STOP## ; to BASIC.
ret z
;
ld a,(RAM_ED+key_channel) ;Poll the keyboard and jump
EROS @RSTAT## ; if an error occured (NZ).
jr nz,key_error
cp c ;Exit if key is ready (C=0)
jr z,key_ready
scan_loop_2: ex af,af' ;Upadte the screen on 63rd time
dec a ; round the loop
jr nz,scan_loop
ex af,af'
;
or (IY+ruler_valid) ;Display ruler line if it
call nz,DISPLAY_RULER ; needs updating.
;
call REDRAW_LINE ;Update cursor line if needed
;
jr scan_loop_2 ;Must get A' back into A to
; keep flashing regular
;
;
;
key_ready: ld a,(RAM_ED+key_channel) ;Read a key from the keyboard.
EROS @RDCH##
key_error: cp .STOP## ;If STOP key pressed then
ret z ; return this error to BASIC
or a
jr z,no_key_error ;Any other error then return
set 7,(IY+error_flag) ; .EKEY error and set the
ld a,.EKEY## ; keyboard error flag.
ret
;
;
no_key_error: ld (RAM_ED+word_flags),a ;Initialise flags for TEST_WORD
;
bit auto_era,(IY+sending_flag)   ;Set Z' depending on
res auto_era,(IY+sending_flag)   ; whether AUTO_ERASE was
ex af,af'      ; set and clear it.
.
.
.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.July.10. 10:25:40
Thanks! I just took the disassembly from the Ep128emu  Debugger, and translated the Hungarians comments from the Segment 0 Rom Disassembly book (http://enterprise.iko.hu/books/Segment_0.pdf).

Then I added some more of what I understood.

Of course yours is the only complete and correct.....

---------------------------

The original Editor device in the 0 segment is exactly the same, but some addresses of the device buffer are accessed directly without indexing because the buffer was put at a fixed position on the FF segment(and probably to gain some free space in the Rom as they saved a byte in some direct addressing). Later with more room, on the Language ROMs they(you) decided to make the Editor, Video and Keyboard buffers relocatable as originally planned, rewriting new bi-lingual devices, and then all the accesses to the buffer addresses are made by indexing.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.July.10. 10:55:49
Here you can see how they(you) mixed the direct and indexed addressing on the first Editor version:

[attach=1]
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.July.30. 19:28:57
At last  I have again a work code. After almost a year trying a lot of ways to do the click event inside the interrupt routine, several parts of the code retained a lot of rubbish  that I needed to clean before attempting the definitive one outside the Mouse driver....

But first I had to found how to communicate the code injected on the Editor driver and the Mouse driver.

It could be made rearranging the Mouse  system variables, but that is incompatible with older apps. After all I only had space for 2 more new Vars, 190 and 191. The first is totally populated of information(4 buttons and Z wheel), but the 191 still has the high nibble free, because on the lower one I have put definitively the Horizontal Wheel counter, just in case it would be implemented.

At the end I have better selected writing the Mouse channel, because once studied that part of the code, it is very simple to add a new command to P, O and o. For better flexibility I have implemented the "A" command, that returns three bytes, the segment and address on page 01 where the Mouse variable zone starts. I plan to access the Mouse data with an index register. This approach can have also its benefit if a Rom version of the Mouse driver is made on a "near" future...  For this purpose I have displaced all the variables to the end of the code, leaving the constants at their original place.

Then, as a way of communication, I will use that four upper bits on the 191 system var as flags. For example, if a Mouse-Editor video page has been opened, I will set bit 7, a click not finished will set bit 6, and the other spare two for other events,(imagine a scroll event with the wheel displacement...).
Title: Re: Universal Mouse Driver
Post by: gflorez on 2017.July.30. 22:48:15
Thinking out loud:

-How will work the click event?

It will be a two phase event. Every time a click is done, the position of the cursor is compared to the actual position of the Mouse pointer. If they are the same, an "Enter" keyclick will be injected on the Keyboard driver buffer(thanks to a program found on a Dutch magazine). If they are different, the escape sequence "1D,3D,20+Y,20+X" will be printed on the Editor channel, moving the cursor to the Mouse pointer position.

-And, how can a scroll be implemented on the EP editor?

The easiest way is by printing control codes to the Editor channel. But if we want a perfect emulation of what happens on a PC, first we must save the cursor position. Then, if the movement found on the Wheel counter is, let's say 3, this indicates an up movement, so first the string "B1, B0, B0, B0"(shift+up, up, up, up) has to be printed to the Editor channel. After that, 3 is taken from the Y coordinate of the cursor saved position(but never below 1, and for the down max position we take the size of the video page). Finally the escape sequence "1D,3D,20+Y,20+X" will be printed on the Editor channel, positioning the cursor exactly on the same place it was before.

To "print" a down scroll, we must send to the Editor channel "shift+down, down, down, etc" and then the cursor positioning escape sequence.

Always after a click or scroll events, their respective flags have to be reset, but in the case of the scroll, also the Wheel counter has to be put to 0.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2019.May.29. 15:45:19
The Mouse driver now has SimbiFace3 USB mouse support. Only the three normal buttons and wheel.

It can be selected by the usual way ":VAR 189 7".
Title: Re: Universal Mouse Driver
Post by: pear on 2019.May.29. 18:24:07
Oh, cool.
I think I'm beginning to want to have this interface :D
Title: Re: Universal Mouse Driver
Post by: gflorez on 2019.May.29. 18:55:52
Your EnterMice is a better option for me.... But this USB HID port comes included on the SF3 as a gift, and I hate non working things....
Title: Re: Universal Mouse Driver
Post by: Tutus on 2020.February.07. 13:47:52
Does the Universal Mouse Driver know this?
There are active links in the text. Clicking the mouse cursor will display another text page or file.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2020.February.07. 19:26:35
No sorry. The Mouse driver is very basic, it returns you a coordinate if a click is done, so is the task of the program to know what is on the coordinate.

I was unable to integrate the mouse on the Editor due my low assembler skills and to the characteristics of the hack(it is a hack that runs on an interrupt), but at least I managed to allow a mouse channel on a text screen(40,80 all dimensions), where the pointer not slides, it moves to the next character boundary. You can learn how to interact with the mouse system on the EnterMice wiki, but I still have not actualised the link to the last version (https://enterpriseforever.com/programming/universal-mouse-driver/msg75937/#msg75937).
Title: Re: Universal Mouse Driver
Post by: gflorez on 2020.February.07. 19:32:54
But....... On SymbiOS the thing changes, there is a HTML viewer that on a future will allow hiper-links, when some SF3 characteristics(WIFI) were being integrated on SymbiOS, but this is a task of Prodatron.
Title: Re: Universal Mouse Driver
Post by: Tutus on 2020.February.07. 20:51:29
But....... On SymbiOS the thing changes, there is a HTML viewer that on a future will allow hiper-links, when some SF3 characteristics(WIFI) were being integrated on SymbiOS, but this is a task of Prodatron.
This is good news! This is exactly what the HTML browser needs. (You guessed :mrgreen:).
The only trouble is that Prodatron is gone again. :(  It hasn't even solved our requests from years ago (though not really many). :(
Now I was communicating to him through Edoz.
Title: Re: Universal Mouse Driver
Post by: gflorez on 2020.February.08. 10:39:33
Here you have the link to Symzilla, source included:

http://www.symbos.de/download/apps/SymZilla.zip