Welcome, Guest. Please login or register.


Author Topic: EP128emu (Read 401052 times)

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #675 on: 2016.September.21. 15:26:49 »
Win32 test version (now with fixed mouse wheel :oops:):
[ Guests cannot view attachments ]

Recording mouse events to demo files is also supported, but it may not be entirely reliable yet:
[ Guests cannot view attachments ]

Offline gflorez

  • EP addict
  • *
  • Posts: 3610
  • Country: es
    • Támogató Támogató
Re: EP128emu
« Reply #676 on: 2016.September.21. 18:18:28 »
IstvanV, I am very grateful to you to emulate the EnterMice. Also to LGB for give you the Xep code.

EnterMice is a great piece of hardware that cannot be evaluated without seeing it working.

Offline gflorez

  • EP addict
  • *
  • Posts: 3610
  • Country: es
    • Támogató Támogató
Re: EP128emu
« Reply #677 on: 2016.September.21. 18:51:51 »
Here you have, KM mouse emulated with EnterMice. SPE128emu running as a Rom inside EP128emu.

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #678 on: 2016.September.22. 10:46:34 »
I tested a few more programs from the EnterMice wiki:

CM2000, PASZIANS.COM, SPEmu128 - these work fine in ep128emu with mouse input
PaintBox - works after loading MOUSE.XR and setting EnterMice mode with SET 189,4
SWAP - moving the pointer works, but the button does not because the game tests the state of the EXT1 fire buttons outside the 1500 us time the emulator allows for mouse I/O after the RTS bit changes. Pressing the actual EXT1 fire button does work, however :)
SymbOS - does not work, it expects mouse input on column J, which is not supported by ep128emu. Perhaps it can be configured somehow to use native EnterMice mode?
EGI - works after replacing the :VAR 189 0 with :VAR 189 4 in EXDOS.INI
EDC Windows - it works, but because of the low horizontal sensitivity, the pointer will frequently hit the left/right edges of the emulator screen

While FLTK does not support mouse grabbing and relative motion, I may try using native APIs (XWarpPointer() on Linux and SetCursorPos() on Windows) in the "fullscreen with no menu bar" mode to center the pointer whenever it gets too close to the edges.

Offline gflorez

  • EP addict
  • *
  • Posts: 3610
  • Country: es
    • Támogató Támogató
Re: EP128emu
« Reply #679 on: 2016.September.22. 10:54:37 »
You must use my SymbOS hack. I modified it to work with K column, but  it still uses right button for main(row 0 on L column), and it is still not detected with your beta emulator while inside SymbOS. Estrange, isn't it?.
« Last Edit: 2016.September.22. 11:03:23 by gflorez »

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #680 on: 2016.September.22. 11:33:21 »
You must use my SymbOS hack. I modified it to work with K column, but  it still uses right button for main(row 0 on L column), and it is still not detected with your beta emulator while inside SymbOS. Estrange, isn't it?.

With the modified version, moving the pointer works for me, but maybe the detection is not always reliable. The buttons do not work for the same reason as in SWAP, they are tested outside the 1500 us timeout. A simple hack to work around that is to swap the two calls at 0598h and 059Bh:
Code: ZiLOG Z80 Assembler
  1. .   0598  CD DC 27     CALL  27DC
  2. .   059B  CD D6 2A     CALL  2AD6
replaced with:
Code: ZiLOG Z80 Assembler
  1. .   0598  CD D6 2A     CALL  2AD6
  2. .   059B  CD DC 27     CALL  27DC
so that the fire buttons are tested after receiving the mouse data, while the 1500 us timer is still active. To fix the left/right button issue, this code needs to be changed:
Code: ZiLOG Z80 Assembler
  1. .   283A  F6 EF        OR    EF
  2. .   283C  21 B4 27     LD    HL, 27B4
  3. .   283F  77           LD    (HL), A
  4. .   2840  3A B1 27     LD    A, (27B1)
  5. .   2843  CB 47        BIT   0, A
  6. .   2845  20 02        JR    NZ, 2849
the modified version that tests the left button instead:
Code: ZiLOG Z80 Assembler
  1. .   283A  17           RLA
  2. .   283B  F6 EF        OR    EF
  3. .   283D  21 B4 27     LD    HL, 27B4
  4. .   2840  77           LD    (HL), A
  5. .   2841  3A B1 27     LD    A, (27B1)
  6. .   2844  1F           RRA
  7. .   2845  38 02        JR    C, 2849
« Last Edit: 2016.September.22. 11:55:15 by IstvanV »

Offline gflorez

  • EP addict
  • *
  • Posts: 3610
  • Country: es
    • Támogató Támogató
