• Please review our updated Terms and Rules here

Tek 405x web-browser emulator

I have downloaded this emulator in addition to obtaining Brad's (Aurelian Design) emulator for Windows. Had a little play with both of them, but ran into several issues with this JavaScript based version and unfortunately could not do very much with it. Firstly can I thank the developers for making the emulator available. Secondly, can I contribute? I have done some javascript work and would be willing to help. Who is actually leading the project? I generally don't work on Windows so I haven't tried Exploder or Edge, but here is what I ran into using both Chrome and Firefox:

1. Chrome/Firefox: which starting point to launch from? jsTEKTRONIX4051.html, jsTEKTRONIX4051_universal.html or index.html?

daver2 wrote the emulator
Philcogrump posted it on github
I did minor edits to improve the graphics, added the top row of keys as they are different than the standard keyboard.
I also added the jsTEKTRONIX4051_universal.html version to run my *.uni files - which will run on both 4051/4052/4054 computers AND the universal version of the Tek 405x emulator

All the other files on my repo that are not .uni extension require the non-universal version of the emulator

2. Chrome/Firefox: when launching from jsTEXTRONIX4051_universal.html, then power button doesn't do anything to the emulator does not start

There is no power button - just the power lamp.

Select Start button to start the emulator.

3. Chrome/Firefox: with either version, caps lock does not work. The only way to enter capitals is using the shift key

Known issue - you may be able to fix it :)

4. Chrome/Firefox: The = key does not work. Tried to enter a short program but my efforts were thwarted when I got something like FOR X=10..... which appeared as FOR X10.... Checked cap lock status but that did not appear to be the issue

Another reason I added the Tektronix keys. Either use Shift key with Tek - or Shift key with PC -

5. Chrome/Firefox: Can't load a program from file. I selected a file and the filename shows next to the Choose button, LIST shows nothing. I even tried the --allow-file-access-from-files trick in Chrome. perhaps it needs to run on a server?

After selecting a program to run, type:

OLD@1:

