Enterprise Forever

:UK => Emulators => Topic started by: gflorez on 2014.September.21. 18:09:27

Title: JavaScript EP Emulator
Post by: gflorez on 2014.September.21. 18:09:27
Good!, JLB. Works flawlesly with a 31 fps on my Asus laptop.....

Have you put a better keyboard recognition?. but I can't press the colon ":" to change the path. can you add something to assign the keys?
Title: Re: JavaScript EP Emulator
Post by: lgb on 2014.September.21. 22:13:13
Quote from: gflorez
Have you put a better keyboard recognition?. but I can't press the colon ":" to change the path. can you add something to assign the keys?

Always an issue with a javascript stuff trying to emulate lower level thing :) Mapping is try to be familiar layout as an UK EP's keyboard layout. So keys are A S D F G H J K L ; : (etc) in the corresponding visible EP key row (not the keyboard matrix, but what you can see on an EP keyboard). As I have to use position mapping (and not symbolic, it's quite hard with high level keyboard layer JavaScript can provide with good cross-browser compatibility, and also problems, like shifted on real EP but not shited on PC keybaord and vice versa) starting with the US PC keyboard layout. So in nutshell, in your (US layout) PC keyboard you should press ; to get ; on the EP, and to press ' to get : on the EP. But as it turned out, it's kinda hard to create good keyboard emulation in JavaScript throughout the different browsers/OSes even if you assume a fixed host (PC) keyboard layout and strict positional mapping ...

Btw, you can get more information (not on this issue but in general on my JavaScript based Enterprise-128 emulator) if you click on the "homepage" link at the top of the page, after text "Enterprise-128 JavaScript Emulator".
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2014.September.21. 22:53:36
Ok no problem, I only have to find the right key, it is there....
Title: Re: JavaScript EP Emulator
Post by: lgb on 2014.September.21. 23:07:29
Quote from: gflorez
Ok no problem, I only have to find the right key, it is there....

Well, the problem exists, since the current solution is not straightforward, layout-dependent, ugly JS code, etc :) But anyway it can be used _somehow_ at least :-P
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2014.September.21. 23:10:06
Now your emulator works with the virtual keyboard of Android, even touching the screen acts like the Enter key and  I can pass the ENTERPRISE logo only with the finger!


Edit: is strange, the screen acts as fire, but the space doesn`t....
Title: Re: JavaScript EP Emulator
Post by: lgb on 2014.September.22. 09:04:16
Quote from: gflorez
Now your emulator works with the virtual keyboard of Android, even touching the screen acts like the Enter key and  I can pass the ENTERPRISE logo only with the finger! Edit: is strange, the screen acts as fire, but the space doesn`t....