Re: EP128emu
« Reply #681 on: 2016.September.22. 12:33:01 »
I did my hack with an Hex editor on the executable, I don't have the  disassembled code.

I can do easily the first fix, but for swapping the buttons we need 1 byte more. Is for that I leaved the left button as Main.

Prodatron has promised a complete rework of the application with all buttons and wheel, so no problem.

Offline gflorez

  • EP addict
  • *
  • Posts: 3610
  • Country: es
    • Támogató Támogató
Re: EP128emu
« Reply #682 on: 2016.September.22. 13:16:49 »
Here is the fixed SymbOS, now it reacts to right button as main.

« Last Edit: 2016.September.22. 13:25:20 by gflorez »

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #683 on: 2016.September.22. 15:23:21 »
I can do easily the first fix, but for swapping the buttons we need 1 byte more. Is for that I leaved the left button as Main.

Actually, my second hack does not change the size of the code: while it does add one more RLA instruction, it also optimizes a test of the lowest bit of A by replacing a BIT 0, A and JR NZ with RRA and JR C. So, with that optimization it is the same size and even the same number of Z80 cycles as before.

Offline gflorez

  • EP addict
  • *
  • Posts: 3610
  • Country: es
    • Támogató Támogató
Re: EP128emu
« Reply #684 on: 2016.September.22. 15:42:10 »
Thank you very much. I'm not a programmer and so I didn't count the bytes but the instructions.....

You did the complete work for me.


Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #685 on: 2016.September.23. 14:25:16 »
I found a possible bug in MOUSE.XR, although it may also be considered a feature. :) In the following routine, the movement values received from the mouse are multiplied by 2 using 8 bit arithmetic, but this overflows if the original value is outside the range -64 to 63. This can be reproduced in the emulator, if the pointer is moved very fast, then it "bounces" back from the edge of the screen when the overflow occurs.
Code: ZiLOG Z80 Assembler
  1. .   C646  2A 36 C9     LD    HL, (C936)
  2. .   C649  3A 41 C9     LD    A, (C941)
  3. .   C64C  FE 02        CP    02
  4. .   C64E  38 05        JR    C, C655
  5. .   C650  FE FF        CP    FF
  6. .   C652  30 01        JR    NC, C655
  7. .   C654  87           ADD   A, A
  8. .   C655  B7           OR    A
  9. .   C656  F2 72 C6     JP    P, C672
  10. .   C659  ED 44        NEG
  11. .   C65B  5F           LD    E, A
  12. .   C65C  16 00        LD    D, 00
  13. .   C65E  19           ADD   HL, DE
  14. .   C65F  22 36 C9     LD    (C936), HL
  15. .   C662  ED 5B D4 C7  LD    DE, (C7D4)
  16. .   C666  1B           DEC   DE
  17. .   C667  B7           OR    A
  18. .   C668  ED 52        SBC   HL, DE
  19. .   C66A  38 14        JR    C, C680
  20. .   C66C  ED 53 36 C9  LD    (C936), DE
  21. .   C670  18 0E        JR    C680
  22. .   C672  16 00        LD    D, 00
  23. .   C674  5F           LD    E, A
  24. .   C675  B7           OR    A
  25. .   C676  ED 52        SBC   HL, DE
  26. .   C678  30 03        JR    NC, C67D
  27. .   C67A  21 00 00     LD    HL, 0000
  28. .   C67D  22 36 C9     LD    (C936), HL
  29. .   C680  2A 38 C9     LD    HL, (C938)
  30. .   C683  3A 42 C9     LD    A, (C942)
  31. .   C686  FE 02        CP    02
  32. .   C688  38 05        JR    C, C68F
  33. .   C68A  FE FF        CP    FF
  34. .   C68C  30 01        JR    NC, C68F
  35. .   C68E  87           ADD   A, A
  36. .   C68F  B7           OR    A
  37. .   C690  F2 AE C6     JP    P, C6AE
  38. .   C693  ED 44        NEG
  39. .   C695  5F           LD    E, A
  40. .   C696  16 00        LD    D, 00
  41. .   C698  19           ADD   HL, DE
  42. .   C699  22 38 C9     LD    (C938), HL
  43. .   C69C  ED 5B 11 C0  LD    DE, (C011)
  44. .   C6A0  CB 23        SLA   E
  45. .   C6A2  CB 12        RL    D
  46. .   C6A4  1B           DEC   DE
  47. .   C6A5  B7           OR    A
  48. .   C6A6  ED 52        SBC   HL, DE
  49. .   C6A8  D8           RET   C
  50. .   C6A9  ED 53 38 C9  LD    (C938), DE
  51. .   C6AD  C9           RET
  52. .   C6AE  16 00        LD    D, 00
  53. .   C6B0  5F           LD    E, A
  54. .   C6B1  B7           OR    A
  55. .   C6B2  ED 52        SBC   HL, DE
  56. .   C6B4  30 03        JR    NC, C6B9
  57. .   C6B6  21 00 00     LD    HL, 0000
  58. .   C6B9  22 38 C9     LD    (C938), HL
  59. .   C6BC  C9           RET

