improve prg2bin, use node_modules

This commit is contained in:
nino-porcino 2022-01-13 13:04:55 +01:00
parent 48ed61f6af
commit ed14016e2c
3 changed files with 53 additions and 3 deletions

26
package.json Normal file
View 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
View 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;

View File

@ -1,9 +1,21 @@
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);
fs.writeFileSync("test_apple1.bin",prg);
fs.writeFileSync(options.output,prg);
console.log(`${options.output} written`);
console.log("bin written");