Actually, my Enterprise-128 JS emulator does not play too well with mobile devices, ie there could be much more specific support, I must admit (the current state of JSep is a really ugly, big mess, I am still planning a full rewrite for clean-up, more mobile devices support, and the ability to easy use for anyone to use it in their own web pages, which is not so possible currently). Besides the keyboard, there was a request from a friend from this EP forum to be able to "press" a single key (it was space or enter, I can't remember now) with a screen touch event on the EP "window" (canvas html element). Well, as far as I remember at least :) I often forget even works I did, ehhhh .... Btw there are two different JSep versions, the base URLs are:

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

The second one (with "demo.new") should be faster (optimized canvas refresh JS typedarray access, etc, according to guys tested, it's about 10% faster or so) and there can be minor differences. The reason to have two versions that I am still not sure I haven't introduced new bugs with some modifications I did with the ".new" version ... But in general, if you have an URL for my web based emulator, and you see /demo/ in the URL, you can always try to replace that part of the URL with /demo.new/
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2014.September.22. 13:33:57
But you must be proud of the speed achieved...Now your emulator only lacks some easy configuration.
Title: Re: JavaScript EP Emulator
Post by: lgb on 2014.September.22. 16:37:41
Quote from: gflorez
But you must be proud of the speed achieved...Now your emulator only lacks some easy configuration.

Well, it's matter of taste. Since it's a web bases stuff, my primary idea was to present some EP software on your own webpage (it's another question that currently it's not so well suited exactly for that purpose), so to be natural to the web techniques, simply the URL holds the configuration so you can include a single URL with any configuration. If you treat JSep as a general emulator comparable eg with ep128emu, then you're right :) But I always thought that a native application (like ep128emu) is a better solution for accurate emulation and general purposes and JSep can be useful for web presentation and not so much for a generic emulation solution. But anyway: if I have time and willpower for the full rewrite, JSep can be downloaded and can be easily integrated by anyone into their web pages, and also, it will provide interface to create a simple web page at a fixed URL with suitable controls for easy configuration if you want to use it as a regular emulator. Currently I have an unfinished project for an "online EP128 assembler" project: it uses codemirror web based editor, and the server side component does the compilation creating an ep128emu compatible snapshot (which can be used with JSep) which is used by JSep then to "run" the program with almost no time spent for "booting" the Enterprise because of the snapshot technique used. I am not sure how useful this project though :)

The speed: it's not my merit, but the unbelievable JavaScript performance of modern web browsers (+ modern JS/web features like typed array and canvas element) especially compared to the situation was some years ago :) An emulator like this was quite unlikely even some years ago with decent speed ...
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2015.October.29. 10:00:13
As I still need a portable EP emulator(like everybody...), I've returned to see the advances on this great LGB project (http://ep.lgb.hu/jsep/).

I'm testing it with an Android tablet running at 2,2Mhz and 4 nucleus and the counter of FPS sometimes reach 90!

Now there is a new download link to put some needed files(mainly the web page file and JS files) inside the device. You can run the emulator locally only clicking to the downloaded HTML file. But still you need to download the Roms and disc image from the JSEP page.

Once downloaded  you can switch off Wifi and have it running for days...

One of the drawbacks JSEP had was its generic keyboard definition, that doesn't coincide with my Bluetooth keyboard, but now you have locally access to keyboard.js, the file where that definitions are made. I want to adapt it as I don't find the ":" symbol.

The file that recalls the remote files is Enterprise.js. I´ve downloaded the needed files from LGB's page, put them on the tablet and changed the URL it calls to my Android partition, but it refuses to charge them. I have to do more test on this.

Not a big problem if I can have the Firefox page waiting there for months, but it could be fantastic to make the emulator completely stand-alone.






Title: Re: JavaScript EP Emulator
Post by: lgb on 2015.October.29. 12:41:36
Honestly, the major problem with my Javascript based EP128 emulator (JSep) that it is (or "was") a "learning material" for me to learn Javascript better than the basic skills only for homepage decoration purposes :) So the code is really ugly, and I don't have the mood to really modify now because of this issue. I really have to to rewrite it now, in a more sane way, from the view point of programming :) Modern Javascript standards allows funny things on a mobile device, like sensing the movement of the device and acceleration, thus it's even possible to map these events as joystick events for the emulated EP128. I don't know if it's useful at all, but it sounds fun in my opinion :) Generally it's surprising how fast javascript is, especially compared to the old times. Also mobile devices are fast enough now, on my first smart phone it ran JSep with about 1FPS only :) And still browser's javascript engines are getting faster and faster, also the hardware, so maybe soon there is not even need for native applications to gain a usable speed even on "said-to-be-limited" devices like a smart phone is (or "was").

I had the plan to port my native-C emulator (Xep128) to Android, as SDL (what Xep128 uses) is available for Android too. But now I am thinking if it's really needed, with today's hardware and browser JS engine speeds ... It took enough time for me, to try to write Xep128 for two different platforms already (Windows and Linux), though SDL is almost completely free of platform specific problems, there are other areas which can be problematic, especially the upcoming EPNET emulation for networking.

The "loading time" issue is not too much about loading the base HTML and various JS files. Ok, those are too, but I guess, the major download size is about the ROM package and the disk image (if any) for example. If the latter is the issue, it can be solved ie with using webstorage feature of modern browsers, though I should write the support for it. Then, it's possible to use the locally stored version of data files instead of downloading them all the time when you want to use JSep.

If you try to use JSep as "offline" the best way currently to check the html file out at:

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