Either use the @ and : keys on the emulator key row or for a PC keyboard use ` key for the Tek @ and ' key for the Tek :

Dave has emulated GPIB device 1 as a simple external tape drive that only supports the OLD command.

I wish the emulator would add full 4924 tape drive support - as it currently does not support any program access to a different file.

6. Firefox: none of the keys work for input. Only when I selected a file did the emulator suddenly start accepting input from the keyboard.

Start must be selected first on Chrome or Firefox before the emulator supports typing.

After Start, you can use immediate mode to type in the emulator, same as with the 'real' 4050 computers.
Even the Auto Number key works, and all the User Definable and Editing keys work.

I expect that some of these issues might be cross-browser (in)compatibility or simply because this is a work in progress. Since I haven't got as far as running a program I can't comment on how well the programs execute or graphics rendering, however I am willing to have a go at helping to fix some of these niggles.

Since the emulator is emulating the 4051 hardware including the 6800 CPU and using the same 4051 ROMs that you have verified - it works just like the 'real' 4051.

One more tweak that I do to the emulator is to speed it up 10x to emulate the speed on my 4052 and 4054.

I edit the mc6800.js file in the same directory as the emulator program and change the 408 on line 64 to 40. Then run the emulator program and enjoy.

I profiled the performance of running the 405x emulator on my PC against benchmarks I wrote in the late 1970's on a 4051 to calibrate the emulator performance close to the 4051 and picked the 408 value as my calibration value.

Since each PC may have different performance running the emulator - that number may have to be changed to calibrate your PC or Mac. I believe I posted my 4051 benchmark programs and results from the late 1970's in this thread. If you can't find that post - I'll repost my benchmark programs and results.

I actually use this emulator to test the programs I have written - before running them on my 4052 or 4054. Example - my screenshot of the Battlestar Galactica demo program was done on the emulator - just press the "Make Copy" key and the emulator will save the screen in a picture file.
 
Here is the link to my 4051 benchmarks with emulator screenshot after calibration:

https://www.vcfed.org/forum/forum/genres/other/62548-tek-405x-web-browser-emulator?p=777588#post777588

I see that the screenshot can't be zoomed - here is the original emulator screenshot running the program below:

Benchmarks on Emulator.png - Click image for larger version  Name:	Benchmarks on Emulator.png Views:	0 Size:	166.6 KB ID:	1218202

And I will repost my original results:

Code:
Results were very close to my original 4051 benchmarks:

10000 LOOP
Benchmark Test Original 4051 result Emulator
-------------- -------------------- ----------
FOR/NEXT_________46 sec_______________45 sec
X=X+1___________105 sec______________105 sec
X=X+1+I_________128 sec______________128 sec
X=X*1.01________138 sec______________142 sec
X=X*1.01*1.01___199 sec______________205 sec
X=SIN(PI)_______442 sec______________448 sec
X=RND(-1)_______183 sec______________156 sec

Here is the benchmark program with Dave's timer at GPIB primary address 2 added:

Code:
90 REM PAGE
95 PRINT " Monty's Benchmarks - 10000 For/Next Loops"
96 PRINT
100 PRINT "Simple Loop"
110 INPUT@2:A$
112 PRINT A$
113 GOSUB 900
114 T=S
119 FOR I=1 TO 10000
120 NEXT I
121 INPUT@2:A$
125 PRINT A$;
130 GOSUB 900
140 T=S-T
150 PRINT " Time= ";T
160 PRINT
200 PRINT "Loop X=X+1"
210 INPUT@2:A$
212 PRINT A$
214 GOSUB 900
215 T=S
217 X=0
218 FOR I=1 TO 10000
219 X=X+1
220 NEXT I
221 INPUT@2:A$
225 PRINT A$;
230 GOSUB 900
240 T=S-T
250 PRINT " Time= ";T
260 PRINT
300 PRINT "Loop X=X+1+I"
310 INPUT@2:A$
312 PRINT A$
313 GOSUB 900
314 T=S
317 X=0
318 FOR I=1 TO 10000
319 X=X+1+I
320 NEXT I
321 INPUT@2:A$
325 PRINT A$;
330 GOSUB 900
340 T=S-T
350 PRINT " Time= ";T
360 PRINT
400 PRINT "Loop X=X*1.01"
410 INPUT@2:A$
412 PRINT A$
413 GOSUB 900
414 T=S
417 X=1
418 FOR I=1 TO 10000
419 X=X*1.01
420 NEXT I
421 INPUT@2:A$
425 PRINT A$;
430 GOSUB 900
440 T=S-T
450 PRINT " Time= ";T
460 PRINT
500 PRINT "Loop X=X*1.01*1.01"
510 INPUT@2:A$
512 PRINT A$
513 GOSUB 900
514 T=S
517 X=1
518 FOR I=1 TO 10000
519 X=X*1.01*1.01
520 NEXT I
521 INPUT@2:A$
525 PRINT A$;
530 GOSUB 900
540 T=S-T
550 PRINT " Time= ";T
560 PRINT
600 PRINT "Loop X=SIN(PI)"
610 INPUT@2:A$
612 PRINT A$
613 GOSUB 900
614 T=S
617 X=0
618 FOR I=1 TO 10000
619 X=SIN(PI)
620 NEXT I
621 INPUT@2:A$
625 PRINT A$;
630 GOSUB 900
640 T=S-T
650 PRINT " Time= ";T
660 PRINT
700 PRINT "Loop X=RND(-1)"
710 INPUT@2:A$
712 PRINT A$
713 GOSUB 900
714 T=S
717 X=0
718 FOR I=1 TO 10000
719 X=RND(-1)
720 NEXT I
721 INPUT@2:A$
725 PRINT A$;
730 GOSUB 900
740 T=S-T
750 PRINT " Time= ";T
760 END
900 REM CALCULATE number of seconds in HH:MM:SS part of A$
910 B$=SEG(A$,11,2)
920 S=VAL(B$)*3600
930 B$=SEG(A$,14,2)
940 S=S+VAL(B$)*60
950 B$=SEG(A$,17,2)
960 S=S+VAL(B$)
970 RETURN
1000 END
 
Last edited:
daver2 wrote the emulator
Philcogrump posted it on github
I did minor edits to improve the graphics, added the top row of keys as they are different than the standard keyboard.
I also added the jsTEKTRONIX4051_universal.html version to run my *.uni files - which will run on both 4051/4052/4054 computers AND the universal version of the Tek 405x emulator

All the other files on my repo that are not .uni extension require the non-universal version of the emulator

Thanks. Noted that. I presume the .uni extension is for Unicode?

There is no power button - just the power lamp.

Select Start button to start the emulator.

Sorry, I meant the Start button. It doesn't function in the Universal version. Works OK in the non-universal version.

Another reason I added the Tektronix keys. Either use Shift key with Tek - or Shift key with PC -

Thanks. That did indeed enter a = character.

After selecting a program to run, type:

OLD@1:

Either use the @ and : keys on the emulator key row or for a PC keyboard use ` key for the Tek @ and ' key for the Tek :

