Welcome, Guest. Please login or register.


Author Topic: EP128emu (Read 400948 times)

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: EP128emu
« Reply #660 on: 2016.September.19. 12:18:29 »
Of course I am eager of answer, but in English please.

I've just mentioned that you gave me several useful tips in the English Xep128 topic in a quite patient way, even if I were quite dumb at the beginning to realize the "big picture" :) Maybe that can be useful for others too, who wants to understand the details and not bothered by reading my "sometimes hard way to realize things"-style posts as well :)

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #661 on: 2016.September.19. 12:58:42 »
Ha ugy ertetted a kerdest, hogy "normal erzekenyseg", hogy adott sw szinten, akkor meg kell kerdezni Gflorez-t, hogy pl az o mouse drivere milyen elmozdulast minek feleltet meg

Yes, that is what I meant, I need to convert the coordinates of the mouse pointer to the dX/dY values sent to the emulated hardware in a way that gives a reasonable sensitivity with most Enterprise software. If the majority of software with mouse support assumes or supports a certain resolution for dX/dY, for example dX = +16 moves one character to the left, then it is possible to write the emulation in a way that in those software the sensitivity of the emulated mouse matches that of the host OS. That is, if you move the pointer by one character on the screen, then it will also move by one character in the EP software, even if the actual position cannot be matched.

The same applies to the mouse wheel, although in that case there might not be a real sensitivity, and it is more like simple up/down buttons that should send +1/-1 as the delta whenever such events are received?

Quote
Xep128-ban olyan feature is van, hogy "kitalalja", hogy a program joystick-ot kerdez vagy egeret, akkor is, ha amugy utkozes lenne, es aszerint valaszol.

I planned a similar feature, while the 1500 us (is that value correct?) timer is active, reading the B6h port returns data from the mouse buffer, otherwise it is the joystick input like before. It would also be possible to send the mouse data on both columns (bits 0 and 1 of port B6h at the same time), if that is of any use and it does not break any software.

Offline gflorez

  • EP addict
  • *
  • Posts: 3610
  • Country: es
    • Támogató Támogató
Re: EP128emu
« Reply #662 on: 2016.September.19. 13:35:35 »
Ok, I am very happy that he is interested on mouse controller to implement on his EP128emu.

The hardest part is to understand how and when the data is put on the joystick ports by the interfaces(Neos-Boxsoft, MSX, EnterMice). It took me two years, you only a week. Maybe IstvanV will understand it in only days or hours....

Resolution is not important on the MSX approach, the mouse only returns a delta of the position, the increments-decrements on 8 bit signed, so the min movement is a pixel, and the max 128, probably not reachable in a 1/50 of second.

The Ps/2 mouse works the same, with deltas, but on 9 bit signed. The eight bit is discarded.

Then, the better sensitivity of modern mouses(or the host OS mouse) benefit directly the PS/2->MSX approach of the EnterMice.

The wheel is only a pulse counter.

You have two "hard wired" buttons and three "software" buttons, five in total.

-----
Zozo proposed to better use K, because until now that line has been unused. Boxsoft uses J and it conflicts with Joy1 on games and apps that read all controls at the same time. This is because the MSX protocol puts "imposible" movements on the direction switches. It is not armful, but freezes the app, for example EPDOS or the ManicMiner Spectrum conversion.

 

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: EP128emu
« Reply #663 on: 2016.September.19. 14:00:09 »
Yes, that is what I meant, I need to convert the coordinates of the mouse pointer to the dX/dY values sent to the emulated hardware in a way that gives a reasonable sensitivity with most Enterprise software.

I think, it's more a "try it" thing :) At least I've done that, implementing and trying the result how it "feels". I cannot say there is an 'exact' value. However what I found, that using Xep128 in window and full screen mode, the "scaling" between the mouse-proto-level dx dy should be modified somewhat compared to the situation when it's fullscreen, since in window mode mouse "feels" too sensitive, for obvious reason. Maybe it's of course not the window/full screen topic at all, but on the fact, how big the emulated screen is (I mean on the PC monitor, that is), currently.

Quote
If the majority of software with mouse support assumes or supports a certain resolution for dX/dY, for example dX = +16 moves one character to the left, then it is possible to write the emulation in a way that in those software the sensitivity of the emulated mouse matches that of the host OS. That is, if you move the pointer by one character on the screen, then it will also move by one character in the EP software, even if the actual position cannot be matched.

