diff --git a/package.json b/package.json new file mode 100644 index 0000000..c7fd0cb --- /dev/null +++ b/package.json @@ -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 ", + "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" + } +} diff --git a/tools/parseOptions.js b/tools/parseOptions.js new file mode 100644 index 0000000..2380d12 --- /dev/null +++ b/tools/parseOptions.js @@ -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; diff --git a/tools/prg2bin.js b/tools/prg2bin.js index 417fb6d..5e5ff87 100644 --- a/tools/prg2bin.js +++ b/tools/prg2bin.js @@ -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");