Dave has emulated GPIB device 1 as a simple external tape drive that only supports the OLD command.

Yes, that worked. The key mapping for @ to ' and : to # (@) felt a bit weird but I got there and was able to load a program from file and then run it. It worked very nicely. The graphics seem a bit better than when running Brads emulator in WINE.

Start must be selected first on Chrome or Firefox before the emulator supports typing.

No, that wasn't it. Open Firefox, load the emulator. Hit Start and then start typing a program. It turns out to be a bit intermittent. Got it working a couple of times since but it is very hit and miss. FF 89.0.2 on Linux Mint 19.3.

I actually use this emulator to test the programs I have written - before running them on my 4052 or 4054. Example - my screenshot of the Battlestar Galactica demo program was done on the emulator - just press the "Make Copy" key and the emulator will save the screen in a picture file.

Nice feature that. Just saved the display from a program I just ran. I am however puzzled about why the keys need to be cross mapped like that?

Obviously want to focus on getting the 4051 and the 4924 emulator up and running, but I don't mind having a look at the Caps Lock problem when time allows.
 
Yes, I apologise for the poor quality of the emulator's code!

However (in my defence) the 'market' for anything Tektronix is somewhat small. You increase the market by 20% :)!

The CAPS LOC should be straight forward. I will have a quick look at that myself.

I was trying to add local tape support to it - but it was getting quite complicated in the end with all of the inherent timing being done by the 6800 itself in ROM. Adding GPIB tape support functions are straight forward. However, you trip over the fact that you can't manipulate host files from within the browser due to security concerns. You can 'brick' the browser by an add-in but (in my mind) that defeats things. I have added the drag-and-drop metaphor to later work I was playing with - so you can drag-and-drop a tape image into the emulator and it would mount it for you and you can then read it. However, you would have to use the 'download' interface to save any data written onto the tape.

My 'starting position' was - is this possible? Answer yes. I got to play with one of my all-time favourite machines again (I used one in the electrical engineering laboratories at Aston University back in the late 70's early 80's).

My basic idea was to load simple text files from the host into the emulator and just use them (i.e. not really editing or saving them from within the emulator).

Monty then came on the scene and pushed the envelope further. The number of files he has supplied to the Tektronix community - outstanding work...

The 4052 emulator may be enhanced somewhat more (if I can get it working that is). This is proving more tricky than the 4051 variant. I don't have access to the firmware source code listings for the 4052 as I do for the 4051.

The keyboard implementation is very simplistic. The 'key confusion' comes from the simplistic use of the implementation of the SHIFT key. A modern PC/MAC does not have the same key mapping as the Tektronix - hence I have had to be a bit 'tricky' with the key mappings. As I stated, the plan was always to download files from a host, so editing the initial program would be in the host environment and not in the Tektronix environment.

Happy for you to have a crack at a better implementation...

Have you tried the moon lander program yet :)!

Dave
 
Last edited:
Thanks. Noted that. I presume the .uni extension is for Unicode?

No - the .uni extension is for universal.

The standard emulator program supports embedded control characters by encoding three characters into a single Tektronix control characters.

Example: in my repo /Games/StarTrek-UDKrequired.txt file line 7570 contains lots of K[BS]_ triplets.
Tek BASIC supports Control-K in PRINT statements for a Vertical Tab and supports eight other control characters for other terminal print features.

The standard emulator finds a backspace followed by underscore character, then takes the previous letter K and only sends Control-K character to BASIC during the OLD of that program.