and also downloading all js files the html refers to (btw, there is a /demo/ and /demo.new/ version, you should use the second, it should be faster, and have some extra fixes etc ... I really should replace the /demo/ with the new version just there were some issues if I remember correctly, that I didn't want to make it as the default one).

Yes, keyboard definition is fixed in keyboard.js, but of course feel free to modify. Of course it's not the best and user-friendly way for configuring the emulator, I know :) My basic idea with keyboard layout to use "positional" mapping as much as possible, ie try to lay keys out in a "shape" it would be on a real EP (so no "symbolic" mapping which does this in a way to use the native meaning of keys on the OS which runs the emulator - also symbolic mapping has some interesting challenges, like if you have shifted key on your device for a key event which is not shifted on an EP128, or vice versa). For positional mapping I use the layout of the US keyboard. These two things putting once means, that the key would be right to key 'L' is the ';' and the next key is ':'. I mean, _if_ the keyboard use the US layout.

Of course any suggestion and feedback is warmly welcome about JSep, the real issue here that I don't know when I have time/mood :) to continue its development, especially because - as I've written above - I should rewrite the whole stuff first ...

And a major problem: the sound, which should be done. There is _some_ limited sound (digi and basic Dave channels though without modulation, filter, distortion and other tricks, also there is no noise), but it must be "asked" in the URL, also it's not synchronised at all, causing clicks, repeats and other sound anomalies. It also makes the emulation to somewhat slower. I really need to learn more about webaudio, it was just a "quick" attempt to do something, but it's completely unusable at the moment. But for a test (it's really awful, I warn everybody ...):

http://ep.lgb.hu/jsep/demo.new/?sound=yes

Another interesting problem with audio, that it seems some browsers and/or OSes (like iOS) does not even allow a javascript produces sound without an "interaction" to prevent users have something audible on a webpage. In this case maybe audio can be initiated from an event handler, like first keypress etc, then browser treat audio request as based on user interaction and not "automatically". So there are interesting problems sometimes :)
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2015.October.29. 15:48:33
I understand that sound on Enterprie emulators is a complicate thing, but by now it is not an important aspect for me.

On Enterprise.js I have changed "http://ep.lgb.hu/jsep/data/" path with "file:///storage/emulated/0/" and it gave me the error "Access to restricted URI denied" because loading local files it's not permitted on Firefox JS.

Also that is not important with my actual "necessities".

I wanted an "approximation" to a stock Enterprise running stand-alone on my tablet, and yours is near perfect...

I only have to put hands on defining the keyboard.




Title: Re: JavaScript EP Emulator
Post by: lgb on 2015.October.29. 16:36:48
I'm not sure, but maybe this ugly stuff can help:

http://ep.lgb.hu/jsep/demo/keytest.html

Try to press keys after page is loaded. Maybe you can use the information from here then, to modify keyboard.js for your needs. Or you can find - I guess - better pages than this for this purpose :)

Well, I can't say too much about the URL change to file:// Since data is loaded with AJAX calls maybe it's really a security policy by the browser itself. I mean, AJAX is not the very same as using resources (ie, a file or js script) referring file:// URLs, AJAX is checked more in modern browsers to avoid some kind of attacks, the "same origin" policy, that a javascript can only issue ajax calls to URLs in the same domain as the script originated from. In JSep this is handled that server of lgb.hu emits a special http header that it's OK to be used from other domain too, even if it's not needed, if you use JSep from ep.lgb.hu directly. The problem that file:// URLs does not have too much the same domain or even the "domain" notion, as you can see. As far as I know, google chrome allows (or allowed in the past when I tried this?) this with a special command line (!!) option: --allow-file-access-from-files but I have no idea about firefox (I more often use firefox, but I always use my lgb.hu server).

