| Filename | Latest commit message | Latest commit date |
|---|---|---|
I spent some time fixing the latter because browsers have started warning that synchronous XMLHttpRequest calls on the "main thread" (as Firefox calls it) are deprecated. Since the days of such calls seems to be numbered, I decided to act sooner rather than later. All PCjs XMLHttpRequests go through a single library function (weblib.loadResource), which accepts an fAsync parameter, and the only code that is still allowed to pass false for that parameter are "emergency" shutdown requests (which I believe browsers must still allow). |
||
| .. | ||
| .jshintrc | ||
| bus.js | ||
| chipset.js | ||
| computer.js | ||
| cpu.js | ||
| debugger.js | ||
| defines.js | ||
| disk.js | ||
| fdc.js | ||
| hdc.js | ||
| keyboard.js | ||
| mem.js | ||
| mouse.js | ||
| nodebugger.js | ||
| panel.js | ||
| ram.js | ||
| README.md | ||
| rom.js | ||
| serial.js | ||
| state.js | ||
| video.js | ||
| x86.js | ||
| x86cpu.js | ||
| x86grps.js | ||
| x86help.js | ||
| x86mods.js | ||
| x86op0f.js | ||
| x86opxx.js | ||
| x86seg.js | ||
PCjs Sources
Structure
All the code for PCjs is contained in the following JavaScript files, which roughly divide the functionality into major PC components, aka "devices". However, not every file implements a device, and "component" is an overloaded term, since Component is also the name of the shared base class used for most PCjs devices (see component.js). So it's best to refer to these files generically as "modules", and more specifically as "device modules" whenever they implement a specific device (or set of devices, in the case of Chipset).
Examples of non-device modules include UI modules like panel.js and debugger.js, and sub-modules like x86opxx.js, x86mods.js and x86help.js that separate the CPU functionality of x86.js into more manageable pieces.
These modules should always be loaded or compiled in the order listed by the pcJSFiles property in package.json, which includes all the necessary shared modules as well. At the time of this writing, the order is:
- shared/defines.js
- shared/diskapi.js
- shared/dumpapi.js
- shared/reportapi.js
- shared/userapi.js
- shared/strlib.js
- shared/usrlib.js
- shared/weblib.js
- shared/component.js
- pcjs-client/defines.js
- pcjs-client/panel.js
- pcjs-client/bus.js
- pcjs-client/mem.js
- pcjs-client/cpu.js
- pcjs-client/x86.js
- pcjs-client/x86seg.js
- pcjs-client/x86cpu.js
- pcjs-client/x86grps.js
- pcjs-client/x86help.js
- pcjs-client/x86mods.js
- pcjs-client/x86op0f.js
- pcjs-client/x86opxx.js
- pcjs-client/chipset.js
- pcjs-client/rom.js
- pcjs-client/ram.js
- pcjs-client/keyboard.js
- pcjs-client/video.js
- pcjs-client/serial.js
- pcjs-client/mouse.js
- pcjs-client/disk.js
- pcjs-client/fdc.js
- pcjs-client/hdc.js
- pcjs-client/debugger.js
- pcjs-client/state.js
- pcjs-client/computer.js
- shared/embed.js
Some of the modules can be reordered or even omitted (eg, debugger.js or embed.js), but you should observe the following:
- component.js must be listed before any module that extends Component
- panel.js should be loaded early to initialize the Control Panel (if any) as soon as possible
- computer.js should be the last device module, as it supervises and notifies all the other device modules
To minimize ordering requirements, the init() handlers and constructors of all modules should avoid referencing other modules. Device modules should define an initBus() notification handler, which the Computer will call after it has created/initialized the Bus object.