Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

PCx86 Timer Services

Compare
Choose a tag to compare
@jeffpar jeffpar released this 08 Aug 23:16
· 1755 commits to master since this release

PC8080 and PDPjs already included a set of timer services to make it easier for those machines to simulate hardware features like serial port baud rate, so it seemed like a good time to port those services to PCx86 as well. I haven't updated the PCx86 ChipSet or SerialPort components yet, but the new services are already being used to:

  • Perform Control Panel updates twice per second
  • Perform Video Display updates 60 times per second
  • Yield control from the CPU 30 times per second (for browser responsiveness)

The key services are:

  • addTimer(id, callback, ms)
  • setTimer(iTimer, ms)

Using the timer index from a previous addTimer() call, setTimer() sets that timer to fire after the specified number of milliseconds. This is preferred over JavaScript's setTimeout(), because all our timers are effectively paused when the CPU is paused (eg, when the Debugger halts execution). Moreover, setTimeout() handlers only run after runCPU() yields, which is far too granular for some components (eg, when the SerialPort tries to simulate interrupts at 9600 baud).

Also included in this release:

  • Added support for 8086/8088 64K wrap-around (eg, pushes, pops, instruction fetches, etc)
  • Added scaleMouse property to control browser-to-machine mouse coordinate scaling
  • Ported PDPjs script support to PCx86 to enable powerful x86 machine demo scripts

To see the new scripting support in action, take a look at the demo machine for TopView 1.01. The README.md defines several scripts at the top of the page:

machineScripts:
  startKbd: |
    wait Keyboard DOS;
    type Keyboard "$date\r$time\rB:\rTV\r";
  startMouse: |
    wait Keyboard DOS;
    type Keyboard "$date\r$time\r";
    wait Keyboard;
    sleep 1000;
    select FDC listDrives "A:";
    select FDC listDisks "MS Mouse 5.00 (System)";
    loadDisk FDC;
    wait FDC;
    type Keyboard "MOUSE\r";
    sleep 5000;
    type Keyboard "B:\rTV\r";

The machine is currently currently configured to use the "startKbd" script:

machines:
  - id: ibm5160
    type: pcx86
    config: /devices/pcx86/machine/5160/cga/640kb/machine.xml
    autoMount:
      A:
        path: /disks/pcx86/dos/ibm/2.00/PCDOS200-DISK1.json
      B:
        path: /disks/pcx86/apps/ibm/topview/1.01/TOPVIEW101-PROGRAM.json
    autoScript: startKbd