Skip to content

Commit

Permalink
New parameters override by code.
Browse files Browse the repository at this point in the history
New BOOSTED Machine Preset.
  • Loading branch information
ppeccin committed Jan 4, 2020
1 parent ae0bb83 commit 8fba701
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 26 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ https://webmsx.org?MACHINE=MSX1E&DISK=https://basicmuseum.org/Demos.dsk&BASIC_RU

| Preset | Description
| --- | ---
| `BOOSTED` | Boosted Machine with HardDisk and CPU/VDP 3x Turbo
| `ALTSLOTCONFIG` | Alternate Slot Configuration. RAM at Primary Slot 3
| `HARDDISK`, `HARDDISKC`, `NOHARDDISK` | Hard Drive Extension
| `DISK`, `DISKA`, `NODISK` | Floppy Drives Extension
Expand Down
1 change: 1 addition & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ https://webmsx.org?MACHINE=MSX1E&DISK=https://basicmuseum.org/Demos.dsk&BASIC_RU

| Preset | Description
| --- | ---
| `BOOSTED` | Boosted Machine with HardDisk and CPU/VDP 3x Turbo
| `ALTSLOTCONFIG` | Alternate Slot Configuration. RAM at Primary Slot 3
| `HARDDISK`, `HARDDISKC`, `NOHARDDISK` | Hard Drive Extension
| `DISK`, `DISKA`, `NODISK` | Floppy Drives Extension
Expand Down
45 changes: 25 additions & 20 deletions src/main/Configurator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ wmsx.Configurator = {
applyConfig: function(then) {
this.backupOriginalConfig();

// Read URL parameters
if (WMSX.ALLOW_URL_PARAMETERS) this.parseURLParams();
// Process parameter overrides (including URL parameters)
this.parseParams();

// Process Config file if asked
if (this.parameters.CONFIG_URL) this.applyParam("CONFIG_URL", this.parameters.CONFIG_URL);
if (WMSX.params.CONFIG_URL) this.applyParam("CONFIG_URL", WMSX.params.CONFIG_URL);
if (WMSX.CONFIG_URL) this.readThenApplyConfigFile(then);
else this.applyConfigDetails(then);
},
Expand All @@ -32,11 +32,11 @@ wmsx.Configurator = {
this.applyPresetsConfigModifications();

// Define Machine
if (this.parameters.MACHINE) this.applyParam("MACHINE", this.parameters.MACHINE);
if (WMSX.params.MACHINE) this.applyParam("MACHINE", WMSX.params.MACHINE);
WMSX.MACHINE = WMSX.MACHINE.trim().toUpperCase();
if (WMSX.MACHINE && !WMSX.MACHINES_CONFIG[WMSX.MACHINE]) return wmsx.Util.message("Invalid Machine: " + WMSX.MACHINE);
if (!WMSX.MACHINES_CONFIG[WMSX.MACHINE] || WMSX.MACHINES_CONFIG[WMSX.MACHINE].AUTO_TYPE) WMSX.MACHINE = this.detectDefaultMachine();
delete this.parameters.MACHINE;
delete WMSX.params.MACHINE;

// Apply all parameters from Machine, Presets and Single Parameters from URL
this.applyFinalConfig();
Expand All @@ -58,8 +58,8 @@ wmsx.Configurator = {
this.applyPresets(WMSX.MACHINES_CONFIG[WMSX.MACHINE].PRESETS);
// Apply additional Presets over Machine configuration
this.applyPresets(WMSX.PRESETS);
// Apply additional Single Parameters from URL
for (var par in this.parameters) this.applyParam(par, this.parameters[par]);
// Apply additional Single Parameters overrides (including URL parameters)
for (var par in WMSX.params) this.applyParam(par, WMSX.params[par]);
// Ensure the correct types of the parameters after all settings applied
this.normalizeParameterTypes();
},
Expand Down Expand Up @@ -97,11 +97,11 @@ wmsx.Configurator = {
},

applyPresetsConfigModifications: function() {
if (this.parameters.PRESETS) this.applyParam("PRESETS", this.parameters.PRESETS);
delete this.parameters.PRESETS;
if (WMSX.params.PRESETS) this.applyParam("PRESETS", WMSX.params.PRESETS);
delete WMSX.params.PRESETS;

// Apply Presets modifications
for (var p in this.parameters) if (wmsx.Util.stringStartsWith(p, "PRESETS_CONFIG")) this.applyParam(p, this.parameters[p]);
for (var p in WMSX.params) if (wmsx.Util.stringStartsWith(p, "PRESETS_CONFIG")) this.applyParam(p, WMSX.params[p]);

// Apply Alternate Slot Config Preset if asked (special case, also modifies other presets)
if ((WMSX.PRESETS || "").toUpperCase().indexOf("ALTSLOTCONFIG") < 0) return;
Expand All @@ -121,14 +121,21 @@ wmsx.Configurator = {
this.applyConfigDetails(then);
},

parseURLParams: function() {
var search = (window.location.search || "").split('+').join(' ');
var reg = /[?&]?([^=]+)=([^&]*)/g;
var tokens;
while (tokens = reg.exec(search)) {
var parName = decodeURIComponent(tokens[1]).trim().toUpperCase();
parName = wmsx.Configurator.abbreviations[parName] || parName;
this.parameters[parName] = decodeURIComponent(tokens[2]).trim();
parseParams: function() {
if (WMSX.ALLOW_URL_PARAMETERS) {
var search = (window.location.search || "").split('+').join(' ');
var reg = /[?&]?([^=]+)=([^&]*)/g;
var tokens;
while (tokens = reg.exec(search))
WMSX.params[decodeURIComponent(tokens[1]).trim().toUpperCase()] = decodeURIComponent(tokens[2]).trim();
}
// Replace abbreviations
for (var parName in WMSX.params) {
var newName = wmsx.Configurator.abbreviations[parName];
if (newName) {
WMSX.params[newName] = WMSX.params[parName];
delete WMSX.params[parName];
}
}
},

Expand Down Expand Up @@ -385,8 +392,6 @@ wmsx.Configurator = {

originalConfig: {},

parameters: {},

abbreviations: {
E: "ENVIRONMENT",
ENV: "ENVIRONMENT",
Expand Down
10 changes: 7 additions & 3 deletions src/main/WMSX.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ WMSX.PRESETS_CONFIG = {
"PRESETS_CONFIG.DISK": { "EXTENSIONS.DISK": 1 }
},

// Boosted Machine Preset

BOOSTED: { CPU_TURBO_MODE: 3, VDP_TURBO_MODE: 3, BOOT_DURATION_AUTO: 165, _INCLUDE: "HARDDISK" },

// MSX2++ Machine Presets. Do not use directly

_MSX2PPA: {
Expand Down Expand Up @@ -340,11 +344,11 @@ WMSX.PRESETS_CONFIG = {

_BASE: {
CPU_TURBO_MODE: 0,
VDP_TURBO_MODE: 0,
VDP_TYPE: -1,
RTC_ACTIVE: -1
VDP_TURBO_MODE: 0
}

};

WMSX.params = {}; // Additional parameter overrides

wmsx = window.wmsx || {}; // Namespace
10 changes: 7 additions & 3 deletions src/main/WMSXCBios.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ WMSX.PRESETS_CONFIG = {
"EXTENSIONS_CONFIG.MSXMUSIC.SLOT": [2, 2]
},

// Boosted Machine Preset

BOOSTED: { CPU_TURBO_MODE: 3, VDP_TURBO_MODE: 3, BOOT_DURATION_AUTO: 165, _INCLUDE: "HARDDISK" },

// MSX2++ Machine Presets. Do not use directly

_MSX2PPA: {
Expand Down Expand Up @@ -322,11 +326,11 @@ WMSX.PRESETS_CONFIG = {

_BASE: {
CPU_TURBO_MODE: 0,
VDP_TURBO_MODE: 0,
VDP_TYPE: -1,
RTC_ACTIVE: -1
VDP_TURBO_MODE: 0
}

};

WMSX.params = {}; // Additional parameter overrides

wmsx = window.wmsx || {}; // Namespace

0 comments on commit 8fba701

Please sign in to comment.