I don't think it would work in general ... Maybe, but for example EP software may be "lazy" to do the check for a while (disk I/O for longer, no mouse check meanwhile) so there will be a difference already. Also, I don't think there is a "standard" of mapping mouse dx/dy values to screen dx/dy, but who knows ... And for me, I would even annoying to see the mouse PC pointer and the EP "drawn" mouse pointer at the same time, to be honest :) That's true, that you can disable (PC) mouse pointer just for the emulator window, and you can try "not to grab it", ie you can "pull out" mouse from the emulator window, and you can use it normally in other windows on your host OS, maybe, that would be a benefit ...

Quote
The same applies to the mouse wheel, although in that case there might not be a real sensitivity, and it is more like simple up/down buttons that should send +1/-1 as the delta whenever such events are received?

Though, I have code for mouse wheel, honestly, I haven't even tried that ever :)

Quote
I planned a similar feature, while the 1500 us (is that value correct?) timer is active, reading the B6h port returns data from the mouse buffer, otherwise it is the joystick input like before. It would also be possible to send the mouse data on both columns (bits 0 and 1 of port B6h at the same time), if that is of any use and it does not break any software.

Honestly, I am even lazy to understand my own code in Xep128 emu :) But my approach was something like checking "mouse pulses" (what is sent over the serial port) and if there is not so much, I treat the read as "joystick scan" otherwise "mouse scan". On joy-1 conflicting I simply use a "veto" variable that "joy is OK". So maybe, it's OK, that you replicate for both of J and K column, and you just need to take care this "veto" stuff in case of a conflict between joy and mouse.

My work was also some kind of try&error process, for example SymbOS didn't worked without some added work-around, what I can't remember too much in details :) I mean, if you do this "heuristic" logic, as SymbOS try to "detect" mouse and maybe too "short" period it was for Xep128 to "judge" it as a mouse scan. And if SymbOS fails to "find mouse" it won't use it then, even if it would work on the next msec, for example ...

Offline pear

  • EP lover
  • *
  • Posts: 825
  • Country: pl
  • Z80 only
    • Támogató Támogató
Re: EP128emu
« Reply #664 on: 2016.September.19. 14:41:38 »
The Ps/2 mouse works the same, with deltas, but on 9 bit signed. The eight bit is discarded.
In Entermice exactly discarded the least significant bit, while the ninth bit is slide to the oldest position in a byte and moving the other bits to the right.
In other words, is issued a 9-bit value divided by two.

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14739
  • Country: hu
    • http://enterprise.iko.hu/
Re: EP128emu
« Reply #665 on: 2016.September.19. 16:17:57 »
I think current days enough emulate EnterMice mode only. All old programs use the MOUSE.XR extension which is already updated for EM. Then no conflict with Ext 1 joy.
Pear can write the exact timing of EM.

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #666 on: 2016.September.20. 20:01:40 »
There is some mouse emulation code in ep128emu on GitHub now, but it still needs more work. :oops:

Offline gflorez

  • EP addict
  • *
  • Posts: 3610
  • Country: es
    • Támogató Támogató
Re: EP128emu
« Reply #667 on: 2016.September.20. 21:38:22 »
Is there a Win executable to try?

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #668 on: 2016.September.21. 09:38:38 »
Is there a Win executable to try?

I will create one soon once the mouse emulation is in a more usable state, but I still have a few questions:
- when the mouse I/O is not active (not within 1500 us of the last change of the RTS bit), should the mouse buttons still appear on port B6h? Currently, I make all mouse input to port B6h disabled (data bits = 1) when no data is requested, but maybe some software simply checks the state of the fire button outside the mouse I/O routine?
- is it safe to use the full range (-128 to 127) for the X/Y movement values? I am getting erratic movement in EP software if I move the pointer too fast, as if there was an overflow somewhere, not sure if this is in the emulator or the emulated software
- are the second fire buttons of the external joysticks useful in practice? I have added these in the DAVE input code, but they are not available yet in the configuration
- for bytes 4 to 7 in the data buffer, I currently return 0x44, 0x14, 0x19, 0x5D, these values are from xep128. Are the values correct (maybe the PS/2 ID could be changed to be different from xep128), and would it make a difference in practice if the emulator did not send them?
- the mouse wheel byte also includes the horizontal wheel in the upper nibble, which is not implemented in hardware yet according to the documentation. Does that break any software?