This three letter sequence was used in some of the early Tek BASIC programs captured over the serial interface - as the typical serial interface will react to those characters instead of just passing them through to the output.

These files will NOT work correctly if they are loaded into a 4050 computer.

My *.uni format saves the original control character in the file - which works not only with all the 4050 computers, but also the universal version of the emulator program - since I modified that version of the emulator to just pass through the control characters.

Examine my /Games/Games in uni format/StarTrek-UDKrequired.uni file with an editor that shows Control characters like Notepad++ configured to "Show all characters and you can see the difference.

Sorry, I meant the Start button. It doesn't function in the Universal version. Works OK in the non-universal version.

That's odd.

I think it is an issue with Chrome in linux. I always run Chrome in Windows.
I remember loading Ubuntu in a VM, then installing Chrome - and it couldn't run the emulator.

Maybe another thing you could take a look at.

The graphics seem a bit better than when running Brads emulator in WINE.

Brads emulator is all custom code - emulating Tek BASIC instructions and math, so it will have different behavior.

No, that wasn't it. Open Firefox, load the emulator. Hit Start and then start typing a program. It turns out to be a bit intermittent. Got it working a couple of times since but it is very hit and miss. FF 89.0.2 on Linux Mint 19.3.

Typing in the Tek 405x emulator - particularly if the timing calibration factor is too small - is a little finicky even on windows.

Nice feature that. Just saved the display from a program I just ran. I am however puzzled about why the keys need to be cross mapped like that?

The primary issue is the Tektronix keyboard matches their terminal keyboards which predate PC keyboard shift mapping.

Another place to improve the emulator :)

Obviously want to focus on getting the 4051 and the 4924 emulator up and running, but I don't mind having a look at the Caps Lock problem when time allows.

Improvements in the emulator would be appreciated - Jon does review and accept changes :)
 
Last edited:
Yes, I apologise for the poor quality of the emulator's code!

I was not in anyway suggesting that and apologise if it came across that way. I was only trying to feed back my observations as a newbie to the emulator.

Yes, I apologise for the poor quality of the emulator's code!
The CAPS LOC should be straight forward. I will have a quick look at that myself.

Thanks.

I was trying to add local tape support to it - but it was getting quite complicated in the end with all of the inherent timing being done by the 6800 itself in ROM. Adding GPIB tape support functions are straight forward. However, you trip over the fact that you can't manipulate host files from within the browser due to security concerns. You can 'brick' the browser by an add-in but (in my mind) that defeats things. I have added the drag-and-drop metaphor to later work I was playing with - so you can drag-and-drop a tape image into the emulator and it would mount it for you and you can then read it. However, you would have to use the 'download' interface to save any data written onto the tape.

That would be a nice feature. JavaScript was designed to prevent easily accessing the local filesystem as you point out, due to security concerns. Monty mentioned the OLD@1: command which I used after selecting a file and that did the trick.

The keyboard implementation is very simplistic. The 'key confusion' comes from the simplistic use of the implementation of the SHIFT key. A modern PC/MAC does not have the same key mapping as the Tektronix - hence I have had to be a bit 'tricky' with the key mappings. As I stated, the plan was always to download files from a host, so editing the initial program would be in the host environment and not in the Tektronix environment.

I just realised what I may have missed. The symbol characters on the Tektronix keyboard are placed in different positions to those on the typical PC keyboard. If the objective is to maintain the Tektronix layout, then I understand the reason for the re-mapping. I don't think Brads implementation makes any attempt to re-map the PC keyboard to the Tektronix layout (although I may be wrong!) but since both the Tek and the PC use the standard ASCII table, the corresponding input on the PC keyboard just works but the symbols are in the PC layout positions.

Happy for you to have a crack at a better implementation...

I have really only commented on aspects of the user interface and will be happy to contribute to that aspect. I might also be able to help with a bit of documentation? I imagine that emulating the actual system and BASIC functions as well as the graphics must have taken an awful lot of work. I appreciate your making the emulator available.

Have you tried the moon lander program yet :)!

Dave

No not yet. Will get around to it eventually.
 
>>> I was not in anyway suggesting that and apologise if it came across that way.

