Welcome, Guest. Please login or register.


Author Topic: Xep128 (Read 116087 times)

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Xep128
« on: 2016.February.21. 01:37:04 »
I will better study the XEP code.

If I understand well, the "mechanics" of your code is to read the mouse and keyboard PC caption, and put the appropriate information on input ports B6h and B5h. Then the EP emulator reads the ports like on the real machine.

Making your emulators "EnterMice-movement compatible" is as easy as to clone bit 0(J column) on bit 1(K column) of input port B6h.

The buttons are a little more complex because the Neos mouse use only one button, the Right one, as main button, and you have put both buttons as main.

Making the EnterMice retro-compatible with the Boxsoft adapter(Boxsoft mode), Pear has implemented a secondary button, at the Left.

EnterMice on the other side has the main and secondary buttons put like on a PC. The mouse driver reads the Main and Secondary button depending on the mode selected, but it must be also done on the hardware(your emulator input.c I/O code). No problem as the Right button is always at the L column row 0. The Left is at the J colum on the Boxsoft and on the K column on the EnterMice.


As you say, by the moment there isn't any program that use more than one mouse button so, the fast solution is cloning bit 2(column L) and 1(column K) on row 0 of port B6h, similar to what I've said for the movement.

But Entermice has been made compatible with Prodatron's Extended MSX mouse protocol, and soon the port of SymbOS for EP will use the five mouse buttons and wheel that a PS/2 mouse can provide....  

----------

Now I only want to know why that jumpy movement with the actual mouse driver version. On real hardware it works, so it must be a little difference on sync.

---------

Useful? I don't mind if it is... Fun is what I look for... The fun of making things work properly.

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: Xep128
« Reply #1 on: 2016.February.21. 02:49:53 »
For Xep128, _mouse_dx and _mouse_dy are for relative movement (d for delta) in X and Y directions. These are updated by SDL movement events, signed values. Function mouse_check_data_shift() is the key stuff in input.c. As you can see there is the _mouse_read_state variable which iterates over four possible values, two "half" bytes for X and two for Y directions. After X or Y is read, those delta values are zeroed. Well, this is what I could understand for MSX protocol + boxsoft, and it seemed that implemented this way allowed both for EGI and SymbOS to work using the mouse. I haven't mentioned the buttons here, but it's simplier case than the movements. Function mouse_check_data_shift() is called from cpu.c in _pwrite(), when 0xB7 port is written by the CPU, the mentioned mouse function checks if the bit changed (bit mask 2) in an "edge triggered" way (so if it changed only). When 0xB6 port is read, and it's for mouse (check function _pread() in cpu.c) function mouse_read() is called, it's in input.c of course. That uses the "half data" stuff set by mouse_check_data_shift(). It also set the button state bit using a variable set by SDL event handler for button change (up/down).

Or something like this :) I only wrote this, to help understanding/following my probably not so well structured code :)

About more buttons: in emulation it can be problematic. For example maybe the real PC mouse used with the your PC (which running Xep128 then) don't even had so much buttons. And even for more buttons, eg for JSep, in browsers it's problematic to handle the right button as it's usually "locked" for the browser's local menu, and only the left button can be used to trigger JS events. Well, it's possible to override the other button as well with some tricks - if I remember correctly - but it's kinda tricky and maybe (?) not portable between different browsers easily.

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Re: Xep128
« Reply #2 on: 2016.February.21. 17:36:50 »
This is the actual Boxsoft injection routine:

Code: [Select]
Uint8 mouse_read(void)
{
Uint8 data = _mouse_button_state ? 0 : 4;
if (kbd_selector > 0 && kbd_selector < 5)
data |= (_mouse_data_half >> (kbd_selector - 1)) & 1;
_mouse_pulse = 0;
return data;
}

And this can be for EnterMice:

Code: [Select]
Uint8 mouse_read(void)
{
Uint8 data = _mouse_button_state ? 0 : 2;
if (kbd_selector > 0 && kbd_selector < 5)
data |= (_mouse_data_half >> (kbd_selector - 1)) & 2;
_mouse_pulse = 0;
return data;
}

Fast compability can be achieved putting 6 for row 0 and 3 for rows 1 to 4, but Boxsoft can be incompatible with some programs that expect only a joystick on joyport 1. Is for it that the EnterMice is read on bit 1 and not on bit 0. Bits 1 and 2 where never used, except for the Boxsoft main button.

For now this is a fix for only the main button.

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Re: Xep128
« Reply #3 on: 2016.February.21. 18:32:48 »
And now for the "jumpy movement".

Code: [Select]
void mouse_check_data_shift(Uint8 val)
{
if ((val & 2) == _mouse_last_shift) return;
_mouse_last_shift = val & 2;
_mouse_pulse = 1;
switch (_mouse_read_state) {
case 0:
_mouse_data_byte = ((unsigned int)_mouse_dx) & 0xFF; // signed will be converted to unsigned
_mouse_dx = 0;
_mouse_data_half = _mouse_data_byte >> 4;
break;
case 1:
_mouse_data_half = _mouse_data_byte & 15;
break;
case 2:
_mouse_data_byte = ((unsigned int)_mouse_dy) & 0xFF; // signed will be converted to unsigned
_mouse_dy = 0;
_mouse_data_half = _mouse_data_byte >> 4;
break;
case 3:
_mouse_data_half = _mouse_data_byte & 15;
break;
}
_mouse_read_state = (_mouse_read_state + 1) & 3;
}

As I said, EnterMice is compatible with Prodatron's extended MSX mouse protocol. This adds at least 2 more bytes on every lecture cycle. That makes 8 nibbles, not only 4 like on your emulator.  The extra lectures fool your routine because it  only sends 4 nibbles.