Offline pear

  • EP lover
  • *
  • Posts: 825
  • Country: pl
  • Z80 only
    • Támogató Támogató
Re: EP128emu
« Reply #669 on: 2016.September.21. 11:03:50 »
In EnterMice:
First: No. After this time buttons bits are set to 1.
Second: Yes, it's safe. If overflow appeared, movements are set the max or min value.
Third: I have no idea ;)
Fourth: Not very important.
Fifth: In any case, you can clear the unused half byte.

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #670 on: 2016.September.21. 11:10:28 »
Fifth: In any case, you can clear the unused half byte.

It seems that MOUSE.XR (the version linked from the wiki) tests the 7th bit of the mouse wheel byte to determine the direction of scrolling, so the implementation that includes the horizontal wheel does break the driver. I removed support for the horizontal wheel, and the data byte is now sign extended from the lower 4 bits.

Offline gflorez

  • EP addict
  • *
  • Posts: 3610
  • Country: es
    • Támogató Támogató
Re: EP128emu
« Reply #671 on: 2016.September.21. 11:22:38 »
1- EnterMice enters to a wait state if there is no request on the RTS line, and then it doesn't sends information to the direction bits of the B6h port nor to the Fire bits.  But it activates itself very fast if a change in RTS is detected. This is because EnterMice is a PS/2 to MSX software converter(on a chip), and then the hardware buttons are emulated. This was not the case of the Neos-Boxsoft approach, that wired directly the buttons of the mouse to the EP.

2- Yes, some software produce jumps in the movement, other run smoothly, but I think that it is not produced by the range, as the mouse routine is read every 1/50 sec. It is improbable to reach -128 or 127 even moving very fast the mouse, I think, but I can be wrong, of course.

3- Secondary wired was already possible with the Boxsoft approach, but the Neos mouse lacked the wire as it was used for synchronism(RTS). On the EnterMice approach the secondary mouse button has been put even if no program still uses it.

Especial case are the three software buttons and wheel. To make the interface's software, Pear has followed the extended MSX protocol from Prodatron(SymbOS developer) and NYYRIKKI(MSX developer), that add that new information. This not harm the old software, as the buttons an wheel information go on other lecture cycles. Later, Pear has extended more the protocol to put EnterMice information.

SymbOs still doesn't uses more than the main button, but soon it will do, like other ports of the OS. Is for it that all that buttons are implemented. Of course they are accessible on Exos by the Mouse driver(a new system var has been created) or in the hardware if a developer wants to implement them on new software.

4- These are the extra cycles added by Pear to the MSX protocol, and still there are space to put more information... Basically, what they add is information for the user-developer, not important for its operation. That bytes return type of mouse as detected by the interface, version of hardware and version of software. The last is Pear sign.

As you only have to emulate the complete mouse(5 buttons and wheel), leave that bytes untouched.

5- As I said, still there isn't software that use the wheel. Horizontal wheel is an idea of Pear, not present on Prodatron extended MSX protocol. Actually the upper nibble is not used, but  I must follow Prodatrons's protocol, so I take the two nibbles as a whole byte. I later can change that behaviour easily.
« Last Edit: 2016.September.21. 11:36:25 by gflorez »

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #672 on: 2016.September.21. 11:26:58 »
This program works now with the GitHub version after loading MOUSE.XR:
[ Guests cannot view attachments ]

Converting the coordinates of the pointer still needs to be improved, since FLTK does not provide relative movement information, only the position of the pointer within the emulator window, so it can reach the edges of the window and then in the emulated machine it stops moving. :oops: The 4th and 5th buttons do not seem to work, but that might be because on the mice I have they send keyboard macros, rather than actual mouse button events.

Offline pear

  • EP lover
  • *
  • Posts: 825
  • Country: pl
  • Z80 only
    • Támogató Támogató
Re: EP128emu
« Reply #673 on: 2016.September.21. 11:28:49 »
4- {...} The last is Pear sign.
Exactly there are the EnterMice serial number.

Offline gflorez

  • EP addict
  • *
  • Posts: 3610
  • Country: es
    • Támogató Támogató
Re: EP128emu
« Reply #674 on: 2016.September.21. 14:56:51 »
It seems to work with the EGI, not with SymbOS as it is a hack that needs the secondary button to work as the main one.


I can say now that on EP128emu the CM2000 game works perfect....