Convert reno to .prg and .d64 because people are curious

This commit is contained in:
Jeremy Penner 2024-01-02 19:38:00 -05:00
parent c84c1c636d
commit 8a64fe3496
6 changed files with 64 additions and 3 deletions

View file

@ -1,3 +1,6 @@
all: mamelink.o down
down: mamelink.o down.o
clean:
rm -f *.o down

View file

@ -77,15 +77,18 @@ static void simple_cmd(char command) {
send_cmd_and_close(prepare_cmd(command));
}
void Init(char *initial_link_dir) {
int Init(char *initial_link_dir) {
if (initial_link_dir == NULL) {
initial_link_dir = getenv("MAMELINK");
}
assert(initial_link_dir != NULL);
if (initial_link_dir == NULL) {
return 0;
}
if (linkdir != NULL) {
free(linkdir);
}
linkdir = strdup(initial_link_dir);
return 1;
}
void Finish() {

View file

@ -1,4 +1,4 @@
void Init(char *initial_link_dir);
int Init(char *initial_link_dir);
void Finish();
void down(char *buf, unsigned short bytes, unsigned short c64Addr);
void up(char *buf, unsigned short bytes, unsigned short c64Addr);

55
mamelink/out2prg.js Normal file
View file

@ -0,0 +1,55 @@
const fs = require('node:fs/promises');
const assert = require('node:assert/strict');
const die = (...message) => {
console.error(...message)
process.exit(1)
}
if (process.argv.length != 3) {
die("Usage: node out2prg.js FILE.out")
}
const replaceExtension = (filename, ext) => {
const idot = filename.lastIndexOf(".")
return `${idot < 0 ? filename : filename.substr(0, idot)}.${ext}`
}
(async () => {
const outfilename = process.argv[2]
const data = await fs.readFile(outfilename)
assert.equal(data.readUint16LE(0), 0xffff, `${outfilename} does not start with magic FFFF bytes`)
const prgfilename = replaceExtension(outfilename, "prg")
const prgfile = await fs.open(prgfilename, "w")
try {
let off = 2
let nextAddress = null
let bootAddr = null
while (off < data.length) {
const startAddr = data.readUint16LE(off)
const endAddr = data.readUint16LE(off + 2)
if (startAddr == endAddr && bootAddr == null) {
bootAddr = startAddr
console.log(`To start, type SYS${bootAddr}`)
console.log(`Skipping byte: ${data.readUint8(off + 4)}`)
off += 5
continue
}
assert.ok(endAddr >= startAddr, `Invalid address range ${startAddr}:${endAddr}`)
assert.ok(nextAddress == null || startAddr >= nextAddress, `Expected ${startAddr} to come after previous segment ending at ${nextAddress}`)
const paddingLength = nextAddress == null ? 0 : startAddr - nextAddress
const blobLength = endAddr - startAddr + 1
if (nextAddress == null) {
await fs.writeFile(prgfile, data.subarray(off, off + 2))
}
if (paddingLength > 0) {
await fs.writeFile(prgfile, Buffer.alloc(paddingLength))
}
off += 4
await fs.writeFile(prgfile, data.subarray(off, off + blobLength))
nextAddress = endAddr + 1
off += blobLength
}
} finally {
await prgfile.close()
}
})()

BIN
mamelink/reno.d64 Normal file

Binary file not shown.

BIN
mamelink/reno.prg Normal file

Binary file not shown.