The Mouse driver then receives the correct movement alternated with (-1,-1) movement, as it reads 255,255(no movement) when it ask for the rest of the data.

You can fix the problem limiting the lectures to four on every lecture cycle(frame), just like the Neos mouse does.

If case is greater than 3 then you must put 0 on the fifth nibble . This indicates to the Mouse driver that  a two mouse button is connected, and it stops asking for more data.

This is enough for now.
« Last Edit: 2016.February.22. 22:27:06 by gflorez »

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Re: Xep128
« Reply #4 on: 2016.February.21. 19:10:50 »
Only to check your emulator, here you have your SD image loaded with the EGI and modified to auto-start on it with the actual mouse driver version.

It is set to Boxsoft mode(sytem var 189 set to 3) on the EXDOS.INI batch file, but you can change it inside FMAN on the EGI, with the Menu, EGI/System (: ).

Type  "VAR 189 4" to set EnterMice mode.

Then you can check the controller mode typing "MOUSE".
« Last Edit: 2016.February.21. 21:25:40 by gflorez »

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Re: Xep128
« Reply #5 on: 2016.March.09. 23:29:15 »
Please, can you add EnterMice emulation? I gave you the hints on the three previous messages.

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: Xep128
« Reply #6 on: 2016.March.10. 00:38:52 »
Please, can you add EnterMice emulation? I gave you the hints on the three previous messages.

Now I am a bit confused, your examples are code fragments in Xep128, however this is the JSep topic. Which emulator do you mean exactly?

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Re: Xep128
« Reply #7 on: 2016.March.10. 00:56:37 »
There isn't a XEP128 thread in English and you said that your two emulators use similar approach to emulate the Boxsoft interface.


Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: Xep128
« Reply #8 on: 2016.March.10. 01:02:16 »
There isn't a XEP128 thread in English and you said that your two emulators use similar approach to emulate the Boxsoft interface.

Similar, however I should know which one you are interested in still :)

http://xep128.lgb.hu/files/xep128-entermice.exe

In theory this is the version with the changes you've described, I have no idea if it works, SymbOS does not work this way, I've tested that at least.

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: Xep128
« Reply #9 on: 2016.March.10. 01:21:14 »
OK, I have to overwrite the previous version ... Now it goes in the original 4 nibble, etc mode, but you can change it run-time with typing the following EXOS commands:

:xep emice
:xep emice 1
:xep emice 0

For query, set and disable Entermice mode. The same EXE above, the URL is my previous post.

The changes from the previous Xep128 version, so you can see:

https://github.com/lgblgblgb/xep128/commit/db5fa219951a182313a2b7170e8541dcb444d92d

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Re: Xep128
« Reply #10 on: 2016.March.10. 01:49:18 »
It moves jumpy... only if I press the main button... I will study your code tomorrow to see why.

Please use the SD-image I posted on 2016.February.21. 19:10:50. It contains an EGI initialisation that must work with the mouse driver. SymbOS only reads the Boxsoft interface.

The EGI starts with the internal Joystick as controller, but it can be changed on the mouse driver to Boxsoft or EnterMice with the system var 189.

:VAR 189 3 sets the controller to Boxsoft.
:VAR 183 4 sets the controller to EnterMice.

You can see the actual controller type with the command :MOUSE without parameters.

Thanks for your interest.

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: Xep128
« Reply #11 on: 2016.March.10. 01:51:26 »
By the way ... Sorry, I don't follow every topic too closely recently because of other (official) works ... But do you have the mouse interface in the form of a ROM too?

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Re: Xep128
« Reply #12 on: 2016.March.10. 01:57:36 »
I would like to have the driver in Rom.... But I am just a beginner at Z80 coding.

Now the driver is very stable, I've removed several errors inherited from its creators and added some new features(Like the extra buttons and wheel). I go slooooowly.

Offline gflorez

  • EP addict
  • *
  • Posts: 3615
  • Country: es
    • Támogató Támogató
Re: Xep128
« Reply #13 on: 2016.March.10. 02:25:12 »
I've seen your attempt to implement an 8 nibbles protocol, but it is unnecessary, as a two buttons PS/2 mouse only  writes four nibbles. You must put a 0000 on the fifth and subsequent nibbles, and the driver detects it and does the rest, waiting for the next reading cycle on the next interrupt.

You can see that the difference between Boxsoft and EnterMice is only the bit where the information is extracted, 0 or 1. It was moved to not collide with the external joystick 1, that is also read on bit 0.

Edit: The driver searchs for a 0000 on the fifth nibble. If found it is a two buttons mouse and it stops the reading cycle. If diffent of 0000 is read then an eight nibble protocol is expected. This is applicable on the Boxoft and EnterMice side.

Yes, also eight nibbles on the Boxsoft side, it may seem confuse, but in reality is was a simplification of the protocol when the extra buttons and wheel where implemented..
« Last Edit: 2016.March.10. 08:20:18 by gflorez »

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: Xep128
« Reply #14 on: 2016.March.10. 09:05:55 »
I've seen your attempt to implement an 8 nibbles protocol, but it is unnecessary, as a two buttons PS/2 mouse only  writes four nibbles. You must put a 0000 on the fifth and subsequent nibbles, and the driver detects it and does the rest, waiting for the next reading cycle on the next interrupt.

Maybe, it's only me who is confused now :) You've written "that makes 8 nibbles, not only 4 like on your emulator". Now, in Entermice mode it does that, and as you can see with the "switch" construct, the first four nibbles are handles as it was before, and with the new "default" part it gives zero as the "new" last four nibbles.

https://github.com/lgblgblgb/xep128/blob/master/input.c

From line 95.