mirror of
https://github.com/nippur72/apple1-videocard-lib.git
synced 2024-12-23 04:29:46 +00:00
improve prg2bin, use node_modules
This commit is contained in:
parent
48ed61f6af
commit
ed14016e2c
26
package.json
Normal file
26
package.json
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "apple1-videocard-lib",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Library and demos for the \"Apple-1 Graphic Card\" by P-LAB, \r featuring the TMS9918 Video Display Processor by Texas Instruments.",
|
||||||
|
"main": "index.js",
|
||||||
|
"directories": {
|
||||||
|
"doc": "docs",
|
||||||
|
"lib": "lib"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/nippur72/apple1-videocard-lib.git"
|
||||||
|
},
|
||||||
|
"author": "Antonino Porcino <nino.porcino@gmail.com>",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/nippur72/apple1-videocard-lib/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/nippur72/apple1-videocard-lib#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"command-line-args": "^5.2.0"
|
||||||
|
}
|
||||||
|
}
|
12
tools/parseOptions.js
Normal file
12
tools/parseOptions.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
const commandLineArgs = require('command-line-args');
|
||||||
|
|
||||||
|
function parseOptions(optionDefinitions) {
|
||||||
|
try {
|
||||||
|
return commandLineArgs(optionDefinitions);
|
||||||
|
} catch(ex) {
|
||||||
|
console.log(ex.message);
|
||||||
|
process.exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = parseOptions;
|
@ -1,9 +1,21 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const parseOptions = require("./parseOptions");
|
||||||
|
|
||||||
let prg = fs.readFileSync("test_apple1.prg");
|
const options = parseOptions([
|
||||||
|
{ name: 'input', alias: 'i', type: String },
|
||||||
|
{ name: 'output', alias: 'o', type: String }
|
||||||
|
]);
|
||||||
|
|
||||||
|
if(options.input === undefined || options.output === undefined) {
|
||||||
|
console.log("usage: prg2bin -i inputfile.prg -o outputfile.bin");
|
||||||
|
process.exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let prg = fs.readFileSync(options.input);
|
||||||
|
|
||||||
prg = prg.slice(2);
|
prg = prg.slice(2);
|
||||||
|
|
||||||
fs.writeFileSync("test_apple1.bin",prg);
|
fs.writeFileSync(options.output,prg);
|
||||||
|
|
||||||
|
console.log(`${options.output} written`);
|
||||||
|
|
||||||
console.log("bin written");
|
|
||||||
|
Loading…
Reference in New Issue
Block a user