I was actually berating myself! I wouldn't (normally) publish any of my work/code etc. unless I was happy with it. This was my first attempt at JavaScript within a browser environment - so it is a vary crude bit of code by my standards (let's say a learning exercise).

Just tried CAPS LOCK on my iMac with Safari and it works fine. Since this is my platform of choice - anything else is probably some sort of cross-browser / JavaScript issue I suspect. There is a function called 'HandleKeyboardEvent' where all the magic happens...

The keyboard scanning and everything else is done within the 4051 6800 code. What I have to do is to turn the host character into a series of button presses in a key matrix. This is fine, until you get something like a key that is shifted on one implementation but not on the other. For example, the '=' on my iMac keyboard is not shifted - but on the Tektronix it is - and then, on a different key! So, what I would have to do is to see the host '=' key and turn that into a SHIFT key followed by the switch matrix for the appropriate key on the Tektronix. Now, how do I release this key combination... I just went for the slightly 'wonky' key implementation with the intention of sorting it out later. Well, later hasn't quite come yet...

It actually didn't take that much work to be honest. Because I use the native Tektronix ROMs and everything else, I get all of the Tektronix BASIC functionality for nothing :). I even get the bugs and all! The 6800 emulation was 'borrowed' - but I had to turn the 'C' code into JavaScript. The fun and games was implementing the I/O and video sub-systems (which was one of the reasons why I fancied doing it in the first place).

>>> I appreciate your making the emulator available.

Well, there is nothing else it is good for :)! And, in the process, I have met a group of like-minded Tektronix enthusiasts (virtually at least).

Dave
 
I have figured out what's going on with Firefox not accepting keyboard input. After clicking 'Start' it is necessary to click anywhere in the emulator window at least once. The reason is that when 'Start' is clicked, it gets disabled and the disabled control does not release focus. I must have inadvertently done that the odd time which is why is sometimes worked. This behaviour does not affect Chrome which works just fine. The fix is actually quite simple and involves adding one line at the end of the tek_start() function in jsTEKTRONIX4051.html:
Code:
document.getElementById('start').blur();

I initially tried using .focus() to shift control to another element, for example:
Code:
window.focus();
document.getElementById('screen').focus();

This was insufficient and .blur() on the disable control is definitely required to release focus from the disabled control. It then reverts back to the main emulator window. I am not sure whether it is a FF bug or "feature" but I suspect it is the former. The change doesn't have any effect on Chrome which continues to work normally.

Just tried CAPS LOCK on my iMac with Safari and it works fine. Since this is my platform of choice - anything else is probably some sort of cross-browser / JavaScript issue I suspect. There is a function called 'HandleKeyboardEvent' where all the magic happens...

I suspect you are probably right. It might also be a Linux implementation specific issue. I should probably clarify that the Caps Lock does work in a sense, but operates like Shift. Upper case characters are generated only while it is pressed down, but as soon as the key is released the emulator reverts back to generating lower case characters. I notice the Tek does not have a Caps Lock key, but does have a TTY Lock which, according to the manual, seems to serve the same function. I don't have a Mac so can't test Safari but I will have a look into this on Chrome and Firefox.

The keyboard scanning and everything else is done within the 4051 6800 code. What I have to do is to turn the host character into a series of button presses in a key matrix. This is fine, until you get something like a key that is shifted on one implementation but not on the other. For example, the '=' on my iMac keyboard is not shifted - but on the Tektronix it is - and then, on a different key! So, what I would have to do is to see the host '=' key and turn that into a SHIFT key followed by the switch matrix for the appropriate key on the Tektronix. Now, how do I release this key combination... I just went for the slightly 'wonky' key implementation with the intention of sorting it out later. Well, later hasn't quite come yet...

Well if the Tek ROM code is actually scanning/reading the key code as opposed to ASCII character code then I see the difficulty.
 
Last edited:
No - the .uni extension is for universal.

The standard emulator program supports embedded control characters by encoding three characters into a single Tektronix control characters.

Example: in my repo /Games/StarTrek-UDKrequired.txt file line 7570 contains lots of K[BS]_ triplets.
Tek BASIC supports Control-K in PRINT statements for a Vertical Tab and supports eight other control characters for other terminal print features.