If you have enough knowledge on Javascript and you _dare_ to dig into my super ugly JS code (used to learn JS, as I've told, shame on me, really ugly!) you may create a solution to build an JS file from the ROMs (I mean simply an "js array" of bytes) and use that instead of the JS AJAX loading stuff madness :) A somewhat better solution as I've told: modify JSep to use localstorage feature of browsers to store information locally, maybe even a way as it would be cache (ie only download from the Net if it cannot be found in localstorage).
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2015.October.29. 20:01:49
Ì have zero knowledge on JS, but can learn if pressed.....

I will try.
Title: Re: JavaScript EP Emulator
Post by: lgb on 2015.October.29. 20:16:56
Ì have zero knowledge on JS, but can learn if pressed.....

I will try.

Well, if you have only plans to modify keyboard.js then it'is relative simple to do, even without any JS knowledge. You can find the keyboard mapping in keyboard.js, a typical line is:

Code: [Select]
81: {row: 2, mask: 0x02},
"81" here is the keyboard event in JS, about the same you would get with the keytest.html page I mentioned. For regular ASCII chars, they are often the same as ASCII values for the given character but not always. Note, that shift is like any key! So the difference between Q and q does not exist, as the same key is pressed just with shift or without meanwhile. That is exactly what makes it hard to create a mapping where key is shifted in EP but not on your PC keybaord or vice versa, as I've already mentioned. Also, because eg ';' and ':' is unshifted on EP, you can't create mapping if it's shifted on the PC keyboard (when I say PC here, I mean the OS which runs the browser which runs JSep ... it can be Android, Mac, etc too of course - PC is just a single example). So you have the idea ...

The "2" after row: shows the enterprise keyboard matrix row position for the given key, and "mask" is the mask for column, ie 1 for col 0 (2^0), 2 for col 1 (2^1), 4 for col 2 (2^2), etc till col 7 for 128 (0x80 in hex, 2^7, "^" here is of course the power math function).

It's also worth to read comments in the table, and also look at "function keyPreTrans(evt)" you can see some workarounds there, too.

I'm afraid, it's not free enough for you maybe, because of the restrictions of nature of positional mapping, ie the shift constraint between the two platforms (the emulated - ep128 - and the "host" platforms). But I also don't know what is your exact goal with the modify :) You can try to assign new key code for ':' for example though.

Ooooops, I forgot to note, that JSep - below the status line (where FPS info is shown as well)  - shows the current key event. So you can use that information too, to modify keyboard.js, no need for the keytest.html I suggested.
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2015.October.30. 08:30:47
I've assigned the missing keys. It was easy with your well documented code. Overall I needed ":" to access EXDOS and EXOS.

Some keys give 00 code and are not assignable, but I managed to have all EP keys.

But sometimes the keys give strange results and I have to reset the JSEP. Maybe some error on the correction subroutines, not a big problem by now.

If I get better performance I will put here the modifications made.
Title: Re: JavaScript EP Emulator
Post by: lgb on 2015.October.30. 09:27:37
Well, I am interested what kind of modifications you did, maybe useful for other people as well. And I should know what kind of keyboard layout you use on the host OS :)

Please have a look at "function keyPreTrans(evt)". As I've written, there are some workarounds implemented there, for example firefox uses some key ids differently than most of the other browsers. Also, you can see the comment there about "Hungarian keys". This is tried to handle the most common situation, ie ';' and ':' on Hungarian host OS kbd layout ... You can see that the "if" block checks for kc == 0 that is: key code zero. Those are keys (you mention the problem as well) do not have keycodes, then the charcode is asked, and I "fake" a keycode for them used to look-up in the kbd matrix JS object. As on EP128 ';' key is right to key 'L', this is the situation with US layout, however, on Hungarian kbd, the key right to 'L' is 'é'. So that's why I tried to handle the situation for people having Hungarian kbd layout, which is a common case on the Hungarian forum :) The problem here, that kbd layout cannot be easily "detected" and of course I can't workaround all possible keyboard layouts etc (without the knowledge of host OS kbd layout) soon there would be even conflicts.

