mirror of
https://github.com/nippur72/apple1-videocard-lib.git
synced 2024-06-16 20:29:31 +00:00
add bin2prg tool
This commit is contained in:
parent
d31b2eeaa0
commit
cd525078a7
26
tools/bin2prg.js
Normal file
26
tools/bin2prg.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
const fs = require('fs');
|
||||
const parseOptions = require("./parseOptions");
|
||||
|
||||
const options = parseOptions([
|
||||
{ name: 'input', alias: 'i', type: String },
|
||||
{ name: 'output', alias: 'o', type: String },
|
||||
{ name: 'start', alias: 's', type: String }
|
||||
]);
|
||||
|
||||
if(options.input === undefined || options.output === undefined || options.start === undefined) {
|
||||
console.log("usage: bin2prg -i inputfile.prg -o outputfile.bin -s hexaddress");
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
let bin = fs.readFileSync(options.input);
|
||||
|
||||
let start_address = parseInt(options.start, 16);
|
||||
let lo = (start_address >> 0) & 0xFF;
|
||||
let hi = (start_address >> 8) & 0xFF;
|
||||
|
||||
let prg = new Uint8Array([ lo, hi, ...bin ]);
|
||||
|
||||
fs.writeFileSync(options.output, prg);
|
||||
|
||||
console.log(`${options.output} written`);
|
||||
|
Loading…
Reference in New Issue
Block a user