The standard emulator finds a backspace followed by underscore character, then takes the previous letter K and only sends Control-K character to BASIC during the OLD of that program.

This three letter sequence was used in some of the early Tek BASIC programs captured over the serial interface - as the typical serial interface will react to those characters instead of just passing them through to the output.

These files will NOT work correctly if they are loaded into a 4050 computer.

My *.uni format saves the original control character in the file - which works not only with all the 4050 computers, but also the universal version of the emulator program - since I modified that version of the emulator to just pass through the control characters.

Examine my /Games/Games in uni format/StarTrek-UDKrequired.uni file with an editor that shows Control characters like Notepad++ configured to "Show all characters and you can see the difference.

Thank you for the explanation.
 
Another Tek BASIC idiosyncrasy is that all the program lines are ONLY terminated by carriage return. Line Feed control characters are only supported within a PRINT statement string for formatting.

So all my *.uni program lines are [CR] terminated and all other control characters in PRINT statements are unmodified - so that these programs can be loaded into Tek BASIC with the OLD command - even from the serial port - if you have the Option 1 Serial interface - and use a serial program like Realterm or Teraterm with the OLD@40: command (Tek Option 1 uses primary address 40 to signify the Option 1 serial interface).
 
I think I have solved the Caps Lock issue.

The simplest solution is to add the following one-liner to the start of the HandleKeyboardEvent function:
Code:
hw.KBD_TTY_0 = e.getModifierState("CapsLock") ? 0 : 1;
This checks the state of Caps Lock on every key press. Case 0x0014 can then be commented out or removed.

The explanation is that case 0x0014 tests whether Caps Lock has been pressed or released, but does not maintain state so it acts like a shift. Furthermore, it turns out that if the caps lock state is tested using 'e.getModifierState("CapsLock")' either during keyDown or keyUp, it always returns true. I suspect that the reason for this is because CapsLock turns on immediately on keyDown, but only turns off once the keyUp event finishes. This means that the state of Caps Lock (particularly whether OFF again after being ON) must be checked outside of the CapsLock keyDown or keyUp event.

The above checks the state of CapsLock on every keypress. I thought to reduce the amount of checking by setting a flag variable and setting it each time Caps Lock is pressed. That way e.getModifierState() is only called after a previous Caps Lock press has been detected. I am assuming here that checking the state of variable capsLockFlg in memory is going to be faster than checking getModifierState() each time, but maybe it doesn't matter. In any case, here is the modified solution:

Add this above the function as a global variable in TekKeyboard:
Code:
var capsLockFlg = 1;    // Always check on first entry