Offline gflorez

  • EP addict
  • *
  • Posts: 3610
  • Country: es
    • Támogató Támogató
Re: EP128emu
« Reply #686 on: 2016.September.23. 15:02:56 »
You are right! I have not though about it....

That modification of the mouse driver, version 1.1, was found on the EGI disks. It is not present on the former versions known until that moment.

In fact this modification was promised in the review about Paintbox in the only known issue of the ECI magazine, page 17.

I will try to fix it soon.
« Last Edit: 2016.September.23. 15:07:25 by gflorez »

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #687 on: 2016.September.23. 19:01:14 »
Here is my attempt at a fixed version of the above routine, it is shorter than the original, but it may be possible to write it better, and I did not test it extensively yet: :oops:
Code: ZiLOG Z80 Assembler
  1.         org     0c646h
  2.  
  3.         ld      hl, (0c936h)            ; HL = X coordinate
  4.         ld      a, (0c941h)             ; A = X motion
  5.         ld      e, a
  6.         rla
  7.         sbc     a, a
  8.         ld      d, a                    ; sign extend to 16 bits
  9.         ld      a, e
  10.         inc     a
  11.         cp      3
  12.         jr      c, l1                   ; -1 to +1?
  13.         sbc     hl, de
  14. l1:     or      a
  15.         sbc     hl, de
  16.         ld      de, (0c7d4h)            ; DE = width
  17.         ld      a, l
  18.         cp      e
  19.         ld      a, h
  20.         sbc     a, d
  21.         jr      c, l2                   ; X not out of range?
  22.         cp      80h
  23.         sbc     hl, hl                  ; X < 0: X = 0, X >= W: X = -1
  24.         jr      nc, l2
  25.         add     hl, de                  ; X = W - 1
  26. l2:     ld      (0c936h), hl
  27.         ld      hl, (0c938h)            ; HL = Y coordinate
  28.         ld      a, (0c942h)             ; A = Y motion
  29.         ld      e, a
  30.         rla
  31.         sbc     a, a
  32.         ld      d, a                    ; sign extend to 16 bits
  33.         ld      a, e
  34.         inc     a
  35.         cp      3
  36.         jr      c, l3                   ; -1 to +1?
  37.         sbc     hl, de
  38. l3:     or      a
  39.         sbc     hl, de
  40.         ex      de, hl
  41.         ld      hl, (0c011h)            ; height / 2
  42.         add     hl, hl
  43.         ex      de, hl                  ; DE = height
  44.         ld      a, l
  45.         cp      e
  46.         ld      a, h
  47.         sbc     a, d
  48.         jr      c, l4                   ; Y not out of range?
  49.         cp      80h
  50.         sbc     hl, hl                  ; Y < 0: Y = 0, Y >= H: Y = -1
  51.         jr      nc, l4
  52.         add     hl, de                  ; Y = H - 1
  53. l4:     ld      (0c938h), hl
  54.         ret

Offline gflorez

  • EP addict
  • *
  • Posts: 3610
  • Country: es
    • Támogató Támogató
Re: EP128emu
« Reply #688 on: 2016.September.23. 19:13:45 »
Ok thanks. I will test it later at home.

I work with a disassembly of the driver, so better if shorter the code.

Surely your fix is much better than what I could do...


Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: EP128emu
« Reply #689 on: 2016.September.23. 21:05:48 »
Another new beta version / újabb beta verzió: :)
[ Guests cannot view attachments ]
[ Guests cannot view attachments ]

- the second and third joystick fire buttons are now configurable via the GUI, and also work in CPC emulation mode
- new configuration options for the mouse sensitivity, separately for X and Y in the range 0.5 to 2.0
- in fullscreen mode with no menu bar, mouse grabbing is simulated using native X11 or Win32 API functions

- a második és harmadik EXT1/EXT2 tűz gombok a grafikus felületen konfigurálhatók, és működnek CPC módban is
- állítható egér érzékenység, külön a vízszintes és a függőleges irányban 0.5 és 2.0 között
- teljes képernyős menü nélküli módban az X11 vagy Win32 API közvetlen használatával javítja az egér emulációt, kevesebb problémát okoz ha a mutató eléri az emulátor ablak szélét (ilyenkor automatikusan visszaugrik középre)