I think, the more rational solution would be to use symbolic mapping, so no knowledge is needed on the layout and  "physical arrangement" of keys, and everybody can use the native layout as they like, with the meaning they would use the kbd on the host OS otherwise, no problem. However the minor issue here, that keys like SHIFT then would be virtual, and also it is not so much possible to give only a "press of shift key" towards the emulator, as shift is only "calculated" from the given keypress by char code (rather than key code, which is done with the current positional mapping). It can be a problem, if an EP software checks only shift. Also, virtual shift is tricky, ie you must simulate to delay the keypress of the normal key, and emulate the shift press first, so EP surely will see the shifted key when scanning the kbd matrix. I even had problems with SymbOS, if I remember correctly, ALT is used for some kind of mouse emulation stuff or such (I can't remember now), but ALT in once is not passed for the browser, as it's a special key on my over-configured Linux desktop. So I even use F9 as an alternative solution for sending the "ALT key press" notification. You see, though keyboard emulation looks so trivial, if you go in details, it's quite complicated. And the fact that browsers have their own idea sometimes how key events in JS are handled, what the IDs, etc, it makes it even more complicated. Eg "function keyPress" is only used in keyboard.js as it seems some browsers / browser versions has the "interesting" feature to generate only up/down event for key or press event, some keys generates both ... Some of them generates events causing "stuck" of a key, as you can see in comments in "function keyUp" for example about my workaround this problem.

Quote
But sometimes the keys give strange results and I have to reset the JSEP. Maybe some error on the correction subroutines, not a big problem by now.

Hmm, interesting, what kind of strange results do you mean here?
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2015.October.30. 10:45:35
You say: "Some of them generates events causing "stuck" of a key, as you can see in comments in "function keyUp" for example about my workaround this problem."

Is that "stuck" problem what I said. Some keys, I still don't know which of them, change the behaviour of all the keyboard, just like Shift, Ctrl or Alt do, but it doesn't return to "normal" state. The solution is resetting. I even don´t know if it is pressing a key, suddenly the keyboard is corrupted. Then, keys give strange results or not at all, others don't Shift or do Caps. And the worst, some keys get stuck and fill the screen with the same un-requested character until I press a 00 code key, then it stops printing.  Strange, isn't it?

This is a Woxter toy keyboard (http://woxter.es/esp/10124-thickbox_default/woxter-slim-keyboard-k-600-touch-pad-bluetooth.jpg) with touch pad, but I have a full-size Logitech bluetooth keyboard (http://img02.olx.com.pk/images_olxpk/106086071_1_1000x700_logitech-media-board-bluetooth-keyboard-for-ps3-pc-mac-andriod-tv-rawalpindi.jpg)  to test.

Surely it is not a problem of your code, but of Firefox. I have to install Chrome for Android to see if it acts the same.

Here you have the keyboard.js file, but not of much aid as I only have changed some assignations.

I think you can make a simple program like keytest.html to guess  the key assignments to do on the keyboard.js file and then JSEP will suit everybody. I only  took few minutes once I understood the grid system as can be seen on the "Converting Spectrum programs to run on the Enterprise (http://enterprise.iko.hu/technical/Converting_Spectrum_programs.pdf)" manual.
Title: Re: JavaScript EP Emulator
Post by: lgb on 2015.October.30. 11:11:21
And does it happen with the original JSep too, or only with the modified version by you? If both are affected, is there any noticeable difference?

One thing is important, but maybe it's trivial: do not ever put a "0" into "var keyCodes" object, I mean no line can start with "0: { ...".

Also, if you map a key to a modifier key on the EP (I mean, like shift), then of course that key will function as a shift. CapsLock is even more interesting of course.

Have you done any modification in the code other than editing the "mapping" in "var keyCodes" object? Ok, just read in your msg, that not so much, OK.

I think, some of the problem can caused by the different JS key event behaviour of Android compared to - for example - a "normal" desktop PC. For example, if keyup even is not generated (but keydown is) of course the emulation won't notice ever that you released the key. In theory, you can see this quite easily. Again, look at the line "KEY ...." below the status line (below FPS etc). You can notice "KEY ^" and "KEY v" like lines if you press/release some keys. Here, the "^" and "v" want to symbolize little arrows, ie "v" is down (key is pressed down) and "^" is up (key is "released up"). If you see a key do not generate the release event, than that's a problem, indeed.

If you have problems like these only with the modified version, please try to modify only a single key at one time, and check if it caused problems.

I found an interesting mistake in my mapping: backtick key ` is meant to be mapped as CapsLock (see the comment, with key code 192) but it's mapped to key 'N' for some reason. It should be corrected :) Btw, the problem with mapping host OS CapsLock as EP128 CapsLock is the fact, that maybe CapsLock is toogled outside of the JSep control (another browser tab, window, etc) so the function of CapsLock will be "inverted" then. That's why I thought, I map another host OS key as EP CapsLock, which is not used otherwise, that is the backtick key here. So, please be careful, I can't say I didn't do mistakes with the mapping matrix, there can be!

An interesting (well for me ...) story: on one of my Linux machines (only one!) using the shift caused to be stuck all the time. I had no idea what happens, then I noticed, that some other - even native code! - software are affected too. It turned out, that some input method defined on the Gnome/Unity desktop caused this behaviour (unfortunately I can't remember which), but even the low level X event dump utility I could see the problem. It seems keyboard handling, emulation etc is kinda black magic everywhere a bit ... If you put all those quirks, workarounds, and problems together I already told about ...

But I could find my bug report on this issue to the VICE (= Versatile Commodore Emulator) team, if you're interested:

https://sourceforge.net/p/vice-emu/bugs/383/

Note, that it's not an JS/in-browser stuff, but a native application and still it was affected! So the issue can be even deeper than just my JS code, or even the browser itself. Huh.
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2015.October.30. 11:24:04
I've already corrected that backtick key error, thanks. It was redundant, as a few lines forward you make another assignment with that same coordinates. 
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2015.October.30. 11:27:17
Is for that "esoteric" behaviour you find on every device, better that every owner do his own assignments.
Title: Re: JavaScript EP Emulator
Post by: lgb on 2015.October.30. 11:40:41
I more or less have the feeling now, that I should give up the positional mapping. It's layout dependent on the host OS, etc. However with symbolic mapping (ie do the same "character" on the EP128 as the host OS) will makes interactivity worse. What I told, that for "virtual" shift I need to delay to propagate key events to handle the modifier key difference (ie: shift). And as we know from the Atmel AVR PS/2 keyboard interface project (by Tigrian, if I remember correctly) already: some people feels that it causes problems in games etc. Also it makes impossible (well or problematic at best) to check SHIFT key state, if an EP program really wants to know you pressed SHIFT in its own not so much as a modifier key. I guess, now you have the idea what my problem is here. There is even a chance to do mistake if no delay is done, ie shift key is scanned after the other keys. On a real EP, it's quite rare it causes problem as humans are not so fast to press eg shift + A in a situation that only microseconds difference EP can notice between them ...

But, a more quick way now: if your short-term goal only to have working ':' for example, then please send me the "KEY" display information below the status line with the key pressed/released you'd like as key ':', but only, if it's not used for other key, and the shift state is the very same on the host OS and from the viewpoint of EP. If you can find a solution like this, and even if it's a keycode = 0 situation, I can include it in the "workaround" section, and we will see ...

Some funny (or sad) material on browser differences: http://www.quirksmode.org/js/keys.html
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2015.October.31. 00:12:15
You can't wait for an standard or try to parse yourself all the incompatibilities. Better make some form of keys editor.

Making virtual the keyboard you lose that precious FPS you have gained.

I have been testing JSEP with Chrome for Android. It is disaponting, at least it is half fast than Firefox.

One of the 00 keys now gives a value, and again ":· is lost.
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2015.October.31. 14:03:56
It is acceptable for me as it is, but I need a way to save a simple Basic program, even if it is lost at getting off Firefox.

How can I remove disc protection?

And, can I upload my disc image to your page by FTP?
Title: Re: JavaScript EP Emulator
Post by: lgb on 2015.October.31. 18:39:24
Well, the the problem with saving that it is simply not implemented, ie no writing support in the WD/EXDOS emulation at all. So it's actually not a protection but the lack of support. Emulator "fakes" a read-only disk situation so at least the emulation does not crash :) Anyway, saving a program is always a problem with a web emulator since web stuffs without specific server side support is not designed for "saving" at all. You can think about that, if you have a web page at a provider, you can visit the page via HTTP, no problem, but it's load (download) information. To upload ("save") something, HTTP is not enough and FTP or other solution (like WebDAV) is needed. So there is a fundamental problem here ... JSep is thought (by me) as a tool to demonstrate running programs, but I would not use it to develop anything, ep128emu etc is much better for that, JSep is only a much simplier web presentation tool, we can say, for an already ready stuff.

At the other hand, in theory it's possible to form a disk image in "localStorage" of your browser (in theory it's persistent, even if you restart your browser, for example, but it will only work with that browser on that device since it's "local"). It would need to re-write some parts of JSep, and there is another problem: you're about the plan to use JSep locally, ie file:// URLs, not from a web server. The problem here, that web is basically designed for the network, ie I am not sure JS scripts from file:// can even have localestorage feature, as it would use - again - the notion of the domain of the URL. But I can be wrong here. There are up-coming standards in JS for example the File API etc, but first of all I am not familiar with them (yet) and I am not sure about the support (last when I read about it, it was read only with Firefox - again the ugly read-only stuff, but you can understand it, from viewpoint of web, "saving" something - ie writing - is dangerous, you wouldn't like a random visited web page start to write your files, or files on other servers at their own, that would  be a very huge security problem).

Uploading anything to my page is not needed at all. JSep is capable to load its files from anywhere, which is accessible via Internet and http. There was a thread on the forum about this somewhere, but maybe it was Hungarian. The only problem with this, is the AJAX cross-domain security policy of the browsers. Ie, a script cannot initiate AJAX calls to another domain. It affects JSep too, of course. The solution, that on your server (where you want to access stuffs from, in JSep) you need to emit a special HTTP header which instructs the browser to allow the access.

Code: [Select]
Access-Control-Allow-Origin: *
As you can see, there are several "interesting" problems with web based stuffs if you want to use them as "local applications". There are products like FirefoxOS which would do everything (ie, even the dialer is a HTML page) with web technologies on a smartphone, but it's not so much widespread and the special extra APIs for this is not quite a standard to be supported by other browsers. As far as I can see, the tendency that more and more techniques are invented to solve these kind of problems on the "generic browsers" as well, but we're quite not there yet, what all is needed for the fair comparison with native applications.

Here it is an example (http://ep.lgb.hu/jsep/demo.new/?disk=http://www.symbos.de/files/SymbOS-EP-Full.dsk&mem=1024&mouse=no&autostart=yes), where JSep loads the disk image from another URL than its "hosting server" (which is ep.lgb.hu in our case), ie in this case from here: http://www.symbos.de/files/SymbOS-EP-Full.dsk so the disk= parameter in JSep's URL accepts even a full URL, just be careful about the cross-domain stuff, I mentioned before (I guess on symbos.de it's allowed by its admin - maybe Prodatron), that's why it works.

Sorry, I can't provide access to my server via FTP or whatever, because it's not entirely "mine" to be exact just I use that too for my domain lgb.hu :) Of course if you have a disk image you can send me to put there, but it's not so much a sane solution if you want to update it regularly.
Title: Re: JavaScript EP Emulator
Post by: lgb on 2015.October.31. 18:41:01
Ah sorry, it seems I also forgot what I code in my own emulator :) JSep currently uses a "proxy" for downloading remote (not from the hosting server of the emulator) stuffs (disk images, ROM images). So the HTTP header maybe not needed at all.
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2015.October.31. 19:55:53
Don't worry, at present I want to know about LPT, and your emulator serves perfectly for that purpose. I only want to do simple basic programs to see how can I implement text modes on the mouse driver.

But is tedious to type every time the same lines. I only wanted to have a draft program and then tweak it some var or constant. Is for that I looked for  some form of saving on JSEP like can be done with "epfileio.rom" on the Ep128emu .

I understand the limitations Java Script has and how titanic has been your task...

 I can do the more complicate things on other computer, no problem.

Title: Re: JavaScript EP Emulator
Post by: lgb on 2015.October.31. 20:55:21
Quote
But is tedious to type every time the same lines. I only wanted to have a draft program and then tweak it some var or constant. Is for that I looked for  some form of saving on JSEP like can be done with "epfileio.rom" on the Ep128emu .

Something like the fileio stuff is may be possible with JSep, but again, it will be done over HTTP. So then individual files (instead of disk images) are needed on a _web_server_. The limitation is again, that it's a "web" based emulator, thus it requires web servers :) In theory, it can be done maybe, to put a button on the emulator page for a "fake" upload (ie, not to the webserver, but JS "catches" it), but I am not even sure at the moment.

Again, what I can suggest: do your stuff with ep128emu, eg at the point that your program is loaded etc, then do a snapshot. JSep is capable of loading ep128emu snapshots, not perfect, but in most cases it works. Just you need to put the snapshot on a webserver (of course) and you must use the right URL parameters for JSep that it loads then. In this way you don't even need to wait "for booting" the emulated ep128emu etc, and you can use ep128emu always running on your computer, developing your driver etc, and taking snapshots when you need to test. If you have somehow assign a network share or whatever of a web capable server, then it's even possible to load that by JSep without too much extra work, or just reloading the page of JSep.

Quote
Don't worry ...
[...]
I understand the limitations Java Script has and how titanic has been your task...

I don't worry, also I don't want to treat my work here being "titanic" :) just I would like others to understand as well, that there are some limitations based on the web nature here. As there were requests on the Hungarian forum as well about features natural to a local-running native up, but quite strange from the view point of web/JS stuffs :)

What was also my plan (but no time to do) is creating a web based IDE. Ie, you can edit ASM program right on the web page, and allow to test it on that page (with the JSep) as well. I can't find a good example for this now:

http://clrhome.org/asm/

Maybe like this, just you can see the result as well running ... A stuff like this - I guess - is great to test shorter things. Of course it's maybe not so much well suited for serious programs.

Well, like this:

http://ep.lgb.hu/jsep/editor/lgb.php

This is what I started to make a year ago or so :) Useless to try, it won't work at all :) Eg some button opens http://index.hu/ (a Hungarian news site) instead what it should do, it's a test from me (about button events, etc), don't be surprised :) If you click on the Build button on the top, it won't build, but starts the emulator. You can see, the emulator itself is under a tab, and still you can change tabs (tabs: I mean my tabs on the page) without restart of the emulator, etc. It's not a big magic, just some css stuff anyway.

But you can get the idea what I wanted to create. I can't see clearly, it's usefull too much, as for serious development it's hard to do this way in a web based editor ...
Title: Re: JavaScript EP Emulator
Post by: lgb on 2015.October.31. 21:13:21
Another note: if you want to test something which is not supported by ep128emu (maybe the mouse?) you can try my native emulator (Xep128) if you have Windows or Linux (on x86) to be able to run it. It supports SD cartridge, again, only read-only, but everything is local in contrast of JSep (which is web based). I guess, there is some windows tool maybe (demontools or whatever? I am not so familiar with windows, to be honest ...) to "mount" disk images, so if you can see one partition of the SD card image as a directory, you can edit your program with a PC editor (or whatever) and save it "into" the SD card image, then Xep128 will be able to "see" it. Just be careful as if the SD card image is used meanwhile and not fully updated before Xep128 uses it (or it changes meanwhile) it can cause some EXDOS headache, I guess :)

https://github.com/lgblgblgb/xep128

You can read some howto on the page (scroll down) how to install on Windows and Linux. SymbOS seems to work with mouse with it.

But one warning: please do not trust in my mouse emulation in Xep128 or JSep it can be wrong, and not your driver is bad :) Though because SymbOS seems to be able to use it with both of JSep and Xep128 it can't be totally wrong at least. Xep128 tries to detect the usage of otherwise conflicting extjoy + mouse thus it's possible that you need to click into Xep128 window for "mouse grab mode" (host OS mouse cursor hidden then etc) to be able to use it.
Title: Re: JavaScript EP Emulator
Post by: gflorez on 2016.February.20. 02:08:17
XEP128, and probably your JavaScript Emulator don't react very well with the actual version of the mouse driver (https://enterpriseforever.com/programming/universal-mouse-driver/?action=dlattach;attach=14686). The movement is imprecise and jumpy, probably because the enlarged reading routine collides with your mouse caption.

On the other side, you have Boxsoft emulation but, can you implement Entermice on your emulators?
Title: Re: JavaScript EP Emulator
Post by: lgb on 2016.February.20. 12:29:21
I feel somewhat confused abouse the mouse topics. It seems Boxsoft was the de-facto standard for mouse on EP, but still only a very limited amount of software used it. I don't feel the need too much to implement many different "standards". My hope that Entermice will be the "standard": as with only a few titles to support mouse, I don't think it worth supporting multiple mouse protocols. A few existing software (like EGI?) can be ported, etc. I would love Entermice that it won't "collide" with the joystick emulation badly, which can cause problems on a real EP, and in my emulatorts too. Honestly, my only goal with mouse support to have usable SymbOS session in my emulators :) Once we can "safely" say that Entermice is enough, I would only support that.

In JSep the situation is even more complicated: it's so bad code (was a kind of learning material for me on JavaScript, to be honest) that I fear to even look on the source currently :( That will need a full rewrite to have any major modification ...

Well, the jumpy and imprecise movement is interesting. Do you feel that with eg plain SymbOS + boxsoft in my emulator too? If not, it's interesting what can be the difference. But I guess it's hard to tell, as SymbOS uses its own routines regardless of the actual hardware would be on a real EP, a boxsoft mouse interface or Entermice. Another problem that I don't have a real working machine to test anything ... neither another emulator which supports mouse, and so on.
Title: Re: JavaScript EP Emulator
Post by: gflorez 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....
Title: Re: JavaScript EP Emulator
Post by: lgb 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 :)
Title: Re: JavaScript EP Emulator
Post by: lgb 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!