Note it is set to 1 to force a check on first entry to detect the state of the Caps Lock key when the emulator is launched.
The actual test routine inside HandleKeyboardEvent is now conditional:
Code:
// Check Caps Lock state when flagged (see case 0x0014)
function HandleKeyboardEvent( i, bool, e ) {

    if (capsLockFlg) {
        hw.KBD_TTY_0 = e.getModifierState("CapsLock") ? 0 : 1; // Caps lock key status 0=on; 1 = off (negative logic sense)
        capsLockFlg = 0;  // Reset flag
    }

    ....

case 0x0014 just flags that Caps Lock has been pressed:
Code:
        case 0x0014 : // Caps lock key.

        // Caps lock key up = logical '1'.
        capsLockFlg = 1; // Flag that caps lock pressed - state will be checked on next character received
        i = 0; break;

Hope this is useful.
 
Last edited:
WaveyDipole - I tried your modifications to the 405x emulator TekKeyboard.js.

I am running the emulator on Windows10 with Chrome web browser, and after pressing the Start button, I could type text and CAPS LOCK worked!

Here are my changes compared to the original code with Notepad++
If these changes look right - I'll upload the proposed TekKeyboard.js to github.

WaveyDipole emulator fix for CAPS LOCK.png
 
Last edited:
Yes, that is exactly what I did.

If there is no gain to be had by using the 'capsLockFlg' flag approach, then the single line at the top of the post after the function statement together with removing case 0x0014 works just as well and is rather simpler. However, I don't know which approach is likely to perform better or whether the difference is likely to even be noticeable at typing speeds. That's why I presented both options and leave it up to the experts to judge. My tests were with Chrome and Firefox on Linux.
 
Yes, that is exactly what I did.

If there is no gain to be had by using the 'capsLockFlg' flag approach, then the single line at the top of the post after the function statement together with removing case 0x0014 works just as well and is rather simpler. However, I don't know which approach is likely to perform better or whether the difference is likely to even be noticeable at typing speeds. That's why I presented both options and leave it up to the experts to judge. My tests were with Chrome and Firefox on Linux.

I'll post your version as a pull request to https://github.com/jonbstanley/Tek405xEmulator
 
WaveyDipole, your update to support CAPS LOCK should clear one of the two issues posted on the Tek405xEmulator. Have you seen the other issue posted to use Web Storage for saving and loading programs?
 
So far I have established that the localStorage feature in Web Storage is persistent. On the other hand sessionStorage is not and disappears when the tab or browser is closed down. The maximum capacity of localStorage is 5mb "per domain". So if the emulator is considered a "domain" then that would be the maximum available storage within the emulator. That might still allow quite a few programs to be stored but its not unlimited like disk storage would be if the browser had access to it. The storage works by saving data in key/value pairs. Could the key/pair be a program number/program listing? I don't know at this point. If all characters could be saved in a string or byte array value then this might work. So far I haven't been able to determine what the maximum size of a value is. More research required but it is already clear that the storage will have limits.
 
I believe I did have a look at this in the past but decided against it all in the end.

For one, I was/am not convinced that storing anything within the browser space is 'safe' (from the perspective of survival over browser upgrades, wiping history and transferring data from one location to another).

With the 4052 I am looking at drag-and-drop. Drag-and-drop to load something from the 'outside world' into the emulator and to 'download' a file to save something from the emulator to the 'outside world'. This is a similar user interface to the online circuit simulator tool at https://www.falstad.com/circuit/.

It is up to the user then to copy the downloaded file to where they want it.

That was my thought anyhow. I like to be in charge of my own data files :)!

Dave
 
You make an valid point regarding survival of data after browser updates. I experimented with web storage in Firefox and Chrome and found that it was possible to save programs to localStorage. One limitation to bear in mind is that each browser has its own store and programs stored in one browser are not available to the other. Having said that, the longest program I loaded had line numbering above 9000+ and I had no problem storing it. I have also experimented a little with drag and drop and loading/saving data to local disk. There is no reason why one couldn't do both types of storage and have the web storage as near-line storage and the disk storage as offline storage. The web-storage could act rather like a tape and as well as individual files, it also ought to be possible to export the "tape" to a file on disk. Still more experimentation needed.
 
Last edited:
I did a bit more work on the emulator storage today and have prototyped a "storage management tool". The first cut has been uploaded to my fork of the repository at https://github.com/jonbstanley/Tek405xEmulator which is at https://github.com/Twilight-Logic/Tek405xEmulator.

The tool can make use of browser storage as well as manually load and save files to local disk. It also has a drag and drop capability so it is possible to drag and drop a file into its window. There are three groups of buttons. Save, Load and Delete operate on web storage and require a file number. Export and Import provide the means to open or or save a file on local disk. Select accepts the file in the window and Close closes the tool. Once a program has been selected and the tool closes, it is still then necessary to do OLD@1: to read the program into Emulator. The aim in the long run would be have the ability to load/save files to web storage using OLD@x: . I was also thinking of adding Archive and Restore buttons to allow saving/loading of the contents of web storage to/from local disk as a "tape". I am thinking that eventually that might allow multi-part programs that load continuation files from tape to be run.

It would be nice if one could just drag and drop a file directly onto the emulator window. I believe that would require changes to the GPIB handling of the OLD command in TEKTRONIX4051.js but that is a problem for another day.... I am still trying to figure out exactly what happens when I type OLD@1: into the emulator window.

At the moment it only works from jsTEXKTRONIX4051.html . I haven't got it working from jsTEXKTRONIX4051_universal.html yet.
Would be interested in any thoughts or constructive feedback.

For the present tested on Chrome, Firefox, IE and Edge, but not Safari as I don't have the means.

BTW, I have also added a mute button to mute the sound effects.
 
Last edited:
Back
Top