naTmeg / ScriptedAmigaEmulator

Amiga Emulator in javascript and HTML5
331 stars 63 forks source link

Serial bridge #21

Closed quartexNOR closed 5 years ago

quartexNOR commented 5 years ago

I have been doing some speed optimization here and there, mostly loop expansion which JSVM can JIT more easily once its baked to bytecodes.

I wrote a little serial program on the 68k side of things to create a bridge, but then i noticed that the serial.js file seem to lack quite a bit of code? Perhaps not missing, but since the original was defined to connect to a "real" serial on the host, we lack a high level JS interface to communicate.

I had a look at the original code here, to compare btw: https://unix.superglobalmegacorp.com/uae-0.8.29/newsrc/src/serial.c.html

Do you have any plans to add the normal ser->write() etc. so that sending data from the JS side of things to the 68k side works properly? I dont mind doing it myself, but could use your input on the matter. It seems that the whole IRQ is just REM'ed out around the codebase. Perhaps im reading it wrong.

Any information is welcome, since I really want to use this. I will also do a commit of my speed optimization so you can have a look at them later. Right now i have 50fps flat on even the most demanding demos, which is a good boost - they used to flux between 20-40 fps depending on the payload.

But please, help me out with the serial interface (or any data-direct bridge). It would really mean a lot. Thank you for your fantastic work! Truly a massive achievement!

mithrendal commented 5 years ago

Looking forward to your speed improvments pull request. Which browser did you use?

May I ask what you plan to do with the received amiga data on the javascript side? Or what kind of JavaScript data do you intend to pump into the amiga ?

naTmeg commented 5 years ago

Just a quick response.

You should be able to move data from 68k->JS. Make sure you have SAEV_config.serial.enabled turned on and also set DEBUG_SERIAL to 3. Fetch the output at flush_buffer().

For JS->68k, try to fix read_buffer() so that it does not return FALSE and put data in inbuf[]/inptr. Try to read from the serial.device and SERDATS()/SERDATR() should get called. (I guess)

I've never really tested this stuff, but maybe I find some time this or next weekend to look into it...

naTmeg commented 5 years ago

OK, the old serial code could not work at all. I've dropped that and ported new code from WinUAE3.2.x/od-win32/serial_win32.cpp

I've also implemented/ported parts of the parallel-code. Both work now.

I've wrote a tiny test-program for OS2.04 that does use the SER: and PAR: handlers. Souce-code is included if you want to modify it: http://scriptedamigaemulator.net/db/tools/serpar.adf

Usage: Goto the new example.htm. Select a A1200. Select a kickstart >= 2.04. Insert a workbench >= 2.0 in DF0. Insert serpar.adf in DF1. Start and boot to workbench. Select "Execute command" from menu and type "cli". In the shell type "df1:" to change-dir. Type "serpar ?" to show params.

Sending to serial: serpar Hello serpar "Hello Amiga"

To receive from serial first initiate by the number of bytes to read: serpar R S 4 The serial.device if now waiting for data. Somehow call test_serial_send(4) from example.js to send the 4 bytes.

Sending to parallel: serpar P Hello serpar P "Hello Amiga"

To receive from parallel just call with the number of bytes to read: serpar P R S 16 The data is transferred immediately. See example.js for hook-usage.