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

Commit

Permalink
Merge branch 'next-release'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpar committed Feb 9, 2016
2 parents d40b081 + eae2750 commit 0c899da
Showing 388 changed files with 59,614 additions and 2,803 deletions.
64 changes: 60 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -312,7 +312,7 @@ module.exports = function(grunt) {
"c1pxsl": {
files: [
{
cwd: "./modules/shared/templates/",
cwd: "modules/shared/templates/",
src: ["common.css", "common.xsl", "document.css", "document.xsl", "machine.xsl", "manifest.xsl", "outline.xsl"],
dest: "versions/c1pjs/<%= pkg.version %>/",
expand: true
@@ -330,7 +330,7 @@ module.exports = function(grunt) {
"pcxsl": {
files: [
{
cwd: "./modules/shared/templates/",
cwd: "modules/shared/templates/",
src: ["common.css", "common.xsl", "document.css", "document.xsl", "machine.xsl", "manifest.xsl", "outline.xsl"],
dest: "versions/pcjs/<%= pkg.version %>/",
expand: true
@@ -348,7 +348,7 @@ module.exports = function(grunt) {
"c1pjs": {
files: [
{
cwd: "./modules/c1pjs/templates/",
cwd: "modules/c1pjs/templates/",
src: ["components.*"],
dest: "versions/c1pjs/<%= pkg.version %>/",
expand: true
@@ -365,7 +365,7 @@ module.exports = function(grunt) {
"pcjs": {
files: [
{
cwd: "./modules/pcjs/templates/",
cwd: "modules/pcjs/templates/",
src: ["components.*"],
dest: "versions/pcjs/<%= pkg.version %>/",
expand: true
@@ -393,6 +393,62 @@ module.exports = function(grunt) {
return content.replace(/\/versions\/\{\$APPCLASS}\/\{\$APPVERSION}\//g, "");
}
}
},
"manifests": {
files: [
{
cwd: "disks/pc/",
src: ["library.xml", "samples.xml"],
dest: "disks/pc/compiled/",
expand: true
}
],
options: {
process: function(content, srcPath) {
/*
* This function mimics what components.xsl normally does for disk manifests referenced
* by the FDC machine component. Compare it to the following template in components.xsl:
*
* <xsl:template match="manifest[not(@ref)]" mode="component">
*
* This code is not perfect (it doesn't process "link" attributes, for example, which is why
* we've left machines that use the samples.xml disk library alone), but for machines that use
* library.xml, having them use compiled/library.xml instead speeds up loading significantly.
*
* Granted, after the first machine has fetched all the individual manifest files, your
* browser should do a reasonably good job using cached copies for all subsequent machines,
* but even then, there's still a noticeable delay.
*/
var contentOrig = content;
var reManifest = /([ \t]*)<manifest.*? ref="(.*?)".*?\/>/g, matchManifest;
while ((matchManifest = reManifest.exec(contentOrig))) {
var sManifest = grunt.file.read(path.join('.', matchManifest[2]));
if (!sManifest) continue;
var sDefaultName = "", match;
match = sManifest.match(/<title.*?>(.*?)<\/title>/);
if (match) {
sDefaultName = match[1];
match = sManifest.match(/<version.*?>(.*?)<\/version>/);
if (match) sDefaultName += ' ' + match[1];
}
var reDisk, matchDisk, sDisks = "";
reDisk = /<disk.*? href="([^"]*)".*?\/>/g;
while ((matchDisk = reDisk.exec(sManifest))) {
if (sDisks) sDisks += "\n";
sDisks += matchManifest[1] + "<disk path=\"" + matchDisk[1] + "\">" + sDefaultName + "</disk>";
}
reDisk = /<disk.*? href="([^"]*)".*?>([\S\s]*?)<\/disk>/g;
while ((matchDisk = reDisk.exec(sManifest))) {
if (sDisks) sDisks += "\n";
var matchName = matchDisk[2].match(/<name.*?>(.*?)<\/name>/);
var sName = matchName && matchName[1] || sDefaultName;
sDisks += matchManifest[1] + "<disk path=\"" + matchDisk[1] + "\">" + sName + "</disk>";
}
content = content.replace(matchManifest[0], sDisks);
}
return content;
}
}
}
},
run: {
5 changes: 3 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ right_brace: "}"

# Build settings

exclude: ["index.html", "**/index.html", "logs", "node_modules", "**/c64", "src", "**/src", "**/static", "tmp", "videos", "web", ".git", ".idea"]
exclude: ["index.html", "**/index.html", "logs", "node_modules", "**/c64", "**/private", "src", "**/src", "**/static", "tmp", "videos", "web", ".git", ".idea"]
markdown: kramdown
kramdown:
input: GFM
@@ -31,7 +31,7 @@ gems:

pcjs:
domain: pcjs.org # whereas site.url is used for linking purposes, site.pcjs.domain is used for display purposes
version: 1.20.7 # IMPORTANT: keep pcjs.version in sync with package.json:version
version: 1.20.8 # IMPORTANT: keep pcjs.version in sync with package.json:version
compiled: true # by default, the compiled pcjs.version scripts will be used (eg, pc.js or pc-dbg.js)
pc_scripts: # if pcjs.compiled is false, the following scripts will be included instead, in the order listed
- /modules/shared/lib/defines.js
@@ -69,6 +69,7 @@ pcjs:
- /modules/pcjs/lib/ram.js
- /modules/pcjs/lib/keyboard.js
- /modules/pcjs/lib/video.js
- /modules/pcjs/lib/parallelport.js
- /modules/pcjs/lib/serialport.js
- /modules/pcjs/lib/mouse.js
- /modules/pcjs/lib/disk.js
4 changes: 4 additions & 0 deletions _developer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
developer: true

pcjs:
compiled: false
2 changes: 1 addition & 1 deletion _includes/machine-engines.html
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
{% else %}
{% assign machine_template = machine.template %}
{% endunless %}
{% capture machine_parms %}{{ site.left_brace }}state:"{{ machine.state }}",autoMount:{{ machine.automount|jsonify }}{{ site.right_brace }}{% endcapture %}
{% capture machine_parms %}{{ site.left_brace }}state:"{{ machine.state }}",autoMount:{{ machine.automount|jsonify }},messages:"{{ machine.messages }}"{{ site.right_brace }}{% endcapture %}
{% if site.pcjs.compiled == true and machine.uncompiled != true %}
{% capture machine_script %}<script type="text/javascript" src="{{ site.baseurl }}/versions/{{ machine.type | remove:'-dbg' }}js/{{ site.pcjs.version }}/{{ machine.type }}.js"></script>{% endcapture %}
{% unless machine_scripts contains machine_script %}
66 changes: 42 additions & 24 deletions _posts/2014-09-30-pcjs-coding-conventions.md
Original file line number Diff line number Diff line change
@@ -51,34 +51,42 @@ can be thought of as "class constants".
For example, the ChipSet component, which manages (among other things) Programmable Interrupt Controllers or PICs,
*could* define the constant for an EOI command like this:

ChipSet.EOI = 0x20; // non-specific EOI (end-of-interrupt)

``` javascript
ChipSet.EOI = 0x20; // non-specific EOI (end-of-interrupt)
```

but since the EOI command is actually one of a number Operation Command Words (specifically, OCW2), I include an
"OCW2_" prefix in the constant name:

ChipSet.OCW2_EOI = 0x20; // non-specific EOI (end-of-interrupt)

``` javascript
ChipSet.OCW2_EOI = 0x20; // non-specific EOI (end-of-interrupt)
```

and since I also like to group constants that are associated with a particular register or port, and since I don't
want the ChipSet constructor becoming littered with property constants, I first define a constant object; in this
case, **PIC_LO**:

ChipSet.PIC_LO = {};
ChipSet.PIC_LO.OCW2_EOI = 0x20; // non-specific EOI (end-of-interrupt)
ChipSet.PIC_LO.OCW2_EOI_SPEC = 0x60; // specific EOI
ChipSet.PIC_LO.OCW2_EOI_ROT = 0xA0; // rotate on non-specific EOI
ChipSet.PIC_LO.OCW2_EOI_ROTSPEC = 0xE0; // rotate on specific EOI
``` javascript
ChipSet.PIC_LO = {};
ChipSet.PIC_LO.OCW2_EOI = 0x20; // non-specific EOI (end-of-interrupt)
ChipSet.PIC_LO.OCW2_EOI_SPEC = 0x60; // specific EOI
ChipSet.PIC_LO.OCW2_EOI_ROT = 0xA0; // rotate on non-specific EOI
ChipSet.PIC_LO.OCW2_EOI_ROTSPEC = 0xE0; // rotate on specific EOI
```

By using fully-qualified property names for each constant, the code has a more C-like appearance (think *#define*)
that's also easier to preprocess.

However, I've gradually switched to the more conventional JavaScript object notation for class constants:

ChipSet.PIC_LO = {
OCW2_EOI: 0x20, // non-specific EOI (end-of-interrupt)
OCW2_EOI_SPEC: 0x60, // specific EOI
OCW2_EOI_ROT: 0xA0, // rotate on non-specific EOI
OCW2_EOI_ROTSPEC: 0xE0 // rotate on specific EOI
};
``` javascript
ChipSet.PIC_LO = {
OCW2_EOI: 0x20, // non-specific EOI (end-of-interrupt)
OCW2_EOI_SPEC: 0x60, // specific EOI
OCW2_EOI_ROT: 0xA0, // rotate on non-specific EOI
OCW2_EOI_ROTSPEC: 0xE0 // rotate on specific EOI
};
```

because, again, the Closure Compiler does an excellent job inlining such constants (or indeed any property that is
never modified *or* enumerated).
@@ -94,17 +102,23 @@ override it, setting it to **FALSE** and disabling debug-only code.

To ensure that debug-only code is not simply *disabled* but also *removed*, the code should be wrapped with:

if (DEBUG) {
[code to be removed by the Closure Compiler]
}
``` javascript
if (DEBUG) {
[code to be removed by the Closure Compiler]
}
```

In many cases, the compiler is able to completely remove calls to debug-only class methods; eg:

Component.assert(off >= 0 && off < this.cb);
``` javascript
Component.assert(off >= 0 && off < this.cb);
```

However, calls to debug-only instance methods seem to be more problematic, so all such calls are wrapped; eg:

if (DEBUG) this.log('load("' + sFileURL + '")');
``` javascript
if (DEBUG) this.log('load("' + sFileURL + '")');
```

There are a number of other important shared constants in [/modules/shared/lib/defines.js](/modules/shared/lib/defines.js)
and PCjs-specific constants in [/modules/pcjs/lib/defines.js](/modules/pcjs/lib/defines.js); refer
@@ -163,12 +177,16 @@ objects, but I'll leave my gripes about JSON for another post.

Generally speaking, the only time I quote property names is when I have to. I'll use the "dot" syntax; eg:

obj.prop = true;

``` javascript
obj.prop = true;
```

instead of:

obj['prop'] = true;

``` javascript
obj['prop'] = true;
```

unless the property name doesn't conform to variable name syntax (eg, if it starts with a digit) or if it's a
"public" property and therefore I can't risk Google's Closure Compiler "minifying" the property name to something
else.
Loading

0 comments on commit 0c899da

Please sign in to comment.