Welcome, Guest. Please login or register.


Author Topic: JavaScript EP Emulator (Read 30761 times)

Offline gflorez

  • EP addict
  • *
  • Posts: 3614
  • Country: es
    • Támogató Támogató
Re: JavaScript EP Emulator
« Reply #30 on: 2016.February.20. 13:54:53 »
Ok, I understand you, but.....

Can you show me the code that translates the mouse caption to Boxsoft?

May be I can see the fault....

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: JavaScript EP Emulator
« Reply #31 on: 2016.February.20. 19:16:28 »
http://ep.lgb.hu/jsep/demo.new/enterprise.js

In this file there are several important parts of the emulator, we can say the "glue" and "init" code or such. It also registers the JS events browser will call in case of mouse events, eg this line:

Code: Javascript
  1. document.addEventListener("mousemove", mouseMoveCallback, false);

The event handlers themselves are in mouse.js, see later. Also, the I/O port emulation is in this file, check functions readport and writeport out. Maybe it's the best to search for words mouse and Mouse in enterprise.js to find important places.

http://ep.lgb.hu/jsep/demo.new/mouse.js

In this file, you can find the mouse specific stuffs, incuding the handlers registered in enterprise.js:

mouseMoveCallback
mouseClickCallback
mouseGrabbingCallback

Also the routines called by the I/O port reading in enterprise.js, function readport, see at port 0xB6, mouseRead(). Also writeport() function uses mouseCheckDataShift() function.

Important to note: in readport() you can see odd port numbers 0x40, 0x41, 0x42. There are for test purposes I used for my initial test, it's nothing to do with the boxsoft compatibilty, honestly I only forget to remove them :) It defines a simple interface without bit shifting etc, so it was easier to test the mouse handling itself. Btw, an interface like this would be very comfortable and simple in real too, but of course it wouldn't be compatible with anything existing software and would require a card in the expansion bay, or such.

One important part is mouseCheckDataShift() in mouse.js  keySel is a quite important variable in many places, it's the value written by port 0xB5 and used by keyboard and joystick emulation as well, again see writeport() in enterprise.js

It was JSep, Xep128 is somewhat different by nature (not JS events, etc, but the SDL even loop, and of course C, not JS), but the idea is very similar, in fact, I used my own code in JSep, the create something similar, without thinking too much about the re-implementation from zero. In Xep128, many input related stuffs (even kbd) are in this file:

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

Check functions out with "mouse" in their name. Quite similar as they're in JSep. As with readport and writeport in JSep, you can find functions _pread and _pwrite here:

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

And the heart of the emulation loop is here:

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

emu_one_frame() is called after each frame, which calls the present frame function first to show it, and then it looks for pending SDL events (it's not like JS events browser call for you, you must check events and process here). They include key events (used to emulate keyboard) and also mouse events.

I am not sure if my post helped :)

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: JavaScript EP Emulator
« Reply #32 on: 2016.February.20. 23:36:42 »
And one important note: I'd love if you have the time & energy to help to find some bugs etc, what can be corrected in my work. Since "it works me" attitude is OK, but not so useful then for other people ;) So help / feedback etc is always warmly